aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--lib/curl.lua19
-rw-r--r--server/opensubtitles.lua7
3 files changed, 10 insertions, 18 deletions
diff --git a/README.md b/README.md
index 0d79c85..e8c0721 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@ TODO
- [x] deprecate subscene (unreliable servers and poor db)
- [x] add key binding to force subtitle lookup
- [ ] implement text search on all severs
-- [ ] remove the default retries
+- [x] remove the default retries
- [ ] shill on reddit and matrix
- [ ] first fetch normally when key is pressed then bring up a menu to select subs(we likely got it wrong)
- [ ] remove this todo
diff --git a/lib/curl.lua b/lib/curl.lua
index f35fcf1..cfc1c11 100644
--- a/lib/curl.lua
+++ b/lib/curl.lua
@@ -17,7 +17,7 @@ local head_to_args = function (t)
return args
end
-local get = function (url, headr, args, tries)
+local get = function (url, headr, args)
local fetch, hcode, def_args
def_args = {
@@ -35,27 +35,20 @@ local get = function (url, headr, args, tries)
headr = util.table_merge(def_headr, headr)
args = util.array_merge(args, head_to_args(headr))
- repeat
- fetch = util.run(args)
- -- hcode can be nil, it means curl was't able to fulfill the http request, either
- -- because curl package is broken or mpv killed it prematurely. we can exit
- -- out of retry loop early if hcode is nil since there's no point in retrying
- hcode = fetch:match('%d*$')
-
- tries = tries - 1
- until hcode == '200' or not hcode or tries <= 0
-
+ fetch = util.run(args)
+ hcode = fetch:match('%d*$')
fetch = fetch:gsub('%s*%d*$', '')
+
return fetch, tonumber(hcode)
end
-local zip_link_to_file = function (url, headr, out, tries)
+local zip_link_to_file = function (url, headr, out)
local hcode, zip, rc, args
zip = os.tmpname()
args = { '-o'.. zip }
- _, hcode = get(url, headr, args, tries)
+ _, hcode = get(url, headr, args)
rc = (hcode == 200)
if rc then
diff --git a/server/opensubtitles.lua b/server/opensubtitles.lua
index 6cbec88..3817ff8 100644
--- a/server/opensubtitles.lua
+++ b/server/opensubtitles.lua
@@ -5,7 +5,6 @@ local util = require 'lib.util'
local attr = require 'lib.attr'
local domain = 'https://www.opensubtitles.org'
-local tries = 10
local ids_fetch = function (page)
local iter, no_name, line, id, name, tab
@@ -64,7 +63,7 @@ local search_ohash = function (ohash, name, lang)
url = domain .. '/en' .. '/search/sublanguageid-' .. lang ..
'/moviehash-' .. ohash
- fetch, hcode = curl.get(url, nil, nil, tries)
+ fetch, hcode = curl.get(url, nil, nil)
id = attr.fuzzy(name, ids_fetch(fetch))
if hcode and not id then
@@ -87,7 +86,7 @@ local search_filesize = function (filesize, name, lang)
end
url = url .. '/moviebytesize-' .. filesize
- fetch, hcode = curl.get(url, nil, nil, tries)
+ fetch, hcode = curl.get(url, nil, nil)
if not hcode then
return nil
end
@@ -117,7 +116,7 @@ local search = function (path, out, info)
end
if link then
- return curl.zip_link_to_file(link, nil, out, tries)
+ return curl.zip_link_to_file(link, nil, out)
end
end