The branch, gotham has been updated via 088f9674f8e595d34e9ce4eb243c13be70fb5874 (commit) via 4b0579786e8d206da75346f6f3f5c64200788eca (commit) from 029371d938e47d4cc3118b1dfc140a77885d6f08 (commit)
- Log ----------------------------------------------------------------- http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=088f9674f8e595d34e9ce4eb243c13be70fb5874 commit 088f9674f8e595d34e9ce4eb243c13be70fb5874 Author: Martijn Kaijser <mcm.kaij...@gmail.com> Date: Sun May 18 12:05:34 2014 +0200 [service.subtitles.subscenter] 3.2.1 diff --git a/service.subtitles.subscenter/addon.xml b/service.subtitles.subscenter/addon.xml index d1abfc8..f7a6aeb 100644 --- a/service.subtitles.subscenter/addon.xml +++ b/service.subtitles.subscenter/addon.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <addon id="service.subtitles.subscenter" name="Subscenter.org" - version="3.1.9" + version="3.2.1" provider-name="CaTz"> <requires> <import addon="xbmc.python" version="2.14.0"/> diff --git a/service.subtitles.subscenter/changelog.txt b/service.subtitles.subscenter/changelog.txt index 9ac03c8..1f575ea 100644 --- a/service.subtitles.subscenter/changelog.txt +++ b/service.subtitles.subscenter/changelog.txt @@ -1,3 +1,10 @@ +3.2.1 - by CaTz 16/05/2014 +- Improvement of RLS title parsing + +3.2.0 - by maortal 14/05/2014 +- Performance boost replaced decode with unicode method (should be replaced again if XBMC moves to python3) +- Fix android issues with re.sub (duo to usage of python 2.6) + 3.1.9 - by CaTz 11/05/2014 - Advanced Movie Title / TV-show parsing (includes release) diff --git a/service.subtitles.subscenter/resources/lib/SUBUtilities.py b/service.subtitles.subscenter/resources/lib/SUBUtilities.py index 968bdad..f76987f 100644 --- a/service.subtitles.subscenter/resources/lib/SUBUtilities.py +++ b/service.subtitles.subscenter/resources/lib/SUBUtilities.py @@ -27,10 +27,11 @@ __addon__ = xbmcaddon.Addon() __version__ = __addon__.getAddonInfo('version') # Module version __scriptname__ = __addon__.getAddonInfo('name') __language__ = __addon__.getLocalizedString -__profile__ = xbmc.translatePath(__addon__.getAddonInfo('profile')).decode("utf-8") -__temp__ = xbmc.translatePath(os.path.join(__profile__, 'temp')).decode("utf-8") +__profile__ = unicode(xbmc.translatePath(__addon__.getAddonInfo('profile')), 'utf-8') +__temp__ = unicode(xbmc.translatePath(os.path.join(__profile__, 'temp')), 'utf-8') cache = StorageServer.StorageServer(__scriptname__, int(24 * 364 / 2)) # 6 months +regexHelper = re.compile('\W+', re.UNICODE) #=============================================================================== # Private utility functions @@ -42,19 +43,22 @@ def normalizeString(str): def clean_title(item): - item["title"] = os.path.splitext(item["title"])[0] - item["tvshow"] = os.path.splitext(item["tvshow"])[0] + item["title"] = unicode(os.path.splitext(item["title"])[0], "utf-8") + item["tvshow"] = unicode(os.path.splitext(item["tvshow"])[0], "utf-8") def parse_rls_title(item): - groups = re.findall(r"(.*)(?:s|season)(\d{2})(?:e|x|episode|\n)(\d{2})", item["title"], re.I) + item["title"] = regexHelper.sub(' ', item["title"]) + item["tvshow"] = regexHelper.sub(' ', item["tvshow"]) + + groups = re.findall(r"(.*) (?:s|season|)(\d{1,2})(?:e|episode|x|\n)(\d{1,2})", item["title"], re.I) if len(groups) == 0: - groups = re.findall(r"(.*)(?:s|season)(\d{2})(?:e|x|episode|\n)(\d{2})", item["tvshow"], re.I) + groups = re.findall(r"(.*) (?:s|season|)(\d{1,2})(?:e|episode|x|\n)(\d{1,2})", item["tvshow"], re.I) if len(groups) > 0 and len(groups[0]) == 3: title, season, episode = groups[0] - item["tvshow"] = re.sub('\W+', ' ', title, 0, re.UNICODE).strip() + item["tvshow"] = regexHelper.sub(' ', title).strip() item["season"] = str(int(season)) item["episode"] = str(int(episode)) log(__scriptname__, "TV Parsed Item: %s" % (item,)) @@ -63,7 +67,7 @@ def parse_rls_title(item): groups = re.findall(r"(.*)(\d{4})", item["title"], re.I) if len(groups) > 0 and len(groups[0]) >= 1: title = groups[0][0] - item["title"] = re.sub('\W+', ' ', title, 0, re.UNICODE).strip() + item["title"] = regexHelper.sub(' ', title).strip() item["year"] = groups[0][1] if len(groups[0]) == 2 else item["year"] log(__scriptname__, "MOVIE Parsed Item: %s" % (item,)) @@ -79,7 +83,7 @@ def log(module, msg): def get_cache_key(prefix="", str=""): - str = re.sub('\W+', '_', str.decode("utf-8"), 0, re.UNICODE).lower() + str = regexHelper.sub('_', str).lower() return prefix + str @@ -108,7 +112,7 @@ class SubscenterHelper: results = eval(results) if not results: - query = {"q": search_string.lower() + "'"} # hack to prevent redirection in hebrew search + query = {"q": search_string.encode("utf-8").lower() + "'"} # hack to prevent redirection in hebrew search search_result = self.urlHandler.request(self.BASE_URL + "/he/subtitle/search/?" + urllib.urlencode(query)) if search_result is None: return results # return empty set @@ -129,21 +133,21 @@ class SubscenterHelper: def _filter_urls(self, urls, search_string, item): filtered = [] - search_string = search_string.decode("utf-8").lower() - search_string = re.sub('\W+', ' ', search_string, 0, re.UNICODE) + search_string = regexHelper.sub(' ', search_string.lower()) + h = HTMLParser.HTMLParser() log(__scriptname__, "urls: %s" % urls) for i, (content_type, slug, heb_name, eng_name, year) in enumerate(urls): - eng_name = eng_name.decode("utf-8") - heb_name = heb_name.decode("utf-8") + eng_name = unicode(eng_name, 'utf-8') + heb_name = unicode(heb_name, 'utf-8') eng_name = h.unescape(eng_name).replace(' ...', '').lower() heb_name = h.unescape(heb_name).replace(' ...', '') - eng_name = re.sub('\W+', ' ', eng_name, 0, re.UNICODE) - heb_name = re.sub('\W+', ' ', heb_name, 0, re.UNICODE) + eng_name = regexHelper.sub(' ', eng_name) + heb_name = regexHelper.sub(' ', heb_name) if ((content_type == "movie" and not item["tvshow"]) or (content_type == "series" and item["tvshow"])) and \ @@ -199,9 +203,9 @@ class SubscenterHelper: file_name = os.path.basename(file_original_path) folder_name = os.path.split(os.path.dirname(file_original_path))[-1] - subsfile = re.sub('\W+', '.', subsfile).lower() - file_name = re.sub('\W+', '.', file_name).lower() - folder_name = re.sub('\W+', '.', folder_name).lower() + subsfile = re.sub(r'\W+', '.', subsfile).lower() + file_name = re.sub(r'\W+', '.', file_name).lower() + folder_name = re.sub(r'\W+', '.', folder_name).lower() log(__scriptname__, "# Comparing Releases:\n [subtitle-rls] %s \n [filename-rls] %s \n [folder-rls] %s" % ( subsfile, file_name, folder_name)) diff --git a/service.subtitles.subscenter/service.py b/service.subtitles.subscenter/service.py index 1fdef75..ab18121 100644 --- a/service.subtitles.subscenter/service.py +++ b/service.subtitles.subscenter/service.py @@ -17,10 +17,10 @@ __scriptname__ = __addon__.getAddonInfo('name') __version__ = __addon__.getAddonInfo('version') __language__ = __addon__.getLocalizedString -__cwd__ = xbmc.translatePath(__addon__.getAddonInfo('path')).decode("utf-8") -__profile__ = xbmc.translatePath(__addon__.getAddonInfo('profile')).decode("utf-8") -__resource__ = xbmc.translatePath(os.path.join(__cwd__, 'resources', 'lib')).decode("utf-8") -__temp__ = xbmc.translatePath(os.path.join(__profile__, 'temp')).decode("utf-8") +__cwd__ = unicode(xbmc.translatePath(__addon__.getAddonInfo('path')),'utf-8') +__profile__ = unicode(xbmc.translatePath(__addon__.getAddonInfo('profile')),'utf-8') +__resource__ = unicode(xbmc.translatePath(os.path.join(__cwd__, 'resources', 'lib')),'utf-8') +__temp__ = unicode(xbmc.translatePath(os.path.join(__profile__, 'temp')),'utf-8') sys.path.append(__resource__) @@ -96,6 +96,7 @@ def get_params(string=""): params = get_params() if params['action'] in ['search', 'manualsearch']: + log(__scriptname__, "Version: '%s'" % (__version__)) log(__scriptname__, "action '%s' called" % (params['action'])) if params['action'] == 'manualsearch': @@ -112,10 +113,10 @@ if params['action'] in ['search', 'manualsearch']: item['title'] = params['searchstring'] if params['action'] == 'manualsearch' \ else normalizeString(xbmc.getInfoLabel("VideoPlayer.OriginalTitle")) # try to get original title item['file_original_path'] = urllib.unquote( - xbmc.Player().getPlayingFile().decode('utf-8')) # Full path of a playing file + unicode(xbmc.Player().getPlayingFile(),'utf-8')) # Full path of a playing file item['3let_language'] = [] - for lang in urllib.unquote(params['languages']).decode('utf-8').split(","): + for lang in unicode(urllib.unquote(params['languages']),'utf-8').split(","): item['3let_language'].append(xbmc.convertLanguage(lang, xbmc.ISO_639_2)) if item['title'] == "": http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=4b0579786e8d206da75346f6f3f5c64200788eca commit 4b0579786e8d206da75346f6f3f5c64200788eca Author: Martijn Kaijser <mcm.kaij...@gmail.com> Date: Sun May 18 12:04:32 2014 +0200 [service.subtitles.subtitle] 4.2.1 diff --git a/service.subtitles.subtitle/addon.xml b/service.subtitles.subtitle/addon.xml index 9f1d0f6..2dbb298 100644 --- a/service.subtitles.subtitle/addon.xml +++ b/service.subtitles.subtitle/addon.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <addon id="service.subtitles.subtitle" name="Subtitle.co.il" - version="4.1.9" + version="4.2.1" provider-name="CaTz"> <requires> <import addon="xbmc.python" version="2.14.0"/> diff --git a/service.subtitles.subtitle/changelog.txt b/service.subtitles.subtitle/changelog.txt index b8a0886..60b21f8 100644 --- a/service.subtitles.subtitle/changelog.txt +++ b/service.subtitles.subtitle/changelog.txt @@ -1,3 +1,10 @@ +4.2.1 - by CaTz 16/05/2014 +- Improvement of RLS title parsing + +4.2.0 - by maortal 14/05/2014 +- Performance boost replaced decode with unicode method (should be replaced again if XBMC moves to python3) +- Fix android issues with re.sub (duo to usage of python 2.6) + 4.1.9 - by CaTz 11/05/2014 - Advanced Movie Title / TV-show parsing (includes release) diff --git a/service.subtitles.subtitle/resources/lib/SUBUtilities.py b/service.subtitles.subtitle/resources/lib/SUBUtilities.py index 8458d60..9981d27 100644 --- a/service.subtitles.subtitle/resources/lib/SUBUtilities.py +++ b/service.subtitles.subtitle/resources/lib/SUBUtilities.py @@ -27,10 +27,11 @@ __addon__ = xbmcaddon.Addon() __version__ = __addon__.getAddonInfo('version') # Module version __scriptname__ = __addon__.getAddonInfo('name') __language__ = __addon__.getLocalizedString -__profile__ = xbmc.translatePath(__addon__.getAddonInfo('profile')).decode("utf-8") -__temp__ = xbmc.translatePath(os.path.join(__profile__, 'temp')).decode("utf-8") +__profile__ = unicode(xbmc.translatePath(__addon__.getAddonInfo('profile')), 'utf-8') +__temp__ = unicode(xbmc.translatePath(os.path.join(__profile__, 'temp')), 'utf-8') cache = StorageServer.StorageServer(__scriptname__, int(24 * 364 / 2)) # 6 months +regexHelper = re.compile('\W+', re.UNICODE) #=============================================================================== # Private utility functions @@ -42,19 +43,22 @@ def normalizeString(str): def clean_title(item): - item["title"] = os.path.splitext(item["title"])[0] - item["tvshow"] = os.path.splitext(item["tvshow"])[0] + item["title"] = unicode(os.path.splitext(item["title"])[0], "utf-8") + item["tvshow"] = unicode(os.path.splitext(item["tvshow"])[0], "utf-8") def parse_rls_title(item): - groups = re.findall(r"(.*)(?:s|season)(\d{2})(?:e|x|episode|\n)(\d{2})", item["title"], re.I) + item["title"] = regexHelper.sub(' ', item["title"]) + item["tvshow"] = regexHelper.sub(' ', item["tvshow"]) + + groups = re.findall(r"(.*) (?:s|season|)(\d{1,2})(?:e|episode|x|\n)(\d{1,2})", item["title"], re.I) if len(groups) == 0: - groups = re.findall(r"(.*)(?:s|season)(\d{2})(?:e|x|episode|\n)(\d{2})", item["tvshow"], re.I) + groups = re.findall(r"(.*) (?:s|season|)(\d{1,2})(?:e|episode|x|\n)(\d{1,2})", item["tvshow"], re.I) if len(groups) > 0 and len(groups[0]) == 3: title, season, episode = groups[0] - item["tvshow"] = re.sub('\W+', ' ', title, 0, re.UNICODE).strip() + item["tvshow"] = regexHelper.sub(' ', title).strip() item["season"] = str(int(season)) item["episode"] = str(int(episode)) log(__scriptname__, "TV Parsed Item: %s" % (item,)) @@ -63,7 +67,7 @@ def parse_rls_title(item): groups = re.findall(r"(.*)(\d{4})", item["title"], re.I) if len(groups) > 0 and len(groups[0]) >= 1: title = groups[0][0] - item["title"] = re.sub('\W+', ' ', title, 0, re.UNICODE).strip() + item["title"] = regexHelper.sub(' ', title).strip() item["year"] = groups[0][1] if len(groups[0]) == 2 else item["year"] log(__scriptname__, "MOVIE Parsed Item: %s" % (item,)) @@ -74,7 +78,7 @@ def log(module, msg): def get_cache_key(prefix="", str=""): - str = re.sub('\W+', '_', str.decode("utf-8"), 0, re.UNICODE).lower() + str = regexHelper.sub('_', str).lower() return prefix + '_' + str @@ -117,14 +121,13 @@ class SubtitleHelper: # return list of tv-series from the site`s search def _search_tvshow(self, item): search_string = re.split(r'\s\(\w+\)$', item["tvshow"])[0] - search_string = re.sub('\W+', ' ', search_string.decode("utf-8"), 0, re.UNICODE).lower().encode("utf-8") cache_key = get_cache_key("tv-show", search_string) results = cache.get(cache_key) if not results: - query = {"q": search_string.lower(), "cs": "series"} - + query = {"q": search_string.encode("utf-8").lower(), "cs": "series"} + log(__scriptname__, query) search_result = self.urlHandler.request(self.BASE_URL + "/browse.php?" + urllib.urlencode(query)) if search_result is None: return results # return empty set @@ -145,7 +148,7 @@ class SubtitleHelper: def _search_movie(self, item): results = [] search_string = item["title"] - query = {"q": search_string.lower(), "cs": "movies"} + query = {"q": search_string.encode("utf-8").lower(), "cs": "movies"} if item["year"]: query["fy"] = int(item["year"]) - 1 query["uy"] = int(item["year"]) + 1 @@ -163,8 +166,7 @@ class SubtitleHelper: def _filter_urls(self, urls, search_string, item): filtered = [] - search_string = search_string.decode("utf-8").lower() - search_string = re.sub('\W+', ' ', search_string, 0, re.UNICODE) + search_string = regexHelper.sub(' ', search_string.lower()) h = HTMLParser.HTMLParser() @@ -172,14 +174,14 @@ class SubtitleHelper: if not item["tvshow"]: for (id, heb_name, eng_name, year) in urls: - eng_name = eng_name.decode("utf-8") - heb_name = heb_name.decode("utf-8") + eng_name = unicode(eng_name, 'utf-8') + heb_name = unicode(heb_name, 'utf-8') eng_name = h.unescape(eng_name).replace(' ...', '').lower() heb_name = h.unescape(heb_name).replace(' ...', '') - eng_name = re.sub('\W+', ' ', eng_name, 0, re.UNICODE) - heb_name = re.sub('\W+', ' ', heb_name, 0, re.UNICODE) + eng_name = regexHelper.sub(' ', eng_name) + heb_name = regexHelper.sub(' ', heb_name) if (search_string.startswith(eng_name) or eng_name.startswith(search_string) or search_string.startswith(heb_name) or heb_name.startswith(search_string)) and \ @@ -190,14 +192,14 @@ class SubtitleHelper: filtered.append({"name": eng_name, "id": id, "year": year}) else: for (id, heb_name, eng_name) in urls: - eng_name = eng_name.decode("utf-8") - heb_name = heb_name.decode("utf-8") + eng_name = unicode(eng_name, 'utf-8') + heb_name = unicode(heb_name, 'utf-8') eng_name = h.unescape(eng_name).replace(' ...', '').lower() heb_name = h.unescape(heb_name).replace(' ...', '') - eng_name = re.sub('\W+', ' ', eng_name, 0, re.UNICODE) - heb_name = re.sub('\W+', ' ', heb_name, 0, re.UNICODE) + eng_name = regexHelper.sub(' ', eng_name) + heb_name = regexHelper.sub(' ', heb_name) if (search_string.startswith(eng_name) or eng_name.startswith(search_string) or search_string.startswith(heb_name) or heb_name.startswith(search_string)): @@ -370,7 +372,8 @@ class SubtitleHelper: def _is_logged_in(self, url): content = self.urlHandler.request(url) - if content is not None and (re.search(r'friends\.php', content) or not re.search(r'login\.php', content)): #check if logged in + if content is not None and ( + re.search(r'friends\.php', content) or not re.search(r'login\.php', content)): #check if logged in return content elif self.login(): return self.urlHandler.request(url) diff --git a/service.subtitles.subtitle/service.py b/service.subtitles.subtitle/service.py index e51e720..1c0e38f 100644 --- a/service.subtitles.subtitle/service.py +++ b/service.subtitles.subtitle/service.py @@ -17,10 +17,10 @@ __scriptname__ = __addon__.getAddonInfo('name') __version__ = __addon__.getAddonInfo('version') __language__ = __addon__.getLocalizedString -__cwd__ = xbmc.translatePath(__addon__.getAddonInfo('path')).decode("utf-8") -__profile__ = xbmc.translatePath(__addon__.getAddonInfo('profile')).decode("utf-8") -__resource__ = xbmc.translatePath(os.path.join(__cwd__, 'resources', 'lib')).decode("utf-8") -__temp__ = xbmc.translatePath(os.path.join(__profile__, 'temp')).decode("utf-8") +__cwd__ = unicode(xbmc.translatePath(__addon__.getAddonInfo('path')), 'utf-8') +__profile__ = unicode(xbmc.translatePath(__addon__.getAddonInfo('profile')), 'utf-8') +__resource__ = unicode(xbmc.translatePath(os.path.join(__cwd__, 'resources', 'lib')), 'utf-8') +__temp__ = unicode(xbmc.translatePath(os.path.join(__profile__, 'temp')), 'utf-8') sys.path.append(__resource__) @@ -93,6 +93,7 @@ def get_params(string=""): params = get_params() if params['action'] in ['search', 'manualsearch']: + log(__scriptname__, "Version: '%s'" % (__version__)) log(__scriptname__, "action '%s' called" % (params['action'])) if params['action'] == 'manualsearch': @@ -109,10 +110,10 @@ if params['action'] in ['search', 'manualsearch']: item['title'] = params['searchstring'] if params['action'] == 'manualsearch' \ else normalizeString(xbmc.getInfoLabel("VideoPlayer.OriginalTitle")) # try to get original title item['file_original_path'] = urllib.unquote( - xbmc.Player().getPlayingFile().decode('utf-8')) # Full path of a playing file + unicode(xbmc.Player().getPlayingFile(),'utf-8')) # Full path of a playing file item['3let_language'] = [] - for lang in urllib.unquote(params['languages']).decode('utf-8').split(","): + for lang in unicode(urllib.unquote(params['languages']),'utf-8').split(","): item['3let_language'].append(xbmc.convertLanguage(lang, xbmc.ISO_639_2)) if item['title'] == "": ----------------------------------------------------------------------- Summary of changes: service.subtitles.subscenter/addon.xml | 2 +- service.subtitles.subscenter/changelog.txt | 7 +++ .../resources/lib/SUBUtilities.py | 42 +++++++++------- service.subtitles.subscenter/service.py | 13 +++-- service.subtitles.subtitle/addon.xml | 2 +- service.subtitles.subtitle/changelog.txt | 7 +++ .../resources/lib/SUBUtilities.py | 51 ++++++++++--------- service.subtitles.subtitle/service.py | 13 +++-- 8 files changed, 80 insertions(+), 57 deletions(-) hooks/post-receive -- Scripts ------------------------------------------------------------------------------ "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs _______________________________________________ Xbmc-addons mailing list Xbmc-addons@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xbmc-addons