aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/attr.lua98
-rw-r--r--lib/curl.lua36
-rw-r--r--lib/iso639.lua366
-rw-r--r--lib/util.lua54
4 files changed, 277 insertions, 277 deletions
diff --git a/lib/attr.lua b/lib/attr.lua
index 5735083..a20b881 100644
--- a/lib/attr.lua
+++ b/lib/attr.lua
@@ -1,64 +1,64 @@
#!/usr/bin/env lua
-local util = require 'lib.util'
+local util = require("lib.util")
-local extract = function (name, patterns)
+local extract = function(name, patterns)
local r
for _, p in pairs(patterns) do
r = r or name:match(p)
- name = name:gsub(p, '')
+ name = name:gsub(p, "")
end
return name, r
end
-local build_dlim = function (name, attrs)
- local dlim ,r
+local build_dlim = function(name, attrs)
+ local dlim, r
attrs = attrs or {}
- dlim = '[%-%.%s]?'
+ dlim = "[%-%.%s]?"
local vcodecs = {
- '[M]m[Pp][Ee][Gg]' .. dlim .. '[1234]',
+ "[M]m[Pp][Ee][Gg]" .. dlim .. "[1234]",
}
local acodecs = {
- '[Dd][Tt][Ss]' .. dlim .. '[Hh][Dd]',
- '[Dd][Dd]' .. dlim .. '[57]%.1',
+ "[Dd][Tt][Ss]" .. dlim .. "[Hh][Dd]",
+ "[Dd][Dd]" .. dlim .. "[57]%.1",
}
- local sources= {
+ local sources = {
"[Ww][Ee][Bb]" .. dlim .. "[Dd][Ll]",
"[Hh][Dd]" .. dlim .. "[Tt][Vv]",
"[Hh][Dd]" .. dlim .. "[Tt][Ss]",
}
local series = {
- '[Ss]%d%d?' .. dlim .. '[Ee]%d%d?',
- '[Ss]%d%d?' .. dlim .. '[Ee][Pp]' .. dlim .. '%d%d?',
- 'Season' .. dlim .. '%d%d?' .. dlim .. 'Episode' .. dlim .. '%d%d?'
+ "[Ss]%d%d?" .. dlim .. "[Ee]%d%d?",
+ "[Ss]%d%d?" .. dlim .. "[Ee][Pp]" .. dlim .. "%d%d?",
+ "Season" .. dlim .. "%d%d?" .. dlim .. "Episode" .. dlim .. "%d%d?",
}
local sizes = {
- '%d%d%d' .. dlim .. '[Mm][Bb]',
- '%d%d?%.%d%d?' .. dlim .. '[Gg][Bb]',
+ "%d%d%d" .. dlim .. "[Mm][Bb]",
+ "%d%d?%.%d%d?" .. dlim .. "[Gg][Bb]",
}
local depths = {
- '1[02]' .. dlim .. '[Bb][Ii][Tt]'
+ "1[02]" .. dlim .. "[Bb][Ii][Tt]",
}
name, attrs.vcodec = extract(name, vcodecs)
name, attrs.source = extract(name, sources)
- name, attrs.acodecs = extract(name, acodecs)
- name, attrs.size = extract(name, sizes)
- name, attrs.depth = extract(name, depths)
+ name, attrs.acodecs = extract(name, acodecs)
+ name, attrs.size = extract(name, sizes)
+ name, attrs.depth = extract(name, depths)
name, r = extract(name, series)
if r then
- attrs.season = tonumber(r:match('%d+'))
- attrs.episode = tonumber(r:match('%d+$'))
+ attrs.season = tonumber(r:match("%d+"))
+ attrs.episode = tonumber(r:match("%d+$"))
end
return name, attrs
end
-local build_atom = function (name, attrs)
+local build_atom = function(name, attrs)
local r, year
attrs = attrs or {}
@@ -75,7 +75,7 @@ local build_atom = function (name, attrs)
"[Ee]?[Aa][Cc]3",
"[Dd][Tt][Ss]",
}
- local sources= {
+ local sources = {
"[Bb][Ll][Uu][Rr][Aa][Yy]",
"[Bb][Rr][Rr][Ii][Pp]",
"[Dd][Vv][Dd][Rr][Ii][Pp]",
@@ -90,50 +90,50 @@ local build_atom = function (name, attrs)
"720[Pp]",
"480[Pp]",
"[Uu][Hh][Dd]",
- "4[Kk]"
+ "4[Kk]",
}
local series = {
- '%d%d[Xx]%d%d',
+ "%d%d[Xx]%d%d",
}
local channels = {
- '6[Cc][Hh]',
- '[57]%.1',
+ "6[Cc][Hh]",
+ "[57]%.1",
}
name, attrs.vcodec = extract(name, vcodecs)
name, attrs.source = extract(name, sources)
- name, attrs.res = extract(name, reses)
- name, attrs.acodecs = extract(name, acodecs)
- name, attrs.channel = extract(name, channels)
+ name, attrs.res = extract(name, reses)
+ name, attrs.acodecs = extract(name, acodecs)
+ name, attrs.channel = extract(name, channels)
name, r = extract(name, series)
if r then
- attrs.season = tonumber(r:match('%d+'))
- attrs.episode = tonumber(r:match('%d+$'))
+ attrs.season = tonumber(r:match("%d+"))
+ attrs.episode = tonumber(r:match("%d+$"))
end
- for y in name:gmatch('%d%d%d%d') do
+ for y in name:gmatch("%d%d%d%d") do
year = tonumber(y)
- if year > 1900 and year <= tonumber(os.date('%Y')) then
+ if year > 1900 and year <= tonumber(os.date("%Y")) then
attrs.year = y
end
end
- if attrs.year then
- name = name:gsub(tostring(attrs.year), '')
+ if attrs.year then
+ name = name:gsub(tostring(attrs.year), "")
end
return name, attrs
end
-local build_low = function (name, attrs)
+local build_low = function(name, attrs)
local low_attr, lows
- lows = { 'SDH' }
+ lows = { "SDH" }
low_attr = {}
for _, low in pairs(lows) do
low_attr[#low_attr + 1] = name:match(low)
- name = name:gsub(low, '')
+ name = name:gsub(low, "")
end
attrs = attrs or {}
@@ -144,9 +144,9 @@ local build_low = function (name, attrs)
return name, attrs
end
-local build_title = function (name, attrs)
+local build_title = function(name, attrs)
attrs.title = {}
- for w in name:gmatch('%w+') do
+ for w in name:gmatch("%w+") do
attrs.title[#attrs.title + 1] = w
end
@@ -158,7 +158,7 @@ local build_title = function (name, attrs)
return attrs
end
-local build = function (name)
+local build = function(name)
local attrs = {}
name = build_dlim(name, attrs)
@@ -169,7 +169,7 @@ local build = function (name)
return attrs
end
-local weigh = function (a1, a2)
+local weigh = function(a1, a2)
local key_score, score
key_score = {
@@ -186,17 +186,17 @@ local weigh = function (a1, a2)
score = 0
for k, v in pairs(a1) do
- if not a2[k] or k == 'episode' then
+ if not a2[k] or k == "episode" then
goto continue
end
- if k == 'title' then
+ if k == "title" then
for _, title in pairs(v) do
if util.array_search(a2.title, title) then
score = score + key_score.title
end
end
- elseif k == 'season' then
+ elseif k == "season" then
if a1.season == a2.season and a1.episode == a2.episode then
score = score + key_score.season + key_score.episode
end
@@ -206,18 +206,18 @@ local weigh = function (a1, a2)
end
end
- ::continue::
+ ::continue::
end
return score
end
-local fuzzy = function (name, tab)
+local fuzzy = function(name, tab)
local name_attr, high, score
high = {
score = 0,
- name = next(tab)
+ name = next(tab),
}
name_attr = build(name)
diff --git a/lib/curl.lua b/lib/curl.lua
index cfc1c11..4c56325 100644
--- a/lib/curl.lua
+++ b/lib/curl.lua
@@ -1,33 +1,33 @@
#!/usr/bin/env lua
-local util = require 'lib.util'
+local util = require("lib.util")
local def_headr = {
- ['User-Agent'] = 'cia',
- ['Accept-Encoding'] = 'gzip, deflate, br'
+ ["User-Agent"] = "cia",
+ ["Accept-Encoding"] = "gzip, deflate, br",
}
-local head_to_args = function (t)
+local head_to_args = function(t)
local args = {}
for k, v in pairs(t) do
- args[#args + 1] = '-H' .. k .. ": " .. v
+ args[#args + 1] = "-H" .. k .. ": " .. v
end
return args
end
-local get = function (url, headr, args)
+local get = function(url, headr, args)
local fetch, hcode, def_args
def_args = {
- 'curl',
- '--silent',
- '--compressed',
- '--write-out',
- '%{http_code}',
- '--globoff',
- '--location',
+ "curl",
+ "--silent",
+ "--compressed",
+ "--write-out",
+ "%{http_code}",
+ "--globoff",
+ "--location",
url,
}
@@ -36,17 +36,17 @@ local get = function (url, headr, args)
args = util.array_merge(args, head_to_args(headr))
fetch = util.run(args)
- hcode = fetch:match('%d*$')
- fetch = fetch:gsub('%s*%d*$', '')
+ hcode = fetch:match("%d*$")
+ fetch = fetch:gsub("%s*%d*$", "")
return fetch, tonumber(hcode)
end
-local zip_link_to_file = function (url, headr, out)
+local zip_link_to_file = function(url, headr, out)
local hcode, zip, rc, args
zip = os.tmpname()
- args = { '-o'.. zip }
+ args = { "-o" .. zip }
_, hcode = get(url, headr, args)
@@ -57,7 +57,7 @@ local zip_link_to_file = function (url, headr, out)
os.remove(zip)
if hcode and not rc then
- util.error('curl: zip_link_to_file')
+ util.error("curl: zip_link_to_file")
end
return rc
diff --git a/lib/iso639.lua b/lib/iso639.lua
index 6e853db..81fa433 100644
--- a/lib/iso639.lua
+++ b/lib/iso639.lua
@@ -3,189 +3,189 @@
local M = {}
local map = {
- ['ab'] = 'abk',
- ['aa'] = 'aar',
- ['af'] = 'afr',
- ['ak'] = 'aka',
- ['sq'] = 'sqi',
- ['am'] = 'amh',
- ['ar'] = 'ara',
- ['an'] = 'arg',
- ['hy'] = 'hye',
- ['as'] = 'asm',
- ['av'] = 'ava',
- ['ae'] = 'ave',
- ['ay'] = 'aym',
- ['az'] = 'aze',
- ['bm'] = 'bam',
- ['ba'] = 'bak',
- ['eu'] = 'eus',
- ['be'] = 'bel',
- ['bn'] = 'ben',
- ['bi'] = 'bis',
- ['bs'] = 'bos',
- ['br'] = 'bre',
- ['bg'] = 'bul',
- ['my'] = 'mya',
- ['ca'] = 'cat',
- ['ch'] = 'cha',
- ['ce'] = 'che',
- ['ny'] = 'nya',
- ['zh'] = 'zho',
- ['cu'] = 'chu',
- ['cv'] = 'chv',
- ['kw'] = 'cor',
- ['co'] = 'cos',
- ['cr'] = 'cre',
- ['hr'] = 'hrv',
- ['cs'] = 'ces',
- ['da'] = 'dan',
- ['dv'] = 'div',
- ['nl'] = 'nld',
- ['dz'] = 'dzo',
- ['en'] = 'eng',
- ['eo'] = 'epo',
- ['et'] = 'est',
- ['ee'] = 'ewe',
- ['fo'] = 'fao',
- ['fj'] = 'fij',
- ['fi'] = 'fin',
- ['fr'] = 'fra',
- ['fy'] = 'fry',
- ['ff'] = 'ful',
- ['gd'] = 'gla',
- ['gl'] = 'glg',
- ['lg'] = 'lug',
- ['ka'] = 'kat',
- ['de'] = 'deu',
- ['el'] = 'ell',
- ['kl'] = 'kal',
- ['gn'] = 'grn',
- ['gu'] = 'guj',
- ['ht'] = 'hat',
- ['ha'] = 'hau',
- ['he'] = 'heb',
- ['hz'] = 'her',
- ['hi'] = 'hin',
- ['ho'] = 'hmo',
- ['hu'] = 'hun',
- ['is'] = 'isl',
- ['io'] = 'ido',
- ['ig'] = 'ibo',
- ['id'] = 'ind',
- ['ia'] = 'ina',
- ['ie'] = 'ile',
- ['iu'] = 'iku',
- ['ik'] = 'ipk',
- ['ga'] = 'gle',
- ['it'] = 'ita',
- ['ja'] = 'jpn',
- ['jv'] = 'jav',
- ['kn'] = 'kan',
- ['kr'] = 'kau',
- ['ks'] = 'kas',
- ['kk'] = 'kaz',
- ['km'] = 'khm',
- ['ki'] = 'kik',
- ['rw'] = 'kin',
- ['ky'] = 'kir',
- ['kv'] = 'kom',
- ['kg'] = 'kon',
- ['ko'] = 'kor',
- ['kj'] = 'kua',
- ['ku'] = 'kur',
- ['lo'] = 'lao',
- ['la'] = 'lat',
- ['lv'] = 'lav',
- ['li'] = 'lim',
- ['ln'] = 'lin',
- ['lt'] = 'lit',
- ['lu'] = 'lub',
- ['lb'] = 'ltz',
- ['mk'] = 'mkd',
- ['mg'] = 'mlg',
- ['ms'] = 'msa',
- ['ml'] = 'mal',
- ['mt'] = 'mlt',
- ['gv'] = 'glv',
- ['mi'] = 'mri',
- ['mr'] = 'mar',
- ['mh'] = 'mah',
- ['mn'] = 'mon',
- ['na'] = 'nau',
- ['nv'] = 'nav',
- ['nd'] = 'nde',
- ['nr'] = 'nbl',
- ['ng'] = 'ndo',
- ['ne'] = 'nep',
- ['no'] = 'nor',
- ['nb'] = 'nob',
- ['nn'] = 'nno',
- ['ii'] = 'iii',
- ['oc'] = 'oci',
- ['oj'] = 'oji',
- ['or'] = 'ori',
- ['om'] = 'orm',
- ['os'] = 'oss',
- ['pi'] = 'pli',
- ['ps'] = 'pus',
- ['fa'] = 'fas',
- ['pl'] = 'pol',
- ['pt'] = 'por',
- ['pa'] = 'pan',
- ['qu'] = 'que',
- ['ro'] = 'ron',
- ['rm'] = 'roh',
- ['rn'] = 'run',
- ['ru'] = 'rus',
- ['se'] = 'sme',
- ['sm'] = 'smo',
- ['sg'] = 'sag',
- ['sa'] = 'san',
- ['sc'] = 'srd',
- ['sr'] = 'srp',
- ['sn'] = 'sna',
- ['sd'] = 'snd',
- ['si'] = 'sin',
- ['sk'] = 'slk',
- ['sl'] = 'slv',
- ['so'] = 'som',
- ['st'] = 'sot',
- ['es'] = 'spa',
- ['su'] = 'sun',
- ['sw'] = 'swa',
- ['ss'] = 'ssw',
- ['sv'] = 'swe',
- ['tl'] = 'tgl',
- ['ty'] = 'tah',
- ['tg'] = 'tgk',
- ['ta'] = 'tam',
- ['tt'] = 'tat',
- ['te'] = 'tel',
- ['th'] = 'tha',
- ['bo'] = 'bod',
- ['ti'] = 'tir',
- ['to'] = 'ton',
- ['ts'] = 'tso',
- ['tn'] = 'tsn',
- ['tr'] = 'tur',
- ['tk'] = 'tuk',
- ['tw'] = 'twi',
- ['ug'] = 'uig',
- ['uk'] = 'ukr',
- ['ur'] = 'urd',
- ['uz'] = 'uzb',
- ['ve'] = 'ven',
- ['vi'] = 'vie',
- ['vo'] = 'vol',
- ['wa'] = 'wln',
- ['cy'] = 'cym',
- ['wo'] = 'wol',
- ['xh'] = 'xho',
- ['yi'] = 'yid',
- ['yo'] = 'yor',
- ['za'] = 'zha',
- ['zu'] = 'zul',
+ ["ab"] = "abk",
+ ["aa"] = "aar",
+ ["af"] = "afr",
+ ["ak"] = "aka",
+ ["sq"] = "sqi",
+ ["am"] = "amh",
+ ["ar"] = "ara",
+ ["an"] = "arg",
+ ["hy"] = "hye",
+ ["as"] = "asm",
+ ["av"] = "ava",
+ ["ae"] = "ave",
+ ["ay"] = "aym",
+ ["az"] = "aze",
+ ["bm"] = "bam",
+ ["ba"] = "bak",
+ ["eu"] = "eus",
+ ["be"] = "bel",
+ ["bn"] = "ben",
+ ["bi"] = "bis",
+ ["bs"] = "bos",
+ ["br"] = "bre",
+ ["bg"] = "bul",
+ ["my"] = "mya",
+ ["ca"] = "cat",
+ ["ch"] = "cha",
+ ["ce"] = "che",
+ ["ny"] = "nya",
+ ["zh"] = "zho",
+ ["cu"] = "chu",
+ ["cv"] = "chv",
+ ["kw"] = "cor",
+ ["co"] = "cos",
+ ["cr"] = "cre",
+ ["hr"] = "hrv",
+ ["cs"] = "ces",
+ ["da"] = "dan",
+ ["dv"] = "div",
+ ["nl"] = "nld",
+ ["dz"] = "dzo",
+ ["en"] = "eng",
+ ["eo"] = "epo",
+ ["et"] = "est",
+ ["ee"] = "ewe",
+ ["fo"] = "fao",
+ ["fj"] = "fij",
+ ["fi"] = "fin",
+ ["fr"] = "fra",
+ ["fy"] = "fry",
+ ["ff"] = "ful",
+ ["gd"] = "gla",
+ ["gl"] = "glg",
+ ["lg"] = "lug",
+ ["ka"] = "kat",
+ ["de"] = "deu",
+ ["el"] = "ell",
+ ["kl"] = "kal",
+ ["gn"] = "grn",
+ ["gu"] = "guj",
+ ["ht"] = "hat",
+ ["ha"] = "hau",
+ ["he"] = "heb",
+ ["hz"] = "her",
+ ["hi"] = "hin",
+ ["ho"] = "hmo",
+ ["hu"] = "hun",
+ ["is"] = "isl",
+ ["io"] = "ido",
+ ["ig"] = "ibo",
+ ["id"] = "ind",
+ ["ia"] = "ina",
+ ["ie"] = "ile",
+ ["iu"] = "iku",
+ ["ik"] = "ipk",
+ ["ga"] = "gle",
+ ["it"] = "ita",
+ ["ja"] = "jpn",
+ ["jv"] = "jav",
+ ["kn"] = "kan",
+ ["kr"] = "kau",
+ ["ks"] = "kas",
+ ["kk"] = "kaz",
+ ["km"] = "khm",
+ ["ki"] = "kik",
+ ["rw"] = "kin",
+ ["ky"] = "kir",
+ ["kv"] = "kom",
+ ["kg"] = "kon",
+ ["ko"] = "kor",
+ ["kj"] = "kua",
+ ["ku"] = "kur",
+ ["lo"] = "lao",
+ ["la"] = "lat",
+ ["lv"] = "lav",
+ ["li"] = "lim",
+ ["ln"] = "lin",
+ ["lt"] = "lit",
+ ["lu"] = "lub",
+ ["lb"] = "ltz",
+ ["mk"] = "mkd",
+ ["mg"] = "mlg",
+ ["ms"] = "msa",
+ ["ml"] = "mal",
+ ["mt"] = "mlt",
+ ["gv"] = "glv",
+ ["mi"] = "mri",
+ ["mr"] = "mar",
+ ["mh"] = "mah",
+ ["mn"] = "mon",
+ ["na"] = "nau",
+ ["nv"] = "nav",
+ ["nd"] = "nde",
+ ["nr"] = "nbl",
+ ["ng"] = "ndo",
+ ["ne"] = "nep",
+ ["no"] = "nor",
+ ["nb"] = "nob",
+ ["nn"] = "nno",
+ ["ii"] = "iii",
+ ["oc"] = "oci",
+ ["oj"] = "oji",
+ ["or"] = "ori",
+ ["om"] = "orm",
+ ["os"] = "oss",
+ ["pi"] = "pli",
+ ["ps"] = "pus",
+ ["fa"] = "fas",
+ ["pl"] = "pol",
+ ["pt"] = "por",
+ ["pa"] = "pan",
+ ["qu"] = "que",
+ ["ro"] = "ron",
+ ["rm"] = "roh",
+ ["rn"] = "run",
+ ["ru"] = "rus",
+ ["se"] = "sme",
+ ["sm"] = "smo",
+ ["sg"] = "sag",
+ ["sa"] = "san",
+ ["sc"] = "srd",
+ ["sr"] = "srp",
+ ["sn"] = "sna",
+ ["sd"] = "snd",
+ ["si"] = "sin",
+ ["sk"] = "slk",
+ ["sl"] = "slv",
+ ["so"] = "som",
+ ["st"] = "sot",
+ ["es"] = "spa",
+ ["su"] = "sun",
+ ["sw"] = "swa",
+ ["ss"] = "ssw",
+ ["sv"] = "swe",
+ ["tl"] = "tgl",
+ ["ty"] = "tah",
+ ["tg"] = "tgk",
+ ["ta"] = "tam",
+ ["tt"] = "tat",
+ ["te"] = "tel",
+ ["th"] = "tha",
+ ["bo"] = "bod",
+ ["ti"] = "tir",
+ ["to"] = "ton",
+ ["ts"] = "tso",
+ ["tn"] = "tsn",
+ ["tr"] = "tur",
+ ["tk"] = "tuk",
+ ["tw"] = "twi",
+ ["ug"] = "uig",
+ ["uk"] = "ukr",
+ ["ur"] = "urd",
+ ["uz"] = "uzb",
+ ["ve"] = "ven",
+ ["vi"] = "vie",
+ ["vo"] = "vol",
+ ["wa"] = "wln",
+ ["cy"] = "cym",
+ ["wo"] = "wol",
+ ["xh"] = "xho",
+ ["yi"] = "yid",
+ ["yo"] = "yor",
+ ["za"] = "zha",
+ ["zu"] = "zul",
}
M.toset2 = function(iso639_lang)
diff --git a/lib/util.lua b/lib/util.lua
index 5b524bf..ce41743 100644
--- a/lib/util.lua
+++ b/lib/util.lua
@@ -1,26 +1,26 @@
#!/usr/bin/env lua
-local table_to_cmd = function (t)
+local table_to_cmd = function(t)
local str = ""
for _, v in ipairs(t) do
- v = v:gsub("'", "\'")
+ v = v:gsub("'", "'")
str = str .. " '" .. v .. "' "
end
return str
end
-local file_exists = function (path)
- return io.open(path, 'r') and true or false
+local file_exists = function(path)
+ return io.open(path, "r") and true or false
end
-local run = function (args)
+local run = function(args)
local sig, rc, stdout, cmd
if mp then
cmd = mp.command_native({
- name = 'subprocess',
+ name = "subprocess",
capture_stdout = true,
args = args,
})
@@ -31,16 +31,16 @@ local run = function (args)
else
cmd = io.popen(table_to_cmd(args))
if cmd then
- stdout = cmd:read('*all')
+ stdout = cmd:read("*all")
_, sig, rc = cmd:close()
- rc = (sig == 'signal') or (sig == 'exit' and rc == 0)
+ rc = (sig == "signal") or (sig == "exit" and rc == 0)
end
end
return stdout or "", rc
end
-local table_merge = function (t1, t2)
+local table_merge = function(t1, t2)
local t = {}
t1 = t1 or {}
t2 = t2 or {}
@@ -55,7 +55,7 @@ local table_merge = function (t1, t2)
return t
end
-local array_merge = function (a1, a2)
+local array_merge = function(a1, a2)
local a = {}
a1 = a1 or {}
a2 = a2 or {}
@@ -70,7 +70,7 @@ local array_merge = function (a1, a2)
return a
end
-local array_search = function (a, key)
+local array_search = function(a, key)
for _, v in pairs(a) do
if v == key then
return true
@@ -80,16 +80,16 @@ local array_search = function (a, key)
return false
end
-local table_print = function (t)
+local table_print = function(t)
for k, v in pairs(t) do
- print( '|'.. k .. '=' .. v .. '|')
+ print("|" .. k .. "=" .. v .. "|")
end
end
-local table_match_or_any = function (t, key)
+local table_match_or_any = function(t, key)
local str
- str= t[key]
+ str = t[key]
if not str then
_, str = next(t, nil)
end
@@ -97,22 +97,22 @@ local table_match_or_any = function (t, key)
return str
end
-local zip_ext_first = function (zip, out)
+local zip_ext_first = function(zip, out)
local dir, rc, srt, findcmd
dir = os.tmpname()
os.remove(dir)
- findcmd = { 'find', dir, '-type', 'f', '-name', '*.srt' }
+ findcmd = { "find", dir, "-type", "f", "-name", "*.srt" }
- _, rc = run({ 'unzip', '-qq', zip, '-d', dir })
- srt = run(findcmd):match('[^\n]*')
- run({ 'mv', srt, out })
+ _, rc = run({ "unzip", "-qq", zip, "-d", dir })
+ srt = run(findcmd):match("[^\n]*")
+ run({ "mv", srt, out })
os.remove(dir)
return rc
end
-local string_vid_path_to_name = function (str)
+local string_vid_path_to_name = function(str)
local extensions = {
"mkv",
"mp4",
@@ -122,19 +122,19 @@ local string_vid_path_to_name = function (str)
"gifv",
"avi",
"mpeg",
- "3gp"
+ "3gp",
}
- str = str:match('[^/]*$')
+ str = str:match("[^/]*$")
for _, ext in ipairs(extensions) do
- str = str:gsub('.' .. ext, '')
+ str = str:gsub("." .. ext, "")
end
return str
end
-local error = function (str)
- str = 'error: ' .. str
+local error = function(str)
+ str = "error: " .. str
if mp then
mp.msg.warn(str)
else
@@ -142,7 +142,7 @@ local error = function (str)
end
end
-local opensubtitles_hash = function (fileName)
+local opensubtitles_hash = function(fileName)
local fil = io.open(fileName, "rb")
if not fil then
return nil