def __getattr__(self, name): if name in ['MOVIE_PATH', 'TV_SHOWS_PATH']: export = self._g.DATA_PATH if self._gs('enablelibraryfolder') == 'true': export = py2_decode(xbmc.translatePath(self._gs('customlibraryfolder'))) export = OSPJoin(export, 'Movies' if 'MOVIE_PATH' == name else 'TV') return export + '\\' if '\\' in export else export + '/' elif 'Language' == name: # Language settings l = jsonRPC('Settings.GetSettingValue', param={'setting': 'locale.audiolanguage'}) l = xbmc.convertLanguage(l['value'], xbmc.ISO_639_1) l = l if l else xbmc.getLanguage(xbmc.ISO_639_1, False) return l if l else 'en' elif 'playMethod' == name: return int(self._gs('playmethod')) elif 'browser' == name: return int(self._gs('browser')) elif 'MaxResults' == name: return int(self._gs('items_perpage')) elif 'tvdb_art' == name: return self._gs('tvdb_art') elif 'tmdb_art' == name: return self._gs('tmdb_art') elif 'showfanart' == name: return self._gs('useshowfanart') == 'true' elif 'dispShowOnly' == name: return self._gs('disptvshow') == 'true' elif 'payCont' == name: return self._gs('paycont') == 'true' elif 'verbLog' == name: return self._gs('logging') == 'true' elif 'useIntRC' == name: return self._gs('remotectrl') == 'true' elif 'RMC_vol' == name: return self._gs('remote_vol') == 'true' elif 'ms_mov' == name: ms_mov = self._gs('mediasource_movie'); return ms_mov if ms_mov else 'Amazon Movies' elif 'ms_tv' == name: ms_tv = self._gs('mediasource_tv'); return ms_tv if ms_tv else 'Amazon TV' elif 'multiuser' == name: return self._gs('multiuser') == 'true' elif 'DefaultFanart' == name: return OSPJoin(self._g.PLUGIN_PATH, 'fanart.png') elif 'ThumbIcon' == name: return OSPJoin(self._g.PLUGIN_PATH, 'resources', 'thumb.png') elif 'NextIcon' == name: return OSPJoin(self._g.PLUGIN_PATH, 'resources', 'next.png') elif 'HomeIcon' == name: return OSPJoin(self._g.PLUGIN_PATH, 'resources', 'home.png') elif 'wl_order' == name: return ['DATE_ADDED_DESC', 'TITLE_DESC', 'TITLE_ASC'][int('0' + self._gs('wl_order'))] elif 'verifySsl' == name: return self._gs('ssl_verif') == 'false' elif 'OfferGroup' == name: return '' if self.payCont else '&OfferGroups=B0043YVHMY' elif 'wl_export' == name: return self._gs('wl_export') == 'true' elif 'region' == name: return int(self._gs('region')) elif 'proxyaddress' == name: return getConfig('proxyaddress') elif 'subtitleStretch' == name: return self._gs('sub_stretch') == 'true' elif 'subtitleStretchFactor' == name: return [24 / 23.976, 23.976 / 24, 25 / 23.976, 23.976 / 25, 25.0 / 24.0, 24.0 / 25.0][int(self._gs('sub_stretch_factor'))] elif 'audioDescriptions' == name: return self._gs('audio_description') == 'true' elif 'removePosters' == name: return self._gs('pv_episode_thumbnails') == 'true' elif 'useEpiThumbs' == name: return self._gs('tld_episode_thumbnails') == 'true' elif 'bypassProxy' == name: return self._gs('proxy_mpdalter') == 'false' elif 'uhdAndroid' == name: return self._gs('uhd_android') == 'true' elif 'skip_scene' == name: return int('0' + self._gs('skip_scene')) elif 'pagination' == name: return { 'all': self._gs('paginate_everything') == 'true', 'watchlist': self._gs('paginate_watchlist') == 'true', 'collections': self._gs('paginate_collections') == 'true', 'search': self._gs('paginate_search') == 'true' }
def display_subs(subs_list, episode_url, filename): """ Display the list of found subtitles :param subs_list: the list or generator of tuples (subs item, synced) :param episode_url: the URL for the episode page on addic7ed.com. It is needed for downloading subs as 'Referer' HTTP header. :param filename: the name of the video-file being played. Each item in the displayed list is a ListItem instance with the following properties: - label: Kodi language name (e.g. 'English') - label2: a descriptive text for subs - thumbnailImage: a 2-letter language code (e.g. 'en') to display a country flag. - 'hearing_imp': if 'true' then 'CC' icon is displayed for the list item. - 'sync': if 'true' then 'SYNC' icon is displayed for the list item. - url: a plugin call URL for downloading selected subs. """ subs_list = sorted( _detect_synced_subs(subs_list, filename), key=lambda i: i[1], reverse=True ) for item, synced in subs_list: if item.unfinished: continue list_item = xbmcgui.ListItem(label=item.language, label2=item.version) list_item.setArt( {'thumb': xbmc.convertLanguage(item.language, xbmc.ISO_639_1)} ) if item.hi: list_item.setProperty('hearing_imp', 'true') if synced: list_item.setProperty('sync', 'true') url = '{0}?{1}'.format( sys.argv[0], urlparse.urlencode( {'action': 'download', 'link': item.link, 'ref': episode_url, 'filename': filename} ) ) xbmcplugin.addDirectoryItem(handle=handle, url=url, listitem=list_item, isFolder=False)
def display_subs(subs_list, episode_url, filename): """ Display the list of found subtitles :param subs_list: the list or generator of tuples (subs item, synced) :param episode_url: the URL for the episode page on addic7ed.com. It is needed for downloading subs as 'Referer' HTTP header. :param filename: the name of the video-file being played. Each item in the displayed list is a ListItem instance with the following properties: - label: Kodi language name (e.g. 'English') - label2: a descriptive text for subs - thumbnailImage: a 2-letter language code (e.g. 'en') to display a country flag. - 'hearing_imp': if 'true' then 'CC' icon is displayed for the list item. - 'sync': if 'true' then 'SYNC' icon is displayed for the list item. - url: a plugin call URL for downloading selected subs. """ subs_list = sorted( _detect_synced_subs(subs_list, filename), key=lambda i: i[1], reverse=True ) for item, synced in subs_list: if addon.getSetting('do_login') != 'true' and item.unfinished: continue list_item = xbmcgui.ListItem(label=item.language, label2=item.version) list_item.setArt( {'thumb': xbmc.convertLanguage(item.language, xbmc.ISO_639_1)} ) if item.hi: list_item.setProperty('hearing_imp', 'true') if synced: list_item.setProperty('sync', 'true') url = '{0}?{1}'.format( sys.argv[0], urlparse.urlencode( {'action': 'download', 'link': item.link, 'ref': episode_url, 'filename': filename} ) ) xbmcplugin.addDirectoryItem(handle=handle, url=url, listitem=list_item, isFolder=False)
def ConvertLanguage(self, *args, **kwargs): return xbmc.convertLanguage(*args, **kwargs)
def containsLanguage(strlang, langs): for lang in strlang.split(','): if xbmc.convertLanguage(lang, xbmc.ISO_639_2) in langs: return True return False
def get(self, name, imdb, season, episode): try: if not control.setting('subtitles') == 'true': raise Exception() langDict = { 'Afrikaans': 'afr', 'Albanian': 'alb', 'Arabic': 'ara', 'Armenian': 'arm', 'Basque': 'baq', 'Bengali': 'ben', 'Bosnian': 'bos', 'Breton': 'bre', 'Bulgarian': 'bul', 'Burmese': 'bur', 'Catalan': 'cat', 'Chinese': 'chi', 'Croatian': 'hrv', 'Czech': 'cze', 'Danish': 'dan', 'Dutch': 'dut', 'English': 'eng', 'Esperanto': 'epo', 'Estonian': 'est', 'Finnish': 'fin', 'French': 'fre', 'Galician': 'glg', 'Georgian': 'geo', 'German': 'ger', 'Greek': 'ell', 'Hebrew': 'heb', 'Hindi': 'hin', 'Hungarian': 'hun', 'Icelandic': 'ice', 'Indonesian': 'ind', 'Italian': 'ita', 'Japanese': 'jpn', 'Kazakh': 'kaz', 'Khmer': 'khm', 'Korean': 'kor', 'Latvian': 'lav', 'Lithuanian': 'lit', 'Luxembourgish': 'ltz', 'Macedonian': 'mac', 'Malay': 'may', 'Malayalam': 'mal', 'Manipuri': 'mni', 'Mongolian': 'mon', 'Montenegrin': 'mne', 'Norwegian': 'nor', 'Occitan': 'oci', 'Persian': 'per', 'Polish': 'pol', 'Portuguese': 'por,pob', 'Portuguese(Brazil)': 'pob,por', 'Romanian': 'rum', 'Russian': 'rus', 'Serbian': 'scc', 'Sinhalese': 'sin', 'Slovak': 'slo', 'Slovenian': 'slv', 'Spanish': 'spa', 'Swahili': 'swa', 'Swedish': 'swe', 'Syriac': 'syr', 'Tagalog': 'tgl', 'Tamil': 'tam', 'Telugu': 'tel', 'Thai': 'tha', 'Turkish': 'tur', 'Ukrainian': 'ukr', 'Urdu': 'urd' } codePageDict = { 'ara': 'cp1256', 'ar': 'cp1256', 'ell': 'cp1253', 'el': 'cp1253', 'heb': 'cp1255', 'he': 'cp1255', 'tur': 'cp1254', 'tr': 'cp1254', 'rus': 'cp1251', 'ru': 'cp1251' } quality = [ 'bluray', 'hdrip', 'brrip', 'bdrip', 'dvdrip', 'webrip', 'hdtv' ] langs = [] try: try: langs = langDict[control.setting( 'subtitles.lang.1')].split(',') except: langs.append(langDict[control.setting('subtitles.lang.1')]) except: pass try: try: langs = langs + langDict[control.setting( 'subtitles.lang.2')].split(',') except: langs.append(langDict[control.setting('subtitles.lang.2')]) except: pass try: subLang = xbmc.Player().getSubtitles() except: subLang = '' if subLang == langs[0]: raise Exception() un = control.setting('os.user') pw = control.setting('os.pass') server = xmlrpc_client.Server( 'http://api.opensubtitles.org/xml-rpc', verbose=0) token = server.LogIn(un, pw, 'en', 'XBMC_Subtitles_Unofficial_v5.2.14')['token'] sublanguageid = ','.join(langs) imdbid = re.sub('[^0-9]', '', imdb) if not (season == None or episode == None): result = server.SearchSubtitles(token, [{ 'sublanguageid': sublanguageid, 'imdbid': imdbid, 'season': season, 'episode': episode }])['data'] fmt = ['hdtv'] else: result = server.SearchSubtitles(token, [{ 'sublanguageid': sublanguageid, 'imdbid': imdbid }])['data'] try: vidPath = xbmc.Player().getPlayingFile() except: vidPath = '' fmt = re.split('\.|\(|\)|\[|\]|\s|\-', vidPath) fmt = [i.lower() for i in fmt] fmt = [i for i in fmt if i in quality] filter = [] result = [i for i in result if i['SubSumCD'] == '1'] for lang in langs: filter += [ i for i in result if i['SubLanguageID'] == lang and any( x in i['MovieReleaseName'].lower() for x in fmt) ] filter += [ i for i in result if i['SubLanguageID'] == lang and any( x in i['MovieReleaseName'].lower() for x in quality) ] filter += [i for i in result if i['SubLanguageID'] == lang] try: lang = xbmc.convertLanguage(filter[0]['SubLanguageID'], xbmc.ISO_639_1) except: lang = filter[0]['SubLanguageID'] subname = str(filter[0]['SubFileName']) content = [ filter[0]['IDSubtitleFile'], ] content = server.DownloadSubtitles(token, content) content = base64.b64decode(content['data'][0]['data']) content = gzip.GzipFile(fileobj=six.BytesIO(content)).read() if six.PY3: content = six.ensure_text(content) subtitle = control.transPath('special://temp/') subtitle = os.path.join(subtitle, 'TemporarySubs.%s.srt' % lang) codepage = codePageDict.get(lang, '') if codepage and control.setting('subtitles.utf') == 'true': try: content_encoded = codecs.decode(content, codepage) content = codecs.encode(content_encoded, 'utf-8') except: pass file = control.openFile(subtitle, 'w') file.write(str(content)) file.close() xbmc.sleep(1000) xbmc.Player().setSubtitles(subtitle) if control.setting('subtitles.notify') == 'true': if xbmc.Player().isPlaying() and xbmc.Player().isPlayingVideo( ): control.execute('Dialog.Close(all,true)') xbmc.sleep(3000) control.infoDialog( subname, heading='{} subtitles downloaded'.format( str(lang).upper()), time=6000) except: pass
item['rar'] = False item['mansearch'] = False item['year'] = xbmc.getInfoLabel("VideoPlayer.Year") # Year item['season'] = str(xbmc.getInfoLabel("VideoPlayer.Season")) # Season item['episode'] = str(xbmc.getInfoLabel("VideoPlayer.Episode")) # Episode item['tvshow'] = xbmc.getInfoLabel("VideoPlayer.TVshowtitle") # Show item['title'] = 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 item['3let_language'] = [] if 'searchstring' in params: item['mansearch'] = True item['mansearchstr'] = params['searchstring'] for lang in urllib.unquote(params['languages']).decode('utf-8').split(","): item['3let_language'].append(xbmc.convertLanguage(lang,xbmc.ISO_639_2)) if item['title'] == "": item['title'] = xbmc.getInfoLabel("VideoPlayer.Title") # no original title, get just Title if item['title'] == os.path.basename(xbmc.Player().getPlayingFile()): # get movie title and year if is filename title, year = xbmc.getCleanMovieTitle(item['title']) item['title'] = title.replace('[','').replace(']','') item['year'] = year if item['episode'].lower().find("s") > -1: # Check if season is "Special" item['season'] = "0" # item['episode'] = item['episode'][-1:] if ( item['file_original_path'].find("http") > -1 ): item['temp'] = True
def gui_language(self): language = xbmc.getLanguage().split(' (')[0] return xbmc.convertLanguage(language, xbmc.ISO_639_1)