There is a unicode relate error at log(...), it simply fixed by removing that. script line 369.
And fix invalid subtitle file is assigned at zip file archive type downloading.
(edit) more correction in file time comparision.
(edit) create unique filename based on url.
Code:
--- E:/download/service.subtitles.subscene-master/service.py Mon Feb 16 12:34:02 2015
+++ E:/download/service.subtitles.subscene-master/service.subtitles.subscene-master/service.py Sun Mar 15 11:28:36 2015
@@ -14,6 +14,7 @@
import string
import difflib
import HTMLParser
+import time
__addon__ = xbmcaddon.Addon()
__author__ = __addon__.getAddonInfo('author')
@@ -289,6 +290,13 @@
downloadlink_pattern = "...<a href=\"(.+?)\" rel=\"nofollow\" onclick=\"DownloadSubtitle"
content, response_url = geturl(link)
+ # get unique name of file based on link
+ base_file_idx = link.rfind('/')
+ if base_file_idx != -1:
+ local_base_file = link[base_file_idx+1:]
+ else:
+ local_base_file = "subscene"
+
match = re.compile(downloadlink_pattern).findall(content)
if match:
downloadlink = main_url + match[0]
@@ -319,7 +327,7 @@
shutil.rmtree(__temp__.encode('utf-8'))
xbmcvfs.mkdirs(__temp__)
- local_tmp_file = os.path.join(__temp__, "subscene.xxx")
+ local_tmp_file = os.path.join(__temp__, local_base_file + ".xxx")
packed = False
try:
@@ -346,8 +354,8 @@
packed = False
log(__name__, "Discovered a non-archive file")
myfile.close()
- local_tmp_file = os.path.join(__temp__, "subscene." + typeid)
- os.rename(os.path.join(__temp__, "subscene.xxx"), local_tmp_file)
+ local_tmp_file = os.path.join(__temp__, local_base_file + "." + typeid)
+ os.rename(os.path.join(__temp__, local_base_file + ".xxx"), local_tmp_file)
log(__name__, "Saving to %s" % local_tmp_file)
except:
log(__name__, "Failed to save subtitle to %s" % local_tmp_file)
@@ -356,6 +364,8 @@
xbmc.sleep(500)
xbmc.executebuiltin(('XBMC.Extract("%s","%s")' % (local_tmp_file, __temp__,)).encode('utf-8'), True)
+ packfile_time = os.stat(local_tmp_file).st_mtime
+
for file in xbmcvfs.listdir(__temp__)[1]:
if sys.platform.startswith('win'):
file = os.path.join(__temp__, file)
@@ -364,8 +374,10 @@
if os.path.splitext(file)[1] in exts:
if search_string and string.find(string.lower(file), string.lower(search_string)) == -1:
continue
- log(__name__, "=== returning subtitle file %s" % file)
- subtitle_list.append(file)
+ ## log(__name__, "=== returning subtitle file %s" % file.decode('utf-8'))
+ cfile_time = os.stat(file).st_mtime
+ if cfile_time >= packfile_time and cfile_time <= time.time():
+ subtitle_list.append(file)
if len(subtitle_list) == 0:
if search_string:
service.subtitles.subscene-master_(12).zip