Skip to content

Commit

Permalink
better handling of TOO MANY DL error by performing retries
Browse files Browse the repository at this point in the history
  • Loading branch information
morsela committed Jan 30, 2015
1 parent e71d60f commit cf379cf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.subtitles.torec"
name="Torec"
version="1.0.4"
version="1.0.5"
provider-name="slmosl">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.0.5
- better handling of TOO MANY DL error by performing retries

1.0.4
- fixed TOO MANY DL issue, again

Expand Down
9 changes: 7 additions & 2 deletions resources/lib/TorecSubtitlesDownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,14 @@ def getDownloadLink(self, subID, optionID, subURL, persist=True):
params = {"sub_id" : subID, "code": optionID, "sh" : "yes", "guest" : requestID, "timewaited" : "12"}
for i in xrange(16):
response = self.urlHandler.request("%s/ajax/sub/downloadun.asp" % self.BASE_URL, params, ajax=True)
if (len(response.data) != 0 or not persist):
if (not persist):
break
time.sleep(1)

if (len(response.data) != 0 and (not response.data.startswith("ERROR"))):
break

print "Response received is inadequate (" + response.data + "). Sleeping a bit"
time.sleep(0.5)

return response.data

Expand Down

0 comments on commit cf379cf

Please sign in to comment.