Skip to content

Commit

Permalink
Merge pull request #29 from XBMCil/service.subtitles.torec.1.0.10
Browse files Browse the repository at this point in the history
1.0.10 fixed a breaking change
  • Loading branch information
morsela authored Sep 7, 2016
2 parents 77595a8 + 53644b5 commit c2516b3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 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.9"
version="1.0.10"
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.10
- fixed a breaking change from torec.net -> http://www.xn--9dbf0cd.net leading to addon download malfunction

1.0.9
- fixed disfunctional addon (@myakove)

Expand Down
18 changes: 13 additions & 5 deletions resources/lib/TorecSubtitlesDownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import zlib

import bs4

import xbmc
import xbmcaddon

Expand Down Expand Up @@ -113,7 +114,7 @@ def login(self):

class TorecSubtitlesDownloader(FirefoxURLHandler):
DEFAULT_SEPERATOR = " "
BASE_URL = "http://www.torec.net"
BASE_URL = "http://www.xn--9dbf0cd.net"
SUBTITLE_PATH = "sub.asp?sub_id="
USER_AUTH_JS_URL = "http://www.torec.net/gjs/subw.js"
DEFAULT_COOKIE = (
Expand All @@ -127,7 +128,7 @@ def __init__(self):
def _build_default_cookie(self, sub_id):
current_time = datetime.datetime.now().strftime("%m/%d/%Y+%I:%M:%S+%p")
return self.DEFAULT_COOKIE % {
"screen_width": 1760,
"screen_width": 1440,
"subId": sub_id,
"current_datetime": current_time
}
Expand All @@ -139,12 +140,15 @@ def _get_time_waited(self, subw_text):
return re.search(r"seconds\s+=\s+(\d+);", subw_text).group(1)

def _request_subtitle(self, sub_id):
params = {
params = {
"sub_id" : sub_id,
"s" : 1440
}
}

return self.opener.open("%s/ajax/sub/guest_time.asp" % self.BASE_URL, urllib.urlencode(params)).read()
response = self.opener.open("%s/ajax/sub/guest_time.asp" % self.BASE_URL, urllib.urlencode(params))
data = response.read()

return data

def search(self, movie_name):
santized_name = self.sanitize(movie_name)
Expand Down Expand Up @@ -194,6 +198,10 @@ def get_download_link(self, sub_id, option_id):
return response.read()

def download(self, download_link):
if not download_link:
log(__name__, "no download link found")
return None, None

response = self.opener.open(
"%s%s" % (self.BASE_URL, download_link)
)
Expand Down
4 changes: 4 additions & 0 deletions tests/basic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def convert_to_utf(file):

result = downloader.get_download_link(page_id, subtitle_id)
subtitleData, fileName = downloader.download(result)
if subtitleData is None:
print "Test FAILED"
sys.exit(1)

extension = os.path.splitext(fileName)[1]

temp = tempfile.NamedTemporaryFile()
Expand Down

0 comments on commit c2516b3

Please sign in to comment.