Skip to content

Commit

Permalink
- Bug fix, add slash or backslash at the end of path (fix xbmcvfs.exi…
Browse files Browse the repository at this point in the history
…sts in Helix)

- Add support for preferred language in Helix
  • Loading branch information
CaTzil committed Nov 8, 2014
1 parent 3a5f819 commit 4055031
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 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.subtitle"
name="Subtitle.co.il"
version="4.2.3"
version="4.3.0"
provider-name="CaTz">
<requires>
<import addon="xbmc.python" version="2.14.0"/>
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
4.3.0 - by CaTz 08/11/2014
- Bug fix, add slash or backslash at the end of path (fix xbmcvfs.exists in Helix)
- Add support for preferred language in Helix

4.2.3 - by CaTz 12/08/2014
- Removes country identifier at the end of the title

Expand Down
14 changes: 8 additions & 6 deletions resources/lib/SUBUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
__scriptname__ = __addon__.getAddonInfo('name')
__language__ = __addon__.getLocalizedString
__profile__ = unicode(xbmc.translatePath(__addon__.getAddonInfo('profile')), 'utf-8')
__temp__ = unicode(xbmc.translatePath(os.path.join(__profile__, 'temp')), '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
#===============================================================================
# ===============================================================================
def normalizeString(str):
return unicodedata.normalize(
'NFKD', unicode(unicode(str, 'utf-8'))
Expand Down Expand Up @@ -226,7 +226,7 @@ def _build_movie_subtitle_list(self, search_results, item):
for it in ret:
it["rating"] = str(int(round(it["rating"] / float(total_downloads), 1) * 5))

return sorted(ret, key=lambda x: (x['lang_index'], x['sync'], x['rating']), reverse=True)
return sorted(ret, key=lambda x: (x['is_preferred'], x['lang_index'], x['sync'], x['rating']), reverse=True)

def _build_tvshow_subtitle_list(self, search_results, item):
ret = []
Expand Down Expand Up @@ -298,7 +298,7 @@ def _build_tvshow_subtitle_list(self, search_results, item):
for it in ret:
it["rating"] = str(int(round(it["rating"] / float(total_downloads), 1) * 5))

return sorted(ret, key=lambda x: (x['lang_index'], x['sync'], x['rating']), reverse=True)
return sorted(ret, key=lambda x: (x['is_preferred'], x['lang_index'], x['sync'], x['rating']), reverse=True)

def _retrive_subtitles(self, page, item):
ret = []
Expand All @@ -324,7 +324,9 @@ def _retrive_subtitles(self, page, item):
'id': subtitle_id,
'rating': int(downloads.replace(",", "")),
'sync': subtitle_rate >= 3.8,
'hearing_imp': 0
'hearing_imp': 0,
'is_preferred':
xbmc.convertLanguage(heb_to_eng(language), xbmc.ISO_639_2) == item['preferredlanguage']
})
return ret, total_downloads

Expand Down
2 changes: 2 additions & 0 deletions service.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def get_params(string=""):
item['file_original_path'] = urllib.unquote(
unicode(xbmc.Player().getPlayingFile(),'utf-8')) # Full path of a playing file
item['3let_language'] = []
item['preferredlanguage'] = unicode(urllib.unquote(params.get('preferredlanguage', '')), 'utf-8')
item['preferredlanguage'] = xbmc.convertLanguage(item['preferredlanguage'], xbmc.ISO_639_2)

for lang in unicode(urllib.unquote(params['languages']),'utf-8').split(","):
item['3let_language'].append(xbmc.convertLanguage(lang, xbmc.ISO_639_2))
Expand Down

0 comments on commit 4055031

Please sign in to comment.