diff --git a/channels.json b/channels.json index 25631448..e2a9f611 100644 --- a/channels.json +++ b/channels.json @@ -13,42 +13,41 @@ "casacinema": "https://www.casacinema.page", "cb01anime": "https://www.cineblog01.red", "cineblog01": "https://cb01.uno", - "cinemalibero": "https://cinemalibero.bar", + "cinemalibero": "https://cinemalibero.surf", "cinetecadibologna": "http://cinestore.cinetecadibologna.it", "discoveryplus": "https://www.discoveryplus.com", "dreamsub": "https://dreamsub.stream", "dsda": "https://www.dsda.press", - "eurostreaming": "https://eurostreaming.bar", + "eurostreaming": "https://eurostreaming.world", "filmigratis": "https://filmigratis.org", "guardaseriecam": "https://guardaserie.cam", "guardaserieclick": "https://www.guardaserie.builders", - "guardaserieicu": "https://guardaserie.cfd", + "guardaserieicu": "https://guardaserie.center", "hd4me": "https://hd4me.net", "ilcorsaronero": "https://ilcorsaronero.link", - "ilgeniodellostreaming": "https://ilgeniodellostreaming.wtf", + "ilgeniodellostreaming": "https://ilgeniodellostreaming.bet", "ilgeniodellostreaming_cam": "https://ilgeniodellostreaming.city", - "italiaserie": "https://italiaserie.date", + "italiaserie": "https://italiaserie.men", "mediasetplay": "https://www.mediasetplay.mediaset.it", "mondoserietv": "https://mondoserietv.club", "paramount": "https://www.paramountnetwork.it", - "piratestreaming": "https://www.piratestreaming.video", + "piratestreaming": "https://www.piratestreaming.design", "polpotv": "https://roma.polpo.tv", "raiplay": "https://www.raiplay.it", "seriehd": "https://altadefinizionecommunity.casa", "serietvonline": "https://serietvonline.art", "serietvsubita": "http://serietvsubita.xyz", "serietvu": "https://www.serietvu.live", - "streamingcommunity": "https://streamingcommunity.vip", "streamtime": "https://t.me/s/StreamTime", - "tantifilm": "https://www.tantifilm.stream", + "tantifilm": "https://www.tantifilm.cfd", "tapmovie": "https://it.tapmovie.net", "toonitalia": "https://toonitalia.co", "vvvvid": "https://www.vvvvid.it" }, "findhost": { - "altadefinizioneclick": "https://altadefinizione-nuovo.click", "altadefinizionecommunity": "https://altaregistrazione.net", + "animealtadefinizione": "https://www.animealtadefinizione.it", "filmpertutti": "https://filmpertuttiii.nuovo.live", - "streamingcommunity": "https://streamingcommunity-nuovo.link" + "streamingcommunity": "https://t.me/s/StreamingCommunity_nuovo_link" } } \ No newline at end of file diff --git a/channels/accuradio.py b/channels/accuradio.py index 8b0aee29..6a484e50 100644 --- a/channels/accuradio.py +++ b/channels/accuradio.py @@ -25,7 +25,7 @@ def mainlist(item): thumbnail = support.thumb('music') )) - itemlist.append(item.clone(title=support.typo(config.get_localized_string(70741) % 'Musica… ', 'bold'), action='search', thumbnail=support.thumb('music_search'))) + itemlist.append(item.clone(title=support.typo(config.getLocalizedString(70741) % 'Musica… ', 'bold'), action='search', thumbnail=support.thumb('music_search'))) support.channel_config(item, itemlist) return itemlist diff --git a/channels/altadefinizionecommunity.py b/channels/altadefinizionecommunity.py index 1630aaf1..4a96c226 100644 --- a/channels/altadefinizionecommunity.py +++ b/channels/altadefinizionecommunity.py @@ -22,7 +22,7 @@ if host.endswith('/'): host = host[:-1] headers = {'Referer': host} -order = ['', 'i_piu_visti', 'i_piu_votati', 'i_piu_votati_dellultimo_mese', 'titolo_az', 'voto_imdb_piu_alto'][config.get_setting('order', 'altadefinizionecommunity')] +order = ['', 'i_piu_visti', 'i_piu_votati', 'i_piu_votati_dellultimo_mese', 'titolo_az', 'voto_imdb_piu_alto'][config.getSetting('order', 'altadefinizionecommunity')] @support.menu @@ -168,9 +168,9 @@ def findvideos(item): def play(item): if host in item.url: # intercetto il server proprietario # if registerOrLogin(): - return support.get_jwplayer_mediaurl(support.httptools.downloadpage(item.url, cloudscraper=True).data, 'Diretto') + return support.get_jwplayer_mediaUrl(support.httptools.downloadpage(item.url, cloudscraper=True).data, 'Diretto') # else: - # platformtools.play_canceled = True + # platformtools.playCanceled = True # return [] else: return [item] @@ -180,9 +180,9 @@ def resolve_url(item): registerOrLogin() if '/watch-unsubscribed' not in item.url and '/watch-external' not in item.url: playWindow = support.match(support.httptools.downloadpage(item.url, cloudscraper=True).data, patron='playWindow" href="([^"]+)') - video_url = playWindow.match + videoUrl = playWindow.match item.data = playWindow.data - item.url = video_url.replace('/watch-unsubscribed', '/watch-external') + item.url = videoUrl.replace('/watch-unsubscribed', '/watch-external') return item @@ -195,33 +195,33 @@ def login(): logger.info('Login in corso') post = {'_token': '', 'form_action':'login', - 'email': config.get_setting('username', channel='altadefinizionecommunity'), - 'password':config.get_setting('password', channel='altadefinizionecommunity')} + 'email': config.getSetting('username', channel='altadefinizionecommunity'), + 'password':config.getSetting('password', channel='altadefinizionecommunity')} r = support.httptools.downloadpage(host + '/login', post=post, headers={'referer': host}, cloudscraper=True) if r.code not in [200, 302] or 'Email o Password non validi' in r.data: - platformtools.dialog_ok('AltadefinizioneCommunity', 'Username/password non validi') + platformtools.dialogOk('AltadefinizioneCommunity', 'Username/password non validi') return False return 'id="logged"' in r.data def registerOrLogin(): - if config.get_setting('username', channel='altadefinizionecommunity') and config.get_setting('password', channel='altadefinizionecommunity'): + if config.getSetting('username', channel='altadefinizionecommunity') and config.getSetting('password', channel='altadefinizionecommunity'): if login(): return True - action = platformtools.dialog_yesno('AltadefinizioneCommunity', + action = platformtools.dialogYesNo('AltadefinizioneCommunity', 'Questo server necessita di un account, ne hai già uno oppure vuoi tentare una registrazione automatica?', yeslabel='Accedi', nolabel='Tenta registrazione', customlabel='Annulla') if action == 1: # accedi from specials import setting from core.item import Item - user_pre = config.get_setting('username', channel='altadefinizionecommunity') - password_pre = config.get_setting('password', channel='altadefinizionecommunity') + user_pre = config.getSetting('username', channel='altadefinizionecommunity') + password_pre = config.getSetting('password', channel='altadefinizionecommunity') setting.channel_config(Item(config='altadefinizionecommunity')) - user_post = config.get_setting('username', channel='altadefinizionecommunity') - password_post = config.get_setting('password', channel='altadefinizionecommunity') + user_post = config.getSetting('username', channel='altadefinizionecommunity') + password_post = config.getSetting('password', channel='altadefinizionecommunity') if user_pre != user_post or password_pre != password_post: return registerOrLogin() @@ -235,7 +235,7 @@ def registerOrLogin(): randPsw = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(10)) logger.debug('email: ' + mailbox.address) logger.debug('pass: ' + randPsw) - reg = platformtools.dialog_register(register_url, email=True, password=True, email_default=mailbox.address, password_default=randPsw) + reg = platformtools.dialogRegister(register_url, email=True, password=True, email_default=mailbox.address, password_default=randPsw) if not reg: return False regPost = httptools.downloadpage(register_url, post={'email': reg['email'], 'password': reg['password']}, cloudscraper=True) @@ -243,27 +243,27 @@ def registerOrLogin(): if regPost.url == register_url: error = scrapertools.htmlclean(scrapertools.find_single_match(regPost.data, 'Impossibile proseguire.*?')) error = scrapertools.unescape(scrapertools.re.sub('\n\s+', ' ', error)) - platformtools.dialog_ok('AltadefinizioneCommunity', error) + platformtools.dialogOk('AltadefinizioneCommunity', error) return False if reg['email'] == mailbox.address: if "L'indirizzo email risulta già registrato" in regPost.data: # httptools.downloadpage(baseUrl + '/forgotPassword', post={'email': reg['email']}) - platformtools.dialog_ok('AltadefinizioneCommunity', 'Indirizzo mail già utilizzato') + platformtools.dialogOk('AltadefinizioneCommunity', 'Indirizzo mail già utilizzato') return False mail = mailbox.waitForMail() if mail: checkUrl = scrapertools.find_single_match(mail.body, ']+>Verifica').replace(r'\/', '/') logger.debug('CheckURL: ' + checkUrl) httptools.downloadpage(checkUrl, cloudscraper=True) - config.set_setting('username', mailbox.address, channel='altadefinizionecommunity') - config.set_setting('password', randPsw, channel='altadefinizionecommunity') - platformtools.dialog_ok('AltadefinizioneCommunity', + config.setSetting('username', mailbox.address, channel='altadefinizionecommunity') + config.setSetting('password', randPsw, channel='altadefinizionecommunity') + platformtools.dialogOk('AltadefinizioneCommunity', 'Registrato automaticamente con queste credenziali:\nemail:' + mailbox.address + '\npass: ' + randPsw) else: - platformtools.dialog_ok('AltadefinizioneCommunity', 'Impossibile registrarsi automaticamente') + platformtools.dialogOk('AltadefinizioneCommunity', 'Impossibile registrarsi automaticamente') return False else: - platformtools.dialog_ok('AltadefinizioneCommunity', 'Hai modificato la mail quindi KoD non sarà in grado di effettuare la verifica in autonomia, apri la casella ' + reg['email'] + platformtools.dialogOk('AltadefinizioneCommunity', 'Hai modificato la mail quindi KoD non sarà in grado di effettuare la verifica in autonomia, apri la casella ' + reg['email'] + ' e clicca sul link. Premi ok quando fatto') logger.debug('Registrazione completata') else: diff --git a/channels/animealtadefinizione.py b/channels/animealtadefinizione.py index 081f1af5..76a440d4 100644 --- a/channels/animealtadefinizione.py +++ b/channels/animealtadefinizione.py @@ -11,7 +11,7 @@ host = support.config.get_channel_url() headers = [['Referer', host]] perpage_list = ['20','30','40','50','60','70','80','90','100'] -perpage = perpage_list[support.config.get_setting('perpage' , 'animealtadefinizione')] +perpage = perpage_list[support.config.getSetting('perpage' , 'animealtadefinizione')] epPatron = r'\s*(?P[^<]+)[^>]+>[^>]+>\s*<a href="(?P<url>[^"]+)"' @@ -118,7 +118,7 @@ def findvideos(item): for title, url in matches: get_video_list(item, url, title, itemlist) else: - get_video_list(item, item.url, support.config.get_localized_string(30137), itemlist) + get_video_list(item, item.url, support.config.getLocalizedString(30137), itemlist) return support.server(item, itemlist=itemlist) diff --git a/channels/animeforce.py b/channels/animeforce.py index 5e6e9dfa..cf7d45b6 100644 --- a/channels/animeforce.py +++ b/channels/animeforce.py @@ -168,6 +168,6 @@ def findvideos(item): if url.startswith('//'): url = 'https:' + url elif url.startswith('/'): url = 'https:/' + url if 'vvvvid' in url: itemlist.append(item.clone(action="play", title='VVVVID', url=url, server='vvvvid')) - else: itemlist.append(item.clone(action="play", title=support.config.get_localized_string(30137), url=url, server='directo')) + else: itemlist.append(item.clone(action="play", title=support.config.getLocalizedString(30137), url=url, server='directo')) return support.server(item, itemlist=itemlist) diff --git a/channels/animesaturn.py b/channels/animesaturn.py index 61ee3437..56c45175 100644 --- a/channels/animesaturn.py +++ b/channels/animesaturn.py @@ -8,14 +8,14 @@ from platformcode import logger host = support.config.get_channel_url() __channel__ = 'animesaturn' -cookie = support.config.get_setting('cookie', __channel__) +cookie = support.config.getSetting('cookie', __channel__) headers = {'X-Requested-With': 'XMLHttpRequest', 'Cookie': cookie} def get_cookie(data): global cookie, headers cookie = support.match(data, patron=r'document.cookie="([^\s]+)').match - support.config.set_setting('cookie', cookie, __channel__) + support.config.setSetting('cookie', cookie, __channel__) headers = [['Cookie', cookie]] @@ -129,7 +129,7 @@ def movies(item): action = 'findvideos' def itemlistHook(itemlist): if page: - itemlist.append(item.clone(title=support.typo(support.config.get_localized_string(30992), 'color kod bold'),page= page, thumbnail=support.thumb())) + itemlist.append(item.clone(title=support.typo(support.config.getLocalizedString(30992), 'color kod bold'),page= page, thumbnail=support.thumb())) return itemlist elif 'filter' in item.args: page = support.match(data, patron=r'totalPages:\s*(\d+)').match @@ -138,7 +138,7 @@ def movies(item): if item.nextpage: item.nextpage += 1 else: item.nextpage = 2 if page and item.nextpage < int(page): - itemlist.append(item.clone(title=support.typo(support.config.get_localized_string(30992), 'color kod bold'), url= '{}&page={}'.format(item.url, item.nextpage), infoLabels={}, thumbnail=support.thumb())) + itemlist.append(item.clone(title=support.typo(support.config.getLocalizedString(30992), 'color kod bold'), url= '{}&page={}'.format(item.url, item.nextpage), infoLabels={}, thumbnail=support.thumb())) return itemlist else: diff --git a/channels/animeunity.py b/channels/animeunity.py index 494a5b4c..6b867966 100644 --- a/channels/animeunity.py +++ b/channels/animeunity.py @@ -47,7 +47,7 @@ def menu(item): if item.contentType == 'tvshow': itemlist += [item.clone(title='In Corso', args=InCorso), item.clone(title='Terminato', args=Terminato)] - itemlist +=[item.clone(title=support.typo(config.get_localized_string(70741).replace(' %s', '…'),'bold'), action='search', thumbnail=support.thumb('search'))] + itemlist +=[item.clone(title=support.typo(config.getLocalizedString(70741).replace(' %s', '…'),'bold'), action='search', thumbnail=support.thumb('search'))] return itemlist @@ -133,7 +133,7 @@ def news(item): fulltitle=it['anime']['title'], thumbnail=it['anime']['imageurl'], forcethumb = True, - video_url=it['scws_id'], + videoUrl=it['scws_id'], plot=it['anime']['plot'], action='findvideos') ) @@ -149,7 +149,7 @@ def movies(item): page = item.page if item.page else 0 item.args['offset'] = page * 30 - order = support.config.get_setting('order', item.channel) + order = support.config.getSetting('order', item.channel) if order: order_list = [ "Standard", "Lista A-Z", "Lista Z-A", "Popolarità", "Valutazione" ] item.args['order'] = order_list[order] @@ -186,7 +186,7 @@ def movies(item): itm.contentSerieName = '' itm.action = 'play' item.forcethumb=True - itm.video_url = it['episodes'][0]['scws_id'] + itm.videoUrl = it['episodes'][0]['scws_id'] else: itm.contentType = 'tvshow' @@ -194,7 +194,7 @@ def movies(item): itm.fulltitle = itm.show = itm.contentSerieName = title itm.action = 'episodes' itm.episodes = it['episodes'] if 'episodes' in it else it['scws_id'] - # itm.video_url = item.url + # itm.videoUrl = item.url itemlist.append(itm) @@ -219,7 +219,7 @@ def episodes(item): action='play', contentType='episode', forcethumb=True, - video_url=it['scws_id'])) + videoUrl=it['scws_id'])) if inspect.stack()[1][3] not in ['find_episodes']: autorenumber.start(itemlist, item) @@ -234,11 +234,11 @@ def play(item): from hashlib import md5 # Calculate Token - client_ip = support.httptools.downloadpage('https://scws.xyz/videos/{}'.format(item.video_url), headers=headers).json.get('client_ip') + client_ip = support.httptools.downloadpage('https://scws.xyz/videos/{}'.format(item.videoUrl), headers=headers).json.get('client_ip') expires = int(time() + 172800) token = b64encode(md5('{}{} Yc8U6r8KjAKAepEA'.format(expires, client_ip).encode('utf-8')).digest()).decode('utf-8').replace('=', '').replace('+', '-').replace('/', '_') - url = 'https://scws.xyz/master/{}?token={}&expires={}&n=1'.format(item.video_url, token, expires) + url = 'https://scws.xyz/master/{}?token={}&expires={}&n=1'.format(item.videoUrl, token, expires) return [item.clone(server='directo', url=url, manifest='hls')] diff --git a/channels/animeuniverse.py b/channels/animeuniverse.py index 9b4264f0..c71ea2c4 100644 --- a/channels/animeuniverse.py +++ b/channels/animeuniverse.py @@ -10,7 +10,7 @@ host = support.config.get_channel_url() headers = {} perpage_list = ['20','30','40','50','60','70','80','90','100'] -perpage = perpage_list[support.config.get_setting('perpage' , 'animeuniverse')] +perpage = perpage_list[support.config.getSetting('perpage' , 'animeuniverse')] epPatron = r'<td>\s*(?P<title>[^ <]+)\s*(?P<episode>\d+)?[^>]+>[^>]+>\s*<a href="(?P<url>[^"]+)"' @@ -94,7 +94,7 @@ def movies(item): def itemlistHook(itemlist): if len(itemlist) == int(perpage): item.pag += 1 - itemlist.append(item.clone(title=support.typo(support.config.get_localized_string(30992), 'color kod bold'), action='movies')) + itemlist.append(item.clone(title=support.typo(support.config.getLocalizedString(30992), 'color kod bold'), action='movies')) return itemlist return locals() @@ -116,7 +116,7 @@ def findvideos(item): for title, url in matches: get_video_list(url, title, itemlist) else: - get_video_list(item.url, support.config.get_localized_string(30137), itemlist) + get_video_list(item.url, support.config.getLocalizedString(30137), itemlist) return support.server(item, itemlist=itemlist) diff --git a/channels/animeworld.py b/channels/animeworld.py index 49c80886..58360ecb 100644 --- a/channels/animeworld.py +++ b/channels/animeworld.py @@ -9,14 +9,14 @@ from platformcode import logger host = support.config.get_channel_url() __channel__ = 'animeworld' -cookie = support.config.get_setting('cookie', __channel__) +cookie = support.config.getSetting('cookie', __channel__) headers = [['Cookie', cookie]] def get_cookie(data): global cookie, headers cookie = support.match(data, patron=r'document.cookie="([^\s]+)').match - support.config.set_setting('cookie', cookie, __channel__) + support.config.setSetting('cookie', cookie, __channel__) headers = [['Cookie', cookie]] @@ -33,7 +33,7 @@ def get_data(item): def order(): # Seleziona l'ordinamento dei risultati - return str(support.config.get_setting("order", __channel__)) + return str(support.config.getSetting("order", __channel__)) @support.menu @@ -130,7 +130,7 @@ def movies(item): if item.args == 'updated': item.contentType='episode' - patron=r'<div class="inner">\s*<a href="(?P<url>[^"]+)" class[^>]+>\s*<img.*?src="(?P<thumb>[^"]+)" alt?="(?P<title>[^\("]+)(?:\((?P<lang>[^\)]+)\))?"[^>]+>[^>]+>\s*(?:<div class="[^"]+">(?P<type>[^<]+)</div>)?[^>]+>[^>]+>\s*<div class="ep">[^\d]+(?P<episode>\d+)[^<]*</div>' + patron=r'<div class="inner">\s*<a href="(?P<url>[^"]+)" class[^>]+>\s*<img.*?src="(?P<thumb>[^"]+)" alt?="(?P<title>[^\("]+)(?:\((?P<lang>[^\)]+)\))?"[^>]+>[^>]+>\s*(?:<div class="[^"]+">(?P<type>[^<]+)</div>)?(?:[^>]+>){2,4}\s*<div class="ep">[^\d]+(?P<episode>\d+)[^<]*</div>' action='findvideos' else: patron= r'<div class="inner">\s*<a href="(?P<url>[^"]+)" class[^>]+>\s*<img.*?src="(?P<thumb>[^"]+)" alt?="(?P<title>[^\("]+)(?:\((?P<year>\d+)\) )?(?:\((?P<lang>[^\)]+)\))?(?P<title2>[^"]+)?[^>]+>[^>]+>(?:\s*<div class="(?P<l>[^"]+)">[^>]+>)?\s*(?:<div class="[^"]+">(?P<type>[^<]+)</div>)?' @@ -138,6 +138,7 @@ def movies(item): # Controlla la lingua se assente patronNext=r'<a href="([^"]+)" class="[^"]+" id="go-next' + patronTotalPages=r'<span class="total">(\d+)</span>' typeContentDict={'movie':['movie', 'special']} typeActionDict={'findvideos':['movie', 'special']} def itemHook(item): diff --git a/channels/aniplay.py b/channels/aniplay.py index 5cfb3937..ba31f13c 100644 --- a/channels/aniplay.py +++ b/channels/aniplay.py @@ -9,9 +9,9 @@ else: from concurrent_py2 import futures host = config.get_channel_url() -sort = ['views', 'title', 'episodeNumber', 'startDate', 'endDate', 'createdDate'][config.get_setting('sort', 'aniplay')] -order = 'asc' if config.get_setting('order', 'aniplay') else 'desc' -perpage = [10, 20, 30 ,40, 50, 60, 70, 80, 90][config.get_setting('perpage', 'aniplay')] +sort = ['views', 'title', 'episodeNumber', 'startDate', 'endDate', 'createdDate'][config.getSetting('sort', 'aniplay')] +order = 'asc' if config.getSetting('order', 'aniplay') else 'desc' +perpage = [10, 20, 30 ,40, 50, 60, 70, 80, 90][config.getSetting('perpage', 'aniplay')] @support.menu @@ -123,9 +123,7 @@ def newest(category): def latest_added(item): itemlist = [] - if config.get_setting("window_type") == 0: - item.window = True - item.folder = False + page = item.page if item.page else 0 url= '{}/api/home/latest-episodes?page={}'.format(host, page) js = httptools.downloadpage(url).json @@ -194,10 +192,6 @@ def episodes(item): logger.debug() itemlist = [] - if config.get_setting("window_type") == 0: - item.window = True - item.folder = False - # url = '{}/api/anime/{}'.format(host, item.id) json = httptools.downloadpage(item.url, CF=False ).json @@ -299,7 +293,7 @@ def findvideos(item): videourl = json['episodeVideo'] - itemlist = [item.clone(title=config.get_localized_string(30137), + itemlist = [item.clone(title=config.getLocalizedString(30137), url=videourl, server='directo')] diff --git a/channels/cineblog01.py b/channels/cineblog01.py index 396c4fe4..c0f31c76 100644 --- a/channels/cineblog01.py +++ b/channels/cineblog01.py @@ -191,7 +191,7 @@ def episodes(item): itemlist = support.season_pagination(itemlist, item, [], 'episodes') else: itemlist = support.pagination(itemlist, item, 'episodes') - if config.get_setting('episode_info'): + if config.getSetting('episode_info'): support.tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) support.videolibrary(itemlist, item) support.download(itemlist, item) diff --git a/channels/cinetecadibologna.py b/channels/cinetecadibologna.py index c441f273..acb8f5e9 100644 --- a/channels/cinetecadibologna.py +++ b/channels/cinetecadibologna.py @@ -68,7 +68,7 @@ def findvideos(item): matches = support.match(item, patron=r'filename: "(.*?)"').matches for url in matches: - itemlist.append(item.clone(action="play", title=support.config.get_localized_string(30137), server='directo', url=host + url)) + itemlist.append(item.clone(action="play", title=support.config.getLocalizedString(30137), server='directo', url=host + url)) return support.server(item, itemlist=itemlist) diff --git a/channels/discoveryplus.py b/channels/discoveryplus.py index c4c76ccc..48f40687 100644 --- a/channels/discoveryplus.py +++ b/channels/discoveryplus.py @@ -23,7 +23,7 @@ def Dict(item): @support.menu def mainlist(item): - top = [('Dirette {bold}', ['', 'live']), + top = [('Dirette {bullet bold}', ['', 'live']), ('Programmi {bullet bold tv}', ['', 'movies', 'programmi']), ('Generi {bullet bold tv}', ['', 'genres'])] @@ -32,20 +32,6 @@ def mainlist(item): return locals() -def liveDict(): - livedict = {} - - for key in session.get(api + '/cms/routes/canali?decorators=viewingHistory&include=default', headers=headers).json()['included']: - - if key['type'] == 'channel' and key.get('attributes',{}).get('hasLiveStream', '') and 'Free' in key.get('attributes',{}).get('packages', []): - title = key['attributes']['name'] - livedict[title] = {} - livedict[title]['plot'] = key['attributes']['description'] - livedict[title]['url'] = '{}/canali/{}'.format(host, key['attributes']['alternateId']) - livedict[title]['id'] = key['id'] - return livedict - - def search(item, text): itemlist = [] item.args = 'search' @@ -63,8 +49,14 @@ def search(item, text): def live(item): logger.debug() itemlist =[] - for name, values in liveDict().items(): - itemlist.append(item.clone(title=name, fulltitle=name, plot=values['plot'], url=values['url'], id=values['id'], action='play', forcethumb=True, no_return=True)) + for key in session.get(api + '/cms/routes/canali?decorators=viewingHistory&include=default', headers=headers).json()['included']: + if key['type'] == 'channel' and key.get('attributes',{}).get('hasLiveStream', '') and 'Free' in key.get('attributes',{}).get('packages', []): + title = key['attributes']['name'] + plot = key['attributes']['description'] + url = '{}/canali/{}'.format(host, key['attributes']['alternateId']) + _id = key['id'] + + itemlist.append(item.clone(title=title, fulltitle=title, plot=plot, url=url, id=_id, action='findvideos', forcethumb=True)) return support.thumb(itemlist, mode='live') @@ -166,7 +158,7 @@ def episodes(item): fulltitle=title, plot=plot, id=episode['id'], - action='play', + action='findvideos', contentType='episode', season=option['id'], episode=episode['attributes']['episodeNumber'], @@ -176,6 +168,9 @@ def episodes(item): if itemlist: itemlist.sort(key=lambda it: (int(it.season), int(it.episode))) return itemlist +def findvideos(item): + logger.debug() + return support.server(item, itemlist=[item.clone(server='directo', action='play')]) def play(item): if item.livefilter: diff --git a/channels/ilcorsaronero.py b/channels/ilcorsaronero.py index 84c76c37..3b159ed1 100644 --- a/channels/ilcorsaronero.py +++ b/channels/ilcorsaronero.py @@ -60,7 +60,7 @@ def movies(item): args = item.args args[0] += 1 support.nextPage(itemlist, item, next_page=item.url, "movies") - # itemlist.append(item.clone(title=support.typo(support.config.get_localized_string(30992), 'color kod bold'), args=args, thumbnail=support.thumb())) + # itemlist.append(item.clone(title=support.typo(support.config.getLocalizedString(30992), 'color kod bold'), args=args, thumbnail=support.thumb())) return itemlist return locals() diff --git a/channels/la7.py b/channels/la7.py index 49ebee1d..c737b360 100644 --- a/channels/la7.py +++ b/channels/la7.py @@ -24,8 +24,8 @@ headers = { @support.menu def mainlist(item): - top = [('Dirette {bold}', ['', 'live']), - ('Replay {bold}', ['', 'replay_channels'])] + top = [('Dirette {bullet bold}', ['', 'live']), + ('Replay {bullet bold}', ['', 'replay_channels'])] menu = [('Programmi TV {bullet bold}', ['/tutti-i-programmi', 'movies', '', 'tvshow']), ('Teche La7 {bullet bold}', ['/i-protagonisti', 'movies', '', 'tvshow'])] @@ -35,14 +35,14 @@ def mainlist(item): def live(item): - itemlist = [item.clone(title=support.typo('La7', 'bold'), fulltitle='La7', url= host + '/dirette-tv', action='play', forcethumb = True, no_return=True), - item.clone(title=support.typo('La7d', 'bold'), fulltitle='La7d', url= host + '/live-la7d', action='play', forcethumb = True, no_return=True)] + itemlist = [item.clone(title='La7', fulltitle='La7', url= host + '/dirette-tv', action='findvideos', forcethumb = True), + item.clone(title='La7d', fulltitle='La7d', url= host + '/live-la7d', action='findvideos', forcethumb = True)] return support.thumb(itemlist, mode='live') def replay_channels(item): - itemlist = [item.clone(title=support.typo('La7', 'bold'), fulltitle='La7', url= host + '/rivedila7/0/la7', action='replay_menu', forcethumb = True), - item.clone(title=support.typo('La7d', 'bold'), fulltitle='La7d', url= host + '/rivedila7/0/la7d', action='replay_menu', forcethumb = True)] + itemlist = [item.clone(title='La7', fulltitle='La7', url= host + '/rivedila7/0/la7', action='replay_menu', forcethumb = True), + item.clone(title='La7d', fulltitle='La7d', url= host + '/rivedila7/0/la7d', action='replay_menu', forcethumb = True)] return support.thumb(itemlist, mode='live') @@ -51,17 +51,17 @@ def replay_menu(item): action = 'replay' patron = r'href="(?P<url>[^"]+)"><div class="giorno-text">\s*(?P<day>[^>]+)</div><[^>]+>\s*(?P<num>[^<]+)</div><[^>]+>\s*(?P<month>[^<]+)<' def itemHook(item): - item.title = support.typo(item.day + ' ' + item.num + ' ' + item.month,'bold') + item.title = '{} {} {}'.format(item.day, item.num, item.month) return item return locals() @support.scrape def replay(item): - action = 'play' + action = 'findvideos' patron = r'guida-tv"><[^>]+><[^>]+>(?P<hour>[^<]+)<[^>]+><[^>]+><[^>]+>\s*<a href="(?P<url>[^"]+)"><[^>]+><div class="[^"]+" data-background-image="(?P<t>[^"]+)"><[^>]+><[^>]+><[^>]+><[^>]+>\s*(?P<name>[^<]+)<[^>]+><[^>]+><[^>]+>(?P<plot>[^<]+)<' def itemHook(item): - item.title = support.typo(item.hour + ' - ' + item.name,'bold') + item.title = '{} - {}'.format(item.hour, item.name) item.contentTitle = item.fulltitle = item.show = item.name item.thumbnail = 'http:' + item.t item.fanart = item.thumbnail @@ -85,14 +85,18 @@ def search(item, text): @support.scrape def movies(item): search = item.search - tmdbEnabled = False - videlibraryEnabled = False - downloadEnabled = False + disableAll = True action = 'episodes' patron = r'<a href="(?P<url>[^"]+)"[^>]+><div class="[^"]+" data-background-image="(?P<t>[^"]+)"></div><div class="titolo">\s*(?P<title>[^<]+)<' def itemHook(item): - logger.debug(item) - item.thumbnail = 'http:' + item.t if item.t.startswith('//') else item.t if item.t else item.thumbnail + prepose = '' + if item.t.startswith('//'): + prepose = 'http:' + elif item.t.startswith('/'): + prepose = host + elif not item.t.startswith('http'): + prepose = host + '/' + item.thumbnail = prepose + item.t item.fanart = item.thumb return item return locals() @@ -101,8 +105,7 @@ def movies(item): @support.scrape def episodes(item): data = support.match(item).data - # debug = True - action = 'play' + action = 'findvideos' if '>puntate<' in data: patronBlock = r'>puntate<(?P<block>.*?)home-block-outbrain' url = support.match(data, patron=r'>puntate<[^>]+>[^>]+>[^>]+><a href="([^"]+)"').match @@ -119,10 +122,10 @@ def episodes(item): def itemHook(item): if item.Thumb: item.t = item.Thumb item.thumbnail = 'http:' + item.t if item.t.startswith('//') else item.t if item.t else item.thumbnail - if item.Title: item.title = support.typo(item.Title, 'bold') + if item.Title: item.title = item.Title if item.date: item.title = support.re.sub(r'[Pp]untata (?:del )?\d+/\d+/\d+', '', item.title) - item.title += support.typo(item.date, '_ [] bold') + item.title = '{} [{}]'.format(item.title, item.date) if item.desc: item.plot = item.desc item.forcethumb = True item.fanart = item.thumbnail @@ -130,21 +133,16 @@ def episodes(item): return locals() +def findvideos(item): + logger.debug() + return support.server(item, itemlist=[item.clone(server='directo', action='play')]) + def play(item): logger.debug() - if item.livefilter: - for it in live(item): - if it.fulltitle == item.livefilter: - item = it - break data = support.match(item).data - match = support.match(data, patron='/content/entry/data/(.*?).mp4').match - if match: - url = 'https://awsvodpkg.iltrovatore.it/local/hls/,/content/entry/data/' + support.match(item, patron='/content/entry/data/(.*?).mp4').match + '.mp4.urlset/master.m3u8' - item = item.clone(title='Direct', url=url, server='directo', action='play') - else: + url = support.match(data, patron=r'''["]?dash["]?\s*:\s*["']([^"']+)["']''').match + if url: preurl = support.match(data, patron=r'preTokenUrl = "(.+?)"').match - url = support.match(data, patron=r'''["]?dash["]?\s*:\s*["']([^"']+)["']''').match tokenHeader = { 'host': headers['host_token'], 'user-agent': headers['user-agent'], @@ -171,4 +169,9 @@ def play(item): lic_url='%s|%s|R{SSM}|'%(license_url, preLic) item.drm = DRM item.license = lic_url + else: + match = support.match(data, patron='/content/entry/data/(.*?).mp4').match + if match: + url = 'https://awsvodpkg.iltrovatore.it/local/hls/,/content/entry/data/' + support.match(item, patron='/content/entry/data/(.*?).mp4').match + '.mp4.urlset/master.m3u8' + item = item.clone(url=url, server='directo', action='play') return support.servertools.find_video_items(item, data=url) diff --git a/channels/mediasetplay.py b/channels/mediasetplay.py index 4507f98f..9574dcf3 100644 --- a/channels/mediasetplay.py +++ b/channels/mediasetplay.py @@ -38,7 +38,7 @@ session.headers.update({'authorization': 'Bearer ' + Token}) sessionKey = session.get(sessionUrl.format(uuid=str(uuid.uuid4())), verify=False).json()['sessionKey'] session.headers.update({'x-session': sessionKey}) -pagination = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100][config.get_setting('pagination', 'mediasetplay')] +pagination = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100][config.getSetting('pagination', 'mediasetplay')] @support.menu @@ -224,7 +224,7 @@ def episodes(item): def play(item): logger.debug() item.no_return=True - mpd = config.get_setting('mpd', item.channel) + mpd = config.getSetting('mpd', item.channel) lic_url = 'https://widevine.entitlement.theplatform.eu/wv/web/ModularDrm/getRawWidevineLicense?releasePid={pid}&account=http://access.auth.theplatform.com/data/Account/2702976343&schema=1.0&token={token}|Accept=*/*&Content-Type=&User-Agent={ua}|R{{SSM}}|' diff --git a/channels/metalvideo.py b/channels/metalvideo.py index 61ca5616..371f2bc6 100644 --- a/channels/metalvideo.py +++ b/channels/metalvideo.py @@ -25,7 +25,7 @@ def mainlist(item): itemlist.append( support.Item( channel=item.channel, - title=support.typo(config.get_localized_string(70741) % 'Musica… ', 'bold'), + title=support.typo(config.getLocalizedString(70741) % 'Musica… ', 'bold'), contentType='music', url=item.url, action='search', diff --git a/channels/raiplay.py b/channels/raiplay.py index 004d309f..5b7e6ebc 100644 --- a/channels/raiplay.py +++ b/channels/raiplay.py @@ -100,8 +100,8 @@ def episodes(item): items = item.data elif item.season_url: items = requests.get(item.season_url).json()['items'] - elif item.video_url: - items = requests.get(item.video_url).json()['blocks'] + elif item.videoUrl: + items = requests.get(item.videoUrl).json()['blocks'] if 'sets' in items[0]: if len(items) > 1: @@ -119,7 +119,7 @@ def episodes(item): def epMenu(item): - video_url = '' + videoUrl = '' itemlist = [] for it in item.data: if 'sets' in it: @@ -141,7 +141,7 @@ def live(item): current = it['currentItem'] next = it['nextItem'] plot = '[B]{}[/B]\n{}\n\nA Seguire: [B]{}[/B]\n{}'.format(current['name'], current['description'], next['name'], next['description']) - itemlist.append(item.clone(title=title, fulltitle=title, fanart=fanart, plot=plot, url=url, video_url=url + '.json', action='play')) + itemlist.append(item.clone(title=title, fulltitle=title, fanart=fanart, plot=plot, url=url, videoUrl=url + '.json', action='play')) itemlist.sort(key=lambda it: support.channels_order.get(it.fulltitle, 999)) support.thumb(itemlist, mode='live') return itemlist @@ -206,7 +206,7 @@ def replay(item): fanart = image, plot = info['description'], url = getUrl(it['weblink']), - video_url = getUrl(it['path_id']), + videoUrl = getUrl(it['path_id']), action = 'play', forcethumb = True) @@ -228,7 +228,7 @@ def replay(item): def play(item): logger.debug() - res = requests.get(item.video_url).json() + res = requests.get(item.videoUrl).json() if 'first_item_path' in res: res = requests.get(getUrl(res['first_item_path'])).json() @@ -279,7 +279,7 @@ def addinfo(items, item): thumbnail= getUrl(thumb), fanart=getUrl(fanart), url=getUrl(key.get('weblink', '')), - video_url=getUrl(key['path_id']), + videoUrl=getUrl(key['path_id']), plot=info.get('description', '')) if 'Genere' not in key.get('sub_type', '') and ('layout' not in key or key['layout'] == 'single'): diff --git a/channels/serietvsubita.py b/channels/serietvsubita.py index a27bb4a0..a61fa8a8 100644 --- a/channels/serietvsubita.py +++ b/channels/serietvsubita.py @@ -55,7 +55,7 @@ def findvideos(item): data = re.sub(r'\n|\t|\s+', ' ', data) # recupero il blocco contenente i link blocco = scrapertools.find_single_match(data, r'<div class="entry">([\s\S.]*?)<div class="post').replace('..:: Episodio ', 'Episodio ').strip() - matches = scrapertools.find_multiple_matches(blocco, r'(S(\d*)E(\d*))\s') + matches = scrapertools.findMultipleMatches(blocco, r'(S(\d*)E(\d*))\s') if len(matches) > 0: for fullseasonepisode, season, episode in matches: blocco = blocco.replace(fullseasonepisode + ' ', 'Episodio ' + episode + ' ') @@ -67,7 +67,7 @@ def findvideos(item): logger.debug(patron) logger.debug(blocco) - matches = scrapertools.find_multiple_matches(blocco, patron) + matches = scrapertools.findMultipleMatches(blocco, patron) if len(matches): data = matches[0][0] @@ -78,7 +78,7 @@ def findvideos(item): ['Referer', keeplinks]] html = httptools.downloadpage(keeplinks, headers=headers2).data - data += str(scrapertools.find_multiple_matches(html, '</lable><a href="([^"]+)" target="_blank"')) + data += str(scrapertools.findMultipleMatches(html, '</lable><a href="([^"]+)" target="_blank"')) return support.server(item, data=data) @@ -157,7 +157,7 @@ def episodes(item, itemlist=[]): blocco = scrapertools.find_single_match(data, r'<div class="entry">[\s\S.]*?<div class="post') blocco = blocco.replace('<strong>Episodio ', '<strong>Episodio ').replace(' </strong>', ' </strong>') blocco = blocco.replace('<strong>Episodio ', '<strong>S' + season.zfill(2) + 'E') - matches = scrapertools.find_multiple_matches(blocco, r'(S(\d*)E(\d*))\s') + matches = scrapertools.findMultipleMatches(blocco, r'(S(\d*)E(\d*))\s') episodes = [] if len(matches) > 0: for fullepisode_s, season, episode in matches: @@ -173,7 +173,7 @@ def episodes(item, itemlist=[]): title = scrapedtitle.split(" S0")[0].strip() title = title.split(" S1")[0].strip() title = title.split(" S2")[0].strip() - episodes = scrapertools.find_multiple_matches(scrapedtitle, r'((\d*)x(\d*))') + episodes = scrapertools.findMultipleMatches(scrapedtitle, r'((\d*)x(\d*))') for fullepisode, season, episode in episodes: infoLabels = {} @@ -227,7 +227,7 @@ def movies_tv(item): scrapedplot = "" scrapedtitle = cleantitle(scrapedtitle) infoLabels = {} - episode = scrapertools.find_multiple_matches(scrapedtitle, r'((\d*)x(\d*))') + episode = scrapertools.findMultipleMatches(scrapedtitle, r'((\d*)x(\d*))') if episode: # workaround per quando mettono le serie intere o altra roba, sarebbero da intercettare TODO episode = episode[0] title = scrapedtitle.split(" S0")[0].strip() diff --git a/channels/streamingcommunity.py b/channels/streamingcommunity.py index c7dfb5fc..c9444fa5 100644 --- a/channels/streamingcommunity.py +++ b/channels/streamingcommunity.py @@ -4,7 +4,7 @@ # ------------------------------------------------------------ import json, requests, sys -from core import support, channeltools +from core import support, channeltools, jsontools from platformcode import config, logger if sys.version_info[0] >= 3: from concurrent import futures @@ -12,28 +12,34 @@ else: from concurrent_py2 import futures def findhost(url): - return 'https://' + support.match(url, patron='var domain\s*=\s*"([^"]+)').match + matches = support.match(url, patron='<a href="([^"]+)" target="_blank"').matches + if matches: + return matches[-1] host = support.config.get_channel_url(findhost) session = requests.Session() headers = {} -perpage = config.get_setting('pagination', 'streamingcommunity', default=1) * 10 + 10 +perpage = config.getSetting('pagination', 'streamingcommunity', default=1) * 10 + 10 -def getHeaders(): +def getHeaders(forced=False): global headers global host - # support.dbg() if not headers: - headers = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14'} - response = session.get(host, headers=headers) - if response.status_code != 200 or response.url != host: + try: + headers = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14'} + response = session.get(host, headers=headers) + if not response.url.startswith(host): + host = support.config.get_channel_url(findhost, forceFindhost=True) + csrf_token = support.match(response.text, patron='name="csrf-token" content="([^"]+)"').match + headers = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14', + 'content-type': 'application/json;charset=UTF-8', + 'Referer': host, + 'x-csrf-token': csrf_token, + 'Cookie': '; '.join([x.name + '=' + x.value for x in response.cookies])} + except: host = support.config.get_channel_url(findhost, forceFindhost=True) - csrf_token = support.match(response.text, patron='name="csrf-token" content="([^"]+)"').match - headers = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14', - 'content-type': 'application/json;charset=UTF-8', - 'Referer': host, - 'x-csrf-token': csrf_token, - 'Cookie': '; '.join([x.name + '=' + x.value for x in response.cookies])} + if not forced: getHeaders(True) + getHeaders() @support.menu @@ -118,6 +124,7 @@ def movies(item): if type(item.args) == int: data = support.scrapertools.decodeHtmlentities(support.match(item).data) records = json.loads(support.match(data, patron=r'slider-title titles-json="(.*?)" slider-name="').matches[item.args]) + elif not item.search: payload = json.dumps({'type': videoType, 'offset':offset, 'genre':item.args}) records = session.post(host + '/api/browse', headers=headers, data=payload).json()['records'] @@ -131,6 +138,8 @@ def movies(item): js += record else: js = records + + logger.debug(jsontools.dump(js)) itemlist = makeItems(item, js) diff --git a/channels/tantifilm.py b/channels/tantifilm.py index 3c7805d6..6493f2ac 100644 --- a/channels/tantifilm.py +++ b/channels/tantifilm.py @@ -177,7 +177,7 @@ def findvideos(item): item.contentType = 'movie' # if 'protectlink' in data: - # urls = scrapertools.find_multiple_matches(data, r'<iframe src="[^=]+=(.*?)"') + # urls = scrapertools.findMultipleMatches(data, r'<iframe src="[^=]+=(.*?)"') # logger.debug("SONO QUI: ", urls) # for url in urls: # url = url.decode('base64') diff --git a/channels/tunein.py b/channels/tunein.py index 103818c1..3da5c31f 100644 --- a/channels/tunein.py +++ b/channels/tunein.py @@ -21,7 +21,7 @@ def mainlist(item): return item def itemlistHook(itemlist): itemlist.append( - item.clone(title=support.typo(config.get_localized_string(70741) % 'Musica… ', 'bold'), action='search', thumbnail=support.thumb('search'))) + item.clone(title=support.typo(config.getLocalizedString(70741) % 'Musica… ', 'bold'), action='search', thumbnail=support.thumb('search'))) support.channel_config(item, itemlist) return itemlist return locals() diff --git a/channels/vvvvid.py b/channels/vvvvid.py index df538f33..a3d3615b 100644 --- a/channels/vvvvid.py +++ b/channels/vvvvid.py @@ -140,10 +140,6 @@ def movies(item): def episodes(item): itemlist = [] - if config.get_setting("window_type") == 0: - item.window = True - item.folder = False - if item.episodes: episodes = item.episodes show_id = item.show_id @@ -202,7 +198,7 @@ def findvideos(item): url = url.split()[-1] itemlist.append( item.clone(action= 'play', - title=config.get_localized_string(30137), + title=config.getLocalizedString(30137), url= 'https://or01.top-ix.org/videomg/_definst_/mp4:' + item.url + '/' + url, server= 'directo') ) @@ -212,7 +208,7 @@ def findvideos(item): itemlist.append( item.clone(action= 'play', - title=config.get_localized_string(30137), + title=config.getLocalizedString(30137), url= item.url + '?' + key, server= 'directo')) diff --git a/channelselector.py b/channelselector.py index a5d07961..c901a8fc 100644 --- a/channelselector.py +++ b/channelselector.py @@ -15,46 +15,46 @@ def getmainlist(view="thumb_"): # Main Menu Channels if addon.getSetting('enable_news_menu') == "true": - itemlist.append(Item(title=config.get_localized_string(30130), channel="news", action="mainlist", - thumbnail=thumb("news"), category=config.get_localized_string(30119), viewmode="thumbnails", - context=[{"title": config.get_localized_string(70285), "channel": "shortcuts", "action": "SettingOnPosition", "category":7, "setting":1}])) + itemlist.append(Item(title=config.getLocalizedString(30130), channel="news", action="mainlist", + thumbnail=thumb("news"), category=config.getLocalizedString(30119), viewmode="thumbnails", + context=[{"title": config.getLocalizedString(70285), "channel": "shortcuts", "action": "SettingOnPosition", "category":7, "setting":1}])) if addon.getSetting('enable_channels_menu') == "true": - itemlist.append(Item(title=config.get_localized_string(30118), channel="channelselector", action="getchanneltypes", - thumbnail=thumb("channels"), view=view, category=config.get_localized_string(30119), viewmode="thumbnails")) + itemlist.append(Item(title=config.getLocalizedString(30118), channel="channelselector", action="getchanneltypes", + thumbnail=thumb("channels"), view=view, category=config.getLocalizedString(30119), viewmode="thumbnails")) if addon.getSetting('enable_search_menu') == "true": - itemlist.append(Item(title=config.get_localized_string(30103), channel="search", path='special', action="mainlist", - thumbnail=thumb("search"), category=config.get_localized_string(30119), viewmode="list", - context = [{"title": config.get_localized_string(60412), "action": "channels_selections", "channel": "search"}, - {"title": config.get_localized_string(70286), "channel": "shortcuts", "action": "SettingOnPosition", "category":5 , "setting":1}])) + itemlist.append(Item(title=config.getLocalizedString(30103), channel="search", path='special', action="mainlist", + thumbnail=thumb("search"), category=config.getLocalizedString(30119), viewmode="list", + context = [{"title": config.getLocalizedString(60412), "action": "channels_selections", "channel": "search"}, + {"title": config.getLocalizedString(70286), "channel": "shortcuts", "action": "SettingOnPosition", "category":5 , "setting":1}])) if addon.getSetting('enable_onair_menu') == "true": - itemlist.append(Item(channel="filmontv", action="mainlist", title=config.get_localized_string(50001), + itemlist.append(Item(channel="filmontv", action="mainlist", title=config.getLocalizedString(50001), thumbnail=thumb("live"), viewmode="thumbnails")) if addon.getSetting('enable_link_menu') == "true": - itemlist.append(Item(title=config.get_localized_string(70527), channel="kodfavorites", action="mainlist", thumbnail=thumb("mylink"), - view=view, category=config.get_localized_string(70527), viewmode="thumbnails")) + itemlist.append(Item(title=config.getLocalizedString(70527), channel="kodfavorites", action="mainlist", thumbnail=thumb("mylink"), + view=view, category=config.getLocalizedString(70527), viewmode="thumbnails")) if addon.getSetting('enable_fav_menu') == "true": - itemlist.append(Item(title=config.get_localized_string(30102), channel="favorites", action="mainlist", - thumbnail=thumb("favorites"), category=config.get_localized_string(30102), viewmode="thumbnails")) + itemlist.append(Item(title=config.getLocalizedString(30102), channel="favorites", action="mainlist", + thumbnail=thumb("favorites"), category=config.getLocalizedString(30102), viewmode="thumbnails")) if config.get_videolibrary_support() and addon.getSetting('enable_library_menu') == "true": - itemlist.append(Item(title=config.get_localized_string(30131), channel="videolibrary", action="mainlist", - thumbnail=thumb("videolibrary"), category=config.get_localized_string(30119), viewmode="thumbnails", - context=[{"title": config.get_localized_string(70287), "channel": "shortcuts", "action": "SettingOnPosition", "category":2, "setting":1}, - {"title": config.get_localized_string(60568), "channel": "videolibrary", "action": "update_videolibrary"}])) + itemlist.append(Item(title=config.getLocalizedString(30131), channel="videolibrary", action="mainlist", + thumbnail=thumb("videolibrary"), category=config.getLocalizedString(30119), viewmode="thumbnails", + context=[{"title": config.getLocalizedString(70287), "channel": "shortcuts", "action": "SettingOnPosition", "category":2, "setting":1}, + {"title": config.getLocalizedString(60568), "channel": "videolibrary", "action": "update_videolibrary"}])) if downloadenabled != "false": - itemlist.append(Item(title=config.get_localized_string(30101), channel="downloads", action="mainlist", thumbnail=thumb("download"), viewmode="list", - context=[{"title": config.get_localized_string(70288), "channel": "shortcuts", "action": "SettingOnPosition", "category":6}])) + itemlist.append(Item(title=config.getLocalizedString(30101), channel="downloads", action="mainlist", thumbnail=thumb("download"), viewmode="list", + context=[{"title": config.getLocalizedString(70288), "channel": "shortcuts", "action": "SettingOnPosition", "category":6}])) - itemlist.append(Item(title=config.get_localized_string(30100), channel="setting", action="settings", - thumbnail=thumb('setting'), category=config.get_localized_string(30100), viewmode="list", folder=False)) - itemlist.append(Item(title=config.get_localized_string(30104) + " (v" + config.get_addon_version(with_fix=True) + ")", channel="help", action="mainlist", - thumbnail=thumb("help"), category=config.get_localized_string(30104), viewmode="list")) + itemlist.append(Item(title=config.getLocalizedString(30100), channel="setting", action="settings", + thumbnail=thumb('setting'), category=config.getLocalizedString(30100), viewmode="list", folder=False)) + itemlist.append(Item(title=config.getLocalizedString(30104) + " (v" + config.getAddonVersion(with_fix=True) + ")", channel="help", action="mainlist", + thumbnail=thumb("help"), category=config.getLocalizedString(30104), viewmode="list")) return itemlist @@ -70,19 +70,19 @@ def getchanneltypes(view="thumb_"): # Build Itemlist itemlist = list() - title = config.get_localized_string(30121) + title = config.getLocalizedString(30121) itemlist.append(Item(title=title, channel="channelselector", action="filterchannels", view=view, category=title, channel_type="all", thumbnail=thumb("all"), viewmode="thumbnails")) for channel_type in channel_types: - title = config.get_localized_category(channel_type) + title = config.getLocalizedCategory(channel_type) itemlist.append(Item(title=title, channel="channelselector", action="filterchannels", category=title, channel_type=channel_type, viewmode="thumbnails", thumbnail=thumb(channel_type))) - itemlist.append(Item(title=config.get_localized_string(70685), channel="community", action="mainlist", view=view, - category=config.get_localized_string(70685), channel_type="all", thumbnail=thumb("community"), + itemlist.append(Item(title=config.getLocalizedString(70685), channel="community", action="mainlist", view=view, + category=config.getLocalizedString(70685), channel_type="all", thumbnail=thumb("community"), viewmode="thumbnails")) return itemlist @@ -99,7 +99,7 @@ def filterchannels(category, view="thumb_"): category = "all" appenddisabledchannels = True - channel_path = os.path.join(config.get_runtime_path(), 'channels', '*.json') + channel_path = os.path.join(config.getRuntimePath(), 'channels', '*.json') logger.debug("channel_path = %s" % channel_path) channel_files = glob.glob(channel_path) @@ -134,7 +134,7 @@ def filterchannels(category, view="thumb_"): continue # The channel is skipped if it is not active and we are not activating / deactivating the channels - channel_status = config.get_setting("enabled", channel_parameters["channel"]) + channel_status = config.getSetting("enabled", channel_parameters["channel"]) if channel_status is None: # if channel_status does not exist, there is NO value in _data.json. @@ -158,7 +158,7 @@ def filterchannels(category, view="thumb_"): # If you have configuration we add an item in the context context = [] if channel_parameters["has_settings"]: - context.append({"title": config.get_localized_string(70525), "channel": "setting", "action": "channel_config", + context.append({"title": config.getLocalizedString(70525), "channel": "setting", "action": "channel_config", "config": channel_parameters["channel"]}) channel_info = set_channel_info(channel_parameters) @@ -175,7 +175,7 @@ def filterchannels(category, view="thumb_"): channelslist.sort(key=lambda item: item.title.lower().strip()) - if not config.get_setting("only_channel_icons"): + if not config.getSetting("only_channel_icons"): from core.support import thumb if category == "all": @@ -184,12 +184,12 @@ def filterchannels(category, view="thumb_"): # if view == "banner_" and "banner" in channel_parameters: # channel_parameters["thumbnail"] = channel_parameters["banner"] - channelslist.insert(0, Item(title=config.get_localized_string(60088), action="mainlist", channel="url", + channelslist.insert(0, Item(title=config.getLocalizedString(60088), action="mainlist", channel="url", thumbnail=channel_parameters["thumbnail"], type="generic", viewmode="list")) # Special Category if category in ['movie', 'tvshow']: ch_list = [] - titles = [config.get_localized_string(70028), config.get_localized_string(30985), config.get_localized_string(70559), config.get_localized_string(60264), config.get_localized_string(70560)] + titles = [config.getLocalizedString(70028), config.getLocalizedString(30985), config.getLocalizedString(70559), config.getLocalizedString(60264), config.getLocalizedString(70560)] ids = ['popular', 'top_rated', 'now_playing', 'on_the_air'] for x in range(0,3): if x == 2 and category != 'movie': @@ -203,7 +203,7 @@ def filterchannels(category, view="thumb_"): list_type='%s/%s' % (category.replace('show',''), id), mode=category)) - ch_list.insert(3, Item(channel='classicsearch', action='genres_menu', title=config.get_localized_string(30987) + '{' + category.replace('show','') + '}', + ch_list.insert(3, Item(channel='classicsearch', action='genres_menu', title=config.getLocalizedString(30987) + '{' + category.replace('show','') + '}', type=category.replace('show',''), mode=category)) channelslist = thumb(ch_list) + channelslist @@ -214,10 +214,10 @@ def filterchannels(category, view="thumb_"): # from core import filetools # if thumb_name.startswith('http'): # return thumb_name -# elif config.get_setting('enable_custom_theme') and config.get_setting('custom_theme') and filetools.isfile(config.get_setting('custom_theme') + view + thumb_name): -# media_path = config.get_setting('custom_theme') +# elif config.getSetting('enable_custom_theme') and config.getSetting('custom_theme') and filetools.isfile(config.getSetting('custom_theme') + view + thumb_name): +# media_path = config.getSetting('custom_theme') # else: -# icon_pack_name = config.get_setting('icon_set', default="default") +# icon_pack_name = config.getSetting('icon_set', default="default") # media_path = filetools.join("https://raw.githubusercontent.com/kodiondemand/media/master/themes/new", icon_pack_name) # return filetools.join(media_path, thumb_name) @@ -246,22 +246,22 @@ def set_channel_info(parameters): categories = parameters['categories'] for cat in categories: if content != '': - content = '%s, %s' % (content, config.get_localized_category(cat)) + content = '%s, %s' % (content, config.getLocalizedCategory(cat)) else: - content = config.get_localized_category(cat) + content = config.getLocalizedCategory(cat) - info = '[B]' + config.get_localized_string(70567) + ' [/B]' + content + '\n\n' - info += '[B]' + config.get_localized_string(70568) + ' [/B] ' + language + info = '[B]' + config.getLocalizedString(70567) + ' [/B]' + content + '\n\n' + info += '[B]' + config.getLocalizedString(70568) + ' [/B] ' + language return info def auto_filter(auto_lang=False): list_lang = ['ita', 'vos', 'sub-ita'] - if config.get_setting("channel_language") == 'auto' or auto_lang == True: - lang = config.get_localized_string(20001) + if config.getSetting("channel_language") == 'auto' or auto_lang == True: + lang = config.getLocalizedString(20001) else: - lang = config.get_setting("channel_language", default="all") + lang = config.getSetting("channel_language", default="all") if lang not in list_lang: lang = 'all' diff --git a/contextmenu.py b/contextmenu.py index 585c9f98..21b7c05a 100644 --- a/contextmenu.py +++ b/contextmenu.py @@ -1,14 +1,14 @@ from platformcode import config, logger import xbmc, sys, xbmcgui, os -librerias = xbmc.translatePath(os.path.join(config.get_runtime_path(), 'lib')) +librerias = xbmc.translatePath(os.path.join(config.getRuntimePath(), 'lib')) sys.path.insert(0, librerias) from core import jsontools, support -addon_id = config.get_addon_core().getAddonInfo('id') +addon_id = config.getAddonCore().getAddonInfo('id') -LOCAL_FILE = os.path.join(config.get_runtime_path(), "platformcode/contextmenu/contextmenu.json") +LOCAL_FILE = os.path.join(config.getRuntimePath(), "platformcode/contextmenu/contextmenu.json") f = open(LOCAL_FILE) contextmenu_settings = jsontools.load(open(LOCAL_FILE).read()) f.close() @@ -53,7 +53,7 @@ def build_menu(): def empty_item(): - return config.get_localized_string(90004) + return config.getLocalizedString(90004) if __name__ == '__main__': diff --git a/core/__init__.py b/core/__init__.py index 1237650b..691cb7a0 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -36,9 +36,13 @@ def encode(obj): def decode(obj): return pickle.loads(zlib.decompress(bytes(obj))) -db_name = filetools.join(config.get_data_path(), "db.sqlite") -db = nested_dict_sqlite(lambda table: SqliteDict(db_name, table, 'c', True)) +db_name = filetools.join(config.getDataPath(), "db.sqlite") +vdb_name = filetools.join(config.getVideolibraryPath(), "videolibrary.sqlite") -vdb_name = filetools.join(config.get_videolibrary_path(), "videolibrary.sqlite") -# videolibrarydb = nested_dict_sqlite(lambda table: SqliteDict(vdb_name, table, 'c', True)) +db = nested_dict_sqlite(lambda table: SqliteDict(db_name, table, 'c', True)) videolibrarydb = nested_dict_sqlite(lambda table: SqliteDict(vdb_name, table, 'c', True, encode=encode, decode=decode)) + + +if 'played_time' not in SqliteDict.get_tablenames(vdb_name): + for k, v in dict(db['viewed']).items(): + videolibrarydb['played_time'][k] = v diff --git a/core/autoplay.py b/core/autoplay.py index 399b1ad3..d836eb85 100644 --- a/core/autoplay.py +++ b/core/autoplay.py @@ -32,13 +32,13 @@ def start(itemlist, item): if not config.is_xbmc(): return itemlist - if config.get_setting('autoplay') or item.autoplay: + if config.getSetting('autoplay') or item.autoplay: # Save the current value of "Action and Player Mode" in preferences - user_config_setting_action = config.get_setting("default_action") - # user_config_setting_player = config.get_setting("player_mode") + user_config_setting_action = config.getSetting("default_action") + # user_config_setting_player = config.getSetting("player_mode") # Enable the "View in high quality" action (if the server returns more than one quality, eg gdrive) - if not user_config_setting_action: config.set_setting("default_action", 2) + if not user_config_setting_action: config.setSetting("default_action", 2) from core.servertools import sort_servers autoplay_list = sort_servers(itemlist) @@ -48,8 +48,8 @@ def start(itemlist, item): max_intents_servers = {} # If something is playing it stops playing - if platformtools.is_playing(): - platformtools.stop_video() + if platformtools.isPlaying(): + platformtools.stopVideo() for autoplay_elem in autoplay_list: play_item = Item @@ -57,7 +57,7 @@ def start(itemlist, item): if autoplay_elem.channel == 'videolibrary': channel_id = autoplay_elem.contentChannel - if not platformtools.is_playing() and not PLAYED: + if not platformtools.isPlaying() and not PLAYED: videoitem = autoplay_elem if videoitem.server.lower() not in max_intents_servers: max_intents_servers[videoitem.server.lower()] = max_intents @@ -69,16 +69,16 @@ def start(itemlist, item): lang = " [{}]".format(videoitem.language) if videoitem.language else '' quality = ' [{}]'.format(videoitem.quality) if videoitem.quality and videoitem.quality != 'default' else '' name = servername(videoitem.server) - platformtools.dialog_notification('AutoPlay', '{}{}{}'.format(name, lang, quality), sound=False) + platformtools.dialogNotification('AutoPlay', '{}{}{}'.format(name, lang, quality), sound=False) # Try to play the links If the channel has its own play method, use it - channel = platformtools.channel_import(channel_id) + channel = platformtools.channelImport(channel_id) if not channel: return if hasattr(channel, 'play'): resolved_item = getattr(channel, 'play')(videoitem) if len(resolved_item) > 0: - if isinstance(resolved_item[0], list): videoitem.video_urls = resolved_item + if isinstance(resolved_item[0], list): videoitem.videoUrls = resolved_item else: videoitem = resolved_item[0] play_item.autoplay = True @@ -88,16 +88,16 @@ def start(itemlist, item): if base_item.contentChannel == 'videolibrary' or base_item.nfo: # Fill the video with the data of the main item and play play_item = base_item.clone(**videoitem.__dict__) - platformtools.play_video(play_item, autoplay=True) + platformtools.playVideo(play_item, autoplay=True) else: videoitem.window = base_item.window # If it doesn't come from the video library, just play - platformtools.play_video(videoitem, autoplay=True) + platformtools.playVideo(videoitem, autoplay=True) except: pass # sleep(3) try: - if platformtools.is_playing(): + if platformtools.isPlaying(): PLAYED = True break except: @@ -108,20 +108,20 @@ def start(itemlist, item): # If the maximum number of attempts of this server has been reached, ask if we want to continue testing or ignore it. if max_intents_servers[videoitem.server.lower()] == 0: - text = config.get_localized_string(60072) % name - if not platformtools.dialog_yesno("AutoPlay", text, config.get_localized_string(60073)): + text = config.getLocalizedString(60072) % name + if not platformtools.dialogYesNo("AutoPlay", text, config.getLocalizedString(60073)): max_intents_servers[videoitem.server.lower()] = max_intents # If there are no items in the list, it is reported if autoplay_elem == autoplay_list[-1]: - platformtools.dialog_notification('AutoPlay', config.get_localized_string(60072) % name) + platformtools.dialogNotification('AutoPlay', config.getLocalizedString(60072) % name) else: - platformtools.dialog_notification(config.get_localized_string(60074), config.get_localized_string(60075)) + platformtools.dialogNotification(config.getLocalizedString(60074), config.getLocalizedString(60075)) # Restore if necessary the previous value of "Action and Player Mode" in preferences - if not user_config_setting_action: config.set_setting("default_action", user_config_setting_action) - # if user_config_setting_player != 0: config.set_setting("player_mode", user_config_setting_player) + if not user_config_setting_action: config.setSetting("default_action", user_config_setting_action) + # if user_config_setting_player != 0: config.setSetting("player_mode", user_config_setting_player) return itemlist @@ -133,7 +133,7 @@ def play_multi_channel(item, itemlist): def servername(server): from core.servertools import translate_server_name - path = filetools.join(config.get_runtime_path(), 'servers', server.lower() + '.json') + path = filetools.join(config.getRuntimePath(), 'servers', server.lower() + '.json') name = jsontools.load(open(path, "rb").read())['name'] - if name.startswith('@'): name = config.get_localized_string(int(name.replace('@',''))) + if name.startswith('@'): name = config.getLocalizedString(int(name.replace('@',''))) return translate_server_name(name) diff --git a/core/channeltools.py b/core/channeltools.py index 79b35e78..945075c0 100644 --- a/core/channeltools.py +++ b/core/channeltools.py @@ -16,8 +16,7 @@ remote_path = 'https://raw.githubusercontent.com/kodiondemand/media/master/' def is_enabled(channel_name): logger.debug("channel_name=" + channel_name) - return get_channel_parameters(channel_name)["active"] and get_channel_setting("enabled", channel=channel_name, - default=True) + return get_channel_parameters(channel_name)["active"] and getChannelSetting("enabled", channel=channel_name, default=True) def get_channel_parameters(channel_name): @@ -90,13 +89,13 @@ def get_channel_json(channel_name): from core import filetools channel_json = None try: - channel_path = filetools.join(config.get_runtime_path(), "channels", channel_name + ".json") + channel_path = filetools.join(config.getRuntimePath(), "channels", channel_name + ".json") if not filetools.isfile(channel_path): - channel_path = filetools.join(config.get_runtime_path(), "specials", channel_name + ".json") + channel_path = filetools.join(config.getRuntimePath(), "specials", channel_name + ".json") if not filetools.isfile(channel_path): - channel_path = filetools.join(config.get_runtime_path(), "servers", channel_name + ".json") + channel_path = filetools.join(config.getRuntimePath(), "servers", channel_name + ".json") if not filetools.isfile(channel_path): - channel_path = filetools.join(config.get_runtime_path(), "servers", "debriders", + channel_path = filetools.join(config.getRuntimePath(), "servers", "debriders", channel_name + ".json") if filetools.isfile(channel_path): @@ -115,24 +114,27 @@ def get_channel_json(channel_name): def get_channel_controls_settings(channel_name): logger.debug("channel_name=" + channel_name) dict_settings = {} - # import web_pdb; web_pdb.set_trace() - # list_controls = get_channel_json(channel_name).get('settings', list()) + list_controls = get_default_settings(channel_name) for c in list_controls: if 'id' not in c or 'type' not in c or 'default' not in c: # If any control in the list does not have id, type or default, we ignore it continue - # new dict with key(id) and value(default) from settings - dict_settings[c['id']] = c['default'] + if c['type'] == 'list' and c.get('values'): + dict_settings[c['id']] = list(c['values'])[c['default']] + elif c['type'] == 'list' and c.get('dvalues'): + dict_settings[c['id']] = list(c['dvalues'].values())[c['default']] + else: + dict_settings[c['id']] = c['default'] return list_controls, dict_settings def get_lang(channel_name): channel = __import__('channels.%s' % channel_name, fromlist=["channels.%s" % channel_name]) - list_language = [config.get_localized_string(70522)] + list_language = [config.getLocalizedString(70522)] if hasattr(channel, 'list_language'): for language in channel.list_language: list_language.append(language) @@ -160,7 +162,7 @@ def get_default_settings(channel_name): from core import filetools import copy - default_path = filetools.join(config.get_runtime_path(), 'default_channel_settings' + '.json') + default_path = filetools.join(config.getRuntimePath(), 'default_channel_settings' + '.json') if channel_name not in ['trakt', 'autoplay']: global default_file else: @@ -168,7 +170,7 @@ def get_default_settings(channel_name): if not default_file: default_file = jsontools.load(filetools.read(default_path)) - channel_path = filetools.join(config.get_runtime_path(), 'channels', channel_name + '.json') + channel_path = filetools.join(config.getRuntimePath(), 'channels', channel_name + '.json') if filetools.exists(channel_path): default_controls = default_file['settings'] @@ -183,35 +185,36 @@ def get_default_settings(channel_name): default_off = channel_json['default_off'] if 'default_off' in channel_json else [] # Apply default configurations if they do not exist + # logger.dbg() for control in copy.deepcopy(default_controls): if control['id'] not in str(channel_controls): if 'include_in_newest' in control['id'] and 'include_in_newest' not in not_active and control['id'] not in not_active: label = control['id'].split('_') label = label[-1] - if label == 'movies': + if label == 'movie': if 'movie' in categories: - control['label'] = config.get_localized_string(70727) + ' - ' + config.get_localized_string( 30122) + control['label'] = config.getLocalizedString(70727) + ' - ' + config.getLocalizedString( 30122) control['default'] = False if ('include_in_newest' in default_off) or ( ' include_in_newest_movie' in default_off) else True channel_controls.append(control) else: pass - elif label == 'tvshows': + elif label == 'tvshow': if 'tvshow' in categories: - control['label'] = config.get_localized_string(70727) + ' - ' + config.get_localized_string( 30123) - control['default'] = False if ('include_in_newest' in default_off) or ( 'include_in_newest_series' in default_off) else True + control['label'] = config.getLocalizedString(70727) + ' - ' + config.getLocalizedString( 30123) + control['default'] = False if ('include_in_newest' in default_off) or ( 'include_in_newest_tvshow' in default_off) else True channel_controls.append(control) else: pass elif label == 'anime': if 'anime' in categories: - control['label'] = config.get_localized_string(70727) + ' - ' + config.get_localized_string( 30124) + control['label'] = config.getLocalizedString(70727) + ' - ' + config.getLocalizedString( 30124) control['default'] = False if ('include_in_newest' in default_off) or ( 'include_in_newest_anime' in default_off) else True channel_controls.append(control) else: pass else: - control['label'] = config.get_localized_string(70727) + ' - ' + label.capitalize() + control['label'] = config.getLocalizedString(70727) + ' - ' + label.capitalize() control['default'] = control['default'] if control['id'] not in default_off else False channel_controls.append(control) @@ -231,7 +234,7 @@ def get_default_settings(channel_name): return channel_controls -def get_channel_setting(name, channel, default=None): +def getChannelSetting(name, channel, default=None): from core import filetools """ Returns the configuration value of the requested parameter. @@ -255,7 +258,7 @@ def get_channel_setting(name, channel, default=None): @rtype: any """ - file_settings = filetools.join(config.get_data_path(), "settings_channels", channel + "_data.json") + file_settings = filetools.join(config.getDataPath(), "settings_channels", channel + "_data.json") dict_settings = {} dict_file = {} @@ -288,7 +291,7 @@ def get_channel_setting(name, channel, default=None): return dict_settings.get(name, default) -def set_channel_setting(name, value, channel): +def setChannelSetting(name, value, channel): from core import filetools """ Sets the configuration value of the indicated parameter. @@ -312,10 +315,10 @@ def set_channel_setting(name, value, channel): """ # We create the folder if it does not exist - if not filetools.exists(filetools.join(config.get_data_path(), "settings_channels")): - filetools.mkdir(filetools.join(config.get_data_path(), "settings_channels")) + if not filetools.exists(filetools.join(config.getDataPath(), "settings_channels")): + filetools.mkdir(filetools.join(config.getDataPath(), "settings_channels")) - file_settings = filetools.join(config.get_data_path(), "settings_channels", channel + "_data.json") + file_settings = filetools.join(config.getDataPath(), "settings_channels", channel + "_data.json") dict_settings = {} dict_file = None diff --git a/core/downloader.py b/core/downloader.py index 5e26c22f..f6c57900 100644 --- a/core/downloader.py +++ b/core/downloader.py @@ -102,16 +102,16 @@ class Downloader(object): return os.path.abspath(filetools.join(self._path, self._filename)) # Features - def start_dialog(self, title=config.get_localized_string(60200)): + def start_dialog(self, title=config.getLocalizedString(60200)): from platformcode import platformtools - progreso = platformtools.dialog_progress_bg(title, config.get_localized_string(60201)) + progreso = platformtools.dialogProgressBg(title, config.getLocalizedString(60201)) try: self.start() while self.state == self.states.downloading: time.sleep(0.2) line1 = "%s" % (self.filename) - line2 = config.get_localized_string(59983) % ( self.downloaded[1], self.downloaded[2], self.size[1], self.size[2], self.speed[1], self.speed[2], self.connections[0], self.connections[1]) - line3 = config.get_localized_string(60202) % (self.remaining_time) + line2 = config.getLocalizedString(59983) % ( self.downloaded[1], self.downloaded[2], self.size[1], self.size[2], self.speed[1], self.speed[2], self.connections[0], self.connections[1]) + line3 = config.getLocalizedString(60202) % (self.remaining_time) progreso.update(int(self.progress), line1 + '\n' + line2 + " " + line3) self.__update_json() diff --git a/core/downloadtools.py b/core/downloadtools.py index f0a7d4cf..d61bfc8b 100644 --- a/core/downloadtools.py +++ b/core/downloadtools.py @@ -127,7 +127,7 @@ def getfilefromtitle(url, title): # Print in the log what you will discard logger.info("title=" + title) logger.info("url=" + url) - plataforma = config.get_system_platform() + plataforma = config.getSystemPlatform() logger.info("platform=" + plataforma) # filename = xbmc.makeLegalFilename(title + url[-4:]) @@ -146,7 +146,7 @@ def getfilefromtitle(url, title): logger.info("filename= %s" % nombrefichero) - fullpath = filetools.join(config.get_setting("downloadpath"), nombrefichero) + fullpath = filetools.join(config.getSetting("downloadpath"), nombrefichero) logger.info("fullpath= %s" % fullpath) if config.is_xbmc() and fullpath.startswith("special://"): @@ -161,11 +161,11 @@ def downloadtitle(url, title): return downloadfile(url, fullpath) -def downloadbest(video_urls, title, continuar=False): +def downloadbest(videoUrls, title, continuar=False): logger.info() # Flip it over, to put the highest quality one first (list () is for you to make a copy of) - invertida = list(video_urls) + invertida = list(videoUrls) invertida.reverse() for elemento in invertida: @@ -271,7 +271,7 @@ def downloadfile(url, nombrefichero, headers=None, silent=False, continuar=False # Create the progress dialog if not silent: - progreso = platformtools.dialog_progress(header, "Downloading..." + '\n' + url + '\n' + nombrefichero) + progreso = platformtools.dialogProgress(header, "Downloading..." + '\n' + url + '\n' + nombrefichero) # If the platform does not return a valid dialog box, it assumes silent mode if progreso is None: @@ -399,7 +399,7 @@ def downloadfile(url, nombrefichero, headers=None, silent=False, continuar=False if not silent: progreso.close() - # platformtools.dialog_ok('Error al descargar' , 'Se ha producido un error' , 'al descargar el archivo') + # platformtools.dialogOk('Error al descargar' , 'Se ha producido un error' , 'al descargar el archivo') return -2 @@ -408,7 +408,7 @@ def downloadfile(url, nombrefichero, headers=None, silent=False, continuar=False error = downloadfileRTMP(url, nombrefichero, silent) if error and not silent: from platformcode import platformtools - platformtools.dialog_ok("You cannot download that video "," RTMP downloads not yet supported") + platformtools.dialogOk("You cannot download that video "," RTMP downloads not yet supported") else: import traceback from pprint import pprint @@ -448,7 +448,7 @@ def downloadfileRTMP(url, nombrefichero, silent): if not filetools.isfile(rtmpdump_cmd) and not silent: from platformcode import platformtools - advertencia = platformtools.dialog_ok("Lack " + rtmpdump_cmd, "Check that rtmpdump is installed") + advertencia = platformtools.dialogOk("Lack " + rtmpdump_cmd, "Check that rtmpdump is installed") return True valid_rtmpdump_options = ["help", "url", "rtmp", "host", "port", "socks", "protocol", "playpath", "playlist", @@ -480,7 +480,7 @@ def downloadfileRTMP(url, nombrefichero, silent): rtmpdump_exit = spawnv(P_NOWAIT, rtmpdump_cmd, rtmpdump_args) if not silent: from platformcode import platformtools - advertencia = platformtools.dialog_ok("RTMP download option is experimental", "and the video will download in the background. \n No progress bar will be displayed.") + advertencia = platformtools.dialogOk("RTMP download option is experimental", "and the video will download in the background. \n No progress bar will be displayed.") except: return True @@ -520,7 +520,7 @@ def downloadfileGzipped(url, pathfichero): # Create the progress dialog from platformcode import platformtools - progreso = platformtools.dialog_progress("addon", config.get_localized_string(60200) + '\n' + url.split("|")[0] + '\n' + nombrefichero) + progreso = platformtools.dialogProgress("addon", config.getLocalizedString(60200) + '\n' + url.split("|")[0] + '\n' + nombrefichero) # Socket timeout at 60 seconds socket.setdefaulttimeout(10) @@ -662,7 +662,7 @@ def downloadfileGzipped(url, pathfichero): def GetTitleFromFile(title): # Print in the log what you will discard logger.info("title= " + title) - plataforma = config.get_system_platform() + plataforma = config.getSystemPlatform() logger.info("plataform= " + plataforma) # nombrefichero = xbmc.makeLegalFilename(title + url[-4:]) @@ -852,14 +852,14 @@ def download_all_episodes(item, channel, first_episode="", preferred_server="vid video_item = video_items[0] # Check that it is available - video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing(video_item.server, video_item.url, video_password="", muestra_dialogo=False) + videoUrls, puedes, motivo = servertools.resolve_videoUrls_for_playing(video_item.server, video_item.url, video_password="", muestra_dialogo=False) # Adds it to the download list if puedes: logger.info("downloading mirror started...") # The highest quality video is the latest - # mediaurl = video_urls[len(video_urls) - 1][1] - devuelve = downloadbest(video_urls, show_title + " " + episode_title + " " + idioma + + # mediaUrl = videoUrls[len(videoUrls) - 1][1] + devuelve = downloadbest(videoUrls, show_title + " " + episode_title + " " + idioma + " [" + video_item.server + "]", continuar=False) if devuelve == 0: @@ -869,7 +869,7 @@ def download_all_episodes(item, channel, first_episode="", preferred_server="vid elif devuelve == -1: try: from platformcode import platformtools - platformtools.dialog_ok("plugin", "Descarga abortada") + platformtools.dialogOk("plugin", "Descarga abortada") except: pass return diff --git a/core/filetools.py b/core/filetools.py index 130ccab9..e6aecc5a 100644 --- a/core/filetools.py +++ b/core/filetools.py @@ -255,7 +255,7 @@ def file_open(path, mode="r", silent=False, vfs=True): logger.error("ERROR when opening file: %s, %s" % (path, mode)) if not silent: logger.error(traceback.format_exc()) - platformtools.dialog_notification("Error Opening", path) + platformtools.dialogNotification("Error Opening", path) return False @@ -301,7 +301,7 @@ def rename(path, new_name, silent=False, strict=False, vfs=True): if not result and not strict: logger.error("ERROR RENAME file: %s. Copying and deleting" % path) if not silent: - dialogo = platformtools.dialog_progress("Copying file", "") + dialogo = platformtools.dialogProgress("Copying file", "") result = xbmcvfs.copy(path, dest) if not result: return False @@ -317,7 +317,7 @@ def rename(path, new_name, silent=False, strict=False, vfs=True): logger.error("ERROR when renaming the file: %s" % path) if not silent: logger.error(traceback.format_exc()) - platformtools.dialog_notification("Error renaming", path) + platformtools.dialogNotification("Error renaming", path) return False else: return True @@ -342,7 +342,7 @@ def move(path, dest, silent=False, strict=False, vfs=True): if not result and not strict: logger.error("ERROR when MOVING the file: %s. Copying and deleting" % path) if not silent: - dialogo = platformtools.dialog_progress("Copying file", "") + dialogo = platformtools.dialogProgress("Copying file", "") result = xbmcvfs.copy(path, dest) if not result: return False @@ -362,7 +362,7 @@ def move(path, dest, silent=False, strict=False, vfs=True): # mixed In this case the file is copied and then the source file is deleted else: if not silent: - dialogo = platformtools.dialog_progress("Copying file", "") + dialogo = platformtools.dialogProgress("Copying file", "") return copy(path, dest) == True and remove(path) == True except: logger.error("ERROR when moving file: %s to %s" % (path, dest)) @@ -390,14 +390,14 @@ def copy(path, dest, silent=False, vfs=True): path = encode(path) dest = encode(dest) if not silent: - dialogo = platformtools.dialog_progress("Copying file", "") + dialogo = platformtools.dialogProgress("Copying file", "") return bool(xbmcvfs.copy(path, dest)) fo = file_open(path, "rb") fd = file_open(dest, "wb") if fo and fd: if not silent: - dialogo = platformtools.dialog_progress("Copying file", "") + dialogo = platformtools.dialogProgress("Copying file", "") size = getsize(path) copiado = 0 while True: @@ -559,7 +559,7 @@ def remove(path, silent=False, vfs=True): logger.error("ERROR deleting file: %s" % path) if not silent: logger.error(traceback.format_exc()) - platformtools.dialog_notification("ERROR deleting file", path) + platformtools.dialogNotification("ERROR deleting file", path) return False else: return True @@ -599,7 +599,7 @@ def rmdirtree(path, silent=False, vfs=True): logger.error("ERROR deleting directory: %s" % path) if not silent: logger.error(traceback.format_exc()) - platformtools.dialog_notification("ERROR deleting directory", path) + platformtools.dialogNotification("ERROR deleting directory", path) return False else: return not exists(path) @@ -627,7 +627,7 @@ def rmdir(path, silent=False, vfs=True): logger.error("ERROR deleting directory: %s" % path) if not silent: logger.error(traceback.format_exc()) - platformtools.dialog_notification("ERROR deleting directory", path) + platformtools.dialogNotification("ERROR deleting directory", path) return False else: return True @@ -660,7 +660,7 @@ def mkdir(path, silent=False, vfs=True): logger.error("ERROR when creating directory: %s" % path) if not silent: logger.error(traceback.format_exc()) - platformtools.dialog_notification("ERROR when creating directory", path) + platformtools.dialogNotification("ERROR when creating directory", path) return False else: return True diff --git a/core/filtertools.py b/core/filtertools.py index 09f016db..383d7942 100644 --- a/core/filtertools.py +++ b/core/filtertools.py @@ -47,10 +47,10 @@ class Filter(object): def __get_data(self, item, global_filter_lang_id): - dict_filtered_shows = jsontools.get_node_from_file(item.channel, TAG_TVSHOW_FILTER) + dict_filtered_shows = jsontools.getNodeFromFile(item.channel, TAG_TVSHOW_FILTER) tvshow = item.show.lower().strip() - global_filter_language = config.get_setting(global_filter_lang_id, item.channel) + global_filter_language = config.getSetting(global_filter_lang_id, item.channel) if tvshow in list(dict_filtered_shows.keys()): @@ -86,7 +86,7 @@ def access(): """ allow = False - if config.is_xbmc() or config.get_platform() == "mediaserver": + if config.is_xbmc() or config.getXBMCPlatform() == "mediaserver": allow = True return allow @@ -119,7 +119,7 @@ def context(item, list_language=None, list_quality=None, exist=False): _context = [] if access(): - dict_data = {"title": config.get_localized_string(60426), "action": "config_item", "channel": "filtertools"} + dict_data = {"title": config.getLocalizedString(60426), "action": "config_item", "channel": "filtertools"} if list_language: dict_data["list_language"] = list_language if list_quality: @@ -138,10 +138,10 @@ def context(item, list_language=None, list_quality=None, exist=False): if item.action == "play": if not exist: - _context.append({"title": config.get_localized_string(60427) % item.language, "action": "save_from_context", + _context.append({"title": config.getLocalizedString(60427) % item.language, "action": "save_from_context", "channel": "filtertools", "from_channel": item.channel}) else: - _context.append({"title": config.get_localized_string(60428) % item.language, "action": "delete_from_context", + _context.append({"title": config.getLocalizedString(60428) % item.language, "action": "delete_from_context", "channel": "filtertools", "from_channel": item.channel}) return _context @@ -149,7 +149,7 @@ def context(item, list_language=None, list_quality=None, exist=False): def show_option(itemlist, channel, list_language, list_quality): if access(): - itemlist.append(Item(channel=__channel__, title=config.get_localized_string(60429) % COLOR.get("parent_item", "auto"), action="load", + itemlist.append(Item(channel=__channel__, title=config.getLocalizedString(60429) % COLOR.get("parent_item", "auto"), action="load", list_language=list_language, list_quality=list_quality, from_channel=channel)) return itemlist @@ -286,7 +286,7 @@ def get_links(list_item, item, list_language, list_quality=None, global_filter_l return list_item - second_lang = config.get_setting('second_language') + second_lang = config.getSetting('second_language') logger.debug("total de items : %s" % len(list_item)) @@ -326,7 +326,7 @@ def get_links(list_item, item, list_language, list_quality=None, global_filter_l for i in list_item: list_item_all.append(i.tourl()) - _context = [{"title": config.get_localized_string(60430) % _filter.language, "action": "delete_from_context", "channel": "filtertools", "to_channel": item.channel}] + _context = [{"title": config.getLocalizedString(60430) % _filter.language, "action": "delete_from_context", "channel": "filtertools", "to_channel": item.channel}] if _filter.quality_allowed: msg_quality_allowed = " y calidad %s" % _filter.quality_allowed @@ -339,7 +339,7 @@ def get_links(list_item, item, list_language, list_quality=None, global_filter_l new_itemlist.append(Item(channel=__channel__, action="no_filter", list_item_all=list_item_all, show=item.show, - title=config.get_localized_string(60432) % (_filter.language, msg_quality_allowed), + title=config.getLocalizedString(60432) % (_filter.language, msg_quality_allowed), context=_context)) else: @@ -386,7 +386,7 @@ def mainlist(channel, list_language, list_quality): """ logger.debug() itemlist = [] - dict_series = jsontools.get_node_from_file(channel, TAG_TVSHOW_FILTER) + dict_series = jsontools.getNodeFromFile(channel, TAG_TVSHOW_FILTER) idx = 0 for tvshow in sorted(dict_series): @@ -404,16 +404,16 @@ def mainlist(channel, list_language, list_quality): idx += 1 name = dict_series.get(tvshow, {}).get(TAG_NAME, tvshow) - activo = config.get_localized_string(60433) + activo = config.getLocalizedString(60433) if dict_series[tvshow][TAG_ACTIVE]: activo = "" - title = config.get_localized_string(60434) % (tag_color, name, activo) + title = config.getLocalizedString(60434) % (tag_color, name, activo) itemlist.append(Item(channel=__channel__, action="config_item", title=title, show=name, list_language=list_language, list_quality=list_quality, from_channel=channel)) if len(itemlist) == 0: - itemlist.append(Item(channel=channel, action="mainlist", title=config.get_localized_string(60435))) + itemlist.append(Item(channel=channel, action="mainlist", title=config.getLocalizedString(60435))) return itemlist @@ -429,7 +429,7 @@ def config_item(item): logger.debug("item %s" % item.tostring()) # WE GET THE JSON DATA - dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER) + dict_series = jsontools.getNodeFromFile(item.from_channel, TAG_TVSHOW_FILTER) tvshow = item.show.lower().strip() default_lang = '' @@ -443,7 +443,7 @@ def config_item(item): pass if default_lang == '': - platformtools.dialog_notification("FilterTools", "There are no defined languages") + platformtools.dialogNotification("FilterTools", "There are no defined languages") return else: lang_selected = dict_series.get(tvshow, {}).get(TAG_LANGUAGE, default_lang) @@ -457,7 +457,7 @@ def config_item(item): if item.show.lower().strip() in dict_series: allow_option = True active = dict_series.get(item.show.lower().strip(), {}).get(TAG_ACTIVE, False) - custom_button = {'label': config.get_localized_string(60437), 'function': 'delete', 'visible': True, 'close': True} + custom_button = {'label': config.getLocalizedString(60437), 'function': 'delete', 'visible': True, 'close': True} list_controls = [] @@ -465,7 +465,7 @@ def config_item(item): active_control = { "id": "active", "type": "bool", - "label": config.get_localized_string(60438), + "label": config.getLocalizedString(60438), "color": "", "default": active, "enabled": allow_option, @@ -476,7 +476,7 @@ def config_item(item): language_option = { "id": "language", "type": "list", - "label": config.get_localized_string(60439), + "label": config.getLocalizedString(60439), # "color": "0xFFee66CC", "default": item.list_language.index(lang_selected), "enabled": True, @@ -509,9 +509,9 @@ def config_item(item): # we concatenate list_controls with list_controls_quality list_controls.extend(list_controls_calidad) - title = config.get_localized_string(60441) % (COLOR.get("selected", "auto"), item.show) + title = config.getLocalizedString(60441) % (COLOR.get("selected", "auto"), item.show) - platformtools.show_channel_settings(list_controls=list_controls, callback='save', item=item, + platformtools.showChannelSettings(list_controls=list_controls, callback='save', item=item, caption=title, custom_button=custom_button) @@ -519,30 +519,30 @@ def delete(item, dict_values): logger.debug() if item: - dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER) + dict_series = jsontools.getNodeFromFile(item.from_channel, TAG_TVSHOW_FILTER) tvshow = item.show.strip().lower() - heading = config.get_localized_string(60442) - line1 = config.get_localized_string(60443) % (COLOR.get("selected", "auto"), item.show.strip()) + heading = config.getLocalizedString(60442) + line1 = config.getLocalizedString(60443) % (COLOR.get("selected", "auto"), item.show.strip()) - if platformtools.dialog_yesno(heading, line1) == 1: + if platformtools.dialogYesNo(heading, line1) == 1: lang_selected = dict_series.get(tvshow, {}).get(TAG_LANGUAGE, "") dict_series.pop(tvshow, None) - result, json_data = jsontools.update_node(dict_series, item.from_channel, TAG_TVSHOW_FILTER) + result, json_data = jsontools.updateNode(dict_series, item.from_channel, TAG_TVSHOW_FILTER) sound = False if result: - message = config.get_localized_string(60444) + message = config.getLocalizedString(60444) else: - message = config.get_localized_string(60445) + message = config.getLocalizedString(60445) sound = True heading = "%s [%s]" % (item.show.strip(), lang_selected) - platformtools.dialog_notification(heading, message, sound=sound) + platformtools.dialogNotification(heading, message, sound=sound) if item.action in ["findvideos", "play"]: - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() def save(item, dict_data_saved): @@ -561,7 +561,7 @@ def save(item, dict_data_saved): if item.from_channel == "videolibrary": item.from_channel = item.contentChannel - dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER) + dict_series = jsontools.getNodeFromFile(item.from_channel, TAG_TVSHOW_FILTER) tvshow = item.show.strip().lower() logger.debug("Data is updated") @@ -576,20 +576,20 @@ def save(item, dict_data_saved): TAG_LANGUAGE: lang_selected, TAG_QUALITY_ALLOWED: list_quality} dict_series[tvshow] = dict_filter - result, json_data = jsontools.update_node(dict_series, item.from_channel, TAG_TVSHOW_FILTER) + result, json_data = jsontools.updateNode(dict_series, item.from_channel, TAG_TVSHOW_FILTER) sound = False if result: - message = config.get_localized_string(60446) + message = config.getLocalizedString(60446) else: - message = config.get_localized_string(70593) + message = config.getLocalizedString(70593) sound = True heading = "%s [%s]" % (item.show.strip(), lang_selected) - platformtools.dialog_notification(heading, message, sound=sound) + platformtools.dialogNotification(heading, message, sound=sound) if item.from_action in ["findvideos", "play"]: - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() def save_from_context(item): @@ -601,13 +601,13 @@ def save_from_context(item): """ logger.debug() - dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER) + dict_series = jsontools.getNodeFromFile(item.from_channel, TAG_TVSHOW_FILTER) tvshow = item.show.strip().lower() dict_filter = {TAG_NAME: item.show, TAG_ACTIVE: True, TAG_LANGUAGE: item.language, TAG_QUALITY_ALLOWED: []} dict_series[tvshow] = dict_filter - result, json_data = jsontools.update_node(dict_series, item.from_channel, TAG_TVSHOW_FILTER) + result, json_data = jsontools.updateNode(dict_series, item.from_channel, TAG_TVSHOW_FILTER) sound = False if result: @@ -617,10 +617,10 @@ def save_from_context(item): sound = True heading = "%s [%s]" % (item.show.strip(), item.language) - platformtools.dialog_notification(heading, message, sound=sound) + platformtools.dialogNotification(heading, message, sound=sound) if item.from_action in ["findvideos", "play"]: - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() def delete_from_context(item): @@ -636,13 +636,13 @@ def delete_from_context(item): if item.to_channel != "": item.from_channel = item.to_channel - dict_series = jsontools.get_node_from_file(item.from_channel, TAG_TVSHOW_FILTER) + dict_series = jsontools.getNodeFromFile(item.from_channel, TAG_TVSHOW_FILTER) tvshow = item.show.strip().lower() lang_selected = dict_series.get(tvshow, {}).get(TAG_LANGUAGE, "") dict_series.pop(tvshow, None) - result, json_data = jsontools.update_node(dict_series, item.from_channel, TAG_TVSHOW_FILTER) + result, json_data = jsontools.updateNode(dict_series, item.from_channel, TAG_TVSHOW_FILTER) sound = False if result: @@ -652,7 +652,7 @@ def delete_from_context(item): sound = True heading = "%s [%s]" % (item.show.strip(), lang_selected) - platformtools.dialog_notification(heading, message, sound=sound) + platformtools.dialogNotification(heading, message, sound=sound) if item.from_action in ["findvideos", "play", "no_filter"]: # 'no_filter' es el mismo caso que L#601 - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() diff --git a/core/httptools.py b/core/httptools.py index 2ea2dc1b..52f0309b 100755 --- a/core/httptools.py +++ b/core/httptools.py @@ -21,16 +21,16 @@ from core import scrapertools import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) # Get the addon version -__version = config.get_addon_version() +__version = config.getAddonVersion() cookies_lock = Lock() cj = cookielib.MozillaCookieJar() -cookies_file = os.path.join(config.get_data_path(), "cookies.dat") +cookies_file = os.path.join(config.getDataPath(), "cookies.dat") # Headers by default, if nothing is specified default_headers = dict() -default_headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36" % config.get_setting("chrome_ua_version") +default_headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36" % config.getSetting("chrome_ua_version") default_headers["Accept"] = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" default_headers["Accept-Language"] = "it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3" default_headers["Accept-Charset"] = "UTF-8" @@ -52,7 +52,7 @@ directIP = { } # Maximum wait time for downloadpage, if nothing is specified -HTTPTOOLS_DEFAULT_DOWNLOAD_TIMEOUT = config.get_setting('httptools_timeout', default=15) +HTTPTOOLS_DEFAULT_DOWNLOAD_TIMEOUT = config.getSetting('httptools_timeout', default=15) if HTTPTOOLS_DEFAULT_DOWNLOAD_TIMEOUT == 0: HTTPTOOLS_DEFAULT_DOWNLOAD_TIMEOUT = None # Random use of User-Agents, if nad is not specified @@ -67,7 +67,7 @@ HTTPTOOLS_DEFAULT_RANDOM_HEADERS = False # domainCF.extend(otherCF) # CF_LIST = list() -# CF_LIST_PATH = os.path.join(config.get_data_path(), "CF_Domains.txt") +# CF_LIST_PATH = os.path.join(config.getDataPath(), "CF_Domains.txt") # # if os.path.exists(CF_LIST_PATH): # with open(CF_LIST_PATH, "rb") as CF_File: @@ -167,7 +167,7 @@ def random_useragent(): import random - UserAgentPath = os.path.join(config.get_runtime_path(), 'tools', 'UserAgent.csv') + UserAgentPath = os.path.join(config.getRuntimePath(), 'tools', 'UserAgent.csv') if os.path.exists(UserAgentPath): UserAgentIem = random.choice(list(open(UserAgentPath))).strip() if UserAgentIem: @@ -203,7 +203,7 @@ def show_infobox(info_dict): width = 100 - version = '%s: %s' % (config.get_localized_string(20000), __version) + version = '%s: %s' % (config.getLocalizedString(20000), __version) if config.is_xbmc(): box = box_items_kodi else: @@ -292,7 +292,7 @@ def downloadpage(url, **opt): from lib import requests session = requests.session() - if config.get_setting('resolver_dns') and not opt.get('use_requests', False): + if config.getSetting('resolver_dns') and not opt.get('use_requests', False): from core import resolverdns session.mount('https://', resolverdns.CipherSuiteAdapter(domain)) @@ -454,7 +454,7 @@ def downloadpage(url, **opt): if not 'api.themoviedb' in url and not opt.get('alfa_s', False): show_infobox(info_dict) - if not config.get_setting("debug"): logger.info('Page URL:',url) + if not config.getSetting("debug"): logger.info('Page URL:',url) return type('HTTPResponse', (), response) def fill_fields_pre(url, opt, proxy_data, file_name): diff --git a/core/jsontools.py b/core/jsontools.py index b80c2cec..83287093 100644 --- a/core/jsontools.py +++ b/core/jsontools.py @@ -58,7 +58,7 @@ def to_utf8(dct): return dct -def get_node_from_file(name_file, node, path=None): +def getNodeFromFile(name_file, node, path=None): """ Gets the node of a JSON file @@ -80,7 +80,7 @@ def get_node_from_file(name_file, node, path=None): name_file += "_data.json" if not path: - path = filetools.join(config.get_data_path(), "settings_channels") + path = filetools.join(config.getDataPath(), "settings_channels") fname = filetools.join(path, name_file) @@ -126,7 +126,7 @@ def check_to_backup(data, fname, dict_data): logger.debug("The file is empty: %s" % fname) -def update_node(dict_node, name_file, node, path=None, silent=False): +def updateNode(dict_node, name_file, node, path=None, silent=False): """ update the json_data of a file with the last dictionary @@ -152,7 +152,7 @@ def update_node(dict_node, name_file, node, path=None, silent=False): name_file += "_data.json" if not path: - path = filetools.join(config.get_data_path(), "settings_channels") + path = filetools.join(config.getDataPath(), "settings_channels") fname = filetools.join(path, name_file) diff --git a/core/resolverdns.py b/core/resolverdns.py index 7f22ddef..1ba8f83e 100644 --- a/core/resolverdns.py +++ b/core/resolverdns.py @@ -127,7 +127,7 @@ class CipherSuiteAdapter(host_header_ssl.HostHeaderSSLAdapter): logger.info(e) # if 'SSLError' in str(e): # # disabilito - # config.set_setting("resolver_dns", False) + # config.setSetting("resolver_dns", False) # request.url = realUrl # ret = super(CipherSuiteAdapter, self).send(request, **kwargs) # else: diff --git a/core/scraper.py b/core/scraper.py index 503b0a63..e46b3144 100644 --- a/core/scraper.py +++ b/core/scraper.py @@ -25,14 +25,14 @@ def find_and_set_infoLabels(item): scraper = None # logger.debug("item:\n" + item.tostring('\n')) - list_opciones_cuadro = [config.get_localized_string(60223), config.get_localized_string(60224)] + list_opciones_cuadro = [config.getLocalizedString(60223), config.getLocalizedString(60224)] # If more scrapers are added, they must be declared here-> "modulo_scraper": "Text_in_box" - scrapers_disponibles = {'tmdb': config.get_localized_string(60225), 'tvdb': config.get_localized_string(60226)} + scrapers_disponibles = {'tmdb': config.getLocalizedString(60225), 'tvdb': config.getLocalizedString(60226)} # Get the default Scraper of the configuration according to the content type if item.contentType == "movie": scraper_actual = 'tmdb' - # scraper_actual = ['tmdb'][config.get_setting("scraper_movies", "videolibrary")] + # scraper_actual = ['tmdb'][config.getSetting("scraper_movies", "videolibrary")] tipo_contenido = "movie" title = item.contentTitle # Complete list of options for this type of content @@ -40,7 +40,7 @@ def find_and_set_infoLabels(item): else: scraper_actual = 'tmdb' - # scraper_actual = ['tmdb', 'tvdb'][config.get_setting("scraper_tvshows", "videolibrary")] + # scraper_actual = ['tmdb', 'tvdb'][config.getSetting("scraper_tvshows", "videolibrary")] tipo_contenido = "serie" title = item.contentSerieName # Complete list of options for this type of content @@ -68,14 +68,14 @@ def find_and_set_infoLabels(item): return True elif scraper_result: # Content found but no 'code' - msg = config.get_localized_string(60227) % title + msg = config.getLocalizedString(60227) % title else: # Content not found - msg = config.get_localized_string(60228) % title + msg = config.getLocalizedString(60228) % title logger.debug(msg) # Show box with other options: - item = platformtools.dialog_info(item, scraper_actual) + item = platformtools.dialogInfo(item, scraper_actual) if item.exit: logger.debug("You have clicked 'cancel' in the window '%s'" % msg) return False @@ -91,19 +91,19 @@ def find_and_set_infoLabels(item): # COLOR = ["0xFF65B3DA", "0xFFFFFFFF"] # # We create the list of infoLabel fields -# controls = [("title", "text", config.get_localized_string(60230)), -# ("originaltitle", "text", config.get_localized_string(60231)), -# ("year", "text", config.get_localized_string(60232)), -# ("identificadores", "label", config.get_localized_string(60233)), -# ("tmdb_id", "text", config.get_localized_string(60234)), -# ("url_tmdb", "text", config.get_localized_string(60235), "+!eq(-1,'')"), -# ("tvdb_id", "text", config.get_localized_string(60236), "+eq(-7,'Serie')"), -# ("url_tvdb", "text", config.get_localized_string(60237), "+!eq(-1,'')+eq(-8,'Serie')"), -# ("imdb_id", "text", config.get_localized_string(60238)), -# ("otro_id", "text", config.get_localized_string(60239), "+eq(-1,'')"), -# ("urls", "label", config.get_localized_string(60240)), -# ("fanart", "text", config.get_localized_string(60241)), -# ("thumbnail", "text", config.get_localized_string(60242))] +# controls = [("title", "text", config.getLocalizedString(60230)), +# ("originaltitle", "text", config.getLocalizedString(60231)), +# ("year", "text", config.getLocalizedString(60232)), +# ("identificadores", "label", config.getLocalizedString(60233)), +# ("tmdb_id", "text", config.getLocalizedString(60234)), +# ("url_tmdb", "text", config.getLocalizedString(60235), "+!eq(-1,'')"), +# ("tvdb_id", "text", config.getLocalizedString(60236), "+eq(-7,'Serie')"), +# ("url_tvdb", "text", config.getLocalizedString(60237), "+!eq(-1,'')+eq(-8,'Serie')"), +# ("imdb_id", "text", config.getLocalizedString(60238)), +# ("otro_id", "text", config.getLocalizedString(60239), "+eq(-1,'')"), +# ("urls", "label", config.getLocalizedString(60240)), +# ("fanart", "text", config.getLocalizedString(60241)), +# ("thumbnail", "text", config.getLocalizedString(60242))] # if item.infoLabels["mediatype"] == "movie": # mediatype_default = 0 @@ -112,12 +112,12 @@ def find_and_set_infoLabels(item): # listado_controles = [{'id': "mediatype", # 'type': "list", -# 'label': config.get_localized_string(60243), +# 'label': config.getLocalizedString(60243), # 'color': COLOR[1], # 'default': mediatype_default, # 'enabled': True, # 'visible': True, -# 'lvalues': [config.get_localized_string(60244), config.get_localized_string(70136)] +# 'lvalues': [config.getLocalizedString(60244), config.getLocalizedString(70136)] # }] # for i, c in enumerate(controls): @@ -154,7 +154,7 @@ def find_and_set_infoLabels(item): # 'visible': True}) # # logger.debug(dict_default) -# if platformtools.show_channel_settings(list_controls=listado_controles, caption=config.get_localized_string(60246), item=item, +# if platformtools.showChannelSettings(list_controls=listado_controles, caption=config.getLocalizedString(60246), item=item, # callback="core.scraper.callback_cuadro_completar", # custom_button={"visible": False}): # return True @@ -225,16 +225,16 @@ def get_nfo(item, search_groups=False): return info_nfo else: - try: return scraper.get_nfo(item) - except: - if item.contentType == "movie": scraper_actual = ['tmdb'][config.get_setting("scraper_movies", "videolibrary")] - else: scraper_actual = ['tmdb', 'tvdb'][config.get_setting("scraper_tvshows", "videolibrary")] - scraper = __import__('core.%s' % scraper_actual, fromlist=["core.%s" % scraper_actual]) - return scraper.get_nfo(item, search_groups) + # try: return scraper.get_nfo(item) + # except: + # if item.contentType == "movie": scraper_actual = ['tmdb'][config.getSetting("scraper_movies", "videolibrary")] + # else: scraper_actual = ['tmdb', 'tvdb'][config.getSetting("scraper_tvshows", "videolibrary")] + scraper = __import__('core.tmdb', fromlist=["core.tmdb" ]) + return scraper.get_nfo(item, search_groups) def sort_episode_list(episodelist): - scraper_actual = ['tmdb', 'tvdb'][config.get_setting("scraper_tvshows", "videolibrary")] + scraper_actual = ['tmdb', 'tvdb'][config.getSetting("scraper_tvshows", "videolibrary")] if scraper_actual == "tmdb": episodelist.sort(key=lambda e: (int(e.contentSeason), int(e.contentEpisodeNumber))) diff --git a/core/scrapertools.py b/core/scrapertools.py index e47455e7..69209273 100644 --- a/core/scrapertools.py +++ b/core/scrapertools.py @@ -59,11 +59,11 @@ def find_single_match(data, patron, index=0): # Parse string and extracts multiple matches using regular expressions -def find_multiple_matches(text, pattern): +def findMultipleMatches(text, pattern): return re.findall(pattern, text, re.DOTALL) -def find_multiple_matches_groups(text, pattern): +def findMultipleMatches_groups(text, pattern): r = re.compile(pattern) return [m.groupdict() for m in r.finditer(text)] diff --git a/core/servertools.py b/core/servertools.py index d3fa22b7..f9510693 100644 --- a/core/servertools.py +++ b/core/servertools.py @@ -223,7 +223,7 @@ def get_server_from_url(url): return None -def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialogo=False, background_dialog=False): +def resolve_videoUrls_for_playing(server, url, video_password="", muestra_dialogo=False, background_dialog=False): """ Function to get the real url of the video @param server: Server where the video is hosted @@ -244,7 +244,7 @@ def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialo server = server.lower() - video_urls = [] + videoUrls = [] video_exists = True error_messages = [] opciones = [] @@ -254,7 +254,7 @@ def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialo if isinstance(video_password, list): return video_password, len(video_password) > 0, "<br/>".join(error_messages) logger.info("Server: %s, url is good" % server) - video_urls.append({'type':urlparse.urlparse(url)[2].split('.')[-1], 'url':url}) + videoUrls.append({'type':urlparse.urlparse(url)[2].split('.')[-1], 'url':url}) # Find out the video URL else: @@ -266,7 +266,7 @@ def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialo if server_parameters: # Show a progress dialog if muestra_dialogo: - progreso = (platformtools.dialog_progress_bg if background_dialog else platformtools.dialog_progress)(config.get_localized_string(20000), config.get_localized_string(70180) % translate_server_name(server_parameters["name"])) + progreso = (platformtools.dialogProgressBg if background_dialog else platformtools.dialogProgress)(config.getLocalizedString(20000), config.getLocalizedString(70180) % translate_server_name(server_parameters["name"])) # Count the available options, to calculate the percentage @@ -279,15 +279,15 @@ def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialo if server_parameters["free"] == True: opciones.append("free") opciones.extend( - [premium for premium in server_parameters["premium"] if config.get_setting("premium", server=premium)]) + [premium for premium in server_parameters["premium"] if config.getSetting("premium", server=premium)]) - priority = int(config.get_setting("resolve_priority")) + priority = int(config.getSetting("resolve_priority")) opciones = sorted(opciones, key=lambda x: order[priority].index(x)) logger.info("Available options: %s | %s" % (len(opciones), opciones)) else: logger.error("There is no connector for the server %s" % server) - error_messages.append(config.get_localized_string(60004) % server) + error_messages.append(config.getLocalizedString(60004) % server) muestra_dialogo = False # Import the server @@ -336,60 +336,60 @@ def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialo # Show progress if muestra_dialogo: - progreso.update((old_div(100, len(opciones))) * opciones.index(opcion), config.get_localized_string(70180) % server_name) + progreso.update((old_div(100, len(opciones))) * opciones.index(opcion), config.getLocalizedString(70180) % server_name) # Free mode if opcion == "free": try: - logger.info("Invoking a %s.get_video_url" % server) - response = serverid.get_video_url(page_url=url, video_password=video_password) - video_urls.extend(response) + logger.info("Invoking a %s.get_videoUrl" % server) + response = serverid.get_videoUrl(page_url=url, video_password=video_password) + videoUrls.extend(response) except: logger.error("Error getting url in free mode") - error_messages.append(config.get_localized_string(60014)) + error_messages.append(config.getLocalizedString(60014)) import traceback logger.error(traceback.format_exc()) # Premium mode else: try: - logger.info("Invoking a %s.get_video_url" % opcion) - response = serverid.get_video_url(page_url=url, premium=True, - user=config.get_setting("user", server=opcion), - password=config.get_setting("password", server=opcion), + logger.info("Invoking a %s.get_videoUrl" % opcion) + response = serverid.get_videoUrl(page_url=url, premium=True, + user=config.getSetting("user", server=opcion), + password=config.getSetting("password", server=opcion), video_password=video_password) if response and response[0][1]: - video_urls.extend(response) + videoUrls.extend(response) elif response and response[0][0]: error_messages.append(response[0][0]) else: - error_messages.append(config.get_localized_string(60014)) + error_messages.append(config.getLocalizedString(60014)) except: logger.error("Server errorr: %s" % opcion) - error_messages.append(config.get_localized_string(60014)) + error_messages.append(config.getLocalizedString(60014)) import traceback logger.error(traceback.format_exc()) # If we already have URLS, we stop searching - if video_urls and config.get_setting("resolve_stop") == True: + if videoUrls and config.getSetting("resolve_stop") == True: break # We close progress if muestra_dialogo: - progreso.update(100, config.get_localized_string(60008)) + progreso.update(100, config.getLocalizedString(60008)) progreso.close() # If there are no options available, we show the notice of premium accounts if video_exists and not opciones and server_parameters.get("premium"): listapremium = [get_server_parameters(premium)["name"] for premium in server_parameters["premium"]] error_messages.append( - config.get_localized_string(60009) % (server, " o ".join(listapremium))) + config.getLocalizedString(60009) % (server, " o ".join(listapremium))) # If we do not have urls or error messages, we put a generic one - elif not video_urls and not error_messages: - error_messages.append(config.get_localized_string(60014)) + elif not videoUrls and not error_messages: + error_messages.append(config.getLocalizedString(60014)) - return video_urls, len(video_urls) > 0, "<br/>".join(error_messages) + return videoUrls, len(videoUrls) > 0, "<br/>".join(error_messages) def get_server_name(serverid): @@ -444,11 +444,11 @@ def is_server_enabled(server): server_parameters = get_server_parameters(server) if server_parameters["active"] == True: - if not config.get_setting("hidepremium"): + if not config.getSetting("hidepremium"): return True elif server_parameters["free"] == True: return True - elif [premium for premium in server_parameters["premium"] if config.get_setting("premium", server=premium)]: + elif [premium for premium in server_parameters["premium"] if config.getSetting("premium", server=premium)]: return True return False @@ -473,12 +473,12 @@ def get_server_parameters(server): try: path = '' # Servers - if filetools.isfile(filetools.join(config.get_runtime_path(), "servers", server + ".json")): - path = filetools.join(config.get_runtime_path(), "servers", server + ".json") + if filetools.isfile(filetools.join(config.getRuntimePath(), "servers", server + ".json")): + path = filetools.join(config.getRuntimePath(), "servers", server + ".json") # Debriders - elif filetools.isfile(filetools.join(config.get_runtime_path(), "servers", "debriders", server + ".json")): - path = filetools.join(config.get_runtime_path(), "servers", "debriders", server + ".json") + elif filetools.isfile(filetools.join(config.getRuntimePath(), "servers", "debriders", server + ".json")): + path = filetools.join(config.getRuntimePath(), "servers", "debriders", server + ".json") # When the server is not well defined in the channel (there is no connector), it shows an error because there is no "path" and the channel has to be checked dict_server = jsontools.load(filetools.read(path)) @@ -487,7 +487,7 @@ def get_server_parameters(server): # Images: url and local files are allowed inside "resources / images" if dict_server.get("thumbnail") and "://" not in dict_server["thumbnail"]: - dict_server["thumbnail"] = filetools.join(config.get_runtime_path(), "resources", "media", + dict_server["thumbnail"] = filetools.join(config.getRuntimePath(), "resources", "media", "servers", dict_server["thumbnail"]) for k in ['premium', 'id']: dict_server[k] = dict_server.get(k, list()) @@ -507,7 +507,7 @@ def get_server_parameters(server): dict_servers_parameters[server] = dict_server except: - mensaje = config.get_localized_string(59986) % server + mensaje = config.getLocalizedString(59986) % server import traceback logger.error(mensaje + traceback.format_exc()) return {} @@ -539,7 +539,7 @@ def get_server_controls_settings(server_name): return list_controls, dict_settings -def get_server_setting(name, server, default=None): +def getServerSetting(name, server, default=None): """ Returns the configuration value of the requested parameter. @@ -563,10 +563,10 @@ def get_server_setting(name, server, default=None): """ # We create the folder if it does not exist - if not filetools.exists(filetools.join(config.get_data_path(), "settings_servers")): - filetools.mkdir(filetools.join(config.get_data_path(), "settings_servers")) + if not filetools.exists(filetools.join(config.getDataPath(), "settings_servers")): + filetools.mkdir(filetools.join(config.getDataPath(), "settings_servers")) - file_settings = filetools.join(config.get_data_path(), "settings_servers", server + "_data.json") + file_settings = filetools.join(config.getDataPath(), "settings_servers", server + "_data.json") dict_settings = {} dict_file = {} if filetools.exists(file_settings): @@ -596,12 +596,12 @@ def get_server_setting(name, server, default=None): return dict_settings.get(name, default) -def set_server_setting(name, value, server): +def setServerSetting(name, value, server): # We create the folder if it does not exist - if not filetools.exists(filetools.join(config.get_data_path(), "settings_servers")): - filetools.mkdir(filetools.join(config.get_data_path(), "settings_servers")) + if not filetools.exists(filetools.join(config.getDataPath(), "settings_servers")): + filetools.mkdir(filetools.join(config.getDataPath(), "settings_servers")) - file_settings = filetools.join(config.get_data_path(), "settings_servers", server + "_data.json") + file_settings = filetools.join(config.getDataPath(), "settings_servers", server + "_data.json") dict_settings = {} dict_file = None @@ -639,7 +639,7 @@ def get_servers_list(): """ global server_list if not server_list: - for server in filetools.listdir(filetools.join(config.get_runtime_path(), "servers")): + for server in filetools.listdir(filetools.join(config.getRuntimePath(), "servers")): if server.endswith(".json") and not server == "version.json": server_parameters = get_server_parameters(server) if server_parameters['active']: @@ -657,7 +657,7 @@ def get_debriders_list(): @rtype: dict """ server_list = {} - for server in filetools.listdir(filetools.join(config.get_runtime_path(), "servers", "debriders")): + for server in filetools.listdir(filetools.join(config.getRuntimePath(), "servers", "debriders")): if server.endswith(".json"): server_parameters = get_server_parameters(server) if server_parameters["active"] == True: @@ -682,13 +682,13 @@ def sort_servers(servers_list): if not servers_list: return [] - blacklisted_servers = config.get_setting("black_list", server='servers', default=[]) - favorite_servers = [s for s in config.get_setting('favorites_servers_list', server='servers', default=[]) if s not in blacklisted_servers] + blacklisted_servers = config.getSetting("black_list", server='servers', default=[]) + favorite_servers = [s for s in config.getSetting('favorites_servers_list', server='servers', default=[]) if s not in blacklisted_servers] sorted_list = [] inverted = False - if config.get_setting('default_action') == 2: + if config.getSetting('default_action') == 2: inverted = True # Priorities when ordering itemlist: @@ -697,8 +697,8 @@ def sort_servers(servers_list): # 2: Qualities and Servers priority = 0 - if config.get_setting('favorites_servers') and favorite_servers: priority = 1 - if config.get_setting('quality_priority'): priority = 2 + if config.getSetting('favorites_servers') and favorite_servers: priority = 1 + if config.getSetting('quality_priority'): priority = 2 for item in servers_list: element = dict() @@ -802,16 +802,16 @@ def check_video_link(item, timeout=3): def translate_server_name(name): - if '@' in name: return config.get_localized_string(int(name.replace('@',''))) + if '@' in name: return config.getLocalizedString(int(name.replace('@',''))) else: return name # def get_server_json(server_name): # # logger.info("server_name=" + server_name) # try: -# server_path = filetools.join(config.get_runtime_path(), "servers", server_name + ".json") +# server_path = filetools.join(config.getRuntimePath(), "servers", server_name + ".json") # if not filetools.exists(server_path): -# server_path = filetools.join(config.get_runtime_path(), "servers", "debriders", server_name + ".json") +# server_path = filetools.join(config.getRuntimePath(), "servers", "debriders", server_name + ".json") # # # logger.info("server_path=" + server_path) # server_json = jsontools.load(filetools.read(server_path)) diff --git a/core/support.py b/core/support.py index 8fab6952..724de7aa 100755 --- a/core/support.py +++ b/core/support.py @@ -174,7 +174,7 @@ class scrape: scrapingTime = time() if self.patronBlock: if self.debugBlock: regexDbg(item, self.patronBlock, self.headers, self.data) - blocks = scrapertools.find_multiple_matches_groups(self.data, self.patronBlock) + blocks = scrapertools.findMultipleMatches_groups(self.data, self.patronBlock) for bl in blocks:self._scrapeBlock(item, bl) elif self.patron: @@ -226,10 +226,6 @@ class scrape: self.itemlist = newFunc() self.itemlist = [i for i in self.itemlist if i.action not in ['add_movie_to_library', 'add_serie_to_library']] - if not self.group and not self.args.get('groupExplode') and ((self.pagination and len(self.matches) <= self.pag * self.pagination) or not self.pagination): # next page with pagination - if self.patronNext and not stackCheck('newest') and not stackCheck('get_channel_results'): - nextPage(self.itemlist, item, self.function, data=self.data, patron=self.patronNext, patron_total_pages=self.patronTotalPages) - if self.numerationEnabled and not stackCheck('find_episodes'): from platformcode import autorenumber if self.function == 'episodes': @@ -251,9 +247,13 @@ class scrape: if self.tmdbEnabled and ( self.action != 'play' and 'patronMenu' not in self.args and 'patronGenreMenu' not in self.args and not stackCheck(['add_tvshow', 'get_newest']) and (self.function not in ['episodes', 'mainlist'] - or (self.function in ['episodes'] and config.get_setting('episode_info')))): + or (self.function in ['episodes'] and config.getSetting('episode_info')))): tmdb.set_infoLabels_itemlist(self.itemlist, seekTmdb=True) + + if not self.group and not self.args.get('groupExplode') and ((self.pagination and len(self.matches) <= self.pag * self.pagination) or not self.pagination): # next page with pagination + if self.patronNext and not stackCheck('newest') and not stackCheck('get_channel_results'): + nextPage(self.itemlist, item, self.function, data=self.data, patron=self.patronNext, patron_total_pages=self.patronTotalPages) if not stackCheck(['find_episodes', 'add_tvshow']): if self.videlibraryEnabled and (item.infoLabels["title"] or item.fulltitle): @@ -274,7 +274,7 @@ class scrape: raise logger.ChannelScraperException - if config.get_setting('trakt_sync'): + if config.getSetting('trakt_sync'): from core import trakt_tools trakt_tools.trakt_check(self.itemlist) logger.debug(item.channel, 'scraping time:', time()-scrapingTime) @@ -292,7 +292,7 @@ class scrape: if self.debug: regexDbg(item, self.patron, self.headers, block) - matches = scrapertools.find_multiple_matches_groups(block, self.patron) + matches = scrapertools.findMultipleMatches_groups(block, self.patron) logger.debug('MATCHES =', matches) for match in matches: @@ -320,7 +320,7 @@ class scrape: self.itemParams._plot = cleantitle(self.itemParams._plot) self.itemParams._language = scrapeLang(self.itemParams, self.lang) - self.set_infolabels(item) + self.setInfolabels(item) if self.sceneTitle: self.set_sceneTitle() if not self.group or item.grouped: @@ -330,13 +330,13 @@ class scrape: if self.itemParams._season: self.itemParams.infoLabels['season'] = int(self.itemParams._season) if self.itemParams._episode: self.itemParams.infoLabels['episode'] = int(self.itemParams._episode) - it = self.set_item(item, match) + it = self.setItem(item, match) if it: itemlist.append(it) self.itemlist.extend(itemlist) self.matches.extend(matches) - def set_infolabels(self, item): + def setInfolabels(self, item): if item.infoLabels["title"]: infolabels = item.infoLabels else: @@ -349,7 +349,7 @@ class scrape: if self.itemParams._plot: infolabels['plot'] = self.itemParams._plot if self.itemParams._duration: - dur = scrapertools.find_multiple_matches(self.itemParams._duration, r'([0-9])\s*?(?:[hH]|:|\.|,|\\|\/|\||\s)\s*?([0-9]+)') + dur = scrapertools.findMultipleMatches(self.itemParams._duration, r'([0-9])\s*?(?:[hH]|:|\.|,|\\|\/|\||\s)\s*?([0-9]+)') for h, m in dur: self.itemParams._duration = int(h) * 60 + int(m) if not dur: @@ -359,7 +359,7 @@ class scrape: except: self.itemParams._duration = '' if self.itemParams._genre: - genres = scrapertools.find_multiple_matches(self.itemParams._genre, '[A-Za-z]+') + genres = scrapertools.findMultipleMatches(self.itemParams._genre, '[A-Za-z]+') infolabels['genere'] = ", ".join(genres) if self.itemParams._rating: rating = scrapertools.decodeHtmlentities(self.itemParams._rating) @@ -397,7 +397,7 @@ class scrape: self.itemParams.infoLabels['episode'] = parsedTitle.get('episode') elif parsedTitle.get('season') and type(parsedTitle.get('season')) == list: - self.itemParams._extraInfo = '{}: {}-{}'.format(config.get_localized_string(30140), parsedTitle.get('season')[0], parsedTitle.get('season')[-1]) + self.itemParams._extraInfo = '{}: {}-{}'.format(config.getLocalizedString(30140), parsedTitle.get('season')[0], parsedTitle.get('season')[-1]) elif parsedTitle.get('season'): self.itemParams._season = str(parsedTitle.get('season')) if parsedTitle.get('episode_title'): @@ -439,7 +439,7 @@ class scrape: logger.debug('invalid episode: ' + self.itemParams._episode) pass - def set_item(self, item, match): + def setItem(self, item, match): AC = '' CT = '' if self.typeContentDict: @@ -485,11 +485,6 @@ class scrape: else: it.action=self.action - if it.action == 'findvideos': - platformtools.window_type(it) - # it.window = True if item.window_type == 0 or (config.get_setting("window_type") == 0) else False - if it.window: it.folder = False - for lg in list(set(match.keys()).difference(self.known_keys)): it.__setattr__(lg, match[lg]) @@ -506,7 +501,7 @@ class scrape: def regexDbg(item, patron, headers, data=''): - if config.dev_mode(): + if config.devMode(): import json, webbrowser url = 'https://regex101.com' @@ -608,11 +603,11 @@ def menu(func): single_search = False # listUrls = ['film', 'filmSub', 'tvshow', 'tvshowSub', 'anime', 'animeSub', 'search', 'top', 'topSub'] listUrls = ['top', 'film', 'tvshow', 'anime', 'search', 'host'] - names = {'film':config.get_localized_string(30122), - 'tvshow':config.get_localized_string(30123), - 'anime':config.get_localized_string(30124), - 'doc':config.get_localized_string(30125), - 'music':config.get_localized_string(30139)} + names = {'film':config.getLocalizedString(30122), + 'tvshow':config.getLocalizedString(30123), + 'anime':config.getLocalizedString(30124), + 'doc':config.getLocalizedString(30125), + 'music':config.getLocalizedString(30139)} listUrls_extra = [] dictUrl = {} @@ -665,7 +660,7 @@ def menu(func): args=var[2] if len(var) > 2 else '', contentType= var[3] if len(var) > 3 else 'movie' if name == 'film' else 'tvshow') # add search menu for category - if 'search' not in args: menuItem(itemlist, channel, config.get_localized_string(70741) % title + '… {submenu bold}', 'search', host + url, contentType='movie' if name == 'film' else 'tvshow', style=not global_search) + if 'search' not in args: menuItem(itemlist, channel, config.getLocalizedString(70741) % title + '… {submenu bold}', 'search', host + url, contentType='movie' if name == 'film' else 'tvshow', style=not global_search) # Make EXTRA MENU (on bottom) for name, var in args.items(): @@ -684,7 +679,7 @@ def menu(func): contentType= var[3] if len(var) > 3 else 'movie',) if single_search: - menuItem(itemlist, channel, config.get_localized_string(70741).replace(' %s', '… {bold}'), 'search', host + dictUrl['search'], style=not global_search) + menuItem(itemlist, channel, config.getLocalizedString(70741).replace(' %s', '… {bold}'), 'search', host + dictUrl['search'], style=not global_search) if not global_search: channel_config(item, itemlist) @@ -788,7 +783,7 @@ def match(item_url_string, **args): if type(patronBlocks) == str: patronBlocks = [patronBlocks] for p in patronBlocks: - blocks += scrapertools.find_multiple_matches(data, p) + blocks += scrapertools.findMultipleMatches(data, p) else: blocks = [data] @@ -798,10 +793,10 @@ def match(item_url_string, **args): patron = [patron] for b in blocks: for p in patron: - matches += scrapertools.find_multiple_matches(b, p) + matches += scrapertools.findMultipleMatches(b, p) # debug mode - if config.dev_mode(): + if config.devMode(): if debugBlock: match_dbg(data, patronBlock) if debug: @@ -884,7 +879,7 @@ def nextPage(itemlist, item, function_or_level=1, **kwargs): # create Item if next_page or page: itemlist.append(item.clone(action = inspect.stack()[function_or_level][3] if type(function_or_level) == int else function_or_level, - title=typo(config.get_localized_string(90006), 'color kod bold'), + title=typo(config.getLocalizedString(90006), 'color kod bold'), nextPage=True, page=page if page else item.page + 1 if item.page else 2, prevthumb = item.thumbnail, @@ -892,11 +887,12 @@ def nextPage(itemlist, item, function_or_level=1, **kwargs): thumbnail=thumb())) - itemlist.append(item.clone(action='gotopage', + itemlist.append(item.clone(from_cannel=item.channel, + channel='shortcuts', + action='gotopage', real_action = inspect.stack()[function_or_level][3] if type(function_or_level) == int else function_or_level, - title=typo(config.get_localized_string(90007), 'color kod bold'), + title=typo(config.getLocalizedString(90007), 'color kod bold'), nextPage=True, - total_pages = total_pages, page=page if page else item.page + 1 if item.page else 2, prevthumb = item.thumbnail, thumbnail=thumb(), @@ -910,7 +906,7 @@ def pagination(itemlist, item, function_level=1): if not item.page: item.page = 1 - perpage = config.get_setting('pagination', default=20) + perpage = config.getSetting('pagination', default=20) action = function_level if type(function_level) == str else inspect.stack()[function_level][3] itlist = [] for i, it in enumerate(itemlist): @@ -924,7 +920,7 @@ def pagination(itemlist, item, function_level=1): Item(channel=item.channel, contentType=item.contentType, action=action, - title=typo(config.get_localized_string(90006), 'color kod bold'), + title=typo(config.getLocalizedString(90006), 'color kod bold'), page=item.page + 1, total_pages=round(len(itemlist)/perpage), nextPage = True, @@ -933,18 +929,19 @@ def pagination(itemlist, item, function_level=1): thumbnail=thumb())) if len(itemlist) > perpage: itlist.append( - Item(channel=item.channel, - contentType=item.contentType, - action='gotopage', - real_action=action, - title=typo(config.get_localized_string(90007), 'color kod bold'), - page=item.page + 1, - total_pages=round(len(itemlist)/perpage), - nextPage = True, - itemlist = True, - prevthumb = item.thumbnail, - thumbnail=thumb(), - folder = False)) + Item(from_cannel=item.channel, + channel='shortcuts', + contentType=item.contentType, + action='gotopage', + real_action=action, + title=typo(config.getLocalizedString(90007), 'color kod bold'), + page=item.page + 1, + total_pages=round(len(itemlist)/perpage), + nextPage = True, + itemlist = True, + prevthumb = item.thumbnail, + thumbnail=thumb(), + folder = False)) return itlist @@ -981,17 +978,18 @@ def season_pagination(itemlist, item, seasons=[], function_level=1): itlist.append( Item(channel=item.channel, action=action, - title=typo(config.get_localized_string(90008), 'color kod bold'), + title=typo(config.getLocalizedString(90008), 'color kod bold'), allSeasons = seasons, nextSeason = item.nextSeason + 1, itemlist = True, prevthumb = item.thumbnail, thumbnail=thumb())) itlist.append( - Item(channel=item.channel, + Item(from_cannel=item.channel, + channel='shortcuts', action='gotoseason', real_action=action, - title=typo(config.get_localized_string(90009), 'color kod bold'), + title=typo(config.getLocalizedString(90009), 'color kod bold'), allSeasons = seasons, nextSeason = item.nextSeason + 1, itemlist = True, @@ -1021,14 +1019,14 @@ def server(item, data='', itemlist=[], headers='', AutoPlay=True, CheckLinks=Tru verifiedItemlist = [] def getItem(videoitem): - if not videoitem.video_urls: + if not videoitem.videoUrls: srv_param = servertools.get_server_parameters(videoitem.server.lower()) if not srv_param: # do not exists or it's empty findS = servertools.get_server_from_url(videoitem.url) logger.debug(findS) if not findS: if item.channel == 'community': - findS= (config.get_localized_string(30137), videoitem.url, 'directo') + findS= (config.getLocalizedString(30137), videoitem.url, 'directo') else: videoitem.url = unshortenit.unshorten_only(videoitem.url)[0] findS = servertools.get_server_from_url(videoitem.url) @@ -1042,12 +1040,12 @@ def server(item, data='', itemlist=[], headers='', AutoPlay=True, CheckLinks=Tru else: videoitem.server = videoitem.server.lower() - if videoitem.video_urls or srv_param.get('active', False): + if videoitem.videoUrls or srv_param.get('active', False): vi = item.clone(server=videoitem.server, serverName=videoitem.serverName, url=videoitem.url, - video_urls= videoitem.video_urlsn, + videoUrls= videoitem.videoUrlsn, ch_name=channeltools.get_channel_parameters(item.channel)['title'], action = "play") @@ -1069,7 +1067,7 @@ def server(item, data='', itemlist=[], headers='', AutoPlay=True, CheckLinks=Tru # videoitem.fulltitle = item.fulltitle # videoitem.show = item.show # videoitem.ch_name = channeltools.get_channel_parameters(item.channel)['title'] - # if not videoitem.video_urls: videoitem.thumbnail = item.thumbnail + # if not videoitem.videoUrls: videoitem.thumbnail = item.thumbnail # videoitem.contentType = item.contentType # videoitem.infoLabels = item.infoLabels # videoitem.quality = quality @@ -1082,13 +1080,13 @@ def server(item, data='', itemlist=[], headers='', AutoPlay=True, CheckLinks=Tru # non threaded for webpdb # dbg() - thL = [getItem(videoitem) for videoitem in itemlist if videoitem.url or videoitem.video_urls] + thL = [getItem(videoitem) for videoitem in itemlist if videoitem.url or videoitem.videoUrls] for it in thL: - if it and not config.get_setting("black_list", server=it.server.lower()): + if it and not config.getSetting("black_list", server=it.server.lower()): verifiedItemlist.append(it) # with futures.ThreadPoolExecutor() as executor: - # thL = [executor.submit(getItem, videoitem) for videoitem in itemlist if videoitem.url or videoitem.video_urls] + # thL = [executor.submit(getItem, videoitem) for videoitem in itemlist if videoitem.url or videoitem.videoUrls] # for it in futures.as_completed(thL): # if it.result(): # verifiedItemlist.append(it.result()) @@ -1097,8 +1095,8 @@ def server(item, data='', itemlist=[], headers='', AutoPlay=True, CheckLinks=Tru addQualityTag(item, verifiedItemlist, data, patronTag) # Check Links - if not item.global_search and config.get_setting('checklinks') and CheckLinks and not config.get_setting('autoplay'): - checklinks_number = config.get_setting('checklinks_number') + if not item.global_search and config.getSetting('checklinks') and CheckLinks and not config.getSetting('autoplay'): + checklinks_number = config.getSetting('checklinks_number') verifiedItemlist = servertools.check_list_links(verifiedItemlist, checklinks_number) try: @@ -1145,7 +1143,7 @@ def videolibrary(itemlist, item, typography='', function_level=1, function=''): if not typography: typography = 'color kod bold' - title = typo(config.get_localized_string(30161), typography) + title = typo(config.getLocalizedString(30161), typography) contentSerieName=item.contentSerieName if item.contentSerieName else item.fulltitle if item.contentType != 'movie' else '' contentTitle=item.contentTitle if item.contentTitle else item.fulltitle if item.contentType == 'movie' else '' @@ -1171,22 +1169,22 @@ def videolibrary(itemlist, item, typography='', function_level=1, function=''): def download(itemlist, item, typography='', function_level=1, function=''): - if config.get_setting('downloadenabled'): + if config.getSetting('downloadenabled'): if not typography: typography = 'color kod bold' if item.contentType == 'movie': from_action = 'findvideos' - title = typo(config.get_localized_string(60354), typography) + title = typo(config.getLocalizedString(60354), typography) elif item.contentType == 'episode': from_action = 'findvideos' - title = typo(config.get_localized_string(60356), typography) + ' - ' + item.title + title = typo(config.getLocalizedString(60356), typography) + ' - ' + item.title elif item.contentType in 'tvshow': - if item.channel == 'community' and config.get_setting('show_seasons', item.channel): + if item.channel == 'community' and config.getSetting('show_seasons', item.channel): from_action = 'season' else: from_action = 'episodes' - title = typo(config.get_localized_string(60355), typography) + title = typo(config.getLocalizedString(60355), typography) elif item.contentType in 'season': from_action = 'get_seasons' else: # content type does not support download @@ -1228,7 +1226,7 @@ def download(itemlist, item, typography='', function_level=1, function=''): itemlist.append( Item(channel='downloads', from_channel=item.channel, - title=typo(config.get_localized_string(60357),typography), + title=typo(config.getLocalizedString(60357),typography), fulltitle=item.fulltitle, show=item.fulltitle, contentType=item.contentType, @@ -1261,7 +1259,7 @@ def channel_config(item, itemlist): itemlist.append( Item(channel='setting', action="channel_config", - title=typo(config.get_localized_string(60587), 'color kod bold'), + title=typo(config.getLocalizedString(60587), 'color kod bold'), config=item.channel, folder=False, thumbnail=thumb('setting')) @@ -1373,8 +1371,8 @@ def thumb(data=None, mode=None): _year = ['anno', 'anni', 'year', 'years'] _top = ['voto', 'voti', 'votato', 'votati', 'migliore', 'migliori', 'fortunato', 'classifica', 'classifiche', 'vote', 'voted', 'best', 'top', 'lucky', 'ranking', 'rating', 'charts'] _popular = ['popolare', 'popolari', 'raccomandato', 'raccomandati', 'raccomandazione', 'raccomandazioni', 'momento', 'popular', 'recommended', 'recommendation', 'recommendations', 'moment'] - _all = ['tutto', 'tutta', 'tutti', 'tutte' 'all'] - _az = ['lettera', 'lettere', 'lista', 'liste', 'alfabetico', 'a-z', 'letter', 'letters', 'list', 'alphabetical'] + _all = ['tutto', 'tutta', 'tutti', 'tutte', 'all'] + _az = ['lettera', 'lettere', 'lista', 'liste', 'alfabetico', 'a-z', 'letter', 'letters', 'list', 'alphabetical', 'order', 'ordine'] _news = ['novità', "novita'", 'aggiornamenti', 'nuovo', 'nuova', 'nuovi', 'nuove', 'ultimo', 'ultima', 'ultimi', 'ultime', 'notizia', 'notizie', 'new', 'newest', 'last', 'latest', 'news'] _cinema = ['cinema', 'sala', 'theatre', 'theatres'] _genre = ['genere', 'generi', 'categoria', 'categorie', 'genre', 'genres', 'category', 'categories'] @@ -1385,9 +1383,9 @@ def thumb(data=None, mode=None): _info = ['informazione', 'informazioni', 'info', 'information', 'informations'] _star = ['attore', 'attrice', 'attori', 'attrici', 'regista', 'registi', 'personaggio', 'personaggi', 'interprete', 'interpreti', 'star', 'stars', 'character', 'characters', 'performer', 'performers', 'staff', 'actor', 'actors', 'actress', 'actresses', 'director', 'directors'] _winter = ['inverno', 'winter'] - _spring = ['primavera', 'spring'], - _summer = ['estate', 'summer'], - _autumn = ['autunno', 'autumn'], + _spring = ['primavera', 'spring'] + _summer = ['estate', 'summer'] + _autumn = ['autunno', 'autumn'] _teenager = ['ragazzo', 'ragazza', 'ragazzi', 'ragazze','teenager', 'teen'] _learning = ['imparare', 'scuola', 'learn', 'learning', 'school'] _animation = ['animazione', 'cartoni', 'animation', 'cartoon'] @@ -1456,7 +1454,7 @@ def thumb(data=None, mode=None): 'teenager':_teenager, 'learning':_learning, 'quality':_quality, - 'autoplay':[config.get_localized_string(60071)] + 'autoplay':[config.getLocalizedString(60071)] } genre_dict = {'documentary':_documentary, @@ -1562,6 +1560,7 @@ def thumb(data=None, mode=None): thumb = thumb + suffix if not thumb: for t, titles in icon_dict.items(): + logger.debug(titles) if any(word in searched_title for word in titles): thumb = t @@ -1590,10 +1589,10 @@ def get_thumb(thumb_name, view="thumb_"): from core import filetools if thumb_name.startswith('http'): return thumb_name - elif config.get_setting('enable_custom_theme') and config.get_setting('custom_theme') and filetools.isfile(config.get_setting('custom_theme') + view + thumb_name): - media_path = config.get_setting('custom_theme') + elif config.getSetting('enable_custom_theme') and config.getSetting('custom_theme') and filetools.isfile(config.getSetting('custom_theme') + view + thumb_name): + media_path = config.getSetting('custom_theme') else: - icon_pack_name = config.get_setting('icon_set', default="default") + icon_pack_name = config.getSetting('icon_set', default="default") media_path = filetools.join("https://raw.githubusercontent.com/kodiondemand/media/master/themes/new", icon_pack_name) return filetools.join(media_path, thumb_name) @@ -1609,10 +1608,10 @@ def typo(string, typography=''): try: string = str(string) except: string = str(string.encode('utf8')) - if config.get_localized_string(30992) in string: + if config.getLocalizedString(30992) in string: string = string + ' >' - if int(config.get_setting('view_mode_channel').split(',')[-1]) in [0, 50, 55]: + if int(config.getSetting('view_mode_channel').split(',')[-1]) in [0, 50, 55]: VLT = True else: VLT = False @@ -1683,7 +1682,7 @@ def hdpass_get_servers(item, data=''): page = httptools.downloadpage(url, CF=False).data mir = scrapertools.find_single_match(page, patron_mir) - for mir_url, srv in scrapertools.find_multiple_matches(mir, patron_option): + for mir_url, srv in scrapertools.findMultipleMatches(mir, patron_option): mir_url = scrapertools.decodeHtmlentities(mir_url) logger.debug(mir_url) it = hdpass_get_url(item.clone(action='play', quality=quality, url=mir_url))[0] @@ -1712,13 +1711,13 @@ def hdpass_get_servers(item, data=''): res = scrapertools.find_single_match(data, patron_res) # non threaded for webpdb - # for res_url, res_video in scrapertools.find_multiple_matches(res, patron_option): + # for res_url, res_video in scrapertools.findMultipleMatches(res, patron_option): # res_url = scrapertools.decodeHtmlentities(res_url) # itemlist.extend(get_hosts(res_url, res_video)) # with futures.ThreadPoolExecutor() as executor: thL = [] - for res_url, res_video in scrapertools.find_multiple_matches(res, patron_option): + for res_url, res_video in scrapertools.findMultipleMatches(res, patron_option): res_url = scrapertools.decodeHtmlentities(res_url) thL.append(executor.submit(get_hosts, res_url, res_video)) for res in futures.as_completed(thL): @@ -1758,7 +1757,7 @@ def dooplay_get_links(item, host, paramList=[]): if not paramList: data = httptools.downloadpage(item.url).data.replace("'", '"') patron = r'<li id="player-option-[0-9]".*?data-type="([^"]+)" data-post="([^"]+)" data-nume="([^"]+)".*?<span class="title".*?>([^<>]+)</span>(?:<span class="server">([^<>]+))?' - matches = scrapertools.find_multiple_matches(data, patron) + matches = scrapertools.findMultipleMatches(data, patron) else: matches = paramList ret = [] @@ -1846,9 +1845,9 @@ def dooplay_menu(item, type): ########## JWPLAYER ########## -def get_jwplayer_mediaurl(data, srvName, onlyHttp=False, dataIsBlock=False): +def get_jwplayer_mediaUrl(data, srvName, onlyHttp=False, dataIsBlock=False): from core import jsontools - video_urls = [] + videoUrls = [] block = scrapertools.find_single_match(data, r'sources"?\s*:\s*(.*?}?])') if not dataIsBlock else data if block: json = jsontools.load(block) @@ -1865,17 +1864,17 @@ def get_jwplayer_mediaurl(data, srvName, onlyHttp=False, dataIsBlock=False): sources.append((src, s.get('label'))) else: if 'file:' in block: - sources = scrapertools.find_multiple_matches(block, r'file:\s*"([^"]+)"(?:,label:\s*"([^"]+)")?') + sources = scrapertools.findMultipleMatches(block, r'file:\s*"([^"]+)"(?:,label:\s*"([^"]+)")?') elif 'src:' in block: - sources = scrapertools.find_multiple_matches(block, r'src:\s*"([^"]+)",\s*type:\s*"[^"]+"(?:,[^,]+,\s*label:\s*"([^"]+)")?') + sources = scrapertools.findMultipleMatches(block, r'src:\s*"([^"]+)",\s*type:\s*"[^"]+"(?:,[^,]+,\s*label:\s*"([^"]+)")?') else: sources =[(block.replace('"',''), '')] for url, quality in sources: quality = 'auto' if not quality else quality if url.split('.')[-1] != 'mpd': - video_urls.append({'type':url.split('.')[-1], 'res':quality, 'url':url if not onlyHttp else url.replace('https://', 'http://')}) + videoUrls.append({'type':url.split('.')[-1], 'res':quality, 'url':url if not onlyHttp else url.replace('https://', 'http://')}) - return video_urls + return videoUrls ########## ITEMLIST DB FOR PAGINATION ########## diff --git a/core/tmdb.py b/core/tmdb.py index 9725af5e..57e611fb 100644 --- a/core/tmdb.py +++ b/core/tmdb.py @@ -22,7 +22,7 @@ from core.item import InfoLabels from platformcode import config, logger, platformtools info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json -def_lang = info_language[config.get_setting("info_language", "videolibrary")] +def_lang = info_language[config.getSetting("info_language", "videolibrary")] host = 'https://api.themoviedb.org/3' api = 'a1ab8b8669da03637a4b98fa39c39228' @@ -82,7 +82,7 @@ def cache_response(fn): def check_expired(saved_date): valided = False - cache_expire = config.get_setting("tmdb_cache_expire", default=0) + cache_expire = config.getSetting("tmdb_cache_expire", default=0) current_date = datetime.datetime.now() elapsed = current_date - saved_date @@ -123,7 +123,7 @@ def cache_response(fn): try: # cache is not active - if not config.get_setting("tmdb_cache", default=False) or not kwargs.get('cache', True): + if not config.getSetting("tmdb_cache", default=False) or not kwargs.get('cache', True): logger.debug('no cache') result = fn(*args) else: @@ -168,7 +168,7 @@ def set_infoLabels(source, seekTmdb=True, search_language=def_lang, forced=False @rtype: int, list """ - if not config.get_setting('tmdb_active') and not forced: + if not config.getSetting('tmdb_active') and not forced: return start_time = time.time() @@ -199,7 +199,7 @@ def set_infoLabels_itemlist(itemlist, seekTmdb=False, search_language=def_lang, @rtype: list """ - if not config.get_setting('tmdb_active') and not forced: + if not config.getSetting('tmdb_active') and not forced: return r_list = list() @@ -406,7 +406,7 @@ def set_infoLabels_item(item, seekTmdb=True, search_language=def_lang): otmdb = Tmdb(searched_text=searched_title, search_type=search_type, search_language=search_language, filtro=item.infoLabels.get('filtro', {}), year=item.infoLabels['year']) if otmdb is not None: - if otmdb.get_id() and config.get_setting("tmdb_plus_info", default=False): + if otmdb.get_id() and config.getSetting("tmdb_plus_info", default=False): # If the search has been successful and you are not looking for a list of items, # carry out another search to expand the information if search_type == 'multi': @@ -457,11 +457,11 @@ def find_and_set_infoLabels(item): if item.contentType == "movie": search_type = "movie" - content_type = config.get_localized_string(60247) + content_type = config.getLocalizedString(60247) title = item.contentTitle else: search_type = "tv" - content_type = config.get_localized_string(60298) + content_type = config.getLocalizedString(60298) title = item.contentSerieName # If the title includes the (year) we will remove it @@ -483,7 +483,7 @@ def find_and_set_infoLabels(item): # select tmdb_id at the first position if item.infoLabels['selected_tmdb_id']: results.insert(0, results.pop([r.get('id') for r in results].index(int(item.infoLabels['selected_tmdb_id'])))) - tmdb_result = platformtools.show_video_info(results, item=item, caption= content_type % title) + tmdb_result = platformtools.showVideoInfo(results, item=item, caption= content_type % title) elif len(results) > 0: tmdb_result = results[0] @@ -519,7 +519,7 @@ def get_nfo(item, search_groups=False): if search_groups: from platformcode.autorenumber import RENUMBER, GROUP - path = filetools.join(config.get_data_path(), "settings_channels", item.channel + "_data.json") + path = filetools.join(config.getDataPath(), "settings_channels", item.channel + "_data.json") if filetools.exists(path): g = jsontools.load(filetools.read(path)).get(RENUMBER,{}).get(item.fulltitle.strip(),{}).get(GROUP,'') if g: @@ -577,7 +577,7 @@ def select_group(groups, item): selections.append([group.get('name',''), group.get('group_count',0), group.get('episode_count',0), group.get('description',''), item.thumbnail]) ids.append(ID) if selections and ids: - selected = platformtools.dialog_select_group(config.get_localized_string(70831), selections) + selected = platformtools.dialogSelectGroup(config.getLocalizedString(70831), selections) if selected > -1: return ids[selected] return '' @@ -1040,7 +1040,7 @@ class Tmdb(object): self.result = ResultDictDefault(self.results[index_results]) # self.result['mediatype'] = self.result['media_type'] - if not config.get_setting('tmdb_plus_info'): + if not config.getSetting('tmdb_plus_info'): self.result = self.get_mpaa(self.result) return len(self.results) @@ -1369,7 +1369,7 @@ class Tmdb(object): if "status_code" in self.season[seasonNumber]: # An error has occurred - msg = config.get_localized_string(70496) + searching + config.get_localized_string(70497) + msg = config.getLocalizedString(70496) + searching + config.getLocalizedString(70497) msg += "\nTmdb error: %s %s" % ( self.season[seasonNumber]["status_code"], self.season[seasonNumber]["status_message"]) logger.debug(msg) diff --git a/core/trakt_tools.py b/core/trakt_tools.py index ea79e9c9..8b3006e1 100644 --- a/core/trakt_tools.py +++ b/core/trakt_tools.py @@ -15,12 +15,12 @@ else: from concurrent_py2 import futures host = 'https://api.trakt.tv' client_id = '502bd1660b833c1ae69828163c0848e84e9850061e5529f30930e7356cae73b1' client_secret = '1d30d5b24acf223a5e1ab6c61d08b69992d98ed5b0c7e26b052b5e6a592035a4' -token_auth = config.get_setting("token_trakt", "trakt") +token_auth = config.getSetting("token_trakt", "trakt") def auth_trakt(): item = Item() - folder = (config.get_platform() == 'plex') + folder = (config.getXBMCPlatform() == 'plex') item.folder = folder # Autentificación de cuenta Trakt headers = {'Content-Type': 'application/json', 'trakt-api-key': client_id, 'trakt-api-version': '2'} @@ -39,11 +39,11 @@ def auth_trakt(): else: itemlist = [] - title = config.get_localized_string(60248) % item.verify_url + title = config.getLocalizedString(60248) % item.verify_url itemlist.append(item.clone(title=title, action='')) - title = config.get_localized_string(60249) % item.user_code + title = config.getLocalizedString(60249) % item.user_code itemlist.append(item.clone(title=title, action='')) - title = config.get_localized_string(60250) + title = config.getLocalizedString(60250) itemlist.append(item.clone(title=title, action='token_trakt')) return itemlist except: @@ -57,7 +57,7 @@ def token_trakt(item): headers = {'Content-Type': 'application/json', 'trakt-api-key': client_id, 'trakt-api-version': '2'} try: if item.extra == 'renew': - refresh = config.get_setting('refresh_token_trakt', 'trakt') + refresh = config.getSetting('refresh_token_trakt', 'trakt') url = host + '/oauth/device/token' post = {'refresh_token': refresh, 'client_id': client_id, 'client_secret': client_secret, 'redirect_uri': 'urn:ietf:wg:oauth:2.0:oob', 'grant_type': 'refresh_token'} @@ -71,17 +71,17 @@ def token_trakt(item): data = jsontools.load(data) else: import time - dialog_auth = platformtools.dialog_progress(config.get_localized_string(60251), - config.get_localized_string(60252) % item.verify_url + '\n' + - config.get_localized_string(60253) % item.user_code + '\n' + - config.get_localized_string(60254)) + dialog_auth = platformtools.dialogProgress(config.getLocalizedString(60251), + config.getLocalizedString(60252) % item.verify_url + '\n' + + config.getLocalizedString(60253) % item.user_code + '\n' + + config.getLocalizedString(60254)) # Generalmente cada 5 segundos se intenta comprobar si el usuario ha introducido el código while True: time.sleep(item.intervalo) try: if dialog_auth.iscanceled(): - config.set_setting('trakt_sync', False) + config.setSetting('trakt_sync', False) return url = host + '/oauth/device/token' @@ -103,10 +103,10 @@ def token_trakt(item): token = data['access_token'] refresh = data['refresh_token'] - config.set_setting('token_trakt', token, 'trakt') - config.set_setting('refresh_token_trakt', refresh, 'trakt') + config.setSetting('token_trakt', token, 'trakt') + config.setSetting('refresh_token_trakt', refresh, 'trakt') if not item.folder: - platformtools.dialog_notification(config.get_localized_string(60255), config.get_localized_string(60256)) + platformtools.dialogNotification(config.getLocalizedString(60255), config.getLocalizedString(60256)) if config.is_xbmc(): import xbmc xbmc.executebuiltin('Container.Refresh') @@ -116,14 +116,14 @@ def token_trakt(item): import traceback logger.error(traceback.format_exc()) if not item.folder: - return platformtools.dialog_notification(config.get_localized_string(60527), config.get_localized_string(60258)) + return platformtools.dialogNotification(config.getLocalizedString(60527), config.getLocalizedString(60258)) token = '' itemlist = [] if token: - itemlist.append(item.clone(title=config.get_localized_string(60256), action='')) + itemlist.append(item.clone(title=config.getLocalizedString(60256), action='')) else: - itemlist.append(item.clone(title=config.get_localized_string(60260), action='')) + itemlist.append(item.clone(title=config.getLocalizedString(60260), action='')) return itemlist @@ -146,23 +146,23 @@ def get_trakt_watched(id_type, mediatype, update=False): id_list = [] id_dict = dict() - token_auth = config.get_setting('token_trakt', 'trakt') + token_auth = config.getSetting('token_trakt', 'trakt') if token_auth: - sync_path = os.path.join(config.get_data_path(), 'settings_channels', 'trakt') + sync_path = os.path.join(config.getDataPath(), 'settings_channels', 'trakt') if os.path.exists(sync_path) and not update: - trakt_node = jsontools.get_node_from_file('trakt', 'TRAKT') + trakt_node = jsontools.getNodeFromFile('trakt', 'TRAKT') if mediatype == 'shows': return trakt_node['shows'] if mediatype == 'movies': return trakt_node['movies'] else: - token_auth = config.get_setting('token_trakt', 'trakt') + token_auth = config.getSetting('token_trakt', 'trakt') if token_auth: try: - token_auth = config.get_setting('token_trakt', 'trakt') + token_auth = config.getSetting('token_trakt', 'trakt') headers = [['Content-Type', 'application/json'], ['trakt-api-key', client_id], ['trakt-api-version', '2']] if token_auth: @@ -232,24 +232,24 @@ def trakt_check(itemlist): def get_sync_from_file(): logger.debug() - sync_path = os.path.join(config.get_data_path(), 'settings_channels', 'trakt_data.json') + sync_path = os.path.join(config.getDataPath(), 'settings_channels', 'trakt_data.json') trakt_node = {} if os.path.exists(sync_path): - trakt_node = jsontools.get_node_from_file('trakt', 'TRAKT') + trakt_node = jsontools.getNodeFromFile('trakt', 'TRAKT') trakt_node['movies'] = get_trakt_watched('tmdb', 'movies') trakt_node['shows'] = get_trakt_watched('tmdb', 'shows') - jsontools.update_node(trakt_node, 'trakt', 'TRAKT') + jsontools.updateNode(trakt_node, 'trakt', 'TRAKT') def update_trakt_data(mediatype, trakt_data): logger.debug() - sync_path = os.path.join(config.get_data_path(), 'settings_channels', 'trakt_data.json') + sync_path = os.path.join(config.getDataPath(), 'settings_channels', 'trakt_data.json') if os.path.exists(sync_path): - trakt_node = jsontools.get_node_from_file('trakt', 'TRAKT') + trakt_node = jsontools.getNodeFromFile('trakt', 'TRAKT') trakt_node[mediatype] = trakt_data - jsontools.update_node(trakt_node, 'trakt', 'TRAKT') + jsontools.updateNode(trakt_node, 'trakt', 'TRAKT') def ask_install_script(): @@ -257,12 +257,12 @@ def ask_install_script(): from platformcode import platformtools - respuesta = platformtools.dialog_yesno(config.get_localized_string(20000), config.get_localized_string(70521)) + respuesta = platformtools.dialogYesNo(config.getLocalizedString(20000), config.getLocalizedString(70521)) if respuesta: xbmc.executebuiltin('InstallAddon(script.trakt)') return else: - config.set_setting('install_trakt', False) + config.setSetting('install_trakt', False) return @@ -288,7 +288,7 @@ def update_all(): def context(item): Type = item.contentType.replace("tv", "") + "s" item.action = 'traktResults' - title = config.get_localized_string(30122 if item.contentType == 'movie' else 30123) + title = config.getLocalizedString(30122 if item.contentType == 'movie' else 30123) context = [] commands = [] condition = "'tmdb': " + item.infoLabels["tmdb_id"] @@ -296,10 +296,10 @@ def context(item): result = execute(item.clone(url="/sync/watched/" + Type)) post = {Type: [{"ids": {"tmdb": item.infoLabels["tmdb_id"]}}]} if condition in str(result): - context.append(config.get_localized_string(60016 if item.contentType == 'movie' else 60020)) + context.append(config.getLocalizedString(60016 if item.contentType == 'movie' else 60020)) commands.append(item.clone(url="/sync/history/remove", post=post)) else: - context.append(config.get_localized_string(60017 if item.contentType == 'movie' else 60021)) + context.append(config.getLocalizedString(60017 if item.contentType == 'movie' else 60021)) commands.append(item.clone(url="/sync/history", post=post)) except: pass @@ -308,10 +308,10 @@ def context(item): result = execute(item.clone(url="/sync/watchlist/" + Type)) post = {Type: [{"ids": {"tmdb": item.infoLabels["tmdb_id"]}}]} if condition in str(result): - context.append(config.get_localized_string(70343) % title) + context.append(config.getLocalizedString(70343) % title) commands.append(item.clone(url="/sync/watchlist/remove", post=post)) else: - context.append(config.get_localized_string(70344) % title) + context.append(config.getLocalizedString(70344) % title) commands.append(item.clone(url="/sync/watchlist", post=post)) except: pass @@ -320,10 +320,10 @@ def context(item): result = execute(item.clone(url="/sync/collection/" + Type)) post = {Type: [{"ids": {"tmdb": item.infoLabels["tmdb_id"]}}]} if condition in str(result): - context.append(config.get_localized_string(70345) % title) + context.append(config.getLocalizedString(70345) % title) commands.append(item.clone(url="/sync/collection/remove", post=post)) else: - context.append(config.get_localized_string(70346) % title) + context.append(config.getLocalizedString(70346) % title) commands.append(item.clone(url="/sync/collection", post=post)) except: pass @@ -335,7 +335,7 @@ def context(item): execute(commands[index]) def execute(item): - from platformcode.platformtools import dialog_notification + from platformcode.platformtools import dialogNotification url = host + item.url headers = [['Content-Type', 'application/json'], ['trakt-api-key', client_id], ['trakt-api-version', '2']] @@ -349,5 +349,5 @@ def execute(item): if not post: return data else: - if 'not_found' in data: return dialog_notification('Trakt', config.get_localized_string(70347)) - else: return dialog_notification('Trakt', config.get_localized_string(70348)) \ No newline at end of file + if 'not_found' in data: return dialogNotification('Trakt', config.getLocalizedString(70347)) + else: return dialogNotification('Trakt', config.getLocalizedString(70348)) \ No newline at end of file diff --git a/core/tvdb.py b/core/tvdb.py index 2fefce3c..7a82235c 100644 --- a/core/tvdb.py +++ b/core/tvdb.py @@ -27,9 +27,9 @@ from platformcode import platformtools HOST = "https://api.thetvdb.com" HOST_IMAGE = "http://thetvdb.com/banners/" -TOKEN = config.get_setting("tvdb_token", default="") +TOKEN = config.getSetting("tvdb_token", default="") info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json -DEFAULT_LANG = info_language[config.get_setting("info_language", "videolibrary")] +DEFAULT_LANG = info_language[config.getSetting("info_language", "videolibrary")] DEFAULT_HEADERS = { 'Content-Type': 'application/json', 'Accept': 'application/json, application/vnd.thetvdb.v2.1.1', @@ -82,7 +82,7 @@ def find_and_set_infoLabels(item): p_dialog = None if not item.contentSeason: - p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(60296), config.get_localized_string(60293)) + p_dialog = platformtools.dialogProgressBg(config.getLocalizedString(60296), config.getLocalizedString(60293)) global otvdb_global tvdb_result = None @@ -106,24 +106,24 @@ def find_and_set_infoLabels(item): otvdb_global = Tvdb(tvdb_id=item.infoLabels['tvdb_id']) if not item.contentSeason: - p_dialog.update(50, config.get_localized_string(60296) + '\n' + config.get_localized_string(60295)) + p_dialog.update(50, config.getLocalizedString(60296) + '\n' + config.getLocalizedString(60295)) results, info_load = otvdb_global.get_list_results() logger.debug("results: %s" % results) if not item.contentSeason: - p_dialog.update(100, config.get_localized_string(60296) + '\n' + config.get_localized_string(60297) % len(results)) + p_dialog.update(100, config.getLocalizedString(60296) + '\n' + config.getLocalizedString(60297) % len(results)) p_dialog.close() if len(results) > 1: - tvdb_result = platformtools.show_video_info(results, item=item, scraper=Tvdb, caption=config.get_localized_string(60298) % title) + tvdb_result = platformtools.showVideoInfo(results, item=item, scraper=Tvdb, caption=config.getLocalizedString(60298) % title) # if not tvdb_result: - # res = platformtools.dialog_info(item, 'tvdb') + # res = platformtools.dialogInfo(item, 'tvdb') # if not res.exit: return find_and_set_infoLabels(res) elif len(results) > 0: tvdb_result = results[0] # else: - # res = platformtools.dialog_info(item, 'tvdb') + # res = platformtools.dialogInfo(item, 'tvdb') # if not res.exit: return find_and_set_infoLabels(res) # todo revisar @@ -355,18 +355,18 @@ class Tvdb(object): if kwargs.get('tvdb_id', ''): # Search by tvdb identifier self.__get_by_id(kwargs.get('tvdb_id', '')) - if not self.list_results and config.get_setting("tvdb_retry_eng", "videolibrary"): + if not self.list_results and config.getSetting("tvdb_retry_eng", "videolibrary"): from platformcode import platformtools - platformtools.dialog_notification(config.get_localized_string(60299) % DEFAULT_LANG, config.get_localized_string(60302), sound=False) + platformtools.dialogNotification(config.getLocalizedString(60299) % DEFAULT_LANG, config.getLocalizedString(60302), sound=False) self.__get_by_id(kwargs.get('tvdb_id', ''), "en") self.lang = "en" elif self.search_name: # BUsqueda by text self.__search(kwargs.get('search', ''), kwargs.get('imdb_id', ''), kwargs.get('zap2it_id', '')) - if not self.list_results and config.get_setting("tvdb_retry_eng", "videolibrary"): + if not self.list_results and config.getSetting("tvdb_retry_eng", "videolibrary"): from platformcode import platformtools - platformtools.dialog_notification(config.get_localized_string(60299) % DEFAULT_LANG, config.get_localized_string(60302)) + platformtools.dialogNotification(config.getLocalizedString(60299) % DEFAULT_LANG, config.getLocalizedString(60302)) self.__search(kwargs.get('search', ''), kwargs.get('imdb_id', ''), kwargs.get('zap2it_id', ''), "en") self.lang = "en" @@ -376,7 +376,7 @@ class Tvdb(object): buscando = kwargs.get('tvdb_id', '') else: buscando = kwargs.get('search', '') - msg = config.get_localized_string(70266) % buscando + msg = config.getLocalizedString(70266) % buscando logger.debug(msg) @classmethod @@ -389,10 +389,10 @@ class Tvdb(object): from time import gmtime, strftime current_date = strftime("%Y-%m-%d", gmtime()) - if config.get_setting("tvdb_token_date", "") != current_date: + if config.getSetting("tvdb_token_date", "") != current_date: # if the token has been renewed we save the new date if cls.__refresh_token(): - config.set_setting("tvdb_token_date", current_date) + config.setSetting("tvdb_token_date", current_date) @staticmethod def __login(): @@ -418,7 +418,7 @@ class Tvdb(object): token = dict_html["token"] DEFAULT_HEADERS["Authorization"] = "Bearer " + token - TOKEN = config.set_setting("tvdb_token", token) + TOKEN = config.setSetting("tvdb_token", token) @classmethod def __refresh_token(cls): @@ -449,7 +449,7 @@ class Tvdb(object): if "token" in dict_html: token = dict_html["token"] DEFAULT_HEADERS["Authorization"] = "Bearer " + token - TOKEN = config.set_setting("tvdb_token", token) + TOKEN = config.setSetting("tvdb_token", token) is_success = True else: cls.__login() diff --git a/core/videolibrarytools.py b/core/videolibrarytools.py index 8d795311..d3e773f8 100644 --- a/core/videolibrarytools.py +++ b/core/videolibrarytools.py @@ -19,14 +19,14 @@ from platformcode import config, dbconverter, logger, platformtools from platformcode.autorenumber import RENUMBER from core import videolibrarydb -FOLDER_MOVIES = config.get_setting("folder_movies") -FOLDER_TVSHOWS = config.get_setting("folder_tvshows") -VIDEOLIBRARY_PATH = config.get_videolibrary_path() +FOLDER_MOVIES = config.getSetting("folder_movies") +FOLDER_TVSHOWS = config.getSetting("folder_tvshows") +VIDEOLIBRARY_PATH = config.getVideolibraryPath() MOVIES_PATH = filetools.join(VIDEOLIBRARY_PATH, FOLDER_MOVIES) TVSHOWS_PATH = filetools.join(VIDEOLIBRARY_PATH, FOLDER_TVSHOWS) if not FOLDER_MOVIES or not FOLDER_TVSHOWS or not VIDEOLIBRARY_PATH or not filetools.exists(MOVIES_PATH) or not filetools.exists(TVSHOWS_PATH): - config.verify_directories_created() + config.verifyDirectoriesCreated() addon_name = "plugin://plugin.video.%s/" % config.PLUGIN_NAME @@ -92,7 +92,7 @@ def save_movie(item, silent=False): return 0, 0, -1, path # progress dialog - if not silent: p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(60062)) + if not silent: p_dialog = platformtools.dialogProgressBg(config.getLocalizedString(20000), config.getLocalizedString(60062)) base_name = set_base_name(item, _id) path = filetools.join(MOVIES_PATH, base_name) @@ -121,7 +121,7 @@ def save_movie(item, silent=False): # get extra info from fanart tv # logger.dbg() - extra_info = get_fanart_tv(item) + extra_info = getFanart_tv(item) if not item.infoLabels.get('posters', []): item.infoLabels['posters'] = [] item.infoLabels['posters'] += extra_info['poster'] if not item.infoLabels.get('fanarts', []): item.infoLabels['fanarts'] = [] @@ -204,7 +204,7 @@ def save_movie(item, silent=False): if not item.contentLanguage in movie_item.lang_list: movie_item.lang_list.append(item.contentLanguage) if len(movie_item.lang_list) > 1: - movie_item.prefered_lang = movie_item.lang_list[platformtools.dialog_select(config.get_localized_string(70246), movie_item.lang_list)] + movie_item.prefered_lang = movie_item.lang_list[platformtools.dialogSelect(config.getLocalizedString(70246), movie_item.lang_list)] else: movie_item.prefered_lang = movie_item.lang_list[0] @@ -216,7 +216,7 @@ def save_movie(item, silent=False): # create strm file if it does not exist if not strm_exists and not local_files: logger.debug("Creating .strm: " + strm_path) - item_strm = Item(channel='videolibrary', action='play_from_library', strm_path=movie_item.strm_path, contentType='movie', contentTitle=item.contentTitle, videolibrary_id=movie_item.videolibrary_id) + item_strm = Item(channel='videolibrary', action='playFromLibrary', strm_path=movie_item.strm_path, contentType='movie', contentTitle=item.contentTitle, videolibrary_id=movie_item.videolibrary_id) strm_exists = filetools.write(filetools.join(MOVIES_PATH, movie_item.strm_path), '{}?{}'.format(addon_name, item_strm.tourl())) # checks if the content already exists @@ -260,11 +260,11 @@ def save_movie(item, silent=False): if not silent: p_dialog.update(100, item.contentTitle) p_dialog.close() - if config.is_xbmc() and config.get_setting("videolibrary_kodi") and not item.not_add: + if config.is_xbmc() and config.getSetting("videolibrary_kodi") and not item.not_add: # Update Kodi Library from platformcode.dbconverter import add_video add_video(movie_item) - # if config.is_xbmc() and config.get_setting("videolibrary_kodi") and not silent and inserted: + # if config.is_xbmc() and config.getSetting("videolibrary_kodi") and not silent and inserted: # from platformcode.xbmc_videolibrary import update # update(MOVIES_PATH) return inserted, overwritten, failed, path @@ -357,7 +357,7 @@ def save_tvshow(item, episodelist, silent=False): head_nfo = scraper.get_nfo(item) if not head_nfo: return 0, 0, -1, '' - extra_info = get_fanart_tv(item) + extra_info = getFanart_tv(item) if not item.infoLabels.get('posters'):item.infoLabels['posters'] = [] item.infoLabels['posters'] += extra_info['poster'].get('all',[]) if not item.infoLabels.get('fanarts'): item.infoLabels['fanarts'] = [] @@ -425,7 +425,7 @@ def save_tvshow(item, episodelist, silent=False): logger.debug() inserted, overwritten, failed = save_episodes(tvshow_item, episodelist, extra_info, item.host, local_files, silent=silent) videolibrarydb.close() - if config.is_xbmc() and config.get_setting("videolibrary_kodi") and not item.not_add: + if config.is_xbmc() and config.getSetting("videolibrary_kodi") and not item.not_add: from platformcode.dbconverter import add_video add_video(tvshow_item) @@ -528,11 +528,11 @@ def save_episodes(item, episodelist, extra_info, host, local_files, silent=False # if not filetools.exists(filetools.join(TVSHOWS_PATH, strm_path)): if season_episode not in local_files.get('db',{}).keys(): logger.debug("Creating .strm: " + episode_item.strm_path) - item_strm = Item(channel='videolibrary', action='play_from_library', strm_path=episode_item.strm_path, contentType='episode', videolibrary_id=episode_item.videolibrary_id, contentSeason = episode_item.contentSeason, contentEpisodeNumber = episode_item.contentEpisodeNumber,) + item_strm = Item(channel='videolibrary', action='playFromLibrary', strm_path=episode_item.strm_path, contentType='episode', videolibrary_id=episode_item.videolibrary_id, contentSeason = episode_item.contentSeason, contentEpisodeNumber = episode_item.contentEpisodeNumber,) filetools.write(filetools.join(TVSHOWS_PATH, episode_item.strm_path), '{}?{}'.format(addon_name, item_strm.tourl())) # update db if episode added - # if failed == 0 and config.get_setting('kod_scraper'): + # if failed == 0 and config.getSetting('kod_scraper'): # add_video(episode_item) return item, episode, season_episode, e.contentLanguage, inserted, overwritten, failed @@ -585,7 +585,7 @@ def save_episodes(item, episodelist, extra_info, host, local_files, silent=False # Silent is to show no progress (for service) if not silent: # progress dialog - p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(60064) ,'') + p_dialog = platformtools.dialogProgressBg(config.getLocalizedString(60064) ,'') inserted = 0 overwritten = 0 @@ -650,14 +650,14 @@ def save_episodes(item, episodelist, extra_info, host, local_files, silent=False seasons[s] = season_item # Add to Kodi DB if Kod is set to add information - # if config.get_setting('kod_scraper'): + # if config.getSetting('kod_scraper'): # add_video(season_item) if not silent: # update tvshow info if forced if len(item.lang_list) > 1: - item.prefered_lang = item.lang_list[platformtools.dialog_select(config.get_localized_string(70246), item.lang_list)] + item.prefered_lang = item.lang_list[platformtools.dialogSelect(config.getLocalizedString(70246), item.lang_list)] else: item.prefered_lang = item.lang_list[0] @@ -684,7 +684,7 @@ def save_episodes(item, episodelist, extra_info, host, local_files, silent=False # return add_movie(item) # else: # videolibrarydb.close() -# platformtools.dialog_ok(config.get_localized_string(30131), config.get_localized_string(70838) % item.contentTitle) +# platformtools.dialogOk(config.getLocalizedString(30131), config.getLocalizedString(70838) % item.contentTitle) def add_to_videolibrary(item, channel): @@ -733,10 +733,10 @@ def add_movie(item): inserted, overwritten, failed, path = save_movie(new_item) if failed == 0: - platformtools.dialog_notification(config.get_localized_string(30131), config.get_localized_string(30135) % new_item.contentTitle) # 'has been added to the video library' + platformtools.dialogNotification(config.getLocalizedString(30131), config.getLocalizedString(30135) % new_item.contentTitle) # 'has been added to the video library' else: filetools.rmdirtree(path) - platformtools.dialog_ok(config.get_localized_string(30131), config.get_localized_string(60066) % new_item.contentTitle) # "ERROR, the movie has NOT been added to the video library") + platformtools.dialogOk(config.getLocalizedString(30131), config.getLocalizedString(60066) % new_item.contentTitle) # "ERROR, the movie has NOT been added to the video library") movies = videolibrarydb['movie'] _id = get_id(item) if _id in list(movies.keys()): @@ -782,7 +782,7 @@ def add_tvshow(item, channel=None, itemlist=[]): item.__dict__["channel"] = item.__dict__.pop("from_channel") if not channel: - channel = platformtools.channel_import(item.channel) + channel = platformtools.channelImport(item.channel) # To disambiguate titles, TMDB is caused to ask for the really desired title # The user can select the title among those offered on the first screen @@ -825,29 +825,29 @@ def add_tvshow(item, channel=None, itemlist=[]): elif not inserted and not overwritten and not failed: filetools.rmdirtree(path) - platformtools.dialog_ok(config.get_localized_string(30131), config.get_localized_string(60067) % item.contentTitle) + platformtools.dialogOk(config.getLocalizedString(30131), config.getLocalizedString(60067) % item.contentTitle) logger.error("The string %s could not be added to the video library. Could not get any episode" % item.contentTitle) elif failed == -1: filetools.rmdirtree(path) - platformtools.dialog_ok(config.get_localized_string(30131), config.get_localized_string(60068) % item.contentTitle) + platformtools.dialogOk(config.getLocalizedString(30131), config.getLocalizedString(60068) % item.contentTitle) logger.error("The string %s could not be added to the video library" % item.contentTitle) elif failed == -2: filetools.rmdirtree(path) elif failed > 0: - platformtools.dialog_ok(config.get_localized_string(30131), config.get_localized_string(60069) % item.contentTitle) + platformtools.dialogOk(config.getLocalizedString(30131), config.getLocalizedString(60069) % item.contentTitle) logger.error("Could not add %s episodes of series %s to the video library" % (failed, item.contentTitle)) else: - platformtools.dialog_notification(config.get_localized_string(30131), config.get_localized_string(60070) % item.contentTitle) + platformtools.dialogNotification(config.getLocalizedString(30131), config.getLocalizedString(60070) % item.contentTitle) logger.debug("%s episodes of series %s have been added to the video library" % (inserted, item.contentTitle)) if config.is_xbmc(): - if config.get_setting("sync_trakt_new_tvshow", "videolibrary"): + if config.getSetting("sync_trakt_new_tvshow", "videolibrary"): import xbmc from platformcode import xbmc_videolibrary - if config.get_setting("sync_trakt_new_tvshow_wait", "videolibrary"): + if config.getSetting("sync_trakt_new_tvshow_wait", "videolibrary"): # Check that you are not looking for content in the Kodi video library while xbmc.getCondVisibility('Library.IsScanningVideo()'): xbmc.sleep(1000) @@ -868,7 +868,7 @@ def get_id(item): return item.infoLabels.get('tmdb_id') -def get_fanart_tv(item, set='', ret={}): +def getFanart_tv(item, set='', ret={}): def set_dict(l): d = {} for k in l: @@ -906,7 +906,7 @@ def get_fanart_tv(item, set='', ret={}): ret[set + 'disc'] = [k.get('url') for k in res.get('moviedisc', [])] if item.infoLabels.get('setid'): it = item.clone(infoLabels = {'tmdb_id':item.infoLabels['setid']}) - get_fanart_tv(it, 'set', ret) + getFanart_tv(it, 'set', ret) return ret @@ -958,9 +958,9 @@ def get_local_files(path, item): def select_local_path(item): - if not item.local_episodes_path and config.get_setting('local_episodes'): - if platformtools.dialog_yesno(config.get_localized_string(30131), config.get_localized_string(80044) % item.title): - local_episodes_path = platformtools.dialog_browse(0, config.get_localized_string(80046)) + if not item.local_episodes_path and config.getSetting('local_episodes'): + if platformtools.dialogYesNo(config.getLocalizedString(30131), config.getLocalizedString(80044) % item.title): + local_episodes_path = platformtools.dialogBrowse(0, config.getLocalizedString(80046)) if local_episodes_path: item.local_episodes_path = local_episodes_path return item @@ -969,7 +969,7 @@ def select_local_path(item): def update_renumber_options(item): from core import jsontools - filename = filetools.join(config.get_data_path(), "settings_channels", item.channel + '_data.json') + filename = filetools.join(config.getDataPath(), "settings_channels", item.channel + '_data.json') if filetools.isfile(filename): json_file = jsontools.load(filetools.read(filename)) json = json_file.get(RENUMBER,{}).get(item.fulltitle,{}) @@ -982,7 +982,7 @@ def update_renumber_options(item): def add_renumber_options(item): from core import jsontools ret = None - filename = filetools.join(config.get_data_path(), "settings_channels", item.channel + '_data.json') + filename = filetools.join(config.getDataPath(), "settings_channels", item.channel + '_data.json') json_file = jsontools.load(filetools.read(filename)) if item.renumber and not json_file.get(RENUMBER,{}).get(item.fulltitle): check_renumber_options(item) @@ -1046,12 +1046,12 @@ def set_base_name(item, _id): # set base_name for videolibrary logger.debug() if item.contentType == 'movie': - if config.get_setting("original_title_folder", "videolibrary") and item.infoLabels['originaltitle']: + if config.getSetting("original_title_folder", "videolibrary") and item.infoLabels['originaltitle']: base_name = item.infoLabels['originaltitle'] else: base_name = item.contentTitle else: - if config.get_setting("original_title_folder", "videolibrary") and item.infoLabels['originaltitle']: + if config.getSetting("original_title_folder", "videolibrary") and item.infoLabels['originaltitle']: base_name = item.infoLabels['originaltitle'] elif item.infoLabels['tvshowtitle']: base_name = item.infoLabels['tvshowtitle'] @@ -1065,7 +1065,7 @@ def set_base_name(item, _id): else: base_name = filetools.validate_path(base_name.replace('/', '-')) - if config.get_setting("lowerize_title", "videolibrary"): + if config.getSetting("lowerize_title", "videolibrary"): base_name = base_name.lower() return '{} [{}]'.format(base_name, _id) @@ -1076,7 +1076,7 @@ def restore_videolibrary(): tvshows = [x['item'] for x in dict(videolibrarydb['tvshow']).values()] total = len(movies) + len(tvshows) progress = 0 - dialog = platformtools.dialog_progress(config.get_localized_string(20000), 'Ripristino videoteca in corso') + dialog = platformtools.dialogProgress(config.getLocalizedString(20000), 'Ripristino videoteca in corso') try: os.mkdir(MOVIES_PATH) except: pass try: os.mkdir(TVSHOWS_PATH) @@ -1100,7 +1100,7 @@ def restore_videolibrary(): filetools.write(filetools.join(MOVIES_PATH, item.nfo_path), item.head_nfo) if not "{}.strm".format(base_name) in movie_files and not local: - item_strm = Item(channel='videolibrary', action='play_from_library', strm_path=item.strm_path, contentType='movie', contentTitle=item.contentTitle, videolibrary_id=item.videolibrary_id) + item_strm = Item(channel='videolibrary', action='playFromLibrary', strm_path=item.strm_path, contentType='movie', contentTitle=item.contentTitle, videolibrary_id=item.videolibrary_id) filetools.write(filetools.join(MOVIES_PATH, item.strm_path), '{}?{}'.format(addon_name, item_strm.tourl())) progress += 1 @@ -1131,7 +1131,7 @@ def restore_videolibrary(): local = True if 'local' in videolibrarydb['episode'][item.videolibrary_id][season_episode]['channels'] else False if not '{}.strm'.format(season_episode) in episode_files and not local: logger.debug("Creating .strm: " + strm_path) - item_strm = Item(channel='videolibrary', action='play_from_library', strm_path=strm_path, contentType='episode', videolibrary_id=e.videolibrary_id, contentSeason = e.contentSeason, contentEpisodeNumber = e.contentEpisodeNumber,) + item_strm = Item(channel='videolibrary', action='playFromLibrary', strm_path=strm_path, contentType='episode', videolibrary_id=e.videolibrary_id, contentSeason = e.contentSeason, contentEpisodeNumber = e.contentEpisodeNumber,) filetools.write(filetools.join(TVSHOWS_PATH, strm_path), '{}?{}'.format(addon_name, item_strm.tourl())) progress += 1 dialog.update(int(progress / total * 100), item.title) @@ -1144,15 +1144,15 @@ def convert_videolibrary(): from platformcode import xbmc_videolibrary from core import jsontools - dialog = platformtools.dialog_progress(config.get_localized_string(20000), 'Conversione videoteca in corso') + dialog = platformtools.dialogProgress(config.getLocalizedString(20000), 'Conversione videoteca in corso') path_to_delete = [] film_lst = glob.glob(filetools.join(MOVIES_PATH, '*/*.json')) tvshow_lst = glob.glob((filetools.join(TVSHOWS_PATH, '*/tvshow.nfo'))) total = len(film_lst) + len(tvshow_lst) progress = 0 - tvPath = filetools.join(config.get_setting('videolibrarypath'), config.get_setting('folder_tvshows')) - moviePath = filetools.join(config.get_setting('videolibrarypath'), config.get_setting('folder_movies')) + tvPath = filetools.join(config.getSetting('videolibrarypath'), config.getSetting('folder_tvshows')) + moviePath = filetools.join(config.getSetting('videolibrarypath'), config.getSetting('folder_movies')) # set local info only xbmc_videolibrary.execute_sql_kodi('update path set strScraper="metadata.local", strSettings="" where strPath = "{}{}"'.format(tvPath, '/' if '/' in tvPath else '\\')) @@ -1170,12 +1170,12 @@ def convert_videolibrary(): for tvshow in tvshow_lst: if not dialog: - dialog = platformtools.dialog_progress(config.get_localized_string(20000), 'Conversione videoteca in corso') + dialog = platformtools.dialogProgress(config.getLocalizedString(20000), 'Conversione videoteca in corso') js = jsontools.load('\n'.join(filetools.read(tvshow).splitlines()[1:])) channels_dict = js.get('library_urls') if channels_dict: for ch, url in channels_dict.items(): - dir = filetools.listdir(xbmc.translatePath(filetools.join(config.get_setting('videolibrarypath'), config.get_setting('folder_tvshows'), js['path']))) + dir = filetools.listdir(xbmc.translatePath(filetools.join(config.getSetting('videolibrarypath'), config.getSetting('folder_tvshows'), js['path']))) json_files = [f for f in dir if f.endswith('.json')] if json_files: path_to_delete.append(filetools.dirname(tvshow)) @@ -1186,7 +1186,7 @@ def convert_videolibrary(): it.url = channels_dict[ch] remove_host(it) tmdb.find_and_set_infoLabels(it) - channel = platformtools.channel_import(ch) + channel = platformtools.channelImport(ch) it.host = channel.host it.url = channel.host + it.url episodes = getattr(channel, 'episodes')(it) diff --git a/core/ziptools.py b/core/ziptools.py index f7f73db6..34481b39 100644 --- a/core/ziptools.py +++ b/core/ziptools.py @@ -53,13 +53,13 @@ class ziptools(object): try: if filetools.exists(outfilename) and overwrite_question: from platformcode import platformtools - dyesno = platformtools.dialog_yesno("File already exists "," File %s to unzip already exists, do you want to overwrite it?" % filetools.basename(outfilename)) + dyesno = platformtools.dialogYesNo("File already exists "," File %s to unzip already exists, do you want to overwrite it?" % filetools.basename(outfilename)) if not dyesno: break if backup: import time hora_folder = "Backup [%s]" % time.strftime("%d-%m_%H-%M", time.localtime()) - backup = filetools.join(config.get_data_path(), 'backups', hora_folder, folder_to_extract) + backup = filetools.join(config.getDataPath(), 'backups', hora_folder, folder_to_extract) if not filetools.exists(backup): filetools.mkdir(backup) filetools.copy(outfilename, filetools.join(backup, filetools.basename(outfilename))) diff --git a/default.py b/default.py index eb72aed5..f95a54ab 100644 --- a/default.py +++ b/default.py @@ -20,7 +20,7 @@ from platformcode import config, logger logger.info("init...") -librerias = xbmc.translatePath(os.path.join(config.get_runtime_path(), 'lib')) +librerias = xbmc.translatePath(os.path.join(config.getRuntimePath(), 'lib')) sys.path.insert(0, librerias) from platformcode import launcher diff --git a/lib/aadecode.py b/lib/aadecode.py index bb647fb2..aaf69f17 100644 --- a/lib/aadecode.py +++ b/lib/aadecode.py @@ -46,10 +46,10 @@ def toStringCases(txt_result): if "+(" in txt_result: m3 = True sum_base = "+" + find_single_match(txt_result, ".toString...(\d+).") - txt_pre_temp = find_multiple_matches(txt_result, "..(\d),(\d+).") + txt_pre_temp = findMultipleMatches(txt_result, "..(\d),(\d+).") txt_temp = [(n, b) for b, n in txt_pre_temp] else: - txt_temp = find_multiple_matches(txt_result, '(\d+)\.0.\w+.([^\)]+).') + txt_temp = findMultipleMatches(txt_result, '(\d+)\.0.\w+.([^\)]+).') for numero, base in txt_temp: code = toString(int(numero), eval(base + sum_base)) if m3: diff --git a/lib/arm_chromeos.py b/lib/arm_chromeos.py index b33d1dfd..4120a469 100644 --- a/lib/arm_chromeos.py +++ b/lib/arm_chromeos.py @@ -80,7 +80,7 @@ class ChromeOSImage: """Extracts the file from the image""" self.progress = progress - self.progress.update(2, config.get_localized_string(70813)) + self.progress.update(2, config.getLocalizedString(70813)) self.part_offset = self.chromeos_offset() self.sb_dict = self.superblock() self.blk_groups = self.block_groups() @@ -88,7 +88,7 @@ class ChromeOSImage: bin_filename = filename.encode('ascii') chunksize = 4 * 1024**2 percent8 = 40 - self.progress.update(int(percent8 / 8), config.get_localized_string(70814)) + self.progress.update(int(percent8 / 8), config.getLocalizedString(70814)) chunk1 = self.read_stream(chunksize) while True: chunk2 = self.read_stream(chunksize) @@ -107,7 +107,7 @@ class ChromeOSImage: percent8 += 1 self.progress.update(int(percent8 / 8)) - self.progress.update(32, config.get_localized_string(70815)) + self.progress.update(32, config.getLocalizedString(70815)) blk_group_num = (dir_dict['inode'] - 1) // self.sb_dict['s_inodes_per_group'] blk_group = self.blk_groups[blk_group_num] @@ -199,7 +199,7 @@ class ChromeOSImage: @staticmethod def dir_entry(chunk): """Returns the directory entry found in chunk""" - dir_names = ('inode', 'rec_len', 'name_len', 'file_type', 'name') + dir_names = ('inode', 'rec_len', 'name_len', 'fileType', 'name') dir_fmt = '<IHBB' + str(len(chunk) - 8) + 's' dir_dict = dict(zip(dir_names, unpack(dir_fmt, chunk))) @@ -284,7 +284,7 @@ class ChromeOSImage: block_dict = {} for block_id in block_ids: percent = int(35 + 60 * block_ids.index(block_id) / len(block_ids)) - self.progress.update(percent, config.get_localized_string(70816)) + self.progress.update(percent, config.getLocalizedString(70816)) seek_pos = self.part_offset + self.blocksize * block_id self.seek_stream(seek_pos) block_dict[block_id] = self.read_stream(self.blocksize) diff --git a/lib/fakeMail.py b/lib/fakeMail.py index bd033e8b..bd3615df 100644 --- a/lib/fakeMail.py +++ b/lib/fakeMail.py @@ -28,7 +28,7 @@ class Mailbox: def waitForMail(self, timeout=50): info = 'verifica tramite mail richiesta dal sito, sono in attesa di nuove mail sulla casella ' + self.address # info += '\nTimeout tra ' + str(timeout) + ' secondi' - dialog = platformtools.dialog_progress(config.get_localized_string(20000), info) + dialog = platformtools.dialogProgress(config.getLocalizedString(20000), info) secs = 0 while secs < timeout: msg = self.readLast() @@ -113,7 +113,7 @@ class Gmailnator(Mailbox): if e.success and e.data: return e.data else: - platformtools.dialog_ok(config.get_localized_string(20000), 'Impossibile ottenere una mail temporanea') + platformtools.dialogOk(config.getLocalizedString(20000), 'Impossibile ottenere una mail temporanea') def inbox(self): #[{"content":"\n\t\t\t\t<a href=\"https:\/\/gmailnator.com\/jonathanmichaeltmp\/messageid\/#174f933a17b5f625\">\n\t\t\t\t\t<table class=\"message_container\">\n\t\t\t\t\t\t<tbody>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>dsds<\/td>\n\t\t\t\t\t\t\t\t<td>body<\/td>\n\t\t\t\t\t\t\t\t<td class=\"text-right\">one minute ago<\/td>\n\t\t\t\t\t\t\t<\/tr>\n\t\t\t\t\t\t<\/tbody>\n\t\t\t\t\t<\/table>\n\t\t\t\t<\/a>"}] diff --git a/lib/generictools.py b/lib/generictools.py index 0abc56b6..4c863e78 100644 --- a/lib/generictools.py +++ b/lib/generictools.py @@ -153,7 +153,7 @@ def update_title(item): item.channel = new_item.channel # Restoring the name of the channel, in case we had changed it if item.tmdb_stat == True: if new_item.contentSerieName: # If it's serial ... - filter_languages = config.get_setting("filter_languages", item.channel) + filter_languages = config.getSetting("filter_languages", item.channel) if filter_languages and filter_languages >= 0: item.title_from_channel = new_item.contentSerieName # I keep the initial title for Filtertools item.contentSerieName = new_item.contentSerieName # I keep the initial title for Filtertools @@ -223,7 +223,7 @@ def refresh_screen(item): import xbmcgui xlistitem = xbmcgui.ListItem(path=item.url) # We create xlistitem for compatibility with Kodi 18 - if config.get_platform(True)['num_version'] >= 16.0: + if config.getXBMCPlatform(True)['num_version'] >= 16.0: xlistitem.setArt({"thumb": item.contentThumbnail}) # We load the thumb else: xlistitem.setThumbnailImage(item.contentThumbnail) @@ -234,7 +234,7 @@ def refresh_screen(item): except: logger.error(traceback.format_exc()) - platformtools.itemlist_update(item) # we refresh the screen with the new Item + platformtools.itemlistUpdate(item) # we refresh the screen with the new Item return xlistitem @@ -328,7 +328,7 @@ def post_tmdb_listado(item, itemlist): except: logger.error(traceback.format_exc()) - __modo_grafico__ = config.get_setting('modo_grafico', item.channel) + __modo_grafico__ = config.getSetting('modo_grafico', item.channel) # If TMDB has not found the video we clean the year if item_local.infoLabels['year'] == "-": @@ -431,7 +431,7 @@ def post_tmdb_listado(item, itemlist): title += title_add # Additional tags are added, if any # Now we make up the titles a bit depending on whether smart titles have been selected or not - if not config.get_setting("unify"): # If Smart Titles NOT selected: + if not config.getSetting("unify"): # If Smart Titles NOT selected: title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, str(item_local.infoLabels['year']), rating, item_local.quality, str(item_local.language)) else: # If Smart Titles YES selected: @@ -512,7 +512,7 @@ def post_tmdb_seasons(item, itemlist): itemlist_temporadas = [] itemlist_fo = [] - if config.get_setting("no_pile_on_seasons", 'videolibrary') == 2: # If you do not want to show seasonally, we are leaving ... + if config.getSetting("no_pile_on_seasons", 'videolibrary') == 2: # If you do not want to show seasonally, we are leaving ... if item.season_colapse: # We remove the indicator from the list by Seasons del item.season_colapse return (item, itemlist) @@ -558,13 +558,13 @@ def post_tmdb_seasons(item, itemlist): if rating and rating == 0.0: rating = '' - if not config.get_setting("unify"): # If Smart Titles NOT selected: + if not config.getSetting("unify"): # If Smart Titles NOT selected: title = '%s [COLOR yellow][%s][/COLOR] [%s] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (title, str(item_season.infoLabels['year']), rating, item_season.quality, str(item_season.language)) else: # We fixed it a bit for Unify title = title.replace('[', '-').replace(']', '-').replace('.', ',').strip() title = title.replace("--", "").replace("[]", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip() - if config.get_setting("show_all_seasons", 'videolibrary'): + if config.getSetting("show_all_seasons", 'videolibrary'): itemlist_temporadas.append(item_season.clone(title=title, from_title_season_colapse=item.title)) # We review all the episodes to detect the different seasons @@ -577,7 +577,7 @@ def post_tmdb_seasons(item, itemlist): itemlist_temporadas.append(item_season.clone(from_title_season_colapse=item.title)) # If there is more than one season it is followed, or it has been forced to list by seasons, if the original Itemlist is not returned - if len(itemlist_temporadas) > 2 or config.get_setting("no_pile_on_seasons", 'videolibrary') == 0: + if len(itemlist_temporadas) > 2 or config.getSetting("no_pile_on_seasons", 'videolibrary') == 0: for item_local in itemlist_temporadas: if "** Todas las Temporadas" in item_local.title: # If it's the title of ALL Seasons, we ignore it continue @@ -604,7 +604,7 @@ def post_tmdb_seasons(item, itemlist): if item_local.infoLabels['temporada_num_episodes']: # No. of Temp Episodes item_local.title += ' [%s epi]' % str(item_local.infoLabels['temporada_num_episodes']) - if not config.get_setting("unify"): # If Smart Titles NOT selected: + if not config.getSetting("unify"): # If Smart Titles NOT selected: item_local.title = '%s [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.title, item_local.quality, str(item_local.language)) else: # We fixed it a bit for Unify item_local.title = item_local.title.replace("[", "-").replace("]", "-").replace(".", ",").replace("GB", "G B").replace("Gb", "G b").replace("gb", "g b").replace("MB", "M B").replace("Mb", "M b").replace("mb", "m b") @@ -667,11 +667,11 @@ def post_tmdb_episodes(item, itemlist): # logger.debug(item) modo_serie_temp = '' - if config.get_setting('seleccionar_serie_temporada', item.channel) >= 0: - modo_serie_temp = config.get_setting('seleccionar_serie_temporada', item.channel) + if config.getSetting('seleccionar_serie_temporada', item.channel) >= 0: + modo_serie_temp = config.getSetting('seleccionar_serie_temporada', item.channel) modo_ultima_temp = '' - if config.get_setting('seleccionar_ult_temporadda_activa', item.channel) is True or config.get_setting('seleccionar_ult_temporadda_activa', item.channel) is False: - modo_ultima_temp = config.get_setting('seleccionar_ult_temporadda_activa', item.channel) + if config.getSetting('seleccionar_ult_temporadda_activa', item.channel) is True or config.getSetting('seleccionar_ult_temporadda_activa', item.channel) is False: + modo_ultima_temp = config.getSetting('seleccionar_ult_temporadda_activa', item.channel) # Initiates variables to control the number of episodes per season num_episodes = 1 @@ -1015,16 +1015,16 @@ def post_tmdb_findvideos(item, itemlist): # logger.debug(item) # Know if we are in a popup window launched from a bullet in the main menu, - # with the function "play_from_library" + # with the function "playFromLibrary" item.unify = False Window_IsMedia = False try: import xbmc if xbmc.getCondVisibility('Window.IsMedia') == 1: Window_IsMedia = True - item.unify = config.get_setting("unify") + item.unify = config.getSetting("unify") except: - item.unify = config.get_setting("unify") + item.unify = config.getSetting("unify") logger.error(traceback.format_exc()) if item.contentSeason_save: # We restore the num. seasonal @@ -1097,7 +1097,7 @@ def post_tmdb_findvideos(item, itemlist): tiempo = 0 if item.infoLabels['duration']: try: - if config.get_platform(True)['num_version'] < 18 or not Window_IsMedia: + if config.getXBMCPlatform(True)['num_version'] < 18 or not Window_IsMedia: tiempo = item.infoLabels['duration'] elif xbmc.getCondVisibility('Window.IsMedia') == 1: item.quality = re.sub(r'\s?\[\d+:\d+\ h]', '', item.quality) @@ -1176,7 +1176,7 @@ def post_tmdb_findvideos(item, itemlist): if item.channel_alt: title_gen = '[COLOR yellow]%s [/COLOR][ALT]: %s' % (item.category.capitalize(), title_gen) - # elif (config.get_setting("quit_channel_name", "videolibrary") == 1 or item.channel == channel_py) and item.contentChannel == "videolibrary": + # elif (config.getSetting("quit_channel_name", "videolibrary") == 1 or item.channel == channel_py) and item.contentChannel == "videolibrary": else: title_gen = '[COLOR white]%s: %s' % (item.category.capitalize(), title_gen) @@ -1230,10 +1230,10 @@ def get_field_from_kodi_DB(item, from_fields='*', files='file'): """ - FOLDER_MOVIES = config.get_setting("folder_movies") - FOLDER_TVSHOWS = config.get_setting("folder_tvshows") - VIDEOLIBRARY_PATH = config.get_videolibrary_config_path() - VIDEOLIBRARY_REAL_PATH = config.get_videolibrary_path() + FOLDER_MOVIES = config.getSetting("folder_movies") + FOLDER_TVSHOWS = config.getSetting("folder_tvshows") + VIDEOLIBRARY_PATH = config.getVideolibraryConfigPath() + VIDEOLIBRARY_REAL_PATH = config.getVideolibraryPath() if item.contentType == 'movie': # I add the folder corresponding to the path of the Video Library path = filetools.join(VIDEOLIBRARY_REAL_PATH, FOLDER_MOVIES) @@ -1324,7 +1324,7 @@ def fail_over_newpct1(item, patron, patron2=None, timeout=None): # logger.debug(item) if timeout == None: - timeout = config.get_setting('clonenewpct1_timeout_downloadpage', channel_py) # Timeout downloadpage + timeout = config.getSetting('clonenewpct1_timeout_downloadpage', channel_py) # Timeout downloadpage if timeout == 0: timeout = None if item.action == "search" or item.action == "listado_busqueda": timeout = timeout * 2 # More time for searches @@ -1563,9 +1563,9 @@ def web_intervenida(item, data, desactivar=True): # We save the changes made in the .json try: if item.channel != channel_py: - disabled = config.set_setting('enabled', False, item.channel) # We deactivate the channel - disabled = config.set_setting('include_in_global_search', False, item.channel) # We get it out of global searches - channel_path = filetools.join(config.get_runtime_path(), "channels", item.channel + ".json") + disabled = config.setSetting('enabled', False, item.channel) # We deactivate the channel + disabled = config.setSetting('include_in_global_search', False, item.channel) # We get it out of global searches + channel_path = filetools.join(config.getRuntimePath(), "channels", item.channel + ".json") with open(channel_path, 'w') as outfile: # We record the updated .json json.dump(json_data, outfile, sort_keys = True, indent = 2, ensure_ascii = False) except: @@ -1590,20 +1590,20 @@ def regenerate_clones(): try: # Find the paths where to leave the control .json file, and the Video Library - json_path = filetools.exists(filetools.join(config.get_runtime_path(), 'verify_cached_torrents.json')) + json_path = filetools.exists(filetools.join(config.getRuntimePath(), 'verify_cached_torrents.json')) if json_path: logger.debug('Previously repaired video library: WE ARE GOING') return False - json_path = filetools.join(config.get_runtime_path(), 'verify_cached_torrents.json') + json_path = filetools.join(config.getRuntimePath(), 'verify_cached_torrents.json') filetools.write(json_path, json.dumps({"CINE_verify": True})) # Prevents another simultaneous process from being launched - json_error_path = filetools.join(config.get_runtime_path(), 'error_cached_torrents.json') - json_error_path_BK = filetools.join(config.get_runtime_path(), 'error_cached_torrents_BK.json') + json_error_path = filetools.join(config.getRuntimePath(), 'error_cached_torrents.json') + json_error_path_BK = filetools.join(config.getRuntimePath(), 'error_cached_torrents_BK.json') - videolibrary_path = config.get_videolibrary_path() # We calculate the absolute path from the Video Library - movies = config.get_setting("folder_movies") - series = config.get_setting("folder_tvshows") - torrents_movies = filetools.join(videolibrary_path, config.get_setting("folder_movies")) # path of CINE - torrents_series = filetools.join(videolibrary_path, config.get_setting("folder_tvshows")) # path the SERIES + videolibrary_path = config.getVideolibraryPath() # We calculate the absolute path from the Video Library + movies = config.getSetting("folder_movies") + series = config.getSetting("folder_tvshows") + torrents_movies = filetools.join(videolibrary_path, config.getSetting("folder_movies")) # path of CINE + torrents_series = filetools.join(videolibrary_path, config.getSetting("folder_tvshows")) # path the SERIES # We load in .json from Newpct1 to see the lists of values ​​in settings fail_over_list = channeltools.get_channel_json(channel_py) diff --git a/lib/megaserver/client.py b/lib/megaserver/client.py index eb9fb395..f6d9084b 100644 --- a/lib/megaserver/client.py +++ b/lib/megaserver/client.py @@ -21,14 +21,14 @@ class Client(object): '.m4v': 'video/mp4', '.mov': 'video/quicktime', '.mpg': 'video/mpeg','.ogv': 'video/ogg', '.ogg': 'video/ogg', '.webm': 'video/webm', '.ts': 'video/mp2t', '.3gp': 'video/3gpp'} - def __init__(self, url, port=None, ip=None, auto_shutdown=True, wait_time=20, timeout=5, is_playing_fnc=None): + def __init__(self, url, port=None, ip=None, auto_shutdown=True, wait_time=20, timeout=5, isPlaying_fnc=None): self.port = port if port else random.randint(8000,8099) self.ip = ip if ip else "127.0.0.1" self.connected = False self.start_time = None self.last_connect = None - self.is_playing_fnc = is_playing_fnc + self.isPlaying_fnc = isPlaying_fnc self.auto_shutdown = auto_shutdown self.wait_time = wait_time self.timeout = timeout @@ -55,12 +55,12 @@ class Client(object): if self.file and self.file.cursor: self.last_connect = time.time() - if self.is_playing_fnc and self.is_playing_fnc(): + if self.isPlaying_fnc and self.isPlaying_fnc(): self.last_connect = time.time() if self.auto_shutdown: #shudown por haber cerrado el reproductor - if self.connected and self.last_connect and self.is_playing_fnc and not self.is_playing_fnc(): + if self.connected and self.last_connect and self.isPlaying_fnc and not self.isPlaying_fnc(): if time.time() - self.last_connect - 1 > self.timeout: self.stop() @@ -70,7 +70,7 @@ class Client(object): self.stop() #shutdown tras la ultima conexion - if (not self.file or not self.file.cursor) and self.timeout and self.connected and self.last_connect and not self.is_playing_fnc: + if (not self.file or not self.file.cursor) and self.timeout and self.connected and self.last_connect and not self.isPlaying_fnc: if time.time() - self.last_connect - 1 > self.timeout: self.stop() diff --git a/lib/requests_toolbelt/multipart/encoder.py b/lib/requests_toolbelt/multipart/encoder.py index e4c7cd7a..a38fb4c7 100644 --- a/lib/requests_toolbelt/multipart/encoder.py +++ b/lib/requests_toolbelt/multipart/encoder.py @@ -218,22 +218,22 @@ class MultipartEncoder(object): _fields = list(self.fields.items()) for k, v in _fields: file_name = None - file_type = None + fileType = None file_headers = None if isinstance(v, (list, tuple)): if len(v) == 2: file_name, file_pointer = v elif len(v) == 3: - file_name, file_pointer, file_type = v + file_name, file_pointer, fileType = v else: - file_name, file_pointer, file_type, file_headers = v + file_name, file_pointer, fileType, file_headers = v else: file_pointer = v field = fields.RequestField(name=k, data=file_pointer, filename=file_name, headers=file_headers) - field.make_multipart(content_type=file_type) + field.make_multipart(content_type=fileType) yield field def _prepare_parts(self): diff --git a/lib/streamingcommunity/client.py b/lib/streamingcommunity/client.py index c35418d0..1fd3d42f 100644 --- a/lib/streamingcommunity/client.py +++ b/lib/streamingcommunity/client.py @@ -19,14 +19,14 @@ from lib.streamingcommunity.server import Server class Client(object): - def __init__(self, url, port=None, ip=None, auto_shutdown=True, wait_time=20, timeout=5, is_playing_fnc=None, video_id=None): + def __init__(self, url, port=None, ip=None, auto_shutdown=True, wait_time=20, timeout=5, isPlaying_fnc=None, video_id=None): self.port = port if port else random.randint(8000,8099) self.ip = ip if ip else "127.0.0.1" self.connected = False self.start_time = None self.last_connect = None - self.is_playing_fnc = is_playing_fnc + self.isPlaying_fnc = isPlaying_fnc self.auto_shutdown = auto_shutdown self.wait_time = wait_time self.timeout = timeout @@ -71,12 +71,12 @@ class Client(object): if self.file and self.file.cursor: self.last_connect = time.time() - if self.is_playing_fnc and self.is_playing_fnc(): + if self.isPlaying_fnc and self.isPlaying_fnc(): self.last_connect = time.time() if self.auto_shutdown: #shudown por haber cerrado el reproductor - if self.connected and self.last_connect and self.is_playing_fnc and not self.is_playing_fnc(): + if self.connected and self.last_connect and self.isPlaying_fnc and not self.isPlaying_fnc(): if time.time() - self.last_connect - 1 > self.timeout: self.stop() @@ -86,7 +86,7 @@ class Client(object): self.stop() #shutdown tras la ultima conexion - if (not self.file or not self.file.cursor) and self.timeout and self.connected and self.last_connect and not self.is_playing_fnc: + if (not self.file or not self.file.cursor) and self.timeout and self.connected and self.last_connect and not self.isPlaying_fnc: if time.time() - self.last_connect - 1 > self.timeout: self.stop() @@ -124,11 +124,11 @@ class Client(object): for match in r_video.finditer(m3u8_original): line = match.groups()[0] res = match.groups()[1] - video_url = "/video/" + res + ".m3u8" + videoUrl = "/video/" + res + ".m3u8" - # logger.info('replace', match.groups(), line, res, video_url) + # logger.info('replace', match.groups(), line, res, videoUrl) - m3u8_original = m3u8_original.replace( line, video_url ) + m3u8_original = m3u8_original.replace( line, videoUrl ) for match in r_audio.finditer(m3u8_original): @@ -146,10 +146,10 @@ class Client(object): # m_audio = re.search(r'\.\/audio\/(\d+k)\/playlist.m3u8', m3u8_original) # self._audio_res = m_audio.group(1) - # video_url = "/video/" + self._video_res + ".m3u8" + # videoUrl = "/video/" + self._video_res + ".m3u8" # audio_url = "/audio/" + self._audio_res + ".m3u8" - # m3u8_original = m3u8_original.replace( m_video.group(0), video_url ) + # m3u8_original = m3u8_original.replace( m_video.group(0), videoUrl ) # m3u8_original = m3u8_original.replace( m_audio.group(0), audio_url ) return m3u8_original diff --git a/lib/urllib3/contrib/pyopenssl.py b/lib/urllib3/contrib/pyopenssl.py index 3051ef3a..1f0487a2 100644 --- a/lib/urllib3/contrib/pyopenssl.py +++ b/lib/urllib3/contrib/pyopenssl.py @@ -427,7 +427,7 @@ class PyOpenSSLContext(object): @options.setter def options(self, value): self._options = value - self._ctx.set_options(value) + self._ctx.setOptions(value) @property def verify_mode(self): diff --git a/libraryscraper.py b/libraryscraper.py index c020e9a1..667a32a0 100644 --- a/libraryscraper.py +++ b/libraryscraper.py @@ -11,7 +11,7 @@ try: except: pass -librerias = xbmc.translatePath(os.path.join(config.get_runtime_path(), 'lib')) +librerias = xbmc.translatePath(os.path.join(config.getRuntimePath(), 'lib')) sys.path.insert(0, librerias) diff --git a/platformcode/autorenumber.py b/platformcode/autorenumber.py index 6191e4de..0ea1e2bc 100644 --- a/platformcode/autorenumber.py +++ b/platformcode/autorenumber.py @@ -39,7 +39,7 @@ def check(item, itemlist=None): def filename(item): logger.debug() name_file = item.channel + "_data.json" - path = filetools.join(config.get_data_path(), "settings_channels") + path = filetools.join(config.getDataPath(), "settings_channels") fname = filetools.join(path, name_file) return fname @@ -70,7 +70,7 @@ def b64(json, mode = 'encode'): def find_episodes(item): logger.debug() - ch = platformtools.channel_import(item.channel) + ch = platformtools.channelImport(item.channel) itemlist = getattr(ch, item.action)(item) return itemlist @@ -113,7 +113,7 @@ class autorenumber(): from core.videolibrarytools import check_renumber_options check_renumber_options(self.item) self.renumberdict = load(item) - self.auto = config.get_setting('autorenumber', item.channel) + self.auto = config.getSetting('autorenumber', item.channel) self.title = self.item.fulltitle.strip() if item.contentSeason: item.exit = True @@ -137,7 +137,7 @@ class autorenumber(): self.renumberdict = {} for item in self.itemlist: if item.contentType != 'movie': - item.context = [{"title": typo(config.get_localized_string(70585), 'bold'), + item.context = [{"title": typo(config.getLocalizedString(70585), 'bold'), "action": "start", "channel": "autorenumber", "from_channel": item.channel, @@ -161,7 +161,7 @@ class autorenumber(): while not self.item.exit: tmdb.find_and_set_infoLabels(self.item) if self.item.infoLabels['tmdb_id']: self.item.exit = True - else:self.item = platformtools.dialog_info(self.item, 'tmdb') + else:self.item = platformtools.dialogInfo(self.item, 'tmdb') # Rinumerazione Automatica if (not self.id and self.auto) or self.item.setrenumber: @@ -313,7 +313,7 @@ def SelectreNumeration(opt, itemlist, manual=False): def onInit(self): # Compatibility with Kodi 18 - if config.get_platform(True)['num_version'] < 18: self.setCoordinateResolution(2) + if config.getXBMCPlatform(True)['num_version'] < 18: self.setCoordinateResolution(2) fanart = self.item.fanart thumb = self.item.thumbnail self.getControl(SELECT).setVisible(False) @@ -324,7 +324,7 @@ def SelectreNumeration(opt, itemlist, manual=False): self.getControl(MANUAL).setVisible(True) self.getControl(MPOSTER).setImage(thumb) if fanart: self.getControl(MBACKGROUND).setImage(fanart) - self.getControl(INFO).setLabel(typo(config.get_localized_string(70822) + self.title, 'bold')) + self.getControl(INFO).setLabel(typo(config.getLocalizedString(70822) + self.title, 'bold')) self.manual = True @@ -366,7 +366,7 @@ def SelectreNumeration(opt, itemlist, manual=False): if fanart: self.getControl(BACKGROUND).setImage(fanart) self.getControl(MBACKGROUND).setImage(fanart) - self.getControl(INFO).setLabel(typo(config.get_localized_string(70824) + self.title, 'bold')) + self.getControl(INFO).setLabel(typo(config.getLocalizedString(70824) + self.title, 'bold')) self.getControl(LIST).addItems(self.items) self.getControl(SELECTED).addItems(self.selected) @@ -383,19 +383,19 @@ def SelectreNumeration(opt, itemlist, manual=False): def onFocus(self, focus): if focus in [S]: - self.getControl(108).setLabel(typo(config.get_localized_string(70825), 'bold')) + self.getControl(108).setLabel(typo(config.getLocalizedString(70825), 'bold')) elif focus in [E]: - self.getControl(108).setLabel(typo(config.get_localized_string(70826), 'bold')) + self.getControl(108).setLabel(typo(config.getLocalizedString(70826), 'bold')) elif focus in [O]: - self.getControl(108).setLabel(typo(config.get_localized_string(70001), 'bold')) + self.getControl(108).setLabel(typo(config.getLocalizedString(70001), 'bold')) elif focus in [SS]: - self.getControl(108).setLabel(typo(config.get_localized_string(70827), 'bold')) + self.getControl(108).setLabel(typo(config.getLocalizedString(70827), 'bold')) elif focus in [M]: - self.getControl(108).setLabel(typo(config.get_localized_string(70828), 'bold')) + self.getControl(108).setLabel(typo(config.getLocalizedString(70828), 'bold')) elif focus in [D]: - self.getControl(108).setLabel(typo(config.get_localized_string(70829) + self.title, 'bold')) + self.getControl(108).setLabel(typo(config.getLocalizedString(70829) + self.title, 'bold')) elif focus in [C]: - self.getControl(108).setLabel(typo(config.get_localized_string(70002), 'bold')) + self.getControl(108).setLabel(typo(config.getLocalizedString(70002), 'bold')) def onAction(self, action): action = action.getId() @@ -470,11 +470,11 @@ def SelectreNumeration(opt, itemlist, manual=False): def onClick(self, control_id): ## FIRST SECTION if control_id in [S]: - selected = platformtools.dialog_numeric(0, config.get_localized_string(70825), + selected = platformtools.dialogNumeric(0, config.getLocalizedString(70825), self.getControl(S).getLabel()) if selected: s = self.getControl(S).setLabel(selected) elif control_id in [E]: - selected = platformtools.dialog_numeric(0, config.get_localized_string(70826), + selected = platformtools.dialogNumeric(0, config.getLocalizedString(70826), self.getControl(E).getLabel()) if selected: e = self.getControl(E).setLabel(selected) # OPEN SPECIALS OR OK @@ -491,7 +491,7 @@ def SelectreNumeration(opt, itemlist, manual=False): self.setFocusId(OK) # OPEN MANUAL elif control_id in [M]: - self.getControl(INFO).setLabel(typo(config.get_localized_string(70823) + self.title, 'bold')) + self.getControl(INFO).setLabel(typo(config.getLocalizedString(70823) + self.title, 'bold')) self.manual = True if self.episodes: items = [] @@ -588,7 +588,7 @@ def SelectreNumeration(opt, itemlist, manual=False): self.getControl(SELECTED).selectItem(index) # RELOAD SPECIALS if control_id in [SELECTED]: - epnumber = platformtools.dialog_numeric(0, config.get_localized_string(60386)) + epnumber = platformtools.dialogNumeric(0, config.getLocalizedString(60386)) if epnumber: it = self.getControl(SELECTED).getSelectedItem() it.setLabel(str(epnumber)) @@ -613,10 +613,10 @@ def SelectreNumeration(opt, itemlist, manual=False): e = int(self.getControl(MLIST).getSelectedItem().getProperty('episode')) pos = self.getControl(MLIST).getSelectedPosition() if control_id in [MS]: - selected = platformtools.dialog_numeric(0, config.get_localized_string(70825), str(s)) + selected = platformtools.dialogNumeric(0, config.getLocalizedString(70825), str(s)) if selected: s = int(selected) elif control_id in [ME]: - selected = platformtools.dialog_numeric(0, config.get_localized_string(70826), str(e)) + selected = platformtools.dialogNumeric(0, config.getLocalizedString(70826), str(e)) if selected: e = int(selected) if s != self.season or e != self.episode: self.season = s @@ -740,4 +740,4 @@ DOWN = 4 EXIT = 10 BACKSPACE = 92 -path = config.get_runtime_path() \ No newline at end of file +path = config.getRuntimePath() \ No newline at end of file diff --git a/platformcode/backup.py b/platformcode/backup.py index bf86b9d6..965e8707 100644 --- a/platformcode/backup.py +++ b/platformcode/backup.py @@ -25,12 +25,12 @@ videolibrary_tvshows_path = unicode(videolibrarytools.TVSHOWS_PATH) def export_videolibrary(item): logger.info() - zip_file_folder = platformtools.dialog_browse(3, config.get_localized_string(80002)) + zip_file_folder = platformtools.dialogBrowse(3, config.getLocalizedString(80002)) if zip_file_folder == "": return zip_file = unicode(xbmc.translatePath(zip_file_folder + "KoD_video_library-" + str(datetime.date.today()) + ".zip")) - p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(80003)) + p_dialog = platformtools.dialogProgressBg(config.getLocalizedString(20000), config.getLocalizedString(80003)) # p_dialog.update(0) if filetools.exists(videolibrary_temp_path): @@ -50,19 +50,19 @@ def export_videolibrary(item): p_dialog.update(100) xbmc.sleep(1000) p_dialog.close() - platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(80004), time=5000, sound=False) + platformtools.dialogNotification(config.getLocalizedString(20000), config.getLocalizedString(80004), time=5000, sound=False) def import_videolibrary(item): logger.info() - zip_file = unicode(platformtools.dialog_browse(1, config.get_localized_string(80005), mask=".zip")) + zip_file = unicode(platformtools.dialogBrowse(1, config.getLocalizedString(80005), mask=".zip")) if zip_file == "": return - if not platformtools.dialog_yesno(config.get_localized_string(20000), config.get_localized_string(80006)): + if not platformtools.dialogYesNo(config.getLocalizedString(20000), config.getLocalizedString(80006)): return - p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(80007)) + p_dialog = platformtools.dialogProgressBg(config.getLocalizedString(20000), config.getLocalizedString(80007)) # p_dialog.update(0) if filetools.exists(temp_path): @@ -72,14 +72,14 @@ def import_videolibrary(item): unzip(videolibrary_temp_path, zip_file) p_dialog.update(20) - if config.is_xbmc() and config.get_setting("videolibrary_kodi"): + if config.is_xbmc() and config.getSetting("videolibrary_kodi"): xbmc_videolibrary.clean() p_dialog.update(30) shutil.rmtree(videolibrary_movies_path) shutil.rmtree(videolibrary_tvshows_path) p_dialog.update(50) - config.verify_directories_created() + config.verifyDirectoriesCreated() if filetools.exists(movies_path): copy_tree(movies_path, videolibrary_movies_path) p_dialog.update(70) @@ -91,10 +91,10 @@ def import_videolibrary(item): p_dialog.update(100) xbmc.sleep(1000) p_dialog.close() - platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(80008), time=5000, sound=False) + platformtools.dialogNotification(config.getLocalizedString(20000), config.getLocalizedString(80008), time=5000, sound=False) videolibrary.update_videolibrary() - if config.is_xbmc() and config.get_setting("videolibrary_kodi"): + if config.is_xbmc() and config.getSetting("videolibrary_kodi"): xbmc_videolibrary.update() diff --git a/platformcode/checkhost.py b/platformcode/checkhost.py index 235ea220..d80af57d 100644 --- a/platformcode/checkhost.py +++ b/platformcode/checkhost.py @@ -184,13 +184,13 @@ class Kdicc(): txt += '\nIP: %s' % self.ip_addr dialog = xbmcgui.Dialog() - if config.get_setting('checkdns'): - risposta= dialog.yesno(addonname, txt, nolabel=config.get_localized_string(707403), yeslabel=config.get_localized_string(707404)) + if config.getSetting('checkdns'): + risposta= dialog.yesno(addonname, txt, nolabel=config.getLocalizedString(707403), yeslabel=config.getLocalizedString(707404)) if risposta == False: - config.set_setting('checkdns', False) - dialog.textviewer(addonname+' '+config.get_localized_string(707405), config.get_localized_string(707406)) + config.setSetting('checkdns', False) + dialog.textviewer(addonname+' '+config.getLocalizedString(707405), config.getLocalizedString(707406)) else: - txt = config.get_localized_string(707402) + txt = config.getLocalizedString(707402) dialog.notification(addonname, txt, xbmcgui.NOTIFICATION_INFO, 10000) """ def called in launcher.py @@ -204,20 +204,20 @@ def test_conn(is_exit, check_dns, view_msg, # I don't let you get into the addon # enter language code if view_msg == True: - ktest.view_Advise(config.get_localized_string(70720)) + ktest.view_Advise(config.getLocalizedString(70720)) if ktest.is_exit == True: exit() # if it has no ADSL connection, I will communicate it to the user if not ktest.check_Adsl(): if view_msg == True: - ktest.view_Advise(config.get_localized_string(70721)) + ktest.view_Advise(config.getLocalizedString(70721)) if ktest.is_exit == True: exit() # if it has DNS filtered, I will communicate it to the user if check_dns == True: if not ktest.check_Dns(): if view_msg == True: - ktest.view_Advise(config.get_localized_string(70722)) + ktest.view_Advise(config.getLocalizedString(70722)) logger.info("############ Start Check DNS ############") logger.info("## IP: %s" % (ktest.ip_addr)) diff --git a/platformcode/config.py b/platformcode/config.py index aad32626..0c48544b 100644 --- a/platformcode/config.py +++ b/platformcode/config.py @@ -12,33 +12,35 @@ PLUGIN_NAME = "kod" __settings__ = xbmcaddon.Addon(id="plugin.video." + PLUGIN_NAME) __language__ = __settings__.getLocalizedString __version_fix = None -__dev_mode = None +__devMode = None -channels_data = dict() +channelsData = dict() changelogFile = xbmc.translatePath("special://profile/addon_data/plugin.video.kod/changelog.txt") +addonIcon = os.path.join(__settings__.getAddonInfo( "path" ),'resources', 'media', "logo.png" ) -def get_addon_core(): + +def getAddonCore(): return __settings__ -def get_addon_version(with_fix=True): +def getAddonVersion(with_fix=True): ''' Returns the version number of the addon, and optionally fix number if there is one ''' if with_fix: - return __settings__.getAddonInfo('version') + " " + get_addon_version_fix() + return __settings__.getAddonInfo('version') + " " + getAddonVersionFix() else: return __settings__.getAddonInfo('version') -def get_addon_version_fix(): +def getAddonVersionFix(): global __version_fix ret = __version_fix if not ret: - if not dev_mode(): + if not devMode(): try: - sha = open(os.path.join(get_runtime_path(), 'last_commit.txt')).readline() + sha = open(os.path.join(getRuntimePath(), 'last_commit.txt')).readline() ret = sha[:7] except: ret = '??' @@ -47,14 +49,14 @@ def get_addon_version_fix(): return ret -def dev_mode(): - global __dev_mode - if not __dev_mode: - __dev_mode = os.path.isdir(get_runtime_path() + '/.git') - return __dev_mode +def devMode(): + global __devMode + if not __devMode: + __devMode = os.path.isdir(getRuntimePath() + '/.git') + return __devMode -def get_platform(full_version=False): +def getXBMCPlatform(full_version=False): """ Returns the information the version of xbmc or kodi on which the plugin is run @@ -95,6 +97,57 @@ def get_platform(full_version=False): else: return ret['platform'] +def getPlatform(): + import platform + build = xbmc.getInfoLabel("System.BuildVersion") + kodi_version = int(build.split()[0][:2]) + ret = { + "auto_arch": sys.maxsize > 2 ** 32 and "64-bit" or "32-bit", + "arch": sys.maxsize > 2 ** 32 and "x64" or "ia32", + "os": "", + "version": platform.release(), + "kodi": kodi_version, + "build": build + } + if xbmc.getCondVisibility("system.platform.android"): + ret["os"] = "android" + if "arm" in platform.machine() or "aarch" in platform.machine(): + ret["arch"] = "arm" + if "64" in platform.machine() and ret["auto_arch"] == "64-bit": + ret["arch"] = "arm64" + elif xbmc.getCondVisibility("system.platform.linux"): + ret["os"] = "linux" + if "aarch" in platform.machine() or "arm64" in platform.machine(): + if xbmc.getCondVisibility("system.platform.linux.raspberrypi"): + ret["arch"] = "armv7" + elif ret["auto_arch"] == "32-bit": + ret["arch"] = "armv7" + elif ret["auto_arch"] == "64-bit": + ret["arch"] = "arm64" + elif platform.architecture()[0].startswith("32"): + ret["arch"] = "arm" + else: + ret["arch"] = "arm64" + elif "armv7" in platform.machine(): + ret["arch"] = "armv7" + elif "arm" in platform.machine(): + ret["arch"] = "arm" + elif xbmc.getCondVisibility("system.platform.xbox"): + ret["os"] = "win" + ret["arch"] = "x64" + elif xbmc.getCondVisibility("system.platform.windows"): + ret["os"] = "win" + if platform.machine().endswith('64'): + ret["arch"] = "x64" + elif xbmc.getCondVisibility("system.platform.osx"): + ret["os"] = "mac" + ret["arch"] = "x64" + elif xbmc.getCondVisibility("system.platform.ios"): + ret["os"] = "ios" + ret["arch"] = "arm" + + return ret + def is_xbmc(): return True @@ -108,26 +161,26 @@ def get_channel_url(findhostMethod=None, name=None, forceFindhost=False): from core import jsontools import inspect - LOCAL_FILE = os.path.join(get_runtime_path(), "channels.json") - global channels_data - if not channels_data: + LOCAL_FILE = os.path.join(getRuntimePath(), "channels.json") + global channelsData + if not channelsData: with open(LOCAL_FILE) as f: - channels_data = jsontools.load(f.read()) + channelsData = jsontools.load(f.read()) frame = inspect.stack()[1] if not name: name = os.path.basename(frame[0].f_code.co_filename).replace('.py', '') if findhostMethod: - url = jsontools.get_node_from_file(name, 'url') + url = jsontools.getNodeFromFile(name, 'url') if not url or forceFindhost: - url = findhostMethod(channels_data['findhost'][name]) - jsontools.update_node(url, name, 'url') + url = findhostMethod(channelsData['findhost'][name]) + jsontools.updateNode(url, name, 'url') return url else: - return channels_data['direct'][name] + return channelsData['direct'][name] -def get_system_platform(): +def getSystemPlatform(): """ function: to recover the platform that xbmc is running """ platform = "unknown" if xbmc.getCondVisibility("system.platform.linux"): @@ -139,35 +192,35 @@ def get_system_platform(): return platform -def get_all_settings_addon(): +def getAllSettingsAddon(): # Read the settings.xml file and return a dictionary with {id: value} from core import scrapertools - with open(os.path.join(get_data_path(), "settings.xml"), "rb") as infile: + with open(os.path.join(getDataPath(), "settings.xml"), "rb") as infile: data = infile.read().decode('utf-8') ret = {} - matches = scrapertools.find_multiple_matches(data, '<setting id=\"([^\"]+)\"[^>]*>') + matches = scrapertools.findMultipleMatches(data, '<setting id=\"([^\"]+)\"[^>]*>') for _id in matches: - ret[_id] = get_setting(_id) + ret[_id] = getSetting(_id) return ret -def open_settings(): +def openSettings(): xbmc.executebuiltin('Addon.OpenSettings(plugin.video.%s)' % PLUGIN_NAME) -def get_setting(name, channel="", server="", default=None): +def getSetting(name, channel="", server="", default=None): """ Returns the configuration value of the requested parameter. Returns the value of the parameter 'name' in the global configuration, in the own configuration of the channel 'channel' or in that of the server 'server'. The channel and server parameters should not be used simultaneously. If the channel name is specified it will be returned - the result of calling channeltools.get_channel_setting (name, channel, default). If the name of the - server will return the result of calling servertools.get_channel_setting (name, server, default). If I dont know + the result of calling channeltools.getChannelSetting (name, channel, default). If the name of the + server will return the result of calling servertools.getChannelSetting (name, server, default). If I dont know Specify none of the above will return the value of the parameter in the global configuration if it exists or the default value otherwise. @@ -187,23 +240,23 @@ def get_setting(name, channel="", server="", default=None): # Specific channel setting if channel: - # logger.info("get_setting reading channel setting '"+name+"' from channel json") + # logger.info("getSetting reading channel setting '"+name+"' from channel json") from core import channeltools - value = channeltools.get_channel_setting(name, channel, default) - # logger.info("get_setting -> '"+repr(value)+"'") + value = channeltools.getChannelSetting(name, channel, default) + # logger.info("getSetting -> '"+repr(value)+"'") return value # Specific server setting elif server: - # logger.info("get_setting reading server setting '"+name+"' from server json") + # logger.info("getSetting reading server setting '"+name+"' from server json") from core import servertools - value = servertools.get_server_setting(name, server, default) - # logger.info("get_setting -> '"+repr(value)+"'") + value = servertools.getServerSetting(name, server, default) + # logger.info("getSetting -> '"+repr(value)+"'") return value # Global setting else: - # logger.info("get_setting reading main setting '"+name+"'") + # logger.info("getSetting reading main setting '"+name+"'") value = __settings__.getSetting(name) if not value: return default @@ -225,7 +278,7 @@ def get_setting(name, channel="", server="", default=None): return value -def set_setting(name, value, channel="", server=""): +def setSetting(name, value, channel="", server=""): """ Sets the configuration value of the indicated parameter. @@ -249,10 +302,10 @@ def set_setting(name, value, channel="", server=""): """ if channel: from core import channeltools - return channeltools.set_channel_setting(name, value, channel) + return channeltools.setChannelSetting(name, value, channel) elif server: from core import servertools - return servertools.set_server_setting(name, value, server) + return servertools.setServerSetting(name, value, server) else: try: if isinstance(value, bool): @@ -274,7 +327,7 @@ def set_setting(name, value, channel="", server=""): return value -def get_localized_string(code): +def getLocalizedString(code): dev = __language__(code) try: @@ -295,43 +348,43 @@ def get_localized_string(code): return dev -def get_localized_category(categ): - categories = {'movie': get_localized_string(30122), 'tvshow': get_localized_string(30123), - 'anime': get_localized_string(30124), 'documentary': get_localized_string(30125), - 'vos': get_localized_string(30136), 'sub': get_localized_string(30136), - 'direct': get_localized_string(30137), 'torrent': get_localized_string(70015), - 'live': get_localized_string(30138), 'music': get_localized_string(30139) +def getLocalizedCategory(categ): + categories = {'movie': getLocalizedString(30122), 'tvshow': getLocalizedString(30123), + 'anime': getLocalizedString(30124), 'documentary': getLocalizedString(30125), + 'vos': getLocalizedString(30136), 'sub': getLocalizedString(30136), + 'direct': getLocalizedString(30137), 'torrent': getLocalizedString(70015), + 'live': getLocalizedString(30138), 'music': getLocalizedString(30139) } return categories[categ] if categ in categories else categ -def get_localized_language(lang): +def getLocalizedLanguage(lang): languages = {'ita': 'ITA', 'sub-ita': 'Sub-ITA'} return languages[lang] if lang in languages else lang -def get_videolibrary_config_path(): - value = get_setting("videolibrarypath") +def getVideolibraryConfigPath(): + value = getSetting("videolibrarypath") if value == "": - verify_directories_created() - value = get_setting("videolibrarypath") + verifyDirectoriesCreated() + value = getSetting("videolibrarypath") return value -def get_videolibrary_path(): - return xbmc.translatePath(get_videolibrary_config_path()) +def getVideolibraryPath(): + return xbmc.translatePath(getVideolibraryConfigPath()) -def get_temp_file(filename): +def getTempFile(filename): return xbmc.translatePath(os.path.join("special://temp/", filename)) -def get_runtime_path(): +def getRuntimePath(): return xbmc.translatePath(__settings__.getAddonInfo('Path')) -def get_data_path(): +def getDataPath(): dev = xbmc.translatePath(__settings__.getAddonInfo('Profile')) # Create the directory if it doesn't exist @@ -341,17 +394,17 @@ def get_data_path(): return dev -def get_icon(): +def getIcon(): return xbmc.translatePath(__settings__.getAddonInfo('icon')) -def get_fanart(): +def getFanart(): return xbmc.translatePath(__settings__.getAddonInfo('fanart')) -def get_cookie_data(): +def getCookieData(): import os - ficherocookies = os.path.join(get_data_path(), 'cookies.dat') + ficherocookies = os.path.join(getDataPath(), 'cookies.dat') cookiedatafile = open(ficherocookies, 'r') cookiedata = cookiedatafile.read() @@ -361,7 +414,7 @@ def get_cookie_data(): # Test if all the required directories are created -def verify_directories_created(): +def verifyDirectoriesCreated(): from platformcode import logger from core import filetools from platformcode import xbmc_videolibrary @@ -372,18 +425,18 @@ def verify_directories_created(): ["settings_path", "settings_channels"]] for path, default in config_paths: - saved_path = get_setting(path) + saved_path = getSetting(path) # video store if path == "videolibrarypath": if not saved_path: saved_path = xbmc_videolibrary.search_library_path() if saved_path: - set_setting(path, saved_path) + setSetting(path, saved_path) if not saved_path: saved_path = "special://profile/addon_data/plugin.video." + PLUGIN_NAME + "/" + default - set_setting(path, saved_path) + setSetting(path, saved_path) saved_path = xbmc.translatePath(saved_path) if not filetools.exists(saved_path): @@ -394,13 +447,13 @@ def verify_directories_created(): ["folder_tvshows", "Serie TV"]] for path, default in config_paths: - saved_path = get_setting(path) + saved_path = getSetting(path) if not saved_path: saved_path = default - set_setting(path, saved_path) + setSetting(path, saved_path) - content_path = filetools.join(get_videolibrary_path(), saved_path) + content_path = filetools.join(getVideolibraryPath(), saved_path) if not filetools.exists(content_path): logger.debug("Creating %s: %s" % (path, content_path)) @@ -408,8 +461,8 @@ def verify_directories_created(): filetools.mkdir(content_path) from platformcode import xbmc_videolibrary - xbmc_videolibrary.update_sources(get_setting("videolibrarypath")) - xbmc_videolibrary.update_sources(get_setting("downloadpath")) + xbmc_videolibrary.update_sources(getSetting("videolibrarypath")) + xbmc_videolibrary.update_sources(getSetting("downloadpath")) try: from core import scrapertools @@ -419,14 +472,14 @@ def verify_directories_created(): # We extract the name of the default resolution folder folder = "" data = filetools.read(skindir) - res = scrapertools.find_multiple_matches(data, '(<res .*?>)') + res = scrapertools.findMultipleMatches(data, '(<res .*?>)') for r in res: if 'default="true"' in r: folder = scrapertools.find_single_match(r, 'folder="([^"]+)"') break # We check if it exists in the addon and if not, we create it - default = filetools.join(get_runtime_path(), 'resources', 'skins', 'Default') + default = filetools.join(getRuntimePath(), 'resources', 'skins', 'Default') if folder and not filetools.exists(filetools.join(default, folder)): filetools.mkdir(filetools.join(default, folder)) @@ -442,5 +495,5 @@ def verify_directories_created(): logger.error(traceback.format_exc()) -def get_online_server_thumb(server): +def getOnlineServerThumb(server): return "https://raw.github.com/kodiondemand/media/master/resources/servers/" + server.lower().replace('_server','') + '.png' \ No newline at end of file diff --git a/platformcode/contextmenu/search.py b/platformcode/contextmenu/search.py index 9dd82078..4fa5e5d3 100644 --- a/platformcode/contextmenu/search.py +++ b/platformcode/contextmenu/search.py @@ -2,14 +2,14 @@ import xbmc, sys, os from platformcode import config, logger import re # incliuding folder libraries -librerias = xbmc.translatePath(os.path.join(config.get_runtime_path(), 'lib')) +librerias = xbmc.translatePath(os.path.join(config.getRuntimePath(), 'lib')) sys.path.insert(0, librerias) from core import tmdb from core.item import Item -addon_id = config.get_addon_core().getAddonInfo('id') +addon_id = config.getAddonCore().getAddonInfo('id') global item_is_coming_from_kod @@ -26,10 +26,10 @@ def check_condition(): logger.debug('listitem mediatype:',mediatype ) logger.debug('filenamepath:', fileNameAndPath ) logger.info('filepath:', filePath ) - + item_is_coming_from_kod = addon_id in filePath if not item_is_coming_from_kod: - videolibpath = config.get_setting("videolibrarypath") + videolibpath = config.getSetting("videolibrarypath") if filePath.startswith(videolibpath): pattern = re.compile("\[.*\][\\\/]?$") item_is_coming_from_kod = pattern.search(filePath) @@ -43,7 +43,7 @@ def check_condition(): def get_menu_items(): logger.debug('get menu item') if check_condition(): - return [(config.get_localized_string(90003 if item_is_coming_from_kod else 90005), execute)] + return [(config.getLocalizedString(90003 if item_is_coming_from_kod else 90005), execute)] else: return [] diff --git a/platformcode/contextmenu/trailer.py b/platformcode/contextmenu/trailer.py index 6ad64c31..7f7378f2 100644 --- a/platformcode/contextmenu/trailer.py +++ b/platformcode/contextmenu/trailer.py @@ -5,7 +5,7 @@ from platformcode import config def get_menu_items(): - return [(config.get_localized_string(60359), execute)] + return [(config.getLocalizedString(60359), execute)] def execute(): diff --git a/platformcode/contextmenu/tvshow_options.py b/platformcode/contextmenu/tvshow_options.py index 55ec5225..6792302e 100644 --- a/platformcode/contextmenu/tvshow_options.py +++ b/platformcode/contextmenu/tvshow_options.py @@ -2,7 +2,7 @@ import xbmc, sys, xbmcgui, os, xbmcvfs, traceback from platformcode import config, logger -librerias = xbmc.translatePath(os.path.join(config.get_runtime_path(), 'lib')) +librerias = xbmc.translatePath(os.path.join(config.getRuntimePath(), 'lib')) sys.path.insert(0, librerias) from core.item import Item @@ -52,7 +52,7 @@ def search_paths(Id): for record in records: path_records = execute_sql('SELECT strPath FROM path WHERE idPath LIKE "%s"' % record[0]) for path in path_records: - if config.get_setting('videolibrarypath') in path[0] and exists(join(path[0], 'tvshow.nfo')): + if config.getSetting('videolibrarypath') in path[0] and exists(join(path[0], 'tvshow.nfo')): return path[0] return '' @@ -63,7 +63,7 @@ def execute_sql(sql): records = None # We look for the archive of the video database according to the version of kodi - video_db = config.get_platform(True)['video_db'] + video_db = config.getXBMCPlatform(True)['video_db'] if video_db: file_db = os.path.join(xbmc.translatePath("special://userdata/Database"), video_db) @@ -130,7 +130,7 @@ def check_condition(): def get_menu_items(): logger.debug('get menu item') if check_condition(): - items = [(config.get_localized_string(70269), update)] + items = [(config.getLocalizedString(70269), update)] from core.videolibrarytools import read_nfo nfo = path + 'tvshow.nfo' item = read_nfo(nfo)[1] @@ -139,16 +139,16 @@ def get_menu_items(): item_url = item.tourl() # Context menu: Automatically search for new episodes or not if item.active and int(item.active) > 0: - update_text = config.get_localized_string(60022) + update_text = config.getLocalizedString(60022) value = 0 else: - update_text = config.get_localized_string(60023) + update_text = config.getLocalizedString(60023) value = 1 items.append((update_text, lambda: xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?{}&title={}&action=mark_tvshow_as_updatable&channel=videolibrary&active={})".format(item_url, update_text, str(value))))) if item.local_episodes_path == "": - items.append((config.get_localized_string(80048), lambda: xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?{}&action=add_local_episodes&channel=videolibrary&path={})".format(item_url, path)))) + items.append((config.getLocalizedString(80048), lambda: xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?{}&action=add_local_episodes&channel=videolibrary&path={})".format(item_url, path)))) else: - items.append((config.get_localized_string(80049), lambda: xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?{}&action=remove_local_episodes&channel=videolibrary&path={})".format(item_url, path)))) + items.append((config.getLocalizedString(80049), lambda: xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?{}&action=remove_local_episodes&channel=videolibrary&path={})".format(item_url, path)))) return items else: diff --git a/platformcode/dbconverter.py b/platformcode/dbconverter.py index 9b169b16..7dae670c 100644 --- a/platformcode/dbconverter.py +++ b/platformcode/dbconverter.py @@ -52,7 +52,7 @@ def reload(): def add_video(item): global conn conn = sqlite3.connect(get_file_db()) - progress = platformtools.dialog_progress_bg('Sincronizzazione Libreria', item.title) + progress = platformtools.dialogProgressBg('Sincronizzazione Libreria', item.title) progress.update(0) if item.contentType == 'movie': start = time() @@ -70,10 +70,10 @@ def add_video(item): def get_path(item): logger.debug() p = item.strm_path if item.strm_path else item.nfo_path - path = filetools.join(config.get_videolibrary_config_path(), config.get_setting("folder_{}s".format(item.contentType)), p.split('\\')[0].split('/')[0]) - parent = filetools.join(config.get_videolibrary_config_path(), config.get_setting("folder_{}s".format(item.contentType))) + path = filetools.join(config.getVideolibraryConfigPath(), config.getSetting("folder_{}s".format(item.contentType)), p.split('\\')[0].split('/')[0]) + parent = filetools.join(config.getVideolibraryConfigPath(), config.getSetting("folder_{}s".format(item.contentType))) if item.contentType == 'movie': - filepath = filetools.join(config.get_videolibrary_config_path(), config.get_setting("folder_{}s".format(item.contentType)), p) + filepath = filetools.join(config.getVideolibraryConfigPath(), config.getSetting("folder_{}s".format(item.contentType)), p) file = item.strm_path.split('\\')[-1].split('/')[-1] return process_path(path), process_path(parent), file, filepath else: diff --git a/platformcode/download_and_play.py b/platformcode/download_and_play.py index dab22601..636f6940 100644 --- a/platformcode/download_and_play.py +++ b/platformcode/download_and_play.py @@ -37,14 +37,14 @@ def download_and_play(url, file_name, download_path): while True: cancelled = False dialog = xbmcgui.DialogProgress() - dialog.create(config.get_localized_string(60200), config.get_localized_string(60312)) + dialog.create(config.getLocalizedString(60200), config.getLocalizedString(60312)) dialog.update(0) while not cancelled and download_thread.is_alive(): - dialog.update(download_thread.get_progress(), config.get_localized_string(60313) + '\n' + - config.get_localized_string(60314) + str(int(old_div(download_thread.get_speed(), 1024))) + " KB/s " + str( - download_thread.get_actual_size()) + config.get_localized_string(60316) + str( download_thread.get_total_size()) + "MB", - config.get_localized_string(60202) % (str(downloadtools.sec_to_hms(download_thread.get_remaining_time())))) + dialog.update(download_thread.get_progress(), config.getLocalizedString(60313) + '\n' + + config.getLocalizedString(60314) + str(int(old_div(download_thread.get_speed(), 1024))) + " KB/s " + str( + download_thread.get_actual_size()) + config.getLocalizedString(60316) + str( download_thread.get_total_size()) + "MB", + config.getLocalizedString(60202) % (str(downloadtools.sec_to_hms(download_thread.get_remaining_time())))) xbmc.sleep(1000) if dialog.iscanceled(): @@ -189,7 +189,7 @@ class DownloadThread(threading.Thread): oldcwd = os.getcwd() logger.info("oldcwd= " + oldcwd) - cwd = os.path.join(config.get_runtime_path(), "tools") + cwd = os.path.join(config.getRuntimePath(), "tools") logger.info("cwd= " + cwd) os.chdir(cwd) logger.info("directory changed to= " + os.getcwd()) @@ -286,7 +286,7 @@ class DownloadThread(threading.Thread): logger.info("Force_stop file detected, download is interrupted") f.close() - xbmc.executebuiltin("Notification(%s,%s,300)" % (config.get_localized_string(60319),config.get_localized_string(60320))) + xbmc.executebuiltin("Notification(%s,%s,300)" % (config.getLocalizedString(60319),config.getLocalizedString(60320))) return diff --git a/platformcode/elementum_download.py b/platformcode/elementum_download.py index 87b7f416..830156cc 100644 --- a/platformcode/elementum_download.py +++ b/platformcode/elementum_download.py @@ -5,7 +5,7 @@ import xbmc, xbmcaddon, sys, platform host = 'https://github.com' elementum_url = host + '/elgatito/plugin.video.elementum/releases' -filename = filetools.join(config.get_data_path(),'elementum.zip') +filename = filetools.join(config.getDataPath(),'elementum.zip') addon_path = xbmc.translatePath('special://home/addons/') setting_path = xbmc.translatePath('special://profile/addon_data/') elementum_path = filetools.join(addon_path,'plugin.video.elementum') @@ -17,16 +17,16 @@ kod_setting_file = filetools.join(addon_path,'plugin.video.kod', 'resources', 's def download(item=None): if filetools.exists(elementum_path): - if platformtools.dialog_yesno(config.get_localized_string(70784), config.get_localized_string(70783)): + if platformtools.dialogYesNo(config.getLocalizedString(70784), config.getLocalizedString(70783)): addon_file = filetools.file_open(filetools.join(elementum_path,'addon.xml')).read() required = support.match(addon_file, patron=r'addon="([^"]+)').matches for r in required: xbmc.executebuiltin('InstallAddon(' + r + ')', wait=True) setting() - platformtools.dialog_ok('Elementum', config.get_localized_string(70783)) + platformtools.dialogOk('Elementum', config.getLocalizedString(70783)) else: - if platformtools.dialog_yesno(config.get_localized_string(70784), config.get_localized_string(70782)): - pform = get_platform() + if platformtools.dialogYesNo(config.getLocalizedString(70784), config.getLocalizedString(70782)): + pform = getPlatform() url = support.match(elementum_url, patronBlock=r'<div class="release-entry">(.*?)<!-- /.release-body -->', patron=r'<a href="([a-zA-Z0-9/\.-]+%s.zip)' % pform).match logger.debug('OS:', pform) logger.debug('Extract IN:', elementum_path) @@ -90,7 +90,7 @@ def setting(): filetools.remove(filename) -def get_platform(): +def getPlatform(): build = xbmc.getInfoLabel("System.BuildVersion") kodi_version = int(build.split()[0][:2]) ret = { diff --git a/platformcode/envtal.py b/platformcode/envtal.py index 62dd4b57..100aa9cd 100644 --- a/platformcode/envtal.py +++ b/platformcode/envtal.py @@ -32,7 +32,7 @@ def get_environment(): import base64 import ast - environment = config.get_platform(full_version=True) + environment = config.getXBMCPlatform(full_version=True) environment['num_version'] = str(environment['num_version']) environment['python_version'] = str(platform.python_version()) @@ -128,7 +128,7 @@ def get_environment(): except: pass - environment['userdata_path'] = str(xbmc.translatePath(config.get_data_path())) + environment['userdata_path'] = str(xbmc.translatePath(config.getDataPath())) try: if environment['os_name'].lower() == 'windows': free_bytes = ctypes.c_ulonglong(0) @@ -145,21 +145,21 @@ def get_environment(): environment['videolab_series'] = '?' environment['videolab_episodes'] = '?' environment['videolab_pelis'] = '?' - environment['videolab_path'] = str(xbmc.translatePath(config.get_videolibrary_path())) - if filetools.exists(filetools.join(environment['videolab_path'], config.get_setting("folder_tvshows"))): - environment['videolab_series'] = str(len(filetools.listdir(filetools.join(environment['videolab_path'], config.get_setting("folder_tvshows"))))) + environment['videolab_path'] = str(xbmc.translatePath(config.getVideolibraryPath())) + if filetools.exists(filetools.join(environment['videolab_path'], config.getSetting("folder_tvshows"))): + environment['videolab_series'] = str(len(filetools.listdir(filetools.join(environment['videolab_path'], config.getSetting("folder_tvshows"))))) counter = 0 - for root, folders, files in filetools.walk(filetools.join(environment['videolab_path'], config.get_setting("folder_tvshows"))): + for root, folders, files in filetools.walk(filetools.join(environment['videolab_path'], config.getSetting("folder_tvshows"))): for file in files: if file.endswith('.strm'): counter += 1 environment['videolab_episodes'] = str(counter) - if filetools.exists(filetools.join(environment['videolab_path'], config.get_setting("folder_movies"))): - environment['videolab_pelis'] = str(len(filetools.listdir(filetools.join(environment['videolab_path'], config.get_setting("folder_movies"))))) + if filetools.exists(filetools.join(environment['videolab_path'], config.getSetting("folder_movies"))): + environment['videolab_pelis'] = str(len(filetools.listdir(filetools.join(environment['videolab_path'], config.getSetting("folder_movies"))))) except: pass try: video_updates = ['No', 'Inicio', 'Una vez', 'Inicio+Una vez'] - environment['videolab_update'] = str(video_updates[config.get_setting("update", "videolibrary")]) + environment['videolab_update'] = str(video_updates[config.getSetting("update", "videolibrary")]) except: environment['videolab_update'] = '?' try: @@ -177,14 +177,14 @@ def get_environment(): # environment['torrent_list'] = [] # environment['torrentcli_option'] = '' # environment['torrent_error'] = '' - # environment['torrentcli_rar'] = config.get_setting("mct_rar_unpack", server="torrent", default=True) - # environment['torrentcli_backgr'] = config.get_setting("mct_background_download", server="torrent", default=True) - # environment['torrentcli_lib_path'] = config.get_setting("libtorrent_path", server="torrent", default="") + # environment['torrentcli_rar'] = config.getSetting("mct_rar_unpack", server="torrent", default=True) + # environment['torrentcli_backgr'] = config.getSetting("mct_background_download", server="torrent", default=True) + # environment['torrentcli_lib_path'] = config.getSetting("libtorrent_path", server="torrent", default="") # if environment['torrentcli_lib_path']: # lib_path = 'Activo' # else: # lib_path = 'Inactivo' - # environment['torrentcli_unrar'] = config.get_setting("unrar_path", server="torrent", default="") + # environment['torrentcli_unrar'] = config.getSetting("unrar_path", server="torrent", default="") # if environment['torrentcli_unrar']: # if xbmc.getCondVisibility("system.platform.Android"): # unrar = 'Android' @@ -196,33 +196,33 @@ def get_environment(): # unrar = scrapertools.find_single_match(unrar, '\/([^\/]+)\/$').capitalize() # else: # unrar = 'Inactivo' - # torrent_id = config.get_setting("torrent_client", server="torrent", default=0) + # torrent_id = config.getSetting("torrent_client", server="torrent", default=0) # environment['torrentcli_option'] = str(torrent_id) - # torrent_options = platformtools.torrent_client_installed() + # torrentOptions = platformtools.torrentClientInstalled() # if lib_path == 'Activo': - # torrent_options = ['MCT'] + torrent_options - # torrent_options = ['BT'] + torrent_options + # torrentOptions = ['MCT'] + torrentOptions + # torrentOptions = ['BT'] + torrentOptions # environment['torrent_list'].append({'Torrent_opt': str(torrent_id), 'Libtorrent': lib_path, \ # 'RAR_Auto': str(environment['torrentcli_rar']), \ # 'RAR_backgr': str(environment['torrentcli_backgr']), \ # 'UnRAR': unrar}) - # environment['torrent_error'] = config.get_setting("libtorrent_error", server="torrent", default="") + # environment['torrent_error'] = config.getSetting("libtorrent_error", server="torrent", default="") # if environment['torrent_error']: # environment['torrent_list'].append({'Libtorrent_error': environment['torrent_error']}) - # for torrent_option in torrent_options: + # for torrent_option in torrentOptions: # cliente = dict() # cliente['D_load_Path'] = '' # cliente['Libre'] = '?' # cliente['Plug_in'] = torrent_option.replace('Plugin externo: ', '') # if cliente['Plug_in'] == 'BT': - # cliente['D_load_Path'] = str(config.get_setting("bt_download_path", server="torrent", default='')) + # cliente['D_load_Path'] = str(config.getSetting("bt_download_path", server="torrent", default='')) # if not cliente['D_load_Path']: continue - # cliente['Buffer'] = str(config.get_setting("bt_buffer", server="torrent", default=50)) + # cliente['Buffer'] = str(config.getSetting("bt_buffer", server="torrent", default=50)) # elif cliente['Plug_in'] == 'MCT': - # cliente['D_load_Path'] = str(config.get_setting("mct_download_path", server="torrent", default='')) + # cliente['D_load_Path'] = str(config.getSetting("mct_download_path", server="torrent", default='')) # if not cliente['D_load_Path']: continue - # cliente['Buffer'] = str(config.get_setting("mct_buffer", server="torrent", default=50)) + # cliente['Buffer'] = str(config.getSetting("mct_buffer", server="torrent", default=50)) # elif xbmc.getCondVisibility('System.HasAddon("plugin.video.%s")' % cliente['Plug_in']): # __settings__ = xbmcaddon.Addon(id="plugin.video.%s" % cliente['Plug_in']) # cliente['Plug_in'] = cliente['Plug_in'].capitalize() @@ -258,7 +258,7 @@ def get_environment(): environment['proxy_active'] = '' try: - proxy_channel_bloqued_str = base64.b64decode(config.get_setting('proxy_channel_bloqued')).decode('utf-8') + proxy_channel_bloqued_str = base64.b64decode(config.getSetting('proxy_channel_bloqued')).decode('utf-8') proxy_channel_bloqued = dict() proxy_channel_bloqued = ast.literal_eval(proxy_channel_bloqued_str) for channel_bloqued, proxy_active in list(proxy_channel_bloqued.items()): @@ -289,8 +289,8 @@ def get_environment(): environment['log_size_bytes'] = '' environment['log_size'] = '' - environment['debug'] = str(config.get_setting('debug')) - environment['addon_version'] = str(config.get_addon_version()) + environment['debug'] = str(config.getSetting('debug')) + environment['addon_version'] = str(config.getAddonVersion()) except: logger.error(traceback.format_exc()) diff --git a/platformcode/infoplus.py b/platformcode/infoplus.py index 75cfab1d..52a871eb 100644 --- a/platformcode/infoplus.py +++ b/platformcode/infoplus.py @@ -39,7 +39,7 @@ BACKSPACE = 92 def start(item): xbmc.executebuiltin('Dialog.Close(all)') - InfoPlus('InfoPlus.xml', config.get_runtime_path(), item=item) + InfoPlus('InfoPlus.xml', config.getRuntimePath(), item=item) class InfoPlus(xbmcgui.WindowXML): def __init__(self, *args, **kwargs): @@ -57,7 +57,7 @@ class InfoPlus(xbmcgui.WindowXML): self.fanarts = [] self.collection = [] if not self.item.focus: self.item.focus = {} - platformtools.dialog_busy(True) + platformtools.dialogBusy(True) if self.item: # Find Video Info @@ -88,7 +88,7 @@ class InfoPlus(xbmcgui.WindowXML): self.listitem.setProperty('info',info) # Set infoLabels - platformtools.set_infolabels(self.listitem, self.item) + platformtools.setInfolabels(self.listitem, self.item) # Add Cast Info for cast in self.info.get('castandrole',[]): @@ -128,9 +128,9 @@ class InfoPlus(xbmcgui.WindowXML): self.get_trailers() # Add Fanart - self.get_fanarts() + self.getFanarts() - platformtools.dialog_busy(False) + platformtools.dialogBusy(False) self.doModal() @@ -199,10 +199,10 @@ class InfoPlus(xbmcgui.WindowXML): self.item.text = self.item.contentTitle titles = [self.item.text] + [original] if original else [] if original and original != self.item.text: - selection = platformtools.dialog_select(config.get_localized_string(90010), titles) + selection = platformtools.dialogSelect(config.getLocalizedString(90010), titles) if selection > -1: self.item.text = titles[selection] - self.item.mode = 'search_' + self.item.contentType + self.item.mode = 'search/' + self.item.contentType item = self.item.clone(channel='globalsearch', action='new_search') xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + item.tourl() + ")") # new_search(self.item.clone()) @@ -263,7 +263,7 @@ class InfoPlus(xbmcgui.WindowXML): traileitem.setArt({'thumb':'http://img.youtube.com/vi/' + trailer['url'].split('=')[-1] + '/0.jpg'}) self.trailers.append(traileitem) - def get_fanarts(self): + def getFanarts(self): _id = self.info.get('tmdb_id') res = {} fanarts = self.info.get('fanarts',[]) @@ -284,7 +284,7 @@ class InfoPlus(xbmcgui.WindowXML): def showCast(item): xbmc.executebuiltin('Dialog.Close(all)') - CastWindow('CastWindow.xml', config.get_runtime_path(), item=item) + CastWindow('CastWindow.xml', config.getRuntimePath(), item=item) class CastWindow(xbmcgui.WindowXML): def __init__(self, *args, **kwargs): self.item = kwargs.get('item') @@ -296,10 +296,10 @@ class CastWindow(xbmcgui.WindowXML): self.tvshowItems = [] if not self.item.focus: self.item.focus = {} if self.item: - platformtools.dialog_busy(True) + platformtools.dialogBusy(True) self.get_person_info() self.get_credits() - platformtools.dialog_busy(False) + platformtools.dialogBusy(False) self.doModal() def get_person_info(self): @@ -413,7 +413,7 @@ class CastWindow(xbmcgui.WindowXML): rating = video.get('vote_average', 'N/A') color = 'FFFFFFFF' if rating == 'N/A' else 'FFDB2360' if rating < 4 else 'FFD2D531' if rating < 7 else 'FF21D07A' videoitem.setProperties({'rating':str(int(video.get('vote_average',10) * 10)), 'color':color}) - platformtools.set_infolabels(videoitem, item) + platformtools.setInfolabels(videoitem, item) if video.get('media_type') == 'movie': self.movies.append(videoitem) self.movieItems.append(item) @@ -424,7 +424,7 @@ class CastWindow(xbmcgui.WindowXML): def showImages(images, position): xbmc.executebuiltin('Dialog.Close(all)') - return ImagesWindow('imageWindow.xml', config.get_runtime_path()).start(images=images, position=position) + return ImagesWindow('imageWindow.xml', config.getRuntimePath()).start(images=images, position=position) class ImagesWindow(xbmcgui.WindowXMLDialog): def start(self, *args, **kwargs): self.images = [] diff --git a/platformcode/keymaptools.py b/platformcode/keymaptools.py index 34d56e30..fc7e3443 100644 --- a/platformcode/keymaptools.py +++ b/platformcode/keymaptools.py @@ -7,13 +7,12 @@ from platformcode import config, logger, platformtools, launcher from core import filetools from core.item import Item import channelselector -addon_icon = filetools.join( config.__settings__.getAddonInfo( "path" ),'resources', 'media', 'logo.png' ) background = 'FF232323' overlay = '77232323' text = 'FFFFFFFF' select = 'FF0082C2' -if config.get_setting('icon_set') == 'dark': +if config.getSetting('icon_set') == 'dark': background = 'FFDCDCDC' overlay = '77DCDCDC' text = 'FF232323' @@ -37,13 +36,13 @@ class KeyListener(xbmcgui.WindowXMLDialog): def onInit(self): try: - self.getControl(400).setImage(addon_icon) - self.getControl(401).addLabel(config.get_localized_string(70698)) - self.getControl(402).addLabel(config.get_localized_string(70699) % self.TIMEOUT) + self.getControl(400).setImage(config.addonIcon) + self.getControl(401).addLabel(config.getLocalizedString(70698)) + self.getControl(402).addLabel(config.getLocalizedString(70699) % self.TIMEOUT) except AttributeError: - self.getControl(400).setImage(addon_icon) - self.getControl(401).setLabel(config.get_localized_string(70698)) - self.getControl(402).setLabel(config.get_localized_string(70699) % self.TIMEOUT) + self.getControl(400).setImage(config.addonIcon) + self.getControl(401).setLabel(config.getLocalizedString(70698)) + self.getControl(402).setLabel(config.getLocalizedString(70699) % self.TIMEOUT) def onAction(self, action): @@ -68,7 +67,7 @@ class KeyListener(xbmcgui.WindowXMLDialog): def set_key(): - saved_key = config.get_setting("shortcut_key") + saved_key = config.getSetting("shortcut_key") new_key = KeyListener().record_key() if new_key and saved_key != new_key: @@ -76,13 +75,14 @@ def set_key(): from platformcode import platformtools import xbmc file_xml = "special://profile/keymaps/kod.xml" - data = '<keymap><global><keyboard><key id="%s">' % new_key + 'runplugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiAia2V5bWFwIiwNCiAgICAib3BlbiI6IHRydWUNCn0=)</key></keyboard></global></keymap>' + data = '<keymap><global><keyboard><key id="%s">' % new_key + 'runplugin(plugin://plugin.video.kod/?channel=shortcuts&action=shortcut_menu)</key></keyboard></global></keymap>' filetools.write(xbmc.translatePath(file_xml), data) - # platformtools.dialog_notification(config.get_localized_string(70700),config.get_localized_string(70702),4) + # platformtools.dialogNotification(config.getLocalizedString(70700),config.getLocalizedString(70702),4) - config.set_setting("shortcut_key", new_key) + config.setSetting("shortcut_key", new_key) + xbmc.executebuiltin('Action(reloadkeymaps)') - return + # return def delete_key(): @@ -91,9 +91,9 @@ def delete_key(): import xbmc filetools.remove(xbmc.translatePath( "special://profile/keymaps/kod.xml")) - # platformtools.dialog_notification(config.get_localized_string(70701),config.get_localized_string(70702),4) + # platformtools.dialogNotification(config.getLocalizedString(70701),config.getLocalizedString(70702),4) - config.set_setting("shortcut_key", '') + config.setSetting("shortcut_key", '') xbmc.executebuiltin('Action(reloadkeymaps)') LEFT = 1 @@ -113,7 +113,7 @@ class Main(xbmcgui.WindowXMLDialog): self.MENU = self.getControl(1) self.SUBMENU = self.getControl(2) #### Compatibility with Kodi 18 #### - if config.get_platform(True)['num_version'] < 18: + if config.getXBMCPlatform(True)['num_version'] < 18: self.setCoordinateResolution(2) itemlist = self.menulist(channelselector.getmainlist()) @@ -160,7 +160,7 @@ class Main(xbmcgui.WindowXMLDialog): def onAction(self, action): - if action.getButtonCode() == config.get_setting('shortcut_key'): + if action.getButtonCode() == config.getSetting('shortcut_key'): self.close() action = action.getId() @@ -186,7 +186,7 @@ class Main(xbmcgui.WindowXMLDialog): import channelselector itemlist = self.menulist(channelselector.getchanneltypes()) elif channel_name not in ['downloads', 'setting', 'help']: - channel = platformtools.channel_import(channel_name) + channel = platformtools.channelImport(channel_name) itemlist = self.menulist(channel.mainlist(Item().fromurl(self.MENU.getSelectedItem().getProperty('run')))) self.SUBMENU.reset() self.SUBMENU.addItems(itemlist) @@ -196,7 +196,7 @@ class Main(xbmcgui.WindowXMLDialog): focus = self.getFocusId() item_url = self.MENU.getSelectedItem().getProperty('run') item = Item().fromurl(item_url) - commands = platformtools.set_context_commands(item, item_url, Item()) + commands = platformtools.setContextCommands(item, item_url, Item()) context = [c[0] for c in commands] context_commands = [c[1].replace('Container.Refresh', 'RunPlugin').replace('Container.Update', 'RunPlugin') for c in commands] index = xbmcgui.Dialog().contextmenu(context) @@ -205,5 +205,5 @@ class Main(xbmcgui.WindowXMLDialog): def open_shortcut_menu(): if xbmcgui.getCurrentWindowDialogId() == 9999: - main = Main('ShortCutMenu.xml', config.get_runtime_path()) + main = Main('ShortCutMenu.xml', config.getRuntimePath()) main.doModal() diff --git a/platformcode/launcher.py b/platformcode/launcher.py index bd2b8b48..682bf09a 100644 --- a/platformcode/launcher.py +++ b/platformcode/launcher.py @@ -3,33 +3,28 @@ # XBMC Launcher (xbmc / kodi) # ------------------------------------------------------------ -from specials import videolibrary -import sys, os - -PY3 = False -if sys.version_info[0] >= 3:PY3 = True; unicode = str; unichr = chr; long = int - +import sys from core.item import Item -from core import filetools, videolibrarydb +from core import filetools from platformcode import config, logger, platformtools from platformcode.logger import WebErrorException -temp_search_file = config.get_temp_file('temp-search') def start(): - """ First function that is executed when entering the plugin. + ''' + First function that is executed when entering the plugin. Within this function all calls should go to functions that we want to execute as soon as we open the plugin. - """ + ''' logger.debug() - if not config.dev_mode(): + if not config.devMode(): try: with open(config.changelogFile, 'r') as fileC: changelog = fileC.read() if changelog.strip(): - platformtools.dialog_ok('Kodi on Demand', 'Aggiornamenti applicati:\n' + changelog) - os.remove(config.changelogFile) + platformtools.dialogOk('Kodi on Demand', 'Aggiornamenti applicati:\n' + changelog) + filetools.remove(config.changelogFile) except: pass @@ -37,297 +32,57 @@ def start(): def run(item=None): logger.debug() - if not item: - # Extract item from sys.argv - if sys.argv[2]: - sp = sys.argv[2].split('&') - url = sp[0] - item = Item().fromurl(url) - if len(sp) > 1: - for e in sp[1:]: - key, val = e.split('=') - if val.lower() == 'false': val = False - elif val.lower() == 'true': val = True - item.__setattr__(key, val) - # If no item, this is mainlist - else: - item = Item(channel="channelselector", action="getmainlist", viewmode="movie") - if not config.get_setting('show_once'): - if not config.get_all_settings_addon(): - logger.error('corrupted settings.xml!!') - settings_xml = os.path.join(config.get_data_path(), "settings.xml") - settings_bak = os.path.join(config.get_data_path(), "settings.bak") - if filetools.exists(settings_bak): - filetools.copy(settings_bak, settings_xml, True) - logger.info('restored settings.xml from backup') - else: - filetools.write(settings_xml, '<settings version="2">\n</settings>') # resetted settings - else: - from platformcode import xbmc_videolibrary - xbmc_videolibrary.ask_set_content(silent=False) - config.set_setting('show_once', True) + # Extract item from sys.argv + if not item: item = makeItem() - logger.info(item.tostring()) + # Load or Repare Settings + if not config.getSetting('show_once'): showOnce() + + # Acrions + logger.debug(item.tostring()) try: - if not config.get_setting('tmdb_active'): - config.set_setting('tmdb_active', True) + # Active tmdb + if not config.getSetting('tmdb_active'): + config.setSetting('tmdb_active', True) # If item has no action, stops here - if item.action == "": - logger.debug("Item without action") + if item.action == '': + logger.debug('Item without action') return - # Action for main menu in channelselector - elif item.action == "getmainlist": + # Channel Selector + if item.channel == 'channelselector': + itemlist = [] import channelselector + if item.action == 'getmainlist': # Action for main menu in channelselector + itemlist = channelselector.getmainlist() + elif item.action == 'getchanneltypes': # Action for channel types on channelselector: movies, series, etc. + itemlist = channelselector.getchanneltypes() + elif item.action == 'filterchannels': # Action for channel listing on channelselector + itemlist = channelselector.filterchannels(item.channel_type) + platformtools.renderItems(itemlist, item) - itemlist = channelselector.getmainlist() - - platformtools.render_items(itemlist, item) - - # Action for channel types on channelselector: movies, series, etc. - elif item.action == "getchanneltypes": - import channelselector - itemlist = channelselector.getchanneltypes() - - platformtools.render_items(itemlist, item) - - # Action for channel listing on channelselector - elif item.action == "filterchannels": - import channelselector - itemlist = channelselector.filterchannels(item.channel_type) - - platformtools.render_items(itemlist, item) # Special action for playing a video from the library - elif item.action == "play_from_library": - play_from_library(item) - return + elif item.action in ['playFromLibrary', 'play_from_library']: + return playFromLibrary(item) - elif item.action == "keymap": - from platformcode import keymaptools - if item.open: - return keymaptools.open_shortcut_menu() - else: - return keymaptools.set_key() + # Special play action + elif item.action == 'play': play(item) - elif item.channel == "infoplus": - from platformcode import infoplus - return getattr(infoplus, item.action)(item) + # Special findvideos Action + elif item.action == 'findvideos': findvideos(item) - elif item.channel == 'trakt_tools': - from core import trakt_tools - action = getattr(trakt_tools, item.action) - return action(item) + # Special action for adding a movie or serie to the library + elif item.action == 'add_to_library': addToLibrary(item) - elif item.channel == "backup": - from platformcode import backup - return getattr(backup, item.action)(item) + # Special action for searching, first asks for the words then call the "search" function + elif item.action == 'search': search(item) - elif item.channel == "elementum_download": - from platformcode import elementum_download - return getattr(elementum_download, item.action)(item) + # For all other actions + else: actions(item) - elif item.channel == "shortcuts": - from platformcode import shortcuts - return getattr(shortcuts, item.action)(item) - - elif item.channel == "autorenumber": - from platformcode import autorenumber - return getattr(autorenumber, item.action)(item) - - elif item.action == "delete_key": - from platformcode import keymaptools - return keymaptools.delete_key() - - elif item.action == "script": - from core import tmdb - tmdb.clean_cache() - platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(60011), time=2000, sound=False) - elif item.action == "itemInfo": - platformtools.dialog_textviewer('Item info', item.parent) - elif item.action == "open_browser": - import webbrowser - if not webbrowser.open(item.url): - import xbmc - if xbmc.getCondVisibility('system.platform.linux') and xbmc.getCondVisibility('system.platform.android'): # android - xbmc.executebuiltin('StartAndroidActivity("", "android.intent.action.VIEW", "", "%s")' % item.url) - else: - platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(70740) % "\n".join([item.url[j:j+57] for j in range(0, len(item.url), 57)])) - elif item.action == "gotopage": - from core import scrapertools - head = config.get_localized_string(70511) - scraped_page = scrapertools.find_single_match(item.url,'[=/]([0-9]+)') - if item.total_pages and (item.page or scraped_page.isdigit()): - pages = [str(p) for p in range(1, item.total_pages + 1)] - page = item.page if item.page else int(scraped_page) - page = platformtools.dialog_select(head, pages, page - 2) + 1 - else: - page = platformtools.dialog_numeric(0, head) - if page and int(page) > -1: - import xbmc - item.action = item.real_action - item.page = int(page) - import re - item.url = re.sub('([=/])[0-9]+(/?)$', '\g<1>{}\g<2>'.format(page), item.url) - xbmc.executebuiltin("Container.Update(%s?%s)" % (sys.argv[0], item.tourl())) - - elif item.action == "gotoseason": - head = 'Seleziona la stagione' - seasons = [str(s) for s in item.allSeasons] - season = platformtools.dialog_select(head, seasons, item.nextSeason - 1) - if int(season) > -1: - import xbmc - item.action = item.real_action - item.nextSeason = season - xbmc.executebuiltin("Container.Update(%s?%s)" % (sys.argv[0], item.tourl())) - else: - channel = platformtools.channel_import(item.channel) - if not channel: - return - - logger.info("Running channel %s | %s" % (channel.__name__, channel.__file__)) - - # Special play action - if item.action == "play": - # define la info para trakt - try: - from core import trakt_tools - trakt_tools.set_trakt_info(item) - except: - pass - logger.debug("item.action=%s" % item.action.upper()) - # logger.debug("item_toPlay: " + "\n" + item.tostring('\n')) - - # First checks if channel has a "play" function - if hasattr(channel, 'play'): - logger.debug("Executing channel 'play' method") - itemlist = channel.play(item) - b_favourite = item.isFavourite - # Play should return a list of playable URLS - if len(itemlist) > 0 and isinstance(itemlist[0], Item): - item = itemlist[0] - if b_favourite: - item.isFavourite = True - platformtools.play_video(item) - - # Permitir varias calidades desde play en el Channel - elif len(itemlist) > 0 and isinstance(itemlist[0], list): - item.video_urls = itemlist - platformtools.play_video(item) - - # If not, shows user an error message - else: - platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(60339)) - - # If player don't have a "play" function, not uses the standard play from platformtools - else: - logger.debug("Executing core 'play' method") - platformtools.play_video(item) - - # Special action for findvideos, where the plugin looks for known urls - elif item.action == "findvideos": - # logger.dbg() - from core import servertools - p_dialog = None - if item.window: - p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(60683)) - p_dialog.update(0) - - # First checks if channel has a "findvideos" function - if hasattr(channel, 'findvideos'): - itemlist = getattr(channel, item.action)(item) - - # If not, uses the generic findvideos function - else: - logger.debug("No channel 'findvideos' method, " "executing core method") - itemlist = servertools.find_video_items(item) - - if config.get_setting("max_links", "videolibrary") != 0: - itemlist = limit_itemlist(itemlist) - - if p_dialog: - p_dialog.update(100) - p_dialog.close() - platformtools.serverwindow(item, itemlist) - else: - platformtools.render_items(itemlist, item) - - # Special action for adding a movie to the library - elif item.action == "add_movie_to_library": - from core import videolibrarytools - videolibrarytools.add_movie(item) - - # Special action for adding a serie to the library - elif item.action == "add_serie_to_library": - from core import videolibrarytools - videolibrarytools.add_tvshow(item, channel) - - # Special action for adding a serie to the library - elif item.action == "add_to_library": - from core import videolibrarytools - videolibrarytools.add_to_videolibrary(item, channel) - - # Special action for downloading all episodes from a serie - elif item.action == "download_all_episodes": - from specials import downloads - item.action = item.extra - del item.extra - downloads.save_download(item) - - # Special action for searching, first asks for the words then call the "search" function - elif item.action == "search": - if filetools.isfile(temp_search_file) and config.get_setting('videolibrary_kodi'): - itemlist = [] - f = filetools.read(temp_search_file) - strList = f.split(',') - if strList[0] == '[V]' and strList[1] == item.channel: - for it in strList: - if it and it not in ['[V]', item.channel]: - itemlist.append(Item().fromurl(it)) - filetools.write(temp_search_file, f[4:]) - return platformtools.render_items(itemlist, item) - else: - filetools.remove(temp_search_file) - - logger.debug("item.action=%s" % item.action.upper()) - from core import channeltools - - if config.get_setting('last_search'): - last_search = channeltools.get_channel_setting('Last_searched', 'search', '') - else: - last_search = '' - - search_text = platformtools.dialog_input(last_search) - - if search_text is not None: - channeltools.set_channel_setting('Last_searched', search_text, 'search') - itemlist = new_search(item.clone(text=search_text), channel) - else: - return - - platformtools.render_items(itemlist, item) - - # For all other actions - else: - # import web_pdb; web_pdb.set_trace() - logger.debug("Executing channel '%s' method" % item.action) - itemlist = getattr(channel, item.action)(item) - if config.get_setting('trakt_sync'): - from core import trakt_tools - token_auth = config.get_setting("token_trakt", "trakt") - if not token_auth: - trakt_tools.auth_trakt() - else: - import xbmc - if not xbmc.getCondVisibility('System.HasAddon(script.trakt)') and config.get_setting('install_trakt'): - trakt_tools.ask_install_script() - itemlist = trakt_tools.trakt_check(itemlist) - else: - config.set_setting('install_trakt', True) - - platformtools.render_items(itemlist, item) except WebErrorException as e: @@ -336,27 +91,28 @@ def run(item=None): logger.error(traceback.format_exc()) - platformtools.dialog_ok( - config.get_localized_string(59985) % e.channel, - config.get_localized_string(60013) % e.url) + platformtools.dialogOk( + config.getLocalizedString(59985) % e.channel, + config.getLocalizedString(60013) % e.url) + except Exception as e: import traceback from core import scrapertools logger.error(traceback.format_exc()) - patron = 'File "' + os.path.join(config.get_runtime_path(), "channels", "").replace("\\", "\\\\") + r'([^.]+)\.py"' + patron = r'File "{}([^.]+)\.py"'.format(filetools.join(config.getRuntimePath(), 'channels', '').replace('\\', '\\\\')) Channel = scrapertools.find_single_match(traceback.format_exc(), patron) if Channel or e.__class__ == logger.ChannelScraperException: if item.url: - if platformtools.dialog_yesno(config.get_localized_string(60087) % Channel, config.get_localized_string(60014), nolabel='ok', yeslabel=config.get_localized_string(70739)): - run(Item(action="open_browser", url=item.url)) + if platformtools.dialogYesNo(config.getLocalizedString(60087) % Channel, config.getLocalizedString(60014), nolabel='ok', yeslabel=config.getLocalizedString(70739)): + run(Item(action='open_browser', url=item.url)) else: - platformtools.dialog_ok(config.get_localized_string(60087) % Channel, config.get_localized_string(60014)) + platformtools.dialogOk(config.getLocalizedString(60087) % Channel, config.getLocalizedString(60014)) else: - if platformtools.dialog_yesno(config.get_localized_string(60038), config.get_localized_string(60015)): - platformtools.itemlist_update(Item(channel="setting", action="report_menu"), True) + if platformtools.dialogYesNo(config.getLocalizedString(60038), config.getLocalizedString(60015)): + platformtools.itemlistUpdate(Item(channel='setting', action='report_menu'), True) finally: # db need to be closed when not used, it will cause freezes from core import db @@ -374,112 +130,185 @@ def new_search(item, channel=None): writelist = item.channel for it in itemlist: writelist += ',' + it.tourl() - filetools.write(temp_search_file, writelist) + # filetools.write(temp_search_file, writelist) return itemlist -def set_search_temp(item): - if filetools.isfile(temp_search_file) and config.get_setting('videolibrary_kodi'): - f = '[V],' + filetools.read(temp_search_file) - filetools.write(temp_search_file, f) +# def set_search_temp(item): +# if filetools.isfile(temp_search_file) and config.getSetting('videolibrary_kodi'): +# f = '[V],' + filetools.read(temp_search_file) +# filetools.write(temp_search_file, f) -def reorder_itemlist(itemlist): + +def limitItemlist(itemlist): logger.debug() - # logger.debug("Inlet itemlist size: %i" % len(itemlist)) - - new_list = [] - mod_list = [] - not_mod_list = [] - - modified = 0 - not_modified = 0 - - to_change = [[config.get_localized_string(60335), '[V]'], [config.get_localized_string(60336), '[D]']] - - for item in itemlist: - if not PY3: - old_title = unicode(item.title, "utf8").lower().encode("utf8") - else: - old_title = item.title.lower() - for before, after in to_change: - if before in item.title: - item.title = item.title.replace(before, after) - break - - if not PY3: - new_title = unicode(item.title, "utf8").lower().encode("utf8") - else: - new_title = item.title.lower() - if old_title != new_title: - mod_list.append(item) - modified += 1 - else: - not_mod_list.append(item) - not_modified += 1 - - # logger.debug("OLD: %s | NEW: %s" % (old_title, new_title)) - - new_list.extend(mod_list) - new_list.extend(not_mod_list) - - logger.debug("Modified Titles:%i |Unmodified:%i" % (modified, not_modified)) - - if len(new_list) == 0: - new_list = itemlist - - # logger.debug("Outlet itemlist size: %i" % len(new_list)) - return new_list - - -def limit_itemlist(itemlist): - logger.debug() - # logger.debug("Inlet itemlist size: %i" % len(itemlist)) - try: - opt = config.get_setting("max_links", "videolibrary") - if opt == 0: + value = config.getSetting('max_links', 'videolibrary') + if value == 0: new_list = itemlist else: - i_max = 30 * opt - new_list = itemlist[:i_max] - - # logger.debug("Outlet itemlist size: %i" % len(new_list)) + new_list = itemlist[:value] return new_list except: return itemlist -def play_from_library(item): - """ - The .strm files when played from kodi, this expects it to be a "playable" file so it cannot contain - more items, at most a selection dialog can be placed. - We solve this by "cheating kodi" and making him believe that something has been reproduced, so later by - "Container.Update ()" we load the strm as if an item from inside the addon were treated, removing all - the limitations and allowing to reproduce through the general function without having to create new methods to - the video library. - @type item: item - @param item: item with information - """ - - import xbmc, xbmcgui, xbmcplugin - - platformtools.window_type(item) - platformtools.prevent_busy(item) - item.action = item.next_action if item.next_action else 'findvideos' - - if not item.videolibrary_id: - if item.window and item.action == 'findvideos': - return run(item) - else: - xbmc.executebuiltin("Container.Update(" + sys.argv[0] + "?" + item.tourl() + ")") - - elif xbmc.getCondVisibility('Window.IsMedia') and not item.window: - if item.contentType == 'episode': - it = videolibrarydb[item.contentType][item.videolibrary_id]['{}x{:02d}'.format(item.infoLabels['season'], item.infoLabels['episode'])]['item'] - else: - it = videolibrarydb[item.contentType][item.videolibrary_id]['item'] - it.from_library = True - xbmc.executebuiltin("Container.Update(" + sys.argv[0] + "?" + it.tourl() + ")") - videolibrarydb.close() +def makeItem(): + logger.debug() + if sys.argv[2]: + sp = sys.argv[2].split('&') + url = sp[0] + item = Item().fromurl(url) + if len(sp) > 1: + for e in sp[1:]: + key, val = e.split('=') + if val.lower() == 'false': val = False + elif val.lower() == 'true': val = True + item.__setattr__(key, val) + # If no item, this is mainlist else: - item.window = True - return run(item) + item = Item(channel='channelselector', action='getmainlist', viewmode='movie') + + return item + + +def showOnce(): + if not config.getAllSettingsAddon(): + logger.error('corrupted settings.xml!!') + settings_xml = filetools.join(config.getDataPath(), 'settings.xml') + settings_bak = filetools.join(config.getDataPath(), 'settings.bak') + if filetools.exists(settings_bak): + filetools.copy(settings_bak, settings_xml, True) + logger.info('restored settings.xml from backup') + else: + filetools.write(settings_xml, '<settings version="2">\n</settings>') # resetted settings + else: + from platformcode import xbmc_videolibrary + xbmc_videolibrary.ask_set_content(silent=False) + config.setSetting('show_once', True) + + +def play(item): + channel = importChannel(item) + # platformtools.fakeVideo() + # define la info para trakt + try: + from core import trakt_tools + trakt_tools.set_trakt_info(item) + except: + pass + logger.debug('item.action=', item.action.upper()) + + # First checks if channel has a "play" function + if hasattr(channel, 'play'): + logger.debug('Executing channel "play" method') + itemlist = channel.play(item) + # Play should return a list of playable URLS + if len(itemlist) > 0 and isinstance(itemlist[0], Item): + item = itemlist[0] + platformtools.playVideo(item) + + # Allow several qualities from Play in El Channel + elif len(itemlist) > 0 and isinstance(itemlist[0], list): + item.videoUrls = itemlist + platformtools.playVideo(item) + + # If not, shows user an error message + else: + platformtools.dialogOk(config.getLocalizedString(20000), config.getLocalizedString(60339)) + + # If player don't have a "play" function, not uses the standard play from platformtools + else: + logger.debug('Executing core "play" method') + platformtools.playVideo(item) + + +def findvideos(item): + logger.debug('Executing channel', item.channel, 'method', item.action) + channel = importChannel(item) + from core import servertools + + p_dialog = platformtools.dialogProgressBg(config.getLocalizedString(20000), config.getLocalizedString(60683)) + p_dialog.update(0) + + # First checks if channel has a "findvideos" function + if hasattr(channel, 'findvideos'): + itemlist = getattr(channel, item.action)(item) + + # If not, uses the generic findvideos function + else: + logger.debug('No channel "findvideos" method, executing core method') + itemlist = servertools.find_video_items(item) + + itemlist = limitItemlist(itemlist) + + p_dialog.update(100) + p_dialog.close() + + # If there is only one server play it immediately + if len(itemlist) == 1 or len(itemlist) > 1 and not itemlist[1].server: + play(itemlist[0].clone(no_return=True)) + else: + platformtools.serverWindow(item, itemlist) + + +def search(item): + channel = importChannel(item) + from core import channeltools + + if config.getSetting('last_search'): + last_search = channeltools.getChannelSetting('Last_searched', 'search', '') + else: + last_search = '' + + search_text = platformtools.dialogInput(last_search) + + if search_text is not None: + channeltools.setChannelSetting('Last_searched', search_text, 'search') + itemlist = new_search(item.clone(text=search_text), channel) + else: + return + + platformtools.renderItems(itemlist, item) + + +def addToLibrary(item): + channel = importChannel(item) + from core import videolibrarytools + videolibrarytools.add_to_videolibrary(item, channel) + + +def importChannel(item): + channel = platformtools.channelImport(item.channel) + if not channel: + logger.debug('Channel', item.channel, 'not exist!') + return + + logger.debug('Running channel', channel.__name__, '|', channel.__file__) + return channel + + +def actions(item): + logger.debug('Executing channel', item.channel, 'method', item.action) + channel = importChannel(item) + itemlist = getattr(channel, item.action)(item) + if config.getSetting('trakt_sync'): + from core import trakt_tools + token_auth = config.getSetting('token_trakt', 'trakt') + if not token_auth: + trakt_tools.auth_trakt() + else: + import xbmc + if not xbmc.getCondVisibility('System.HasAddon(script.trakt)') and config.getSetting('install_trakt'): + trakt_tools.ask_install_script() + itemlist = trakt_tools.trakt_check(itemlist) + else: + config.setSetting('install_trakt', True) + + platformtools.renderItems(itemlist, item) + + +def playFromLibrary(item): + platformtools.fakeVideo() + item.action = item.next_action if item.next_action else 'findvideos' + logger.debug('Executing channel', item.channel, 'method', item.action) + return run(item) diff --git a/platformcode/logger.py b/platformcode/logger.py index 80c3a3ab..6fcd5302 100644 --- a/platformcode/logger.py +++ b/platformcode/logger.py @@ -16,7 +16,7 @@ try: except: testMode = False LOG_FORMAT = '{addname}[{filename}.{function}:{line}]{sep} {message}' -DEBUG_ENABLED = config.get_setting("debug") +DEBUG_ENABLED = config.getSetting("debug") DEF_LEVEL = xbmc.LOGINFO if sys.version_info[0] >= 3 else xbmc.LOGNOTICE @@ -52,7 +52,7 @@ def log(*args, **kwargs): message=msg), kwargs.get('level', DEF_LEVEL)) def dbg(open=True): - if config.dev_mode(): + if config.devMode(): try: import web_pdb if not web_pdb.WebPdb.active_instance and open: diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index 2a86bea8..cd99d74a 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -23,34 +23,27 @@ from core.item import Item from platformcode import logger, config addon = config.__settings__ -addon_icon = os.path.join( addon.getAddonInfo( "path" ),'resources', 'media', "logo.png" ) -# class XBMCPlayer(xbmc.Player): +xbmcPlayer = xbmc.Player() -# def __init__(self, *args): -# pass +playCanceled = False -xbmc_player = xbmc.Player() - -play_canceled = False - - -def dialog_ok(heading, message): +def dialogOk(heading, message): dialog = xbmcgui.Dialog() return dialog.ok(heading, message) -def dialog_notification(heading, message, icon=3, time=5000, sound=True): +def dialogNotification(heading, message, icon=3, time=5000, sound=True): dialog = xbmcgui.Dialog() try: - l_icono = [xbmcgui.NOTIFICATION_INFO, xbmcgui.NOTIFICATION_WARNING, xbmcgui.NOTIFICATION_ERROR, addon_icon] + l_icono = [xbmcgui.NOTIFICATION_INFO, xbmcgui.NOTIFICATION_WARNING, xbmcgui.NOTIFICATION_ERROR, config.addonIcon] dialog.notification(heading, message, l_icono[icon], time, sound) except: - dialog_ok(heading, message) + dialogOk(heading, message) -def dialog_yesno(heading, message, nolabel=config.get_localized_string(70170), yeslabel=config.get_localized_string(30022), autoclose=0, customlabel=None): +def dialogYesNo(heading, message, nolabel=config.getLocalizedString(70170), yeslabel=config.getLocalizedString(30022), autoclose=0, customlabel=None): dialog = xbmcgui.Dialog() # customlabel only work on kodi 19 if PY3 and customlabel: @@ -59,16 +52,16 @@ def dialog_yesno(heading, message, nolabel=config.get_localized_string(70170), y return dialog.yesno(heading, message, nolabel=nolabel, yeslabel=yeslabel, autoclose=autoclose) -def dialog_select(heading, _list, preselect=0, useDetails=False): +def dialogSelect(heading, _list, preselect=0, useDetails=False): return xbmcgui.Dialog().select(heading, _list, preselect=preselect, useDetails=useDetails) -def dialog_multiselect(heading, _list, autoclose=0, preselect=[], useDetails=False): +def dialogMultiselect(heading, _list, autoclose=0, preselect=[], useDetails=False): return xbmcgui.Dialog().multiselect(heading, _list, autoclose=autoclose, preselect=preselect, useDetails=useDetails) -def dialog_progress(heading, message): - if get_window() in ('WINDOW_HOME', 'WINDOW_SETTINGS_MENU', 'WINDOW_SETTINGS_INTERFACE', 'WINDOW_SKIN_SETTINGS', 'SKIN'): +def dialogProgress(heading, message): + if getWindow() in ('WINDOW_HOME', 'WINDOW_SETTINGS_MENU', 'WINDOW_SETTINGS_INTERFACE', 'WINDOW_SKIN_SETTINGS', 'SKIN'): # in widget, hide any progress class Dummy(object): def __getattr__(self, name): @@ -82,16 +75,16 @@ def dialog_progress(heading, message): return dialog -def dialog_progress_bg(heading, message=""): +def dialogProgressBg(heading, message=""): try: dialog = xbmcgui.DialogProgressBG() dialog.create(heading, message) return dialog except: - return dialog_progress(heading, message) + return dialogProgress(heading, message) -def dialog_input(default="", heading="", hidden=False): +def dialogInput(default="", heading="", hidden=False): keyboard = xbmc.Keyboard(default, heading, hidden) keyboard.doModal() if keyboard.isConfirmed(): @@ -100,23 +93,23 @@ def dialog_input(default="", heading="", hidden=False): return None -def dialog_numeric(_type, heading, default=""): +def dialogNumeric(_type, heading, default="", option=0): dialog = xbmcgui.Dialog() - d = dialog.numeric(_type, heading, default) + d = dialog.numeric(_type, heading, default, option) return d -def dialog_textviewer(heading, text): # available from kodi 16 +def dialogTextviewer(heading, text): # available from kodi 16 return xbmcgui.Dialog().textviewer(heading, text) -def dialog_browse(_type, heading, shares="files", mask="", useThumbs=False, treatAsFolder=False, defaultt="", enableMultiple=False): +def dialogBrowse(_type, heading, shares="files", mask="", useThumbs=False, treatAsFolder=False, defaultt="", enableMultiple=False): dialog = xbmcgui.Dialog() d = dialog.browse(_type, heading, shares, mask, useThumbs, treatAsFolder, defaultt, enableMultiple) return d -def dialog_register(heading, user=False, email=False, password=False, user_default='', email_default='', password_default='', captcha_img=''): +def dialogRegister(heading, user=False, email=False, password=False, user_default='', email_default='', password_default='', captcha_img=''): class Register(xbmcgui.WindowXMLDialog): def Start(self, heading, user, email, password, user_default, email_default, password_default, captcha_img): self.result = {} @@ -138,7 +131,7 @@ def dialog_register(heading, user=False, email=False, password=False, user_defau def onInit(self): #### Kodi 18 compatibility #### - if config.get_platform(True)['num_version'] < 18: + if config.getXBMCPlatform(True)['num_version'] < 18: self.setCoordinateResolution(2) height = 90 self.getControl(10002).setText(self.heading) @@ -184,11 +177,11 @@ def dialog_register(heading, user=False, email=False, password=False, user_defau if self.captcha_img: self.result['captcha'] = self.getControl(10006).getText() self.close() - dialog = Register('Register.xml', config.get_runtime_path()).Start(heading, user, email, password, user_default, email_default, password_default, captcha_img) + dialog = Register('Register.xml', config.getRuntimePath()).Start(heading, user, email, password, user_default, email_default, password_default, captcha_img) return dialog -def dialog_info(item, scraper): +def dialogInfo(item, scraper): class TitleOrIDWindow(xbmcgui.WindowXMLDialog): def Start(self, item, scraper): self.item = item @@ -202,7 +195,7 @@ def dialog_info(item, scraper): def onInit(self): #### Kodi 18 compatibility #### - if config.get_platform(True)['num_version'] < 18: + if config.getXBMCPlatform(True)['num_version'] < 18: self.setCoordinateResolution(2) self.HEADER = self.getControl(100) self.TITLE = self.getControl(101) @@ -210,20 +203,20 @@ def dialog_info(item, scraper): self.EXIT = self.getControl(103) self.EXIT2 = self.getControl(104) - self.HEADER.setText(config.get_localized_string(60228) % self.title) - self.TITLE.setLabel('[UPPERCASE]' + config.get_localized_string(60230).replace(':','') + '[/UPPERCASE]') + self.HEADER.setText(config.getLocalizedString(60228) % self.title) + self.TITLE.setLabel('[UPPERCASE]' + config.getLocalizedString(60230).replace(':','') + '[/UPPERCASE]') self.ID.setLabel(self.idtitle) self.setFocusId(101) def onClick(self, control): if control in [101]: - result = dialog_input(self.title) + result = dialogInput(self.title) if result: if self.item.contentType == 'movie': self.item.contentTitle = result else: self.item.contentSerieName = result self.close() elif control in [102]: - result = dialog_numeric(0, self.idtitle, self.id) + result = dialogNumeric(0, self.idtitle, self.id) if result: if self.scraper == 'tmdb': self.item.infoLabels['tmdb_id'] = result elif self.scraper == 'tvdb': self.item.infoLabels['tvdb_id'] = result @@ -239,11 +232,11 @@ def dialog_info(item, scraper): self.item.exit = True self.close() - dialog = TitleOrIDWindow('TitleOrIDWindow.xml', config.get_runtime_path()).Start(item, scraper) + dialog = TitleOrIDWindow('TitleOrIDWindow.xml', config.getRuntimePath()).Start(item, scraper) return dialog -def dialog_select_group(heading, _list, preselect=0): +def dialogSelectGroup(heading, _list, preselect=0): class SelectGroup(xbmcgui.WindowXMLDialog): def start(self, heading, _list, preselect): self.selected = preselect @@ -284,16 +277,16 @@ def dialog_select_group(heading, _list, preselect=0): self.selected = -1 self.close() - dialog = SelectGroup('SelectGroup.xml', config.get_runtime_path()).start(heading, _list, preselect) + dialog = SelectGroup('SelectGroup.xml', config.getRuntimePath()).start(heading, _list, preselect) return dialog -def dialog_busy(state): +def dialogBusy(state): if state: xbmc.executebuiltin('ActivateWindow(busydialognocancel)') else: xbmc.executebuiltin('Dialog.Close(busydialognocancel)') -def itemlist_refresh(offset=0, disable=False): +def itemlistRefresh(offset=0, disable=False): if disable: xbmc.executebuiltin("Container.Refresh") else: @@ -317,14 +310,14 @@ def itemlist_refresh(offset=0, disable=False): xbmc.executebuiltin("Container.Refresh") -def itemlist_update(item, replace=False): +def itemlistUpdate(item, replace=False): if replace: # reset the path history xbmc.executebuiltin("Container.Update(" + sys.argv[0] + "?" + item.tourl() + ", replace)") else: xbmc.executebuiltin("Container.Update(" + sys.argv[0] + "?" + item.tourl() + ")") -def render_items(itemlist, parent_item): +def renderItems(itemlist, parent_item): """ Function used to render itemlist on kodi """ @@ -333,33 +326,33 @@ def render_items(itemlist, parent_item): if not isinstance(itemlist, list): return - logger.debug('START render_items') - thumb_type = config.get_setting('video_thumbnail_type') + logger.debug('START renderItems') + thumb_type = config.getSetting('video_thumbnail_type') from platformcode import shortcuts _handle = int(sys.argv[1]) - default_fanart = config.get_fanart() + default_fanart = config.getFanart() def_context_commands = shortcuts.context() # if there's no item, add "no elements" item if not len(itemlist): from core.support import thumb - itemlist.append(Item(title=config.get_localized_string(60347), thumbnail=thumb('nofolder'))) + itemlist.append(Item(title=config.getLocalizedString(60347), thumbnail=thumb('nofolder'))) dirItems = [] - def set_item(n, item, parent_item): + def setItem(n, item, parent_item): item.itemlistPosition = n item_url = item.tourl() if item.category == "": item.category = parent_item.category # If there is no action or it is findvideos / play, folder = False because no listing will be returned - if item.action in ['play', '']: + if item.action in ['play', 'findvideos', '']: item.folder = False if item.fanart == "": item.fanart = parent_item.fanart if item.action == 'play' and thumb_type == 1 and not item.forcethumb: - item.thumbnail = config.get_online_server_thumb(item.server) + item.thumbnail = config.getOnlineServerThumb(item.server) icon_image = "DefaultFolder.png" if item.folder else "DefaultVideo.png" @@ -373,9 +366,11 @@ def render_items(itemlist, parent_item): if item.infoLabels.get('clearart'): art['clearart'] = item.infoLabels['clearart'] if item.infoLabels.get('banner'): art['banner'] = item.infoLabels['banner'] if item.infoLabels.get('disc'): art['banner'] = item.infoLabels['disc'] + listitem.setProperty('ResumeTime', str(getPlayedTime(item))) + listitem.setArt(art) - if config.get_setting("player_mode") == 1 and item.action == "play" and not item.nfo: + if config.getSetting("player_mode") == 1 and item.action == "play" and not item.nfo: listitem.setProperty('IsPlayable', 'true') if item.infoLabels.get('castandrole'): @@ -387,12 +382,12 @@ def render_items(itemlist, parent_item): except: pass - set_infolabels(listitem, item) + setInfolabels(listitem, item) # context menu if parent_item.channel != 'special': - context_commands = def_context_commands + set_context_commands(item, item_url, parent_item) + context_commands = def_context_commands + setContextCommands(item, item_url, parent_item) else: context_commands = def_context_commands listitem.addContextMenuItems(context_commands) @@ -400,13 +395,13 @@ def render_items(itemlist, parent_item): # For Debug # logger.dbg() - # r_list = [set_item(i, item, parent_item) for i, item in enumerate(itemlist)] + # r_list = [setItem(i, item, parent_item) for i, item in enumerate(itemlist)] r_list = [] position = None with futures.ThreadPoolExecutor() as executor: - searchList = [executor.submit(set_item, i, item, parent_item) for i, item in enumerate(itemlist)] + searchList = [executor.submit(setItem, i, item, parent_item) for i, item in enumerate(itemlist)] for res in futures.as_completed(searchList): r_list.append(res.result()) r_list.sort(key=lambda it: it[0].itemlistPosition) @@ -428,32 +423,35 @@ def render_items(itemlist, parent_item): else: if 'similar' in parent_item.list_type: if parent_item.contentTitle != '': - breadcrumb = config.get_localized_string(70693) + parent_item.contentTitle + breadcrumb = config.getLocalizedString(70693) + parent_item.contentTitle else: - breadcrumb = config.get_localized_string(70693) + parent_item.contentSerieName + breadcrumb = config.getLocalizedString(70693) + parent_item.contentSerieName else: - breadcrumb = config.get_localized_string(70693) + breadcrumb = config.getLocalizedString(70693) xbmcplugin.setPluginCategory(handle=_handle, category=breadcrumb) - set_view_mode(itemlist[0], parent_item) - - xbmcplugin.endOfDirectory(_handle, succeeded=True, updateListing=False, cacheToDisc=True) - - - logger.debug('END render_items') + setViewMode(itemlist[0], parent_item) + ctrl = None + pos = None if parent_item.channel == 'videolibrary' and parent_item.action in ['get_episodes', 'get_seasons'] and position: - while xbmcgui.getCurrentWindowDialogId() == 10138: - logger.debug('WINDOW ID', xbmcgui.getCurrentWindowDialogId()) - xbmc.sleep(100) - xbmc.sleep(100) win = xbmcgui.Window(10025) ctrlId = win.getFocusId() - ctrl = win.getControl(ctrlId) - pos = position + (1 if xbmc.getInfoLabel('Container(10138).HasParent') else 0) + if ctrlId: + ctrl = win.getControl(ctrlId) + pos = position + (1 if xbmc.getInfoLabel('Container(10138).HasParent') else 0) + + updateListing = True if parent_item.update else False + xbmcplugin.endOfDirectory(_handle, succeeded=True, updateListing=updateListing, cacheToDisc=True) + + if ctrl and pos: ctrl.selectItem(pos) -def setTitle(item): + logger.debug('END renderItems') + + + +def setTitle(item, hideServerName=False): from core.support import typo title = item.title if item.title else item.contentTitle episode = '' @@ -472,8 +470,8 @@ def setTitle(item): if episode: title = '{}. {}'.format(episode, title) if item.title2: title = '{} - {}'.format(title, item.title2) - if config.get_setting('format_title') or item.server: - server = typo(item.serverName, '__ [] bold') if item.server else '' + if config.getSetting('format_title') or item.server: + server = typo(item.serverName, '__ [] bold') if item.server and hideServerName == False else '' quality = typo(item.quality, '_ [] color kod') if item.quality else '' lang = typo(item.contentLanguage, '_ [] color kod') if item.contentLanguage else '' extra = typo(item.extraInfo, '_ [] color kod') if item.extraInfo else '' @@ -484,8 +482,8 @@ def setTitle(item): return title -def viewmodeMonitor(): - if get_window() == 'WINDOW_VIDEO_NAV': +def viewModeMonitor(): + if getWindow() == 'WINDOW_VIDEO_NAV': try: currentModeName = xbmc.getInfoLabel('Container.Viewmode') parent_info = xbmc.getInfoLabel('Container.FolderPath') @@ -496,11 +494,11 @@ def viewmodeMonitor(): if currentModeName and 'plugin.video.kod' in parent_info and 50 <= currentMode < 1000: # inside addon and in itemlist view content, Type = getCurrentView(Item().fromurl(item_info) if item_info else Item(), Item().fromurl(parent_info)) if content: - defaultMode = int(config.get_setting('view_mode_%s' % content).split(',')[-1]) + defaultMode = int(config.getSetting('view_mode_%s' % content).split(',')[-1]) if currentMode != defaultMode: - config.set_setting('view_mode_%s' % content, currentModeName + ', ' + str(currentMode)) - # dialog_notification(config.get_localized_string(70153), - # config.get_localized_string(70187) % (content, currentModeName), + config.setSetting('view_mode_%s' % content, currentModeName + ', ' + str(currentMode)) + # dialogNotification(config.getLocalizedString(70153), + # config.getLocalizedString(70187) % (content, currentModeName), # sound=False) except: import traceback @@ -514,21 +512,10 @@ def getCurrentView(item=None, parent_item=None): if not parent_item: logger.debug('ESCO') return None, None - - # if not parent_item: - # info = xbmc.getInfoLabel('Container.FolderPath') - # if not info: - # return None, None - # parent_item = Item().fromurl(info) - # if not item: - # info = xbmc.getInfoLabel('Container.ListItemPosition(2).FileNameAndPath') # first addon listitem (consider "..") - # if not info: - # item = Item() - # else: - # item = Item().fromurl(info) if info else Item() + parent_actions = ['movies', 'news', 'search', 'get_from_temp', 'newest', 'discover_list', 'new_search', 'channel_search'] - addons = 'addons' if config.get_setting('touch_view') else '' + addons = 'addons' if config.getSetting('touch_view') else '' if parent_item.action == 'findvideos' or (parent_item.action in ['channel_search', 'new_search'] and parent_item.infoLabels['tmdb_id']): return 'server', addons @@ -566,20 +553,20 @@ def getCurrentView(item=None, parent_item=None): return None, None -def set_view_mode(item, parent_item): - def reset_view_mode(): +def setViewMode(item, parent_item): + def resetViewMode(): for mode in ['menu','channel','channels','home', 'movie','tvshow','season','episode','server']: - config.set_setting('skin_name', xbmc.getSkinDir()) - config.set_setting('view_mode_{}'.format(mode), config.get_localized_string(70003) + ' , 0') + config.setSetting('skin_name', xbmc.getSkinDir()) + config.setSetting('view_mode_{}'.format(mode), config.getLocalizedString(70003) + ' , 0') - if xbmc.getSkinDir() != config.get_setting('skin_name') or not config.get_setting('skin_name'): - reset_view_mode() + if xbmc.getSkinDir() != config.getSetting('skin_name') or not config.getSetting('skin_name'): + resetViewMode() xbmcplugin.setContent(handle=int(sys.argv[1]), content='') xbmc.executebuiltin('Container.SetViewMode({})'.format(55)) content, Type = getCurrentView(item, parent_item) if content: - mode = int(config.get_setting('view_mode_{}'.format(content)).split(',')[-1]) + mode = int(config.getSetting('view_mode_{}'.format(content)).split(',')[-1]) if mode == 0: logger.debug('default mode') mode = 55 @@ -588,7 +575,7 @@ def set_view_mode(item, parent_item): logger.debug('TYPE: ' + Type + ' - ' + 'CONTENT: ' + content) -def set_infolabels(listitem, item, player=False): +def setInfolabels(listitem, item, player=False): """ Method to pass the information to the listitem (see tmdb.set_InfoLabels()) item.infoLabels is a dictionary with the key / value pairs described in: @@ -624,7 +611,7 @@ def set_infolabels(listitem, item, player=False): # listitem.setInfo("video", item.infoLabels) -def set_context_commands(item, item_url, parent_item, **kwargs): +def setContextCommands(item, item_url, parent_item, **kwargs): """ Function to generate context menus. 1. Based on the data in item.context @@ -653,7 +640,7 @@ def set_context_commands(item, item_url, parent_item, **kwargs): @type parent_item: item """ context_commands = [] - # num_version_xbmc = config.get_platform(True)['num_version'] + # num_version_xbmc = config.getXBMCPlatform(True)['num_version'] # Create a list with the different options included in item.context if isinstance(item.context, str): @@ -694,29 +681,29 @@ def set_context_commands(item, item_url, parent_item, **kwargs): # Options according to criteria, only if the item is not a tag, nor is it "Add to the video library", etc... if item.action and item.action not in ["add_movie_to_library", "add_serie_to_library", "buscartrailer", "actualizar_titulos"]: # if item.nextPage: - # context_commands.append((config.get_localized_string(70511), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'action=gotopage&real_action='+item.action))) + # context_commands.append((config.getLocalizedString(70511), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'action=gotopage&real_action='+item.action))) # Show information: if the item has a plot, we assume that it is a series, season, chapter or movie # if item.infoLabels['plot'] and (num_version_xbmc < 17.0 or item.contentType == 'season'): - # context_commands.append((config.get_localized_string(60348), "Action(Info)")) + # context_commands.append((config.getLocalizedString(60348), "Action(Info)")) # InfoPlus - # if config.get_setting("infoplus"): + # if config.getSetting("infoplus"): #if item.infoLabels['tmdb_id'] or item.infoLabels['imdb_id'] or item.infoLabels['tvdb_id'] or \ # (item.contentTitle and item.infoLabels["year"]) or item.contentSerieName: if item.infoLabels['tmdb_id'] or item.infoLabels['imdb_id'] or item.infoLabels['tvdb_id']: context_commands.append(("InfoPlus", "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=infoplus&action=start&from_channel=' + item.channel))) - if config.get_setting("token_trakt", "trakt") and item.contentType in ['movie', 'tvshow']: - context_commands.append((config.get_localized_string(70318), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=trakt_tools&action=context'))) + if config.getSetting("token_trakt", "trakt") and item.contentType in ['movie', 'tvshow']: + context_commands.append((config.getLocalizedString(70318), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=trakt_tools&action=context'))) # Open in browser and previous menu if parent_item.channel not in ["news", "channelselector", "downloads", "search"] and item.action != "mainlist" and not parent_item.noMainMenu: - context_commands.insert(1, (config.get_localized_string(70739), "Container.Update (%s?%s)" % (sys.argv[0], Item(action="open_browser", url=item.url).tourl()))) + context_commands.insert(1, (config.getLocalizedString(70739), "Container.Update (%s?%s)" % (sys.argv[0], Item(channel= 'shortcuts', action="open_browser", url=item.url).tourl()))) # Add to kodfavoritos (My links) if item.channel not in ["favorites", "videolibrary", "help", ""] and parent_item.channel != "favorites": - context_commands.append( (config.get_localized_string(70557), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({'channel': "kodfavorites", 'action': "addFavourite", 'from_channel': item.channel, 'from_action': item.action})))) + context_commands.append( (config.getLocalizedString(70557), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({'channel': "kodfavorites", 'action': "addFavourite", 'from_channel': item.channel, 'from_action': item.action})))) # Add to kodfavoritos if parent_item.channel == 'globalsearch': - context_commands.append( (config.get_localized_string(30155), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({'channel': "favorites", 'action': "addFavourite", 'from_channel': item.channel, 'from_action': item.action})))) + context_commands.append( (config.getLocalizedString(30155), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({'channel': "favorites", 'action': "addFavourite", 'from_channel': item.channel, 'from_action': item.action})))) # Search in other channels if item.contentTitle and item.contentType in ['movie', 'tvshow'] and parent_item.channel not in ['search', 'globalsearch'] and item.action not in ['play'] and parent_item.action != 'mainlist': @@ -731,51 +718,51 @@ def set_context_commands(item, item_url, parent_item, **kwargs): else: mediatype = item.contentType - if config.get_setting('new_search'): - context_commands.append((config.get_localized_string(60350), "RunPlugin (%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({'channel': 'search', 'action': "from_context", 'from_channel': item.channel, 'contextual': True})))) + if config.getSetting('new_search'): + context_commands.append((config.getLocalizedString(60350), "RunPlugin (%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({'channel': 'search', 'action': "from_context", 'from_channel': item.channel, 'contextual': True})))) else: - context_commands.append((config.get_localized_string(60350), "Container.Refresh (%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({'channel': 'search', 'action': "from_context", 'from_channel': item.channel, 'contextual': True, 'text': item.wanted})))) - context_commands.append( (config.get_localized_string(70561), "Container.Update (%s?%s&%s)" % (sys.argv[0], item_url, 'channel=search&action=from_context&search_type=list&page=1&list_type=%s/%s/similar' % (mediatype, item.infoLabels['tmdb_id'])))) + context_commands.append((config.getLocalizedString(60350), "Container.Refresh (%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({'channel': 'search', 'action': "from_context", 'from_channel': item.channel, 'contextual': True, 'text': item.wanted})))) + context_commands.append( (config.getLocalizedString(70561), "Container.Update (%s?%s&%s)" % (sys.argv[0], item_url, 'channel=search&action=from_context&search_type=list&page=1&list_type=%s/%s/similar' % (mediatype, item.infoLabels['tmdb_id'])))) if item.channel != "videolibrary" and item.videolibrary != False and not item.disable_videolibrary: # Add Series to the video library if item.contentTitle or item.contentSerieName: - context_commands.append((config.get_localized_string(30161), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'action=add_to_library&from_action={}&contentChannel=videolibrary'.format(item.action)))) + context_commands.append((config.getLocalizedString(30161), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'action=add_to_library&from_action={}&contentChannel=videolibrary'.format(item.action)))) - if not item.local and item.channel not in ["downloads", "filmontv", "search"] and item.server != 'torrent' and parent_item.action != 'mainlist' and config.get_setting('downloadenabled') and not item.disable_videolibrary: + if not item.local and item.channel not in ["downloads", "filmontv", "search"] and item.server != 'torrent' and parent_item.action != 'mainlist' and config.getSetting('downloadenabled') and not item.disable_videolibrary: # Download movie if item.contentType == "movie": - context_commands.append((config.get_localized_string(60354), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=downloads&action=save_download&from_channel=' + item.channel + '&from_action=' + item.action))) + context_commands.append((config.getLocalizedString(60354), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=downloads&action=save_download&from_channel=' + item.channel + '&from_action=' + item.action))) elif item.contentSerieName: # Download series if item.contentType == "tvshow" and item.action not in ['findvideos']: if item.channel == 'videolibrary': - context_commands.append((config.get_localized_string(60003), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=downloads&action=save_download&unseen=true&from_channel=' + item.channel + '&from_action=' + item.action))) - context_commands.append((config.get_localized_string(60355), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=downloads&action=save_download&from_channel=' + item.channel + '&from_action=' + item.action))) - context_commands.append((config.get_localized_string(60357), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=downloads&action=save_download&download=season&from_channel=' + item.channel + '&from_action=' + item.action))) + context_commands.append((config.getLocalizedString(60003), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=downloads&action=save_download&unseen=true&from_channel=' + item.channel + '&from_action=' + item.action))) + context_commands.append((config.getLocalizedString(60355), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=downloads&action=save_download&from_channel=' + item.channel + '&from_action=' + item.action))) + context_commands.append((config.getLocalizedString(60357), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=downloads&action=save_download&download=season&from_channel=' + item.channel + '&from_action=' + item.action))) # Download episode elif item.contentType == "episode" and item.action in ['findvideos']: - context_commands.append((config.get_localized_string(60356), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=downloads&action=save_download&from_channel=' + item.channel + '&from_action=' + item.action))) + context_commands.append((config.getLocalizedString(60356), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=downloads&action=save_download&from_channel=' + item.channel + '&from_action=' + item.action))) # Download season elif item.contentType == "season": - context_commands.append((config.get_localized_string(60357), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=downloads&action=save_download&download=season&from_channel=' + item.channel + '&from_action=' + item.action))) + context_commands.append((config.getLocalizedString(60357), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=downloads&action=save_download&download=season&from_channel=' + item.channel + '&from_action=' + item.action))) # Search trailer... if (item.contentTitle and item.contentType in ['movie', 'tvshow']) or "buscar_trailer" in context: - context_commands.append((config.get_localized_string(60359), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({ 'channel': "trailertools", 'action': "buscartrailer", 'search_title': item.contentTitle if item.contentTitle else item.fulltitle, 'contextual': True})))) + context_commands.append((config.getLocalizedString(60359), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({ 'channel': "trailertools", 'action': "buscartrailer", 'search_title': item.contentTitle if item.contentTitle else item.fulltitle, 'contextual': True})))) - if config.dev_mode(): - context_commands.insert(0, ("item info", "Container.Update (%s?%s)" % (sys.argv[0], Item(action="itemInfo", parent=item.tojson()).tourl()))) + if config.devMode(): + context_commands.insert(0, ("item info", "Container.Update (%s?%s)" % (sys.argv[0], Item(channel='platformtools', action="itemInfo", parent=item.tojson()).tourl()))) return context_commands -def is_playing(): - return xbmc_player.isPlaying() +def isPlaying(): + return xbmcPlayer.isPlaying() -def get_window(): +def getWindow(): """ Return if addon is used as widget For doing so, it check current window ID (https://kodi.wiki/view/Window_IDs) @@ -845,7 +832,7 @@ def get_window(): elif winId == 10100: return 'WINDOW_DIALOG_YES_NO' elif winId == 10101: - return 'WINDOW_DIALOG_PROGRESS' + return 'WINDOW_dialogProgress' elif winId == 10103: return 'WINDOW_DIALOG_KEYBOARD' elif winId == 10104: @@ -857,7 +844,7 @@ def get_window(): elif winId == 10107: return 'WINDOW_DIALOG_KAI_TOAST' elif winId == 10109: - return 'WINDOW_DIALOG_NUMERIC' + return 'WINDOW_dialogNumeric' elif winId == 10110: return 'WINDOW_DIALOG_GAMEPAD' elif winId == 10111: @@ -903,7 +890,7 @@ def get_window(): elif winId == 10137: return 'WINDOW_DIALOG_SMART_PLAYLIST_RULE' elif winId == 10138: - return 'WINDOW_DIALOG_BUSY' + return 'WINDOW_dialogBusy' elif winId == 10139: return 'WINDOW_DIALOG_PICTURE_INFO' elif winId == 10140: @@ -933,11 +920,11 @@ def get_window(): elif winId == 10157: return 'WINDOW_DIALOG_CMS_OSD_SETTINGS' elif winId == 10158: - return 'WINDOW_DIALOG_INFOPROVIDER_SETTINGS' + return 'WINDOW_dialogInfoPROVIDER_SETTINGS' elif winId == 10159: return 'WINDOW_DIALOG_SUBTITLE_OSD_SETTINGS' elif winId == 10160: - return 'WINDOW_DIALOG_BUSY_NOCANCEL' + return 'WINDOW_dialogBusy_NOCANCEL' elif winId == 10500: return 'WINDOW_MUSIC_PLAYLIST' @@ -992,11 +979,11 @@ def get_window(): return 'SKIN' # WINDOW_ID's from 11100 to 11199 reserved for Skins elif winId == 12000: - return 'WINDOW_DIALOG_SELECT' + return 'WINDOW_dialogSelect' elif winId == 12001: return 'WINDOW_DIALOG_MUSIC_INFO' elif winId == 12002: - return 'WINDOW_DIALOG_OK' + return 'WINDOW_dialogOk' elif winId == 12003: return 'WINDOW_DIALOG_VIDEO_INFO' elif winId == 12005: @@ -1034,19 +1021,17 @@ def get_window(): return 'ADDON' # WINDOW_ID's from 14000 to 14099 reserved for Addons -def play_video(item, strm=False, force_direct=False, autoplay=False): +def playVideo(item, strm=False, force_direct=False, autoplay=False): logger.debug(item) def play(): if item.channel == 'downloads': logger.debug("Play local video: %s [%s]" % (item.fulltitle, item.url)) - xlistitem = xbmcgui.ListItem(path=item.url) - xlistitem.setArt({"thumb": item.thumbnail}) - set_infolabels(xlistitem, item, True) - set_player(item, xlistitem, item.url, True, None) # Fix Play From Download Section + xlistitem = setListitem(item, item.url) + setPlayer(item, xlistitem, item.url, True, None) # Fix Play From Download Section return - default_action = config.get_setting("default_action") + default_action = config.getSetting("default_action") logger.debug("default_action=%s" % default_action) # pass referer @@ -1055,47 +1040,46 @@ def play_video(item, strm=False, force_direct=False, autoplay=False): httptools.default_headers['Referer'] = item.referer # Open the selection dialog to see the available options - options, video_urls, selection, _exit = get_options_dialog(item, default_action, strm, autoplay) + options, videoUrls, selection, _exit = getOptionsDialog(item, default_action, strm, autoplay) if _exit: return # get default option of addon configuration - selection = get_selection(default_action, options, selection, video_urls) + selection = getSelection(default_action, options, selection, videoUrls) # Canceled box if selection < 0: - prevent_busy(item) + # preventBusy(item) return logger.debug("selection=%d" % selection) logger.debug("selection=%s" % options[selection]) # run the available option, jdwonloader, download, favorites, add to the video library ... IF IT IS NOT PLAY - _exit = set_option(item, selection, options, video_urls) + _exit = setOption(item, selection, options, videoUrls) if _exit: return # we get the selected video - mediaurl, view, mpd, m3u8 = get_selected_video(item, selection, video_urls, autoplay) - if not mediaurl: return + mediaUrl, view, mpd, m3u8 = getSelectedVideo(item, selection, videoUrls, autoplay) + if not mediaUrl: return # video information is obtained. - xlistitem = xbmcgui.ListItem(item.contentTitle, path=item.url) - xlistitem.setArt({"thumb": item.contentThumbnail if item.contentThumbnail else item.thumbnail}) - set_infolabels(xlistitem, item, True) + xlistitem = setListitem(item, item.url) + setInfolabels(xlistitem, item, True) # if it is a video in mpd format, the listitem is configured to play it ith the inpustreamaddon addon implemented in Kodi 17 if mpd or item.manifest == 'mpd': - if not install_inputstream(): + if not installInputstream(): return xlistitem.setProperty('inputstream' if PY3 else 'inputstreamaddon', 'inputstream.adaptive') xlistitem.setProperty('inputstream.adaptive.manifest_type', 'mpd') if item.drm and item.license: - install_widevine() + # installWidevine() xlistitem.setProperty("inputstream.adaptive.license_type", item.drm) xlistitem.setProperty("inputstream.adaptive.license_key", item.license) xlistitem.setMimeType('application/dash+xml') elif m3u8 or item.manifest == 'hls': - if not install_inputstream(): + if not installInputstream(): return xlistitem.setProperty('inputstream' if PY3 else 'inputstreamaddon', 'inputstream.adaptive') xlistitem.setProperty('inputstream.adaptive.manifest_type', 'hls') @@ -1105,7 +1089,7 @@ def play_video(item, strm=False, force_direct=False, autoplay=False): if force_direct: item.window = True - set_player(item, xlistitem, mediaurl, view, strm) + setPlayer(item, xlistitem, mediaUrl, view, strm) return True if not play(): @@ -1114,13 +1098,13 @@ def play_video(item, strm=False, force_direct=False, autoplay=False): db.close() -def stop_video(): - xbmc_player.stop() +def stopVideo(): + xbmcPlayer.stop() -def get_selection(default_action, options, selection, video_urls): +def getSelection(default_action, options, selection, videoUrls): resolutions = [] - for url in video_urls: + for url in videoUrls: resolutions.append(calcResolution(url['res']) if 'res' in url else 0) resolutions.sort() @@ -1129,7 +1113,7 @@ def get_selection(default_action, options, selection, video_urls): # ask if default_action == 0: # "Choose an option" - selection = dialog_select(config.get_localized_string(30163), options) + selection = dialogSelect(config.getLocalizedString(30163), options) else: selection = 0 @@ -1158,7 +1142,7 @@ def calcResolution(option): return resolution -def show_channel_settings(**kwargs): +def showChannelSettings(**kwargs): """ It shows a customized configuration box for each channel and saves the data when closing it. The parameters passed to it can be seen in the method that is called @@ -1167,10 +1151,11 @@ def show_channel_settings(**kwargs): @rtype: SettingsWindow """ from platformcode.xbmc_config_menu import SettingsWindow - return SettingsWindow("ChannelSettings.xml", config.get_runtime_path()).start(**kwargs) + # return SettingsWindow("ChannelSettings.xml", config.getRuntimePath()).start(**kwargs) + return SettingsWindow("ChSettings.xml", config.getRuntimePath()).start(**kwargs) -def show_video_info(*args, **kwargs): +def showVideoInfo(*args, **kwargs): """ It shows a window with the info of the video. The parameters passed to it can be seen in the method that is called @@ -1180,27 +1165,27 @@ def show_video_info(*args, **kwargs): """ from platformcode.xbmc_info_window import InfoWindow - return InfoWindow("InfoWindow.xml", config.get_runtime_path()).start(*args, **kwargs) + return InfoWindow("InfoWindow.xml", config.getRuntimePath()).start(*args, **kwargs) -def show_recaptcha(key, referer): +def showRecaptcha(key, referer): from platformcode.recaptcha import Recaptcha - return Recaptcha("Recaptcha.xml", config.get_runtime_path()).Start(key, referer) + return Recaptcha("Recaptcha.xml", config.getRuntimePath()).Start(key, referer) -def alert_no_disponible_server(server): +def alertNoDisponibleServer(server): # 'The video is no longer in %s', 'Try another server or another channel' - dialog_ok(config.get_localized_string(30055), (config.get_localized_string(30057) % server) + '\n' + config.get_localized_string(30058)) + dialogOk(config.getLocalizedString(30055), (config.getLocalizedString(30057) % server) + '\n' + config.getLocalizedString(30058)) -def alert_unsopported_server(): +def alertUnsopportedServer(): # 'Unsupported or unknown server ',' Test on another server or on another channel' - dialog_ok(config.get_localized_string(30065), config.get_localized_string(30058)) + dialogOk(config.getLocalizedString(30065), config.getLocalizedString(30058)) -def handle_wait(time_to_wait, title, text): - logger.debug("handle_wait(time_to_wait=%d)" % time_to_wait) - espera = dialog_progress(' ' + title, "") +def handleWait(time_to_wait, title, text): + logger.debug("handleWait(time_to_wait=%d)" % time_to_wait) + waiting = dialogProgress(' ' + title, "") secs = 0 increment = int(old_div(100, time_to_wait)) @@ -1209,11 +1194,11 @@ def handle_wait(time_to_wait, title, text): while secs < time_to_wait: secs += 1 percent = increment * secs - secs_left = str((time_to_wait - secs)) - remaining_display = config.get_localized_string(70176) + secs_left + config.get_localized_string(70177) - espera.update(percent, ' ' + text, remaining_display) + secsLeft = str((time_to_wait - secs)) + remaining_display = config.getLocalizedString(70176) + secsLeft + config.getLocalizedString(70177) + waiting.update(percent, ' ' + text, remaining_display) xbmc.sleep(1000) - if espera.iscanceled(): + if waiting.iscanceled(): cancelled = True break @@ -1225,7 +1210,7 @@ def handle_wait(time_to_wait, title, text): return True -def get_options_dialog(item, default_action, strm, autoplay): +def getOptionsDialog(item, default_action, strm, autoplay): logger.debug() # logger.debug(item.tostring('\n')) from core import servertools @@ -1242,45 +1227,45 @@ def get_options_dialog(item, default_action, strm, autoplay): item.server = "directo" # If it is not the normal mode, it does not show the dialog because XBMC hangs - muestra_dialogo = (config.get_setting("player_mode") == 0 and not strm) + muestra_dialogo = (config.getSetting("player_mode") == 0 and not strm) # Extract the URLs of the videos, and if you can't see it, it tells you the reason # Allow multiple qualities for "direct" server - if item.video_urls: - video_urls, puedes, motivo = item.video_urls, True, "" + if item.videoUrls: + videoUrls, puedes, motivo = item.videoUrls, True, "" else: - video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing( + videoUrls, puedes, motivo = servertools.resolve_videoUrls_for_playing( item.server, item.url, item.password, muestra_dialogo) - if play_canceled: + if playCanceled: return options, [], 0, True selection = 0 # If you can see the video, present the options if puedes: - video_urls = sorted(video_urls, key=lambda k: calcResolution(k['res']) if 'res' in k else 0) - video_urls.reverse() - for video_url in video_urls: - name = '{} {} [{}]'.format(config.get_localized_string(60221), video_url.get('type'), servertools.get_server_parameters(item.server)['name']) - if video_url.get('res',''): name += ' [{}]'.format(video_url.get('res','')) + videoUrls = sorted(videoUrls, key=lambda k: calcResolution(k['res']) if 'res' in k else 0) + videoUrls.reverse() + for videoUrl in videoUrls: + name = '{} {} [{}]'.format(config.getLocalizedString(60221), videoUrl.get('type'), servertools.get_server_parameters(item.server)['name']) + if videoUrl.get('res',''): name += ' [{}]'.format(videoUrl.get('res','')) options.append(name) if item.server == "local": - options.append(config.get_localized_string(30164)) + options.append(config.getLocalizedString(30164)) else: # "Download" - downloadenabled = config.get_setting('downloadenabled') + downloadenabled = config.getSetting('downloadenabled') if downloadenabled != False and item.channel != 'videolibrary': - opcion = config.get_localized_string(30153) + opcion = config.getLocalizedString(30153) options.append(opcion) if item.isFavourite: # "Remove from favorites" - options.append(config.get_localized_string(30154)) + options.append(config.getLocalizedString(30154)) else: # "Add to Favorites" - options.append(config.get_localized_string(30155)) + options.append(config.getLocalizedString(30155)) if default_action == 3: selection = len(options) - 1 @@ -1288,32 +1273,32 @@ def get_options_dialog(item, default_action, strm, autoplay): # Search for trailers if item.channel not in ["trailertools"]: # "Search Trailer" - options.append(config.get_localized_string(30162)) + options.append(config.getLocalizedString(30162)) # If you can't see the video it informs you else: if not autoplay: if item.server != "": if "<br/>" in motivo: - ret = dialog_yesno(config.get_localized_string(60362) % item.server, motivo.split("<br/>")[0] + '\n' + motivo.split("<br/>")[1], nolabel='ok', yeslabel=config.get_localized_string(70739)) + ret = dialogYesNo(config.getLocalizedString(60362) % item.server, motivo.split("<br/>")[0] + '\n' + motivo.split("<br/>")[1], nolabel='ok', yeslabel=config.getLocalizedString(70739)) else: - ret = dialog_yesno(config.get_localized_string(60362) % item.server, motivo, nolabel='ok', yeslabel=config.get_localized_string(70739)) + ret = dialogYesNo(config.getLocalizedString(60362) % item.server, motivo, nolabel='ok', yeslabel=config.getLocalizedString(70739)) else: - ret = dialog_yesno(config.get_localized_string(60362) % item.server, config.get_localized_string(60363) + '\n' + config.get_localized_string(60364), nolabel='ok', yeslabel=config.get_localized_string(70739)) + ret = dialogYesNo(config.getLocalizedString(60362) % item.server, config.getLocalizedString(60363) + '\n' + config.getLocalizedString(60364), nolabel='ok', yeslabel=config.getLocalizedString(70739)) if ret: xbmc.executebuiltin("Container.Update (%s?%s)" % (sys.argv[0], Item(action="open_browser", url=item.url).tourl())) if item.channel == "favorites": # "Remove from favorites" - options.append(config.get_localized_string(30154)) + options.append(config.getLocalizedString(30154)) if len(options) == 0: error = True - return options, video_urls, selection, error + return options, videoUrls, selection, error -def set_option(item, selection, options, video_urls): +def setOption(item, selection, options, videoUrls): logger.debug() # logger.debug(item.tostring('\n')) _exit = False @@ -1321,18 +1306,11 @@ def set_option(item, selection, options, video_urls): if selection == -1: # To avoid the error "One or more elements failed" when deselecting from strm file - listitem = xbmcgui.ListItem(item.title) - - if config.get_platform(True)['num_version'] >= 16.0: - listitem.setArt({'icon': "DefaultVideo.png", 'thumb': item.thumbnail}) - else: - listitem.setIconImage("DefaultVideo.png") - listitem.setThumbnailImage(item.thumbnail) - + listitem = setListitem(item) xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, listitem) # "Download" - elif options[selection] == config.get_localized_string(30153): + elif options[selection] == config.getLocalizedString(30153): from specials import downloads if item.contentType == "list" or item.contentType == "tvshow": @@ -1342,217 +1320,211 @@ def set_option(item, selection, options, video_urls): _exit = True # "Remove from favorites" - elif options[selection] == config.get_localized_string(30154): + elif options[selection] == config.getLocalizedString(30154): from specials import favorites favorites.delFavourite(item) _exit = True # "Add to Favorites": - elif options[selection] == config.get_localized_string(30155): + elif options[selection] == config.getLocalizedString(30155): from specials import favorites item.from_channel = "favorites" favorites.addFavourite(item) _exit = True # "Search Trailer": - elif options[selection] == config.get_localized_string(30162): - config.set_setting("subtitulo", False) + elif options[selection] == config.getLocalizedString(30162): + config.setSetting("subtitulo", False) xbmc.executebuiltin("RunPlugin(%s?%s)" % (sys.argv[0], item.clone(channel="trailertools", action="buscartrailer", contextual=True).tourl())) _exit = True return _exit -def get_selected_video(item, selection, video_urls, autoplay=False): +def getSelectedVideo(item, selection, videoUrls, autoplay=False): logger.debug() - mediaurl = "" + mediaUrl = "" view = False - wait_time = 0 - file_type = '' + waitTime = 0 + fileType = '' mpd = False m3u8 = False - # video_urls Format: + # videoUrls Format: # [{'type':'Video Extension', 'url': 'Video url', 'wait':seconds to wait, 'sub':'subtitle url'}] # You have chosen one of the videos - if selection < len(video_urls): - video_url = video_urls[selection] - mediaurl = video_url.get('url', '') - wait_time = video_url.get('wait', 0) - file_type = video_url.get('type', 'Video').lower() - if not item.subtitle: item.subtitle = video_url.get('sub', '') + if selection < len(videoUrls): + videoUrl = videoUrls[selection] + mediaUrl = videoUrl.get('url', '') + waitTime = videoUrl.get('wait', 0) + fileType = videoUrl.get('type', 'Video').lower() + if not item.subtitle: item.subtitle = videoUrl.get('sub', '') view = True - if 'mpd' in file_type: + if 'mpd' in fileType: mpd = True - elif 'm3u8' in file_type: + elif 'm3u8' in fileType: m3u8 = True - # If there is no mediaurl it is because the video is not there :) - logger.debug("mediaurl=" + mediaurl) - if mediaurl == "" and not autoplay: + # If there is no mediaUrl it is because the video is not there :) + logger.debug("mediaUrl=" + mediaUrl) + if mediaUrl == "" and not autoplay: if item.server == "unknown": - alert_unsopported_server() + alertUnsopportedServer() else: - alert_no_disponible_server(item.server) + alertNoDisponibleServer(item.server) # If there is a timeout (like in megaupload), impose it now - if wait_time > 0: - continuar = handle_wait(wait_time, item.server, config.get_localized_string(60365)) + if waitTime > 0: + continuar = handleWait(waitTime, item.server, config.getLocalizedString(60365)) if not continuar: - mediaurl = "" + mediaUrl = "" - return mediaurl, view, mpd, m3u8 + return mediaUrl, view, mpd, m3u8 -def set_player(item, xlistitem, mediaurl, view, strm): +def setPlayer(item, xlistitem, mediaUrl, view, strm): logger.debug() item.options = {'strm':False} # logger.debug("item:\n" + item.tostring('\n')) # Moved del conector "torrent" here if item.server == "torrent": - play_torrent(item, xlistitem, mediaurl) + playTorrent(item, xlistitem, mediaUrl) return # If it is a strm file, play is not necessary elif strm: xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xlistitem) if item.subtitle: xbmc.sleep(2000) - xbmc_player.setSubtitles(item.subtitle) + xbmcPlayer.setSubtitles(item.subtitle) else: if type(item.player_mode) == int: player_mode = item.player_mode else: - player_mode = config.get_setting("player_mode") - if (player_mode == 3 and mediaurl.startswith("rtmp")): player_mode = 0 - elif "megacrypter.com" in mediaurl: player_mode = 3 - logger.info("mediaurl=" + mediaurl) + player_mode = config.getSetting("player_mode") + if (player_mode == 3 and mediaUrl.startswith("rtmp")): player_mode = 0 + elif "megacrypter.com" in mediaUrl: player_mode = 3 + logger.info("mediaUrl=" + mediaUrl) if player_mode in [0,1]: - prevent_busy(item) + # preventBusy(item) if player_mode in [1]: - item.played_time = resume_playback(get_played_time(item)) + # logger.dbg() + item.played_time = resumePlayback(getPlayedTime(item)) + + from core import db + db['playitem']['item'] = item + db.close() logger.info('Player Mode:',['Direct', 'Bookmark'][player_mode]) # Add the listitem to a playlist playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist.clear() - playlist.add(mediaurl, xlistitem) + playlist.add(mediaUrl, xlistitem) # Reproduce - xbmc_player.play(playlist, xlistitem) - add_next_to_playlist(item) + xbmcPlayer.play(playlist, xlistitem) + addNextToPlaylist(item) - if config.get_setting('trakt_sync'): + if config.getSetting('trakt_sync'): from core import trakt_tools trakt_tools.wait_for_update_trakt() elif player_mode == 2: logger.info('Player Mode: Built-In') - xbmc.executebuiltin("PlayMedia(" + mediaurl + ")") + xbmc.executebuiltin("PlayMedia(" + mediaUrl + ")") elif player_mode == 3: logger.info('Player Mode: Download and Play') from platformcode import download_and_play - download_and_play.download_and_play(mediaurl, "download_and_play.tmp", config.get_setting("downloadpath")) + download_and_play.download_and_play(mediaUrl, "download_and_play.tmp", config.getSetting("downloadpath")) return # ALL LOOKING TO REMOVE VIEW if item.subtitle and view: logger.info("External subtitles: " + item.subtitle) xbmc.sleep(2000) - xbmc_player.setSubtitles(item.subtitle) + xbmcPlayer.setSubtitles(item.subtitle) # if it is a video library file send to mark as seen if strm or item.strm_path or item.from_library: item.options['strm'] = True - # if player_mode == 1: item.options['continue'] = True - from platformcode import xbmc_videolibrary - xbmc_videolibrary.mark_auto_as_watched(item) - - # for cases where the audio playback window appears in place of the video one - # if item.focusOnVideoPlayer: - # while is_playing() and xbmcgui.getCurrentWindowId() != 12006: - # continue - # xbmc.sleep(500) - # xbmcgui.Window(12005).show() -def add_next_to_playlist(item): +def addNextToPlaylist(item): import threading from core import filetools, videolibrarytools from platformcode import xbmc_videolibrary - def add_to_playlist(item): + def addToPlaylist(item): if item.contentType != 'movie': next= xbmc_videolibrary.next_ep(item) if next: next.back = True - nextItem = xbmcgui.ListItem(path=next.url) + nextItem = setListitem(item, next.url) nextItem.setArt({"thumb": next.contentThumbnail if next.contentThumbnail else next.thumbnail}) - set_infolabels(nextItem, next, True) nexturl = "plugin://plugin.video.kod/?" + next.tourl() playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist.add(nexturl, nextItem) - add_to_playlist(next) - if item.contentType != 'movie' and config.get_setting('next_ep') == 3: - threading.Thread(target=add_to_playlist, args=[item]).start() + addToPlaylist(next) + if item.contentType != 'movie' and config.getSetting('next_ep') == 3: + threading.Thread(target=addToPlaylist, args=[item]).start() -def torrent_client_installed(show_tuple=False): +def torrentClientInstalled(showTuple=False): # External plugins found in servers / torrent.json node clients from core import filetools from core import jsontools - torrent_clients = jsontools.get_node_from_file("torrent.json", "clients", filetools.join(config.get_runtime_path(), "servers")) - torrent_options = [] - for client in torrent_clients: + torrentClients = jsontools.getNodeFromFile("torrent.json", "clients", filetools.join(config.getRuntimePath(), "servers")) + torrentOptions = [] + for client in torrentClients: if xbmc.getCondVisibility('System.HasAddon("%s")' % client["id"]): - if show_tuple: - torrent_options.append([client["name"], client["url"]]) + if showTuple: + torrentOptions.append([client["name"], client["url"]]) else: - torrent_options.append(client["name"]) - return torrent_options + torrentOptions.append(client["name"]) + return torrentOptions -def play_torrent(item, xlistitem, mediaurl): +def playTorrent(item, xlistitem, mediaUrl): logger.debug() import time from servers import torrent - torrent_options = torrent_client_installed(show_tuple=True) - if len(torrent_options) == 0: + torrentOptions = torrentClientInstalled(showTuple=True) + if len(torrentOptions) == 0: from platformcode import elementum_download elementum_download.download() - return play_torrent(item, xlistitem, mediaurl) - elif len(torrent_options) > 1: - selection = dialog_select(config.get_localized_string(70193), [opcion[0] for opcion in torrent_options]) + return playTorrent(item, xlistitem, mediaUrl) + elif len(torrentOptions) > 1: + selection = dialogSelect(config.getLocalizedString(70193), [opcion[0] for opcion in torrentOptions]) else: selection = 0 if selection >= 0: - prevent_busy(item) + preventBusy() - mediaurl = urllib.quote_plus(item.url) - torr_client = torrent_options[selection][0] + mediaUrl = urllib.quote_plus(item.url) + torr_client = torrentOptions[selection][0] if torr_client in ['elementum'] and item.infoLabels['tmdb_id']: if item.contentType == 'episode' and "elementum" not in torr_client: - mediaurl += "&episode=%s&library=&season=%s&show=%s&tmdb=%s&type=episode" % (item.infoLabels['episode'], item.infoLabels['season'], item.infoLabels['tmdb_id'], item.infoLabels['tmdb_id']) + mediaUrl += "&episode=%s&library=&season=%s&show=%s&tmdb=%s&type=episode" % (item.infoLabels['episode'], item.infoLabels['season'], item.infoLabels['tmdb_id'], item.infoLabels['tmdb_id']) elif item.contentType == 'movie': - mediaurl += "&library=&tmdb=%s&type=movie" % (item.infoLabels['tmdb_id']) + mediaUrl += "&library=&tmdb=%s&type=movie" % (item.infoLabels['tmdb_id']) if torr_client in ['elementum'] and item.downloadFilename: torrent.elementum_download(item) else: time.sleep(3) - xbmc.executebuiltin("PlayMedia(" + torrent_options[selection][1] % mediaurl + ")") + xbmc.executebuiltin("PlayMedia(" + torrentOptions[selection][1] % mediaUrl + ")") torrent.mark_auto_as_watched(item) if not item.globalsearch: - while is_playing() and not xbmc.Monitor().abortRequested(): + while isPlaying() and not xbmc.Monitor().abortRequested(): time.sleep(3) -def resume_playback(played_time): +def resumePlayback(played_time): class ResumePlayback(xbmcgui.WindowXMLDialog): Close = False Resume = False @@ -1586,7 +1558,7 @@ def resume_playback(played_time): self.close() if played_time and played_time > 30: - Dialog = ResumePlayback('ResumePlayback.xml', config.get_runtime_path(), played_time=played_time) + Dialog = ResumePlayback('ResumePlayback.xml', config.getRuntimePath(), played_time=played_time) Dialog.show() t = 0 while not Dialog.is_close() and t < 100: @@ -1599,9 +1571,9 @@ def resume_playback(played_time): ##### INPUTSTREM ##### -def install_inputstream(): +def installInputstream(): from xbmcaddon import Addon - if not os.path.exists(os.path.join(xbmc.translatePath('special://home/addons/'),'inputstream.adaptive')) and not os.path.exists(os.path.join(xbmc.translatePath('special://xbmcbinaddons/'),'inputstream.adaptive')): + if not filetools.exists(filetools.join(xbmc.translatePath('special://home/addons/'),'inputstream.adaptive')) and not filetools.exists(filetools.join(xbmc.translatePath('special://xbmcbinaddons/'),'inputstream.adaptive')): try: # See if there's an installed repo that has it xbmc.executebuiltin('InstallAddon(inputstream.adaptive)', wait=True) @@ -1612,7 +1584,7 @@ def install_inputstream(): logger.info('InputStream add-on installed from repo.') except RuntimeError: logger.info('InputStream add-on not installed.') - dialog_ok(config.get_localized_string(20000), config.get_localized_string(30126)) + dialogOk(config.getLocalizedString(20000), config.getLocalizedString(30126)) return False else: try: @@ -1625,179 +1597,28 @@ def install_inputstream(): return True -def install_widevine(): - platform = get_platform() - if platform['os'] != 'android': - from core.httptools import downloadpage - from xbmcaddon import Addon - from core import jsontools - from distutils.version import LooseVersion - path = xbmc.translatePath(Addon('inputstream.adaptive').getSetting('DECRYPTERPATH')) +def installWidevine(): + addonName = 'script.module.inputstreamhelper' + def isHelper(): + ret = False + if filetools.exists(xbmc.translatePath('special://home/addons/{}'.format(addonName))): + ret = True + return ret - # if Widevine CDM is not installed - if not os.path.exists(path) or not os.listdir(path): - select = dialog_yesno('Widevine CDM', config.get_localized_string(70808)) - if select > 0: - if not 'arm' in platform['arch']: - last_version = downloadpage('https://dl.google.com/widevine-cdm/versions.txt').data.split()[-1] - download_widevine(last_version, platform, path) - else: - json = downloadpage('https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.json').data - devices = jsontools.load(json) - download_chromeos_image(devices, platform, path) - - # if Widevine CDM is outdated - elif platform['os'] != 'android': - if not 'arm' in platform['arch']: - last_version = downloadpage('https://dl.google.com/widevine-cdm/versions.txt').data.split()[-1] - current_version = jsontools.load(open(os.path.join(path, 'manifest.json')).read())['version'] - if LooseVersion(last_version) > LooseVersion(current_version): - select = dialog_yesno(config.get_localized_string(70810),config.get_localized_string(70809)) - if select > 0: download_widevine(last_version, platform, path) - else: - devices = jsontools.load(downloadpage('https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.json').data) - current_version = jsontools.load(open(os.path.join(path, 'config.json')).read())['version'] - last_version = best_chromeos_image(devices)['version'] - if LooseVersion(last_version) > LooseVersion(current_version): - select = dialog_yesno(config.get_localized_string(70810),config.get_localized_string(70809)) - if select > 0:download_chromeos_image(devices, platform, path) + if isHelper(): + from xbmcaddon import Addon + addon = Addon(id=addonName) + path = filetools.join(addon.getAddonInfo('Path'), 'lib') + sys.path.append(path) + from inputstreamhelper import Helper + helper = Helper('mpd', drm='widevine') + # logger.dbg() + helper._update_widevine() -def download_widevine(version, platform, path): - # for x86 architectures - from zipfile import ZipFile - from core import downloadtools - archiveName = 'https://dl.google.com/widevine-cdm/' + version + '-' + platform['os'] + '-' + platform['arch'] + '.zip' - fileName = config.get_temp_file('widevine.zip') - if not os.path.exists(archiveName): - if not os.path.exists(fileName): - downloadtools.downloadfile(archiveName, fileName, header='Download Widevine CDM') - zip_obj = ZipFile(fileName) - for filename in zip_obj.namelist(): - zip_obj.extract(filename, path) - zip_obj.close() - os.remove(fileName) - - -def download_chromeos_image(devices, platform, path): - # for arm architectures - from core import downloadtools - from core import jsontools - best = best_chromeos_image(devices) - archiveName = best['url'] - version = best['version'] - - fileName = config.get_temp_file(archiveName.split('/')[-1]) - if not os.path.exists(fileName): - downloadtools.downloadfile(archiveName, fileName, header='Download Widevine CDM') - from lib.arm_chromeos import ChromeOSImage - ChromeOSImage(fileName).extract_file( - filename='libwidevinecdm.so', - extract_path=os.path.join(path), - progress=dialog_progress(config.get_localized_string(70811),config.get_localized_string(70812))) - recovery_file = os.path.join(path, os.path.basename('https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.json')) - config_file = os.path.join(path, 'config.json') - if not os.path.exists(path): - os.mkdir(path) - with open(recovery_file, 'w') as reco_file: - reco_file.write(jsontools.dump(devices, indent=4)) - reco_file.close() - with open(config_file, 'w') as conf_file: - conf_file.write(jsontools.dump(best)) - conf_file.close() - os.remove(fileName) - -def best_chromeos_image(devices): - best = None - for device in devices: - # Select ARM hardware only - for arm_hwid in ['BIG','BLAZE','BOB','DRUWL','DUMO','ELM','EXPRESSO','FIEVEL','HANA','JAQ','JERRY','KEVIN','KITTY','MICKEY','MIGHTY','MINNIE','PHASER','PHASER360','PI','PIT','RELM','SCARLET','SKATE','SNOW','SPEEDY','SPRING','TIGER']: - if arm_hwid in device['hwidmatch']: - hwid = arm_hwid - break # We found an ARM device, rejoice ! - else: - continue # Not ARM, skip this device - - device['hwid'] = hwid - - # Select the first ARM device - if best is None: - best = device - continue # Go to the next device - - # Skip identical hwid - if hwid == best['hwid']: - continue - - # Select the newest version - from distutils.version import LooseVersion # pylint: disable=import-error,no-name-in-module,useless-suppression - if LooseVersion(device['version']) > LooseVersion(best['version']): - logger.info('%s (%s) is newer than %s (%s)' % (device['hwid'], device['version'], best['hwid'], best['version'])) - best = device - - # Select the smallest image (disk space requirement) - elif LooseVersion(device['version']) == LooseVersion(best['version']): - if int(device['filesize']) + int(device['zipfilesize']) < int(best['filesize']) + int(best['zipfilesize']): - logger.info('%s (%d) is smaller than %s (%d)' % (device['hwid'], int(device['filesize']) + int(device['zipfilesize']), best['hwid'], int(best['filesize']) + int(best['zipfilesize']))) - best = device - return best - -def get_platform(): - import platform - build = xbmc.getInfoLabel("System.BuildVersion") - kodi_version = int(build.split()[0][:2]) - ret = { - "auto_arch": sys.maxsize > 2 ** 32 and "64-bit" or "32-bit", - "arch": sys.maxsize > 2 ** 32 and "x64" or "ia32", - "os": "", - "version": platform.release(), - "kodi": kodi_version, - "build": build - } - if xbmc.getCondVisibility("system.platform.android"): - ret["os"] = "android" - if "arm" in platform.machine() or "aarch" in platform.machine(): - ret["arch"] = "arm" - if "64" in platform.machine() and ret["auto_arch"] == "64-bit": - ret["arch"] = "arm64" - elif xbmc.getCondVisibility("system.platform.linux"): - ret["os"] = "linux" - if "aarch" in platform.machine() or "arm64" in platform.machine(): - if xbmc.getCondVisibility("system.platform.linux.raspberrypi"): - ret["arch"] = "armv7" - elif ret["auto_arch"] == "32-bit": - ret["arch"] = "armv7" - elif ret["auto_arch"] == "64-bit": - ret["arch"] = "arm64" - elif platform.architecture()[0].startswith("32"): - ret["arch"] = "arm" - else: - ret["arch"] = "arm64" - elif "armv7" in platform.machine(): - ret["arch"] = "armv7" - elif "arm" in platform.machine(): - ret["arch"] = "arm" - elif xbmc.getCondVisibility("system.platform.xbox"): - ret["os"] = "win" - ret["arch"] = "x64" - elif xbmc.getCondVisibility("system.platform.windows"): - ret["os"] = "win" - if platform.machine().endswith('64'): - ret["arch"] = "x64" - elif xbmc.getCondVisibility("system.platform.osx"): - ret["os"] = "mac" - ret["arch"] = "x64" - elif xbmc.getCondVisibility("system.platform.ios"): - ret["os"] = "ios" - ret["arch"] = "arm" - - return ret - - - -def get_played_time(item): +def getPlayedTime(item): logger.debug() - from core import db + from core import videolibrarydb played_time = 0 if not item.infoLabels: @@ -1811,22 +1632,23 @@ def get_played_time(item): result = None try: - result = db['viewed'].get(ID) + result = videolibrarydb['viewed'].get(ID) if type(result) == dict: - result = db['viewed'].get(ID, {}).get('{}x{}'.format(s, e), 0) + result = videolibrarydb['viewed'].get(ID, {}).get('{}x{}'.format(s, e), 0) played_time = result except: import traceback logger.error(traceback.format_exc()) - del db['viewed'][ID] + del videolibrarydb['viewed'][ID] return played_time -def set_played_time(item): +def setPlayedTime(item): logger.debug() - from core import db + # logger.dbg() + from core import videolibrarydb played_time = item.played_time if not item.infoLabels: @@ -1837,44 +1659,62 @@ def set_played_time(item): return s = item.infoLabels.get('season',0) - e = item.infoLabels.get('episode') + e = item.infoLabels.get('episode',0) try: # logger.dbg() if e: - newDict = db['viewed'].get(ID, {}) + newDict = videolibrarydb['viewed'].get(ID, {}) newDict['{}x{}'.format(s, e)] = played_time - db['viewed'][ID] = newDict + videolibrarydb['viewed'][ID] = newDict + else: - db['viewed'][ID] = played_time + videolibrarydb['viewed'][ID] = played_time except: import traceback logger.error(traceback.format_exc()) - del db['viewed'][ID] + del videolibrarydb['viewed'][ID] + + videolibrarydb.close() -def prevent_busy(item): - logger.debug() - if item.action == 'play_from_library' or (not item.autoplay and not item.window): - if item.globalsearch: xbmc.Player().play(os.path.join(config.get_runtime_path(), "resources", "kod.mp4")) - else: xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xbmcgui.ListItem(path=os.path.join(config.get_runtime_path(), "resources", "kod.mp4"))) - xbmc.sleep(200) - xbmc.Player().stop() +def preventBusy(): + xbmc.executebuiltin('Dialog.Close(all,true)') -def serverwindow(item, itemlist): +def fakeVideo(): + media = filetools.join(config.getRuntimePath(), "resources", "kod.mp4") + xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xbmcgui.ListItem(path=media)) + while not isPlaying(): + xbmc.sleep(100) + if xbmc.getCondVisibility("system.platform.android"): + xbmc.sleep(300) + xbmc.Player().stop() + + +def serverWindow(item, itemlist): from core import filetools, jsontools - class ServerWindow(xbmcgui.WindowXMLDialog): + + LEFT = 1 + RIGHT = 2 + UP = 3 + DOWN = 4 + ENTER = 7 + EXIT = 10 + BACKSPACE = 92 + + class ServerWindow(xbmcgui.WindowXML): def start(self, item, itemlist): self.itemlist = itemlist self.item = item self.servers = [] items = [] self.selection = -1 + self.actions = {} for videoitem in self.itemlist: - videoitem.thumbnail = config.get_online_server_thumb(videoitem.server) + videoitem.thumbnail = config.getOnlineServerThumb(videoitem.server) quality = ' [' + videoitem.quality + ']' if videoitem.quality else '' if videoitem.server: color = scrapertools.find_single_match(videoitem.alive, r'(FF[^\]]+)') @@ -1892,61 +1732,77 @@ def serverwindow(item, itemlist): it.setArt({'poster':self.item.contentThumbnail if self.item.contentThumbnail else self.item.thumbnail, 'thumb':videoitem.thumbnail, 'fanart':videoitem.fanart}) self.servers.append(it) items.append(videoitem) + else: + # logger.dbg() + it = xbmcgui.ListItem(videoitem.title) + if 'library' in videoitem.action: + self.actions['videolibrary'] = videoitem + if 'download' in videoitem.action: + self.actions['download'] = videoitem + self.itemlist = items self.doModal() - return self.selection def onInit(self): self.SERVERS = self.getControl(100) + self.VIDEOLIBRARY = self.getControl(102) + self.DOWNLOAD = self.getControl(103) + if 'videolibrary' not in self.actions.keys(): + self.VIDEOLIBRARY.setVisible(False) + if 'download' not in self.actions.keys(): + self.DOWNLOAD.setVisible(False) self.SERVERS.reset() self.SERVERS.addItems(self.servers) self.setFocusId(100) - def onClick(self, control_id): - if control_id == 100: - self.selection = self.itemlist[self.SERVERS.getSelectedPosition()].clone(window=True) + def onAction(self, action): + action = action.getId() + focus = self.getFocusId() + if action in [UP, DOWN, LEFT, RIGHT] and focus not in [100, 101, 102, 103]: + self.setFocusId(100) + elif action in [EXIT, BACKSPACE]: self.close() - reopen = False + def onClick(self, control): + if control == 100: + self.selection = self.itemlist[self.SERVERS.getSelectedPosition()].clone(window=True) + self.run(self.selection) + elif control in [102]: + self.run(self.actions['videolibrary']) + elif control in [103]: + self.run(self.actions['download']) + + def run(self, action): + from platformcode.launcher import run + run(action) + + if itemlist: - reopen = False - while not xbmc.Monitor().abortRequested(): - played = True - if not is_playing(): - if config.get_setting('next_ep') == 3: - xbmc.sleep(500) - if is_playing(): - return - if config.get_setting('autoplay') or reopen: - played_time = get_played_time(item) - if not played_time and played: - return - - selection = ServerWindow('Servers.xml', config.get_runtime_path()).start(item, itemlist) - if selection == -1: - return - else: - from platformcode.launcher import run - run(selection) - reopen = True + xbmc.executebuiltin('Dialog.Close(all)') + ServerWindow('Servers.xml', config.getRuntimePath()).start(item, itemlist) -def window_type(item): - if type(item.window) == bool: - pass - elif config.get_setting('window_type') == 0 or (config.get_setting('next_ep') == 3 and item.contentType != 'movie'): - item.window = True +def channelImport(channelId): + ch = '' + path = filetools.join(config.getRuntimePath(), '{}', channelId + ".py") + if filetools.exists(path.format('channels')): ch = 'channels.{}'.format(channelId) + elif filetools.exists(path.format('specials')): ch = 'specials.{}'.format(channelId) + elif filetools.exists(path.format('platformcode')): ch = 'platformcode.{}'.format(channelId) + elif filetools.exists(path.format('core')): ch = 'core.{}'.format(channelId) + if ch: + channel = __import__(ch, None, None, [ch]) else: - item.window = False - return item - - -def channel_import(channel_id): - if filetools.exists(filetools.join(config.get_runtime_path(), 'channels', channel_id + ".py")): - channel = __import__('channels.'+ channel_id, None, None, ["channels." + channel_id]) - elif filetools.exists(filetools.join(config.get_runtime_path(), 'specials', channel_id + ".py")): - channel = __import__('specials.' + channel_id, None, None, ["specials." + channel_id]) - else: - logger.info('Channel {} not Exist') + logger.info('Channel {} not Exist'.format(channelId)) channel = None - return channel \ No newline at end of file + return channel + + +def itemInfo(item): + dialogTextviewer('Item info', item.parent) + +def setListitem(item, url=''): + listitem = xbmcgui.ListItem(setTitle(item, hideServerName=True), path=url) + listitem.setArt({'icon': "DefaultVideo.png", "thumb": item.contentThumbnail if item.contentThumbnail else item.thumbnail}) + setInfolabels(listitem, item, True) + return listitem + diff --git a/platformcode/recaptcha.py b/platformcode/recaptcha.py index d7265d43..177a914e 100644 --- a/platformcode/recaptcha.py +++ b/platformcode/recaptcha.py @@ -21,7 +21,7 @@ class Recaptcha(xbmcgui.WindowXMLDialog): self.doModal() # Reload if self.result == {}: - self.result = Recaptcha("Recaptcha.xml", config.get_runtime_path()).Start(self.key, self.referer) + self.result = Recaptcha("Recaptcha.xml", config.getRuntimePath()).Start(self.key, self.referer) return self.result @@ -43,7 +43,7 @@ class Recaptcha(xbmcgui.WindowXMLDialog): def onInit(self): #### Kodi 18 compatibility #### - if config.get_platform(True)['num_version'] < 18: + if config.getXBMCPlatform(True)['num_version'] < 18: self.setCoordinateResolution(2) self.update_window() @@ -68,7 +68,7 @@ class Recaptcha(xbmcgui.WindowXMLDialog): logger.debug(data) self.result = scrapertools.find_single_match(data, '<div class="fbc-verification-token">.*?>([^<]+)<') if self.result: - platformtools.dialog_notification("Captcha corretto", "Verifica conclusa") + platformtools.dialogNotification("Captcha corretto", "Verifica conclusa") self.close() else: self.result = {} diff --git a/platformcode/shortcuts.py b/platformcode/shortcuts.py index 740c5a3b..25d20a68 100644 --- a/platformcode/shortcuts.py +++ b/platformcode/shortcuts.py @@ -1,150 +1,197 @@ # -*- coding: utf-8 -*- -from platformcode import logger, platformtools +import sys +from platformcode import logger, platformtools, config def context(): - from platformcode import config - context = [] - # original - # if config.get_setting('quick_menu'): context.append((config.get_localized_string(60360).upper(), "RunPlugin(plugin://plugin.video.kod/?%s)" % Item(channel='shortcuts', action="shortcut_menu").tourl())) - # if config.get_setting('kod_menu'): context.append((config.get_localized_string(60026), "RunPlugin(plugin://plugin.video.kod/?%s)" % Item(channel='shortcuts', action="settings_menu").tourl())) + from platformcode import config + context = [] + # original + # if config.getSetting('quick_menu'): context.append((config.getLocalizedString(60360).upper(), "RunPlugin(plugin://plugin.video.kod/?%s)" % Item(channel='shortcuts', action="shortcut_menu").tourl())) + # if config.getSetting('kod_menu'): context.append((config.getLocalizedString(60026), "RunPlugin(plugin://plugin.video.kod/?%s)" % Item(channel='shortcuts', action="settings_menu").tourl())) - # pre-serialised - if config.get_setting('quick_menu'): context.append((config.get_localized_string(60360), 'RunPlugin(plugin://plugin.video.kod/?ewogICAgImFjdGlvbiI6ICJzaG9ydGN1dF9tZW51IiwgCiAgICAiY2hhbm5lbCI6ICJzaG9ydGN1dHMiLCAKICAgICJpbmZvTGFiZWxzIjoge30KfQ%3D%3D)')) - # if config.get_setting('kod_menu'): context.append((config.get_localized_string(60026), 'RunPlugin(plugin://plugin.video.kod/?ewogICAgImFjdGlvbiI6ICJzZXR0aW5nc19tZW51IiwgCiAgICAiY2hhbm5lbCI6ICJzaG9ydGN1dHMiLCAKICAgICJpbmZvTGFiZWxzIjoge30KfQ%3D%3D)')) + # pre-serialised + if config.getSetting('quick_menu'): context.append((config.getLocalizedString(60360), 'RunPlugin(plugin://plugin.video.kod/?channel=shortcuts&action=shortcut_menu)')) + # if config.getSetting('kod_menu'): context.append((config.getLocalizedString(60026), 'RunPlugin(plugin://plugin.video.kod/?ewogICAgImFjdGlvbiI6ICJzZXR0aW5nc19tZW51IiwgCiAgICAiY2hhbm5lbCI6ICJzaG9ydGN1dHMiLCAKICAgICJpbmZvTGFiZWxzIjoge30KfQ%3D%3D)')) + + return context + +def open_browser(item): + import webbrowser + if not webbrowser.open(item.url): + import xbmc + if xbmc.getCondVisibility('system.platform.linux') and xbmc.getCondVisibility('system.platform.android'): # android + xbmc.executebuiltin('StartAndroidActivity("", "android.intent.action.VIEW", "", "%s")' % item.url) + else: + platformtools.dialogOk(config.getLocalizedString(20000), config.getLocalizedString(70740) % "\n".join([item.url[j:j+57] for j in range(0, len(item.url), 57)])) + +def gotopage(item): + item.channel = item.from_cannel + from core import scrapertools + head = config.getLocalizedString(70511) + scraped_page = scrapertools.find_single_match(item.url,'[=/]([0-9]+)') + + if item.total_pages and (item.page or scraped_page.isdigit()): + pages = [str(p) for p in range(1, item.total_pages + 1)] + page = item.page if item.page else int(scraped_page) + page = platformtools.dialogSelect(head, pages, page - 2) + 1 + else: + page = platformtools.dialogNumeric(0, head) + if page and int(page) > -1: + import xbmc + item.action = item.real_action + item.page = int(page) + item.update = True + import re + item.url = re.sub('([=/])[0-9]+(/?)$', '\g<1>{}\g<2>'.format(page), item.url) + xbmc.executebuiltin("Container.Update(%s?%s)" % (sys.argv[0], item.tourl())) + +def gotoseason(item): + item.channel = item.from_cannel + head = 'Seleziona la stagione' + seasons = [str(s) for s in item.allSeasons] + season = platformtools.dialogSelect(head, seasons, item.nextSeason - 1) + if int(season) > -1: + import xbmc + item.action = item.real_action + item.nextSeason = season + item.update = True + xbmc.executebuiltin("Container.Update(%s?%s)" % (sys.argv[0], item.tourl())) - return context def shortcut_menu(item): - from platformcode import keymaptools - keymaptools.open_shortcut_menu() + from platformcode import keymaptools + if item.add: + keymaptools.set_key() + elif item.delete: + keymaptools.delete_key() + else: + keymaptools.open_shortcut_menu() def settings_menu(item): - from platformcode import config - config.open_settings() + from platformcode import config + config.openSettings() def servers_menu(item): - from core import servertools - from core.item import Item - from platformcode import config, platformtools - from specials import setting + from core import servertools + from core.item import Item + from platformcode import config, platformtools + from specials import setting - names = [] - ids = [] + names = [] + ids = [] - if item.type == 'debriders': - action = 'server_debrid_config' - server_list = list(servertools.get_debriders_list().keys()) - for server in server_list: - server_parameters = servertools.get_server_parameters(server) - if server_parameters['has_settings'] and server_parameters['active']: - names.append(server_parameters['name']) - ids.append(server) + if item.type == 'debriders': + action = 'server_debrid_config' + server_list = list(servertools.get_debriders_list().keys()) + for server in server_list: + server_parameters = servertools.get_server_parameters(server) + if server_parameters['has_settings'] and server_parameters['active']: + names.append(server_parameters['name']) + ids.append(server) - select = platformtools.dialog_select(config.get_localized_string(60552), names) - if select != -1: - ID = ids[select] + select = platformtools.dialogSelect(config.getLocalizedString(60552), names) + if select != -1: + ID = ids[select] - it = Item(channel = 'settings', - action = action, - config = ID) - setting.server_debrid_config(it) - else: - action = 'server_config' - server_list = list(servertools.get_servers_list().keys()) - for server in sorted(server_list): - server_parameters = servertools.get_server_parameters(server) - if server_parameters["has_settings"] and [x for x in server_parameters["settings"]] and server_parameters['active']: - names.append(server_parameters['name']) - ids.append(server) + it = Item(channel = 'settings', + action = action, + config = ID) + setting.server_debrid_config(it) + else: + action = 'server_config' + server_list = list(servertools.get_servers_list().keys()) + for server in sorted(server_list): + server_parameters = servertools.get_server_parameters(server) + if server_parameters["has_settings"] and [x for x in server_parameters["settings"]] and server_parameters['active']: + names.append(server_parameters['name']) + ids.append(server) - select = platformtools.dialog_select(config.get_localized_string(60538), names) - if select != -1: - ID = ids[select] + select = platformtools.dialogSelect(config.getLocalizedString(60538), names) + if select != -1: + ID = ids[select] - it = Item(channel = 'settings', - action = action, - config = ID) + it = Item(channel = 'settings', + action = action, + config = ID) - setting.server_config(it) - if select != -1: - servers_menu(item) + setting.server_config(it) + if select != -1: + servers_menu(item) def channels_menu(item): - import channelselector - from core import channeltools - from core.item import Item - from platformcode import config, platformtools - from specials import setting + import channelselector + from core import channeltools + from core.item import Item + from platformcode import config, platformtools + from specials import setting - names = [] - ids = [] + names = [] + ids = [] - channel_list = channelselector.filterchannels("all") - for channel in channel_list: - if not channel.channel: - continue - channel_parameters = channeltools.get_channel_parameters(channel.channel) - if channel_parameters["has_settings"]: - names.append(channel.title) - ids.append(channel.channel) + channel_list = channelselector.filterchannels("all") + for channel in channel_list: + if not channel.channel: + continue + channel_parameters = channeltools.get_channel_parameters(channel.channel) + if channel_parameters["has_settings"]: + names.append(channel.title) + ids.append(channel.channel) - select = platformtools.dialog_select(config.get_localized_string(60537), names) - if select != -1: - ID = ids[select] + select = platformtools.dialogSelect(config.getLocalizedString(60537), names) + if select != -1: + ID = ids[select] - it = Item(channel='settings', - action="channel_config", - config=ID) + it = Item(channel='settings', + action="channel_config", + config=ID) - setting.channel_config(it) - return channels_menu(item) + setting.channel_config(it) + return channels_menu(item) def check_channels(item): - from specials import setting - from platformcode import config, platformtools - item.channel = 'setting' - item.extra = 'lib_check_datajson' - itemlist = setting.conf_tools(item) - text = '' - for item in itemlist: - text += item.title + '\n' - - platformtools.dialog_textviewer(config.get_localized_string(60537), text) + from specials import setting + from platformcode import config, platformtools + item.channel = 'setting' + item.extra = 'lib_check_datajson' + itemlist = setting.conf_tools(item) + text = '' + for item in itemlist: + text += item.title + '\n' + platformtools.dialogTextviewer(config.getLocalizedString(60537), text) def SettingOnPosition(item): - # addonId is the Addon ID - # item.category is the Category (Tab) offset (0=first, 1=second, 2...etc) - # item.setting is the Setting (Control) offse (0=first, 1=second, 2...etc) - # This will open settings dialog focusing on fourth setting (control) inside the third category (tab) + # addonId is the Addon ID + # item.category is the Category (Tab) offset (0=first, 1=second, 2...etc) + # item.setting is the Setting (Control) offse (0=first, 1=second, 2...etc) + # This will open settings dialog focusing on fourth setting (control) inside the third category (tab) - import xbmc - from platformcode import config - - config.open_settings() - category = item.category if item.category else 0 - setting = item.setting if item.setting else 0 - logger.debug('SETTING= ' + str(setting)) - xbmc.executebuiltin('SetFocus(%i)' % (category - 100)) - xbmc.executebuiltin('SetFocus(%i)' % (setting - 80)) + import xbmc + from platformcode import config + config.openSettings() + category = item.category if item.category else 0 + setting = item.setting if item.setting else 0 + logger.debug('SETTING= ' + str(setting)) + xbmc.executebuiltin('SetFocus(%i)' % (category - 100)) + xbmc.executebuiltin('SetFocus(%i)' % (setting - 80)) def select(item): - from platformcode import config, platformtools - # item.id = setting ID - # item.type = labels or values - # item.values = values separeted by | - # item.label = string or string id + from platformcode import config, platformtools + # item.id = setting ID + # item.type = labels or values + # item.values = values separeted by | + # item.label = string or string id - label = config.get_localized_string(int(item.label)) if item.label.isdigit() else item.label - values = [] + label = config.getLocalizedString(int(item.label)) if item.label.isdigit() else item.label + values = [] - if item.type == 'labels': - for val in item.values.split('|'): - values.append(config.get_localized_string(int(val))) - else: - values = item.values.split('|') - ID = config.get_setting(item.id) if config.get_setting(item.id) else 0 - select = platformtools.dialog_select(label, values, ID) + if item.type == 'labels': + for val in item.values.split('|'): + values.append(config.getLocalizedString(int(val))) + else: + values = item.values.split('|') + ID = config.getSetting(item.id) if config.getSetting(item.id) else 0 + select = platformtools.dialogSelect(label, values, ID) - config.set_setting(item.id, values[select]) + config.setSetting(item.id, values[select]) diff --git a/platformcode/unify.py b/platformcode/unify.py index 2c4a35b5..3d8d83a7 100644 --- a/platformcode/unify.py +++ b/platformcode/unify.py @@ -224,8 +224,8 @@ def set_color(title, category): # logger.info() from core import jsontools - styles_path = os.path.join(config.get_runtime_path(), 'resources', 'color_styles.json') - preset = config.get_setting("preset_style", default="Estilo 1") + styles_path = os.path.join(config.getRuntimePath(), 'resources', 'color_styles.json') + preset = config.getSetting("preset_style", default="Estilo 1") color_setting = jsontools.load((open(styles_path, "r").read()))[preset] color_scheme = {'otro': 'white', 'dual': 'white'} @@ -238,14 +238,14 @@ def set_color(title, category): 'vos', 'vo', 'server', 'library', 'update', 'no_update'] # Check the status of the custom colors options - custom_colors = config.get_setting('title_color') + custom_colors = config.getSetting('title_color') # The color dictionary is formed for each element, the option is active uses the user's configuration, if it does not leave the title blank. if title not in ['', ' ']: for element in color_list: if custom_colors: - color_scheme[element] = remove_format(config.get_setting('%s_color' % element)) + color_scheme[element] = remove_format(config.getSetting('%s_color' % element)) else: color_scheme[element] = remove_format(color_setting.get(element, 'white')) # color_scheme[element] = 'white' @@ -570,7 +570,7 @@ def thumbnail_type(item): # logger.info() # Check what type of thumbnail will be used in findvideos, Poster or Logo of the server - thumb_type = config.get_setting('video_thumbnail_type') + thumb_type = config.getSetting('video_thumbnail_type') info = item.infoLabels if not item.contentThumbnail: item.contentThumbnail = item.thumbnail diff --git a/platformcode/updater.py b/platformcode/updater.py index c0805e89..246bcfb6 100644 --- a/platformcode/updater.py +++ b/platformcode/updater.py @@ -42,7 +42,7 @@ def loadCommits(page=1): except: xbmc.sleep(1000) else: - platformtools.dialog_notification(addonname, config.get_localized_string(70675)) + platformtools.dialogNotification(addonname, config.getLocalizedString(70675)) ret = None return ret @@ -158,7 +158,7 @@ def check(background=False): if addon.getSetting("addon_update_message"): if background: - platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(80040) % commits[0]['sha'][:7], time=3000, sound=False) + platformtools.dialogNotification(config.getLocalizedString(20000), config.getLocalizedString(80040) % commits[0]['sha'][:7], time=3000, sound=False) try: with open(config.changelogFile, 'a+') as fileC: fileC.write(changelog) @@ -166,7 +166,7 @@ def check(background=False): import traceback logger.error(traceback.format_exc()) elif changelog: - platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(80041) + changelog) + platformtools.dialogOk(config.getLocalizedString(20000), config.getLocalizedString(80041) + changelog) else: logger.info('Nessun nuovo aggiornamento') @@ -221,8 +221,8 @@ def getShaStr(str): -def updateFromZip(message=config.get_localized_string(80050)): - dp = platformtools.dialog_progress_bg(config.get_localized_string(20000), message) +def updateFromZip(message=config.getLocalizedString(80050)): + dp = platformtools.dialogProgressBg(config.getLocalizedString(20000), message) dp.update(0) remotefilename = 'https://github.com/' + user + "/" + repo + "/archive/" + branch + ".zip" @@ -242,7 +242,7 @@ def updateFromZip(message=config.get_localized_string(80050)): urllib.urlretrieve(remotefilename, localfilename, lambda nb, bs, fs, url=remotefilename: _pbhook(nb, bs, fs, url, dp)) except Exception as e: - platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(80031)) + platformtools.dialogOk(config.getLocalizedString(20000), config.getLocalizedString(80031)) logger.info('Non sono riuscito a scaricare il file zip') logger.info(e) dp.close() @@ -255,7 +255,7 @@ def updateFromZip(message=config.get_localized_string(80050)): if os.path.isfile(localfilename): logger.info('il file esiste') - dp.update(80, config.get_localized_string(20000) + '\n' + config.get_localized_string(80032)) + dp.update(80, config.getLocalizedString(20000) + '\n' + config.getLocalizedString(80032)) import zipfile try: @@ -297,7 +297,7 @@ def updateFromZip(message=config.get_localized_string(80050)): dp.update(100) xbmc.sleep(1000) dp.close() - if message != config.get_localized_string(80050): + if message != config.getLocalizedString(80050): xbmc.executebuiltin("UpdateLocalAddons") refreshLang() @@ -306,7 +306,7 @@ def updateFromZip(message=config.get_localized_string(80050)): def refreshLang(): from platformcode import config - language = config.get_localized_string(20001) + language = config.getLocalizedString(20001) if language == 'eng': xbmc.executebuiltin("SetGUILanguage(resource.language.it_it)") xbmc.executebuiltin("SetGUILanguage(resource.language.en_en)") diff --git a/platformcode/xbmc_config_menu.py b/platformcode/xbmc_config_menu.py index 4384f041..43f7b46d 100644 --- a/platformcode/xbmc_config_menu.py +++ b/platformcode/xbmc_config_menu.py @@ -10,20 +10,24 @@ if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int from builtins import range from past.utils import old_div -from core import channeltools, servertools +from core import channeltools, jsontools, servertools, filetools, support from platformcode import config, logger, platformtools from core.support import match -BACKGROUND = 100 -HEADER = 101 -CLOSE = 102 -OK = 103 -CANCEL = 104 -DEFAULT = 105 -PARAMETERS = 106 -SCROLLBARBG = 107 -SCROLLBARFG = 108 -LOADING = 109 +if sys.version_info[0] >= 3: + from concurrent import futures +else: + from concurrent_py2 import futures + +HEADER = 1 +LIST = 100 +SCROLLBAR = 101 + +BUTTONS = 200 +MUP = 300 +MDN = 301 +DEL = 302 +CONTROLS = [MUP, MDN, DEL] LEFT = 1 RIGHT =2 @@ -31,264 +35,193 @@ UP = 3 DOWN = 4 SCROLLDOWN = 104 SCROLLUP = 105 -BACK = 92 +EXIT = 10 +BACKSPACE = 92 PREVIOUS = 10 GESTUREBEGIN = 501 GESTUREPAN = 504 +def title(label): + matches = support.match(label, patron=r'@(\d+)').matches + if matches: + for m in matches: + label = label.replace('@' + m, config.getLocalizedString(int(m))) + return label + +def getControlList(c, v=None): + labels = [] + values = [] + currents = {} + if v == None: v = c.get('default', 0) + if c.get('lvalues'): + labels = [title(v) for v in c['lvalues']] + values = range(0, len(labels)) + + elif c.get('dvalues'): + for l, v in c['dvalues'].items(): + labels.append(l) + values.append(v) + if v in values: v = values.index(v) + + elif c.get('values'): + values = c['values'] + labels = [str(v) for v in values] + if v in values: v = values.index(v) + + elif c.get('rvalues'): + values = range(c['rvalues'][0], c['rvalues'][1] + 1, c['rvalues'][2]) + labels = [str(v) for v in values] + + if labels and values: + currents = {'label':labels[v], 'value':values[v]} + + return labels, values, currents class SettingsWindow(xbmcgui.WindowXMLDialog): - """ - Derived class that allows you to use custom configuration boxes. - - This class is derived from xbmcgui.WindowXMLDialog and allows you to create a dialog box with controls of the type: - Radio Button (bool), Text Box (text), List (list) and Information Labels (label). - We can also customize the box by adding a title (title). - - Construction method: - SettingWindow(list_controls, dict_values, title, callback, item) - Parameters: - list_controls: (list) List of controls to include in the window, according to the following scheme: - (opcional)list_controls= [ - {'id': "nameControl1", - 'type': "bool", # bool, text, list, label - 'label': "Control 1: type RadioButton", - 'color': '0xFFee66CC', # text color in hexadecimal ARGB format - 'default': True, - 'enabled': True, - 'visible': True - }, - {'id': "nameControl2", - 'type': "text", # bool, text, list, label - 'label': "Control 2: type text box", - 'color': '0xFFee66CC', - 'default': "Valor por defecto", - 'hidden': False, # only for type = text Indicates whether to hide the text (for passwords) - 'enabled': True, - 'visible': True - }, - {'id': "nameControl3", - 'type': "list", # bool, text, list, label - 'label': "Control 3: type List", - 'color': '0xFFee66CC', - 'default': 0, # Default value index in lvalues - 'enabled': True, - 'visible': True, - 'lvalues':["item1", "item2", "item3", "item4"], # only for type = list - }, - {'id': "nameControl4", - 'type': "label", # bool, text, list, label - 'label': "Control 4: tipo Etiqueta", - 'color': '0xFFee66CC', - 'enabled': True, - 'visible': True - }] - If the controls list is not included, an attempt is made to obtain the json of the channel from which the call is made. - - The format of the controls in the json is: - { - ... - ... - "settings": [ - { - "id": "name_control_1", - "type": "bool", - "label": "Control 1: type RadioButton", - "default": false, - "enabled": true, - "visible": true, - "color": "0xFFee66CC" - }, - { - "id": "name_control_2", - "type": "text", - "label": "Control 2: type text box", - "default": "Default value", - "hidden": true, - "enabled": true, - "visible": true, - "color": "0xFFee66CC" - }, - { - "id": "name_control_3", - "type": "list", - "label": "Control 3: type List", - "default": 0, - "enabled": true, - "visible": true, - "color": "0xFFee66CC", - "lvalues": [ - "item1", - "item2", - "item3", - "item4" - ] - }, - { - "id": "name_control_4", - "type": "label", - "label": "Control 4: tipo Etiqueta", - "enabled": true, - "visible": true, - "color": "0xFFee66CC" - }, - ] - } - - The fields 'label', 'default', 'enabled' and 'lvalues' can be a number preceded by '@'. In which case - it will look for the literal in the string.xml file of the selected language. - The 'enabled' and 'visible' fields support the comparators eq (), gt () and it () and their operation is - described at: http://kodi.wiki/view/Add-on_settings#Different_types - - (opcional) dict_values: (dict) Dictionary representing the pair (id: value) of the controls in the list. - If any control in the list is not included in this dictionary, it will be assigned the default value. - dict_values={"nameControl1": False, - "nameControl2": "Esto es un ejemplo"} - - (opcional) caption: (str) Configuration window title. It can be located by a number preceded by '@' - (opcional) callback (str) Name of the function, of the channel from which the call is made, which will be - invoked when pressing the accept button in the window. This function will be passed as parameters the - object 'item' and the 'dict_values' dictionary. If this parameter does not exist, the channel is searched for - function called 'cb_validate_config' and if it exists it is used as a callback. - - Retorno: If 'callback' is specified or the channel includes 'cb_validate_config' what that function returns will be returned. If not return none - - Usage examples: - platformtools.show_channel_settings(): As such, without passing any argument, the window detects which channel the call has been made, - and read the json settings and load the controls, when you click OK, save them again. - - return platformtools.show_channel_settings(list_controls=list_controls, dict_values=dict_values, callback='cb', item=item): - This opens the window with the passed controls and the dict_values values, if dict_values is not passed, it loads the default values of the controls, - when you accept, it calls the 'callback' function of the channel from where it was called, passing as parameters, item and dict_values - """ - - def start(self, list_controls=None, dict_values=None, caption="", callback=None, item=None, custom_button=None, channelpath=None): + def start(self, *args, **kwargs): logger.debug() - # Media Path - self.mediapath = os.path.join(config.get_runtime_path(), 'resources', 'skins', 'Default', 'media') - # Params - self.list_controls = list_controls - self.values = dict_values - self.caption = caption - self.callback = callback - self.item = item + # logger.dbg() + self.controls = kwargs.get('list_controls', []) + self.values = kwargs.get('dict_values', {}) + self.caption = kwargs.get('caption', '') + self.callback = kwargs.get('callback', None) + self.item = kwargs.get('item', None) + self.customButtons = kwargs.get('custom_buttons', [kwargs.get('custom_button', {})]) + self.listPosition = 0 + self.buttonPosition = 0 - if isinstance(custom_button, dict): - self.custom_button = {} - self.custom_button["label"] = custom_button.get("label", "") - self.custom_button["function"] = custom_button.get("function", "") - self.custom_button["visible"] = bool(custom_button.get("visible", True)) - self.custom_button["close"] = bool(custom_button.get("close", False)) - else: - self.custom_button = None + channelpath = kwargs.get('channelpath', inspect.currentframe().f_back.f_back.f_code.co_filename) - # Load Channel Settings - if not channelpath: - channelpath = inspect.currentframe().f_back.f_back.f_code.co_filename - self.channel = os.path.basename(channelpath).replace(".py", "") - self.ch_type = os.path.basename(os.path.dirname(channelpath)) - # If list_controls does not exist, it is removed from the channel json - if not self.list_controls: + if channelpath: + self.channel = filetools.basename(channelpath).replace('.py', '') + self.ch_type = filetools.basename(filetools.dirname(channelpath)) - # If the channel path is in the "channels" folder, we get the controls and values using chaneltools - if os.path.join(config.get_runtime_path(), "channels") in channelpath or os.path.join(config.get_runtime_path(), "specials") in channelpath: + if not self.controls: + self.controls, default_values = channeltools.get_channel_controls_settings(self.channel) - # The call is made from a channel - self.list_controls, default_values = channeltools.get_channel_controls_settings(self.channel) - self.kwargs = {"channel": self.channel} - self.channelName = channeltools.get_channel_json(self.channel)['name'] + if not self.caption: + if self.ch_type in ['channels', 'specials']: + self.caption = config.getLocalizedString(30100) + ' - ' + channeltools.get_channel_json(self.channel)['name'] + elif self.ch_type in ['servers']: + self.caption = config.getLocalizedString(30100) + ' - ' + servertools.get_server_parameters(self.channel)['name'] - # If the channel path is in the "servers" folder, we get the controls and values through servertools - elif os.path.join(config.get_runtime_path(), "servers") in channelpath: - - # The call is made from a channel - self.list_controls, default_values = servertools.get_server_controls_settings(self.channel) - self.kwargs = {"server": self.channel} - self.channelName = servertools.get_server_parameters(self.channel)['name'] - - # Else Exit - else: - return None - - # If dict_values are not passed, create a blank dict - if self.values is None: - self.values = {} - - # Make title - if self.caption == "": - self.caption = str(config.get_localized_string(30100)) + ' - ' + self.channelName - - matches = match(self.caption, patron=r'@(\d+)').matches - if matches: - for m in matches: - self.caption = self.caption.replace('@' + match, config.get_localized_string(int(m))) - - # Show Window - self.return_value = None + self.ret = None self.doModal() - return self.return_value + return self.ret - @staticmethod - def set_enabled(c, val): - if c["type"] == "list": - c["control"].setEnabled(val) - c["label"].setEnabled(val) - else: - c["control"].setEnabled(val) + def onInit(self): + xbmc.sleep(150) + self.getControl(HEADER).setLabel(self.caption) + self.LIST = self.getControl(LIST) + self.BUTTONS = self.getControl(BUTTONS) + self.makeControls() + self.makeButtons() - @staticmethod - def set_visible(c, val): - if c["type"] == "list": - c["control"].setVisible(val) - c["label"].setVisible(val) - else: - c["control"].setVisible(val) - def evaluate_conditions(self): - for c in self.list_controls: - c["active"] = self.evaluate(self.list_controls.index(c), c["enabled"]) - self.set_enabled(c, c["active"]) - c["show"] = self.evaluate(self.list_controls.index(c), c["visible"]) - if not c["show"]: - self.set_visible(c, c["show"]) - self.visible_controls = [c for c in self.list_controls if c["show"]] + def makeControls(self, index = 0, index2 = None): + itemlist = [] + hidden = 0 + controllist = [] - def evaluate(self, index, cond): - import re + def makeControl(n, control): + label2 = '' + currentval = control.get('control', config.getSetting(control['id'], self.channel)) + control['control'] = currentval + label = title(control.get('label', '')) + if control.get('submenu', False): + label = "•• " + label + + if control['type'] == 'list': + if type(currentval) == list: currentval = control['default'] + labels, values, currents = getControlList(control, currentval) + label2 = currents.get('label', '') + elif control['type'] == 'multi': + if type(currentval) == list: + currents = [c for l, v, c in [getControlList(control, v) for v in currentval]] + else: + l, v, c = getControlList(control, currentval) + currents = [c] + label2 = ', '.join(c.get('label', '') for c in currents) + elif control['type'] == 'text': + if currentval and control.get('hidden', False) or control.get('mode', '') == 'pass' : label2 = '•' * 10 + else: label2 = str(currentval if currentval else '') + else: label2 = str(currentval) + item = xbmcgui.ListItem(label, label2) + item.setProperty('type', control['type']) + item.setProperties({'id': str(n), 'type':control['type']}) + if control['type'] == 'bool': item.setProperty('bool', 'on.png' if currentval else 'off.png') + return n, item + + # for n, control in enumerate(self.controls): + # controllist.append(makeControl(n, control)) + + with futures.ThreadPoolExecutor() as executor: + itlist = [executor.submit(makeControl, n, control) for n, control in enumerate(self.controls)] + for res in futures.as_completed(itlist): + if res.result(): + controllist.append(res.result()) + + controllist.sort(key=lambda x: x[0]) + for n, item in controllist: + if self.evalute('visible', n): + item.setProperty('enabled', str(self.evalute('enabled', n))) + itemlist.append(item) + elif index >= n: + hidden += 1 + if hidden: + index -= 1 + + self.LIST.reset() + self.LIST.addItems(itemlist) + self.setFocusId(LIST) + self.LIST.selectItem(index) + if index2: + self.setFocusId(index2) + + + def makeButtons(self): + for button in ['ok', 'close', 'reset'] + [b.get('icon', 'btn') for b in self.customButtons]: + item = xbmcgui.ListItem(button) + item.setArt({'button': button + '.png'}) + self.BUTTONS.addItem(item) + + + def evalute(self, name, index): ok = False + control_value = None + condition = self.controls[index].get(name, True) + if type(condition) == bool: + return condition + conditions = support.match(condition, patron=r'''(!?eq|!?gt|!?lt)?\s*\(\s*([^, ]+)\s*,\s*["']?([^"'\)]+)["']?\)([+|])?''').matches - # If the condition is True or False, there is nothing else to evaluate, that is the value - if isinstance(cond, bool): - return cond + for operator, _id, value, next in conditions: + value = title(value) + logger.debug('CONDITIONS', operator, _id, value, next) - # Get the conditions - # dbg() - conditions = re.compile(r'''(!?eq|!?gt|!?lt)?\s*\(\s*([^, ]+)\s*,\s*["']?([^"'\)]+)["']?\)([+|])?''').findall(cond) - for operator, id, value, next in conditions: - matches = match(value, patron=r'@(\d+)').matches - if matches: - for m in matches: - value = value.replace('@' + m, config.get_localized_string(int(m))) try: - id = int(id) + # The control to evaluate on has to be within range, otherwise it returns False + if index + int(_id) < 0 or index + int(_id) >= len(self.controls): + return False + + else: + # Obtain the value of the control on which it is compared + control_value = self.controls[index + int(_id)]["control"] + if type(value) == str: + c = self.controls[index + int(_id)] + if c.get('lvalues'): control_value = title(c['lvalues'][control_value]) + elif c.get('dvalues'): control_value = title(c['lvalues'][control_value]) + else: return False except: - return False + for control in self.controls: + if control['id'] == int(_id): + control_value = control["control"] - # The control to evaluate on has to be within range, otherwise it returns False - if index + id < 0 or index + id >= len(self.list_controls): - return False - - else: - # Obtain the value of the control on which it is compared - c = self.list_controls[index + id] - if c["type"] == "bool": control_value = bool(c["control"].isSelected()) - if c["type"] == "text": control_value = c["control"].getText() - if c["type"] == "list": control_value = c["label"].getLabel() - if c["type"] == "label": control_value = c["control"].getLabel() + if not control_value: + continue # Operations lt "less than" and gt "greater than" require comparisons to be numbers, otherwise it returns # False @@ -364,458 +297,195 @@ class SettingsWindow(xbmcgui.WindowXMLDialog): return ok - def add_control_label(self, c): - control = xbmcgui.ControlLabel(0, -100, self.controls_width + 20, 40, "", alignment=4, font=self.font, textColor=c["color"]) - - self.addControl(control) - - control.setVisible(False) - control.setLabel(c["label"]) - c["control"] = control - - - def add_control_list(self, c): - control = xbmcgui.ControlButton(0, -100, self.controls_width + 10, self.height_control, c["label"], - os.path.join(self.mediapath, 'Controls', 'MenuItemFO.png'), - os.path.join(self.mediapath, 'Controls', 'MenuItemNF.png'), - 10, textColor=c["color"], font=self.font) - label = xbmcgui.ControlLabel(0, -100, self.controls_width, self.height_control, "", font=self.font, textColor=c["color"], alignment= 1 | 4) - - self.addControl(control) - self.addControl(label) - - control.setVisible(False) - label.setVisible(False) - logger.debug('VALUES',c["lvalues"][self.values[c["id"]]]) - label.setLabel(c["lvalues"][self.values[c["id"]]]) - - c["control"] = control - c["label"] = label - - - def add_control_text(self, c): - control = xbmcgui.ControlEdit(0, -100, self.controls_width, self.height_control, - c["label"], self.font, c["color"], '', 1 | 4, - focusTexture='', - noFocusTexture='') - - image = xbmcgui.ControlImage(0, -100, self.controls_width + 10, self.height_control, os.path.join(self.mediapath, 'Controls', 'MenuItemFO.png')) - - self.addControl(image) - self.addControl(control) - image.setVisibleCondition('Control.HasFocus(%s)' % control.getId(), True) - - control.setVisible(False) - control.setLabel(c["label"]) - if c['hidden']: control.setType(xbmcgui.INPUT_TYPE_PASSWORD, c["label"]) - # frodo fix - s = self.values[c["id"]] - if s is None: s = c['default'] if 'default' in c else '' - - control.setText(s) - control.setWidth(self.controls_width-10) - control.setHeight(self.height_control) - - c["control"] = control - c['image'] = image - - def add_control_bool(self, c): - # Old versions do not support some textures - if xbmcgui.__version__ in ["1.2", "2.0"]: - control = xbmcgui.ControlRadioButton(0, -100, self.controls_width + 20, self.height_control, - label=c["label"], font=self.font, textColor=c["color"], - focusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemFO.png'), - noFocusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemNF.png')) - else: - control = xbmcgui.ControlRadioButton(0, -100, self.controls_width + 20, - self.height_control, label=c["label"], font=self.font, - textColor=c["color"], - focusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemFO.png'), - noFocusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemNF.png'), - focusOnTexture=os.path.join(self.mediapath, 'Controls', 'radiobutton-focus.png'), - noFocusOnTexture=os.path.join(self.mediapath, 'Controls', 'radiobutton-focus.png'), - focusOffTexture=os.path.join(self.mediapath, 'Controls', 'radiobutton-nofocus.png'), - noFocusOffTexture=os.path.join(self.mediapath, 'Controls', 'radiobutton-nofocus.png')) - - image = xbmcgui.ControlImage(0, -100, self.controls_width + 10, self.height_control, os.path.join(self.mediapath, 'Controls', 'MenuItemFO.png')) - self.addControl(image) - self.addControl(control) - image.setVisibleCondition('Control.HasFocus(%s)' % control.getId(), True) - control.setVisible(False) - control.setRadioDimension(x=self.controls_width - (self.height_control - 5), y=0, width=self.height_control - 5, height=self.height_control - 5) - control.setSelected(self.values[c["id"]]) - - c["control"] = control - c['image'] = image - - def onInit(self): - self.getControl(OK).setEnabled(False) - self.getControl(CANCEL).setEnabled(False) - self.getControl(DEFAULT).setEnabled(False) - self.ok_enabled = False - self.default_enabled = False - - # Kodi 18 compatibility - if config.get_platform(True)['num_version'] < 18: - if xbmcgui.__version__ == "1.2": - self.setCoordinateResolution(1) - else: - self.setCoordinateResolution(5) - - # Title - self.getControl(HEADER).setLabel(self.caption) - - if self.custom_button is not None: - if self.custom_button['visible']: - self.getControl(DEFAULT).setLabel(self.custom_button['label']) - else: - self.getControl(DEFAULT).setVisible(False) - - # Control Area Dimensions - self.controls_width = self.getControl(PARAMETERS).getWidth() - 30 - self.controls_height = self.getControl(PARAMETERS).getHeight() -100 - self.controls_pos_x = self.getControl(PARAMETERS).getPosition()[0] + self.getControl(BACKGROUND).getPosition()[0] + 10 - self.controls_pos_y = self.getControl(PARAMETERS).getPosition()[1] + self.getControl(BACKGROUND).getPosition()[1] - self.height_control = 60 - self.font = "font16" - - # In old versions: we create 5 controls, from the contrary when clicking the second control, - # automatically change third party label to "Short By: Name" I don't know why ... - if xbmcgui.ControlEdit == ControlEdit: - for x in range(5): - control = xbmcgui.ControlRadioButton(-500, 0, 0, 0, "") - self.addControl(control) - - for c in self.list_controls: - # Skip controls that do not have the appropriate values - if "type" not in c: continue - if "label" not in c: continue - if c["type"] != "label" and "id" not in c: continue - if c["type"] == "list" and "lvalues" not in c: continue - if c["type"] == "list" and not isinstance(c["lvalues"], list): continue - if c["type"] == "list" and not len(c["lvalues"]) > 0: continue - if c["type"] != "label" and len([control.get("id") for control in self.list_controls if c["id"] == control.get("id")]) > 1: continue - - # Translation label and lvalues - if c['label'].startswith('@') and unicode(c['label'][1:]).isnumeric(): c['label'] = config.get_localized_string(int(c['label'][1:])) - if c['type'] == 'list': - lvalues = [] - for li in c['lvalues']: - if li.startswith('@') and unicode(li[1:]).isnumeric(): lvalues.append(config.get_localized_string(int(li[1:]))) - else: lvalues.append(li) - c['lvalues'] = lvalues - - # Default values in case the control does not have them - if c["type"] == "bool": default = False - elif c["type"] == "list": default = 0 - else: default = "" # label or text - - c["default"] = c.get("default", default) - c["color"] = c.get("color", "0xFFFFFFFF") - c["visible"] = c.get("visible", True) - c["enabled"] = c.get("enabled", True) - - if c["type"] == "label" and "id" not in c: c["id"] = None - if c["type"] == "text": c["hidden"] = c.get("hidden", False) - - # Decide whether to use the default value or the saved value - if c["type"] in ["bool", "text", "list"]: - if c["id"] not in self.values: - if not self.callback: self.values[c["id"]] = config.get_setting(c["id"], **self.kwargs) - else: self.values[c["id"]] = c["default"] - - if c["type"] == "bool": self.add_control_bool(c) - elif c["type"] == 'text': self.add_control_text(c) - elif c["type"] == 'list': self.add_control_list(c) - elif c["type"] == 'label': self.add_control_label(c) - self.list_controls = [c for c in self.list_controls if "control" in c] - - self.evaluate_conditions() - self.index = -1 - self.dispose_controls(0) - self.getControl(LOADING).setVisible(False) - self.getControl(OK).setEnabled(True) - self.getControl(CANCEL).setEnabled(True) - self.getControl(DEFAULT).setEnabled(True) - self.ok_enabled = True - self.default_enabled = True - self.check_default() - self.check_ok(self.values) - - def dispose_controls(self, index, focus=False, force=False): - show_controls = old_div(self.controls_height, self.height_control) - 1 - - visible_count = 0 - - if focus: - if not index >= self.index or not index <= self.index + show_controls: - if index < self.index: new_index = index - else: new_index = index - show_controls - else:new_index = self.index - else: - if index + show_controls >= len(self.visible_controls): index = len(self.visible_controls) - show_controls - 1 - if index < 0: index = 0 - new_index = index - - if self.index != new_index or force: - for x, c in enumerate(self.visible_controls): - if x < new_index or visible_count > show_controls or not c["show"]: - self.set_visible(c, False) - else: - c["y"] = self.controls_pos_y + visible_count * self.height_control - visible_count += 1 - - if c["type"] == "list": - c["control"].setPosition(self.controls_pos_x, c["y"]) - if xbmcgui.__version__ == "1.2": c["label"].setPosition(self.controls_pos_x + self.controls_width - 30, c["y"]) - else: c["label"].setPosition(self.controls_pos_x, c["y"]) - - else: - if c["type"] == "bool": c["control"].setPosition(self.controls_pos_x, c["y"]) - elif c['type'] == 'text': c["control"].setPosition(self.controls_pos_x +10, c["y"]) - else: c["control"].setPosition(self.controls_pos_x, c["y"]) - if c['type'] in ['bool', 'text']:c['image'].setPosition(self.controls_pos_x, c["y"]) - - self.set_visible(c, True) - - # Calculate the position and size of the ScrollBar - hidden_controls = len(self.visible_controls) - show_controls - 1 - if hidden_controls < 0: hidden_controls = 0 - - scrollbar_height = self.getControl(SCROLLBARBG).getHeight() - (hidden_controls * 3) - scrollbar_y = self.getControl(SCROLLBARBG).getPosition()[1] + (new_index * 3) - self.getControl(SCROLLBARFG).setPosition(self.getControl(SCROLLBARBG).getPosition()[0], scrollbar_y) - self.getControl(SCROLLBARFG).setHeight(scrollbar_height) - - self.index = new_index - - if focus: - self.setFocus(self.visible_controls[index]["control"]) - - def check_ok(self, dict_values=None): - if not self.callback: - if dict_values: - self.init_values = dict_values.copy() - self.getControl(OK).setEnabled(False) - self.ok_enabled = False - - else: - if self.init_values == self.values: - self.getControl(OK).setEnabled(False) - self.ok_enabled = False - else: - self.getControl(OK).setEnabled(True) - self.ok_enabled = True - - def check_default(self): - if self.custom_button is None: - def_values = dict([[c["id"], c.get("default")] for c in self.list_controls if not c["type"] == "label"]) - - if def_values == self.values: - self.getControl(DEFAULT).setEnabled(False) - self.default_enabled = False - else: - self.getControl(DEFAULT).setEnabled(True) - self.default_enabled = True - def onClick(self, control): - # Default values - if control in [DEFAULT]: - if self.custom_button is not None: - if self.custom_button["close"]: - self.close() + logger.debug('CONTROL', control) + if control in [LIST] and self.getControl(control).getSelectedItem().getProperty('enabled') == 'False': + pass + elif control in [LIST]: + item = self.LIST.getSelectedItem() + _type = item.getProperty('type') + _id = int(item.getProperty('id')) + value = self.controls[_id]['control'] - if '.' in self.callback: package, self.callback = self.callback.rsplit('.', 1) - else: package = '%s.%s' % (self.ch_type, self.channel) + if _type == 'bool': + self.controls[_id]['control'] = False if value else True - try: cb_channel = __import__(package, None, None, [package]) - except ImportError: logger.error('Imposible importar %s' % package) + elif _type == 'list': + labels, values, c = getControlList(self.controls[_id]) + + default = labels.index(item.getLabel2()) + selection = platformtools.dialogSelect(item.getLabel(), labels, default) + if selection > -1: + self.controls[_id]['control'] = values[selection] + + elif _type == 'multi': + labels, values, c = getControlList(self.controls[_id]) + default = [labels.index(val.strip()) for val in item.getLabel2().split(',')] + selection = platformtools.dialogMultiselect(item.getLabel(), labels, preselect=default) + self.controls[_id]['control'] = [values[v] for v in selection] + + elif _type == 'text': + mode = {'':None, 'number':0, 'date':1, 'time':2, 'ip':3, 'pass':4}[self.controls[_id].get('mode', '')] + if mode != None: + self.controls[_id]['control'] = platformtools.dialogNumeric(4, item.getLabel(), self.controls[_id]['control']) else: - self.return_value = getattr(cb_channel, self.custom_button['function'])(self.item, self.values) - if not self.custom_button["close"]: - if isinstance(self.return_value, dict) and "label" in self.return_value: self.getControl(DEFAULT).setLabel(self.return_value['label']) + self.controls[_id]['control'] = platformtools.dialogInput(item.getLabel2(), item.getLabel(), hidden=self.controls[_id].get('hidden', False)) - for c in self.list_controls: - if c["type"] == "text": c["control"].setText(self.values[c["id"]]) - if c["type"] == "bool": c["control"].setSelected(self.values[c["id"]]) - if c["type"] == "list": c["label"].setLabel(c["lvalues"][self.values[c["id"]]]) + elif _type == 'insert': + self.insertControls(_id) - self.evaluate_conditions() - self.dispose_controls(self.index, force=True) + self.makeControls(_id) + elif control in [MUP]: + pos = self.LIST.getSelectedPosition() + if self.controls[pos-1]['type'] == 'insert' and self.controls[pos-1].get('label'): + self.controls[pos], self.controls[pos-1] = self.controls[pos-1], self.controls[pos] + self.makeControls(pos-1, MUP) + elif control in [MDN]: + pos = self.LIST.getSelectedPosition() + if self.controls[pos+1]['type'] == 'insert' and self.controls[pos+1].get('label'): + self.controls[pos], self.controls[pos+1] = self.controls[pos+1], self.controls[pos] + self.makeControls(pos+1, MDN) + elif control in [DEL]: + pos = self.LIST.getSelectedPosition() + if self.controls[pos]['type'] == 'insert' and self.controls[pos].get('label'): + self.controls.pop(pos) + self.makeControls(pos, DEL if self.controls[pos].get('label') else None) + + + elif control in [BUTTONS]: + pos = self.BUTTONS.getSelectedPosition() + if pos == 0: + self.saveControls() + self.close() + elif pos == 1: + self.close() + elif pos == 2: + self.resetControls() else: - for c in self.list_controls: - if c["type"] == "text": - c["control"].setText(c["default"]) - self.values[c["id"]] = c["default"] - if c["type"] == "bool": - c["control"].setSelected(c["default"]) - self.values[c["id"]] = c["default"] - if c["type"] == "list": - c["label"].setLabel(c["lvalues"][c["default"]]) - self.values[c["id"]] = c["default"] + self.customAction(pos) - self.evaluate_conditions() - self.dispose_controls(self.index, force=True) - self.check_default() - self.check_ok() - # Cancel button [X] - if control in [CLOSE, CANCEL]: - self.close() + def onAction(self, action): + action = action.getId() + control = self.getFocusId() + self.listPosition = self.LIST.getSelectedPosition() + self.buttonPosition = self.BUTTONS.getSelectedPosition() + item = self.LIST.getSelectedItem() + # logger.dbg() + if item: + if item.getProperty('type') == 'label': + if action in [UP]: self.LIST.selectItem(self.listPosition - 1) + elif action in [DOWN]: self.LIST.selectItem(self.listPosition + 1) + if action in [LEFT]: + if control not in CONTROLS: + self.setFocusId(LIST) + self.LIST.selectItem(self.listPosition) + if action in [RIGHT]: + if control in [LIST]: + if item.getProperty('insert') and item.getLabel(): + self.setFocusId(MUP) + elif len(self.controls) > 10: + self.setFocusId(SCROLLBAR) + else: + self.setFocusId(BUTTONS) + self.BUTTONS.selectItem(self.buttonPosition) + if control in [SCROLLBAR]: + self.setFocusId(BUTTONS) + self.BUTTONS.selectItem(self.buttonPosition) + if action in [BACKSPACE, EXIT]: + self.close() - # OK button - if control in [OK]: - self.close() - if self.callback and '.' in self.callback: package, self.callback = self.callback.rsplit('.', 1) - else: package = '%s.%s' % (self.ch_type, self.channel) - cb_channel = None + def resetControls(self): + # logger.dbg() + controls = [] + for control in self.controls: + if control['type'] == 'insert' and control.get('label'): + continue + control['control'] = control['default'] + controls.append(control) + self.controls = controls + self.makeControls() + + def customAction(self, position): + _id = position - 3 + if '.' in self.customButtons[_id]['function']: package, function = self.customButtons[_id]['function'].rsplit('.', 1) + else: + package = '{}.{}'.format(self.ch_type, self.channel) + function = self.customButtons[_id]['function'] + try: cb_channel = __import__(package, None, None, [package]) + except ImportError: logger.error('Unable to import ' + package) + values = {} + for control in self.controls: + values[control['id']] = control['control'] + results = getattr(cb_channel, function)(self.item, values, self.customButtons[_id]) + + btn = results.get('button',{}) + value = results.get('result',{}) + + if btn.get('icon'): self.BUTTONS.getListItem(position).setArt({'button':btn['icon'] + '.png'}) + # if btn.get('label'): self.BUTTONS.getListItem(position).setLabel(btn['label']) + + _reload = False + if value and type(values) == dict: + for c in (self.controls): + if c['type'] in value: + if c['control'] != value[c['type']]: + c['control'] = value[c['type']] + _reload = True + if c['id'] in value: + if c['control'] != value[c['id']]: + c['control'] = value[c['id']] + _reload = True + + if _reload: self.makeControls(self.listPosition) + + + def saveControls(self): + if self.callback: + if '.' in self.callback: package, self.callback = self.callback.rsplit('.', 1) + else: package = '{}.{}'.format(self.ch_type, self.channel) try: cb_channel = __import__(package, None, None, [package]) - except ImportError:logger.error('Impossible to import %s' % package) - - if self.callback: - # If there is a callback function we invoke it... - self.return_value = getattr(cb_channel, self.callback)(self.item, self.values) - else: - # if not, we test if there is a 'cb_validate_config' function in the channel... - try: - self.return_value = getattr(cb_channel, 'cb_validate_config')(self.item, self.values) - except AttributeError: - # if 'cb_validate_config' doesn't exist either ... - for v in self.values: - config.set_setting(v, self.values[v], **self.kwargs) - - # Adjustment controls, if the value of an adjustment is changed, we change the value saved in the value dictionary - # Get the control that has been clicked - # control = self.getControl(id) - - # We look it up in the list of controls - for cont in self.list_controls: - - if cont['type'] == "list" and cont["control"].getId() == control: - select = platformtools.dialog_select(config.get_localized_string(30041), cont["lvalues"], self.values[cont["id"]]) - if select >= 0: - cont["label"].setLabel(cont["lvalues"][select]) - self.values[cont["id"]] = cont["lvalues"].index(cont["label"].getLabel()) - - # If the control is a "bool", we save the new value True / False - if cont["type"] == "bool" and cont["control"].getId() == control: self.values[cont["id"]] = bool(cont["control"].isSelected()) - - # If the control is a "text", we save the new value - if cont["type"] == "text" and cont["control"].getId() == control: - # Older versions require opening the keyboard manually - if xbmcgui.ControlEdit == ControlEdit: - keyboard = xbmc.Keyboard(cont["control"].getText(), cont["control"].getLabel(), cont["control"].isPassword) - keyboard.setHiddenInput(cont["control"].isPassword) - keyboard.doModal() - if keyboard.isConfirmed(): cont["control"].setText(keyboard.getText()) - - self.values[cont["id"]] = cont["control"].getText() - - self.evaluate_conditions() - self.dispose_controls(self.index, force=True) - self.check_default() - self.check_ok() - - # Older versions require this feature - def onFocus(self, a): - pass - - def onAction(self, raw_action): - # Get Focus - focus = self.getFocusId() - action = raw_action.getId() - - if action in [LEFT]: - # if Focus is on close button - if focus == CLOSE: - self.dispose_controls(0, True) - self.setFocusId(3001) - - # if focus is on List - else: - if self.ok_enabled: - self.setFocusId(OK) - else: - self.setFocusId(CANCEL) - - elif action in [RIGHT]: - # if Focus is on button - if focus in [OK, CANCEL, DEFAULT]: - self.dispose_controls(0, True) - self.setFocusId(3001) - - # if focus is on List - else: - self.setFocusId(CLOSE) - - elif action in [DOWN]: - # if focus is on List - if focus not in [OK, CANCEL, DEFAULT]: - try: - focus_control = [self.visible_controls.index(c) for c in self.visible_controls if c["control"].getId() == self.getFocus().getId()][0] - focus_control += 1 - - except: - focus_control = 0 - - while not focus_control == len(self.visible_controls) and (self.visible_controls[focus_control]["type"] == "label" or not self.visible_controls[focus_control]["active"]): - focus_control += 1 - - if focus_control >= len(self.visible_controls): - focus_control = 0 - self.setFocusId(3001) - - self.dispose_controls(focus_control, True) - - elif action in [UP]: - # if focus is on List - if focus not in [CLOSE, OK, CANCEL, DEFAULT]: - try: - focus_control = \ - [self.visible_controls.index(c) for c in self.visible_controls if c["control"].getId() == self.getFocus().getId()][0] - focus_control -= 1 - - while not focus_control == -1 and (self.visible_controls[focus_control]["type"] == "label" or not - self.visible_controls[focus_control]["active"]): - focus_control -= 1 - - if focus_control < 0: - focus_control = len(self.visible_controls) - 1 - - except: - focus_control = 0 - - self.dispose_controls(focus_control, True) - - elif action in [SCROLLDOWN]: - self.dispose_controls(self.index - 1) - - elif action in [SCROLLUP]: - self.dispose_controls(self.index + 1) - - elif action in [BACK, PREVIOUS]: - self.close() - - elif action in [GESTUREBEGIN]: - self.xx = int(raw_action.getAmount2()) - - elif action in [GESTUREPAN]: - - if self.xx > raw_action.getAmount2(): - if old_div((self.xx - int(raw_action.getAmount2())), self.height_control): - self.xx -= self.height_control - self.dispose_controls(self.index + 1) - else: - if old_div((int(raw_action.getAmount2()) - self.xx), self.height_control): - self.xx += self.height_control - self.dispose_controls(self.index - 1) - return + except ImportError: logger.error('Unable to import ' + package) + values = {} + for control in self.controls: + if control['type'] == 'insert' and not control.get('label'): continue + if control['type'] == 'list': + if control.get('dvalues'): + control['control'] = list(control['dvalues'].values())[control['control']] + elif control.get('values'): + control['control'] = control['values'][control['control']] + values[control['id']] = control['control'] + self.return_value = getattr(cb_channel, self.callback)(self.item, values) + for control in self.controls: + if control['type'] == 'insert': continue + if control['type'] == 'list': + if control.get('dvalues'): + control['control'] = list(control['dvalues'].values())[control['control']] + elif control.get('values'): + control['control'] = control['values'][control['control']] + if self.ch_type in ['channels', 'specials']: + config.setSetting(control['id'], control['control'], self.channel) + elif self.ch_type in ['servers']: + config.setSetting(control['id'], control['control'], server=self.channel) + def insertControls(self, _id): + if '.' in self.controls[_id]['function']: package, function = self.controls[_id]['function'].rsplit('.', 1) + else: + package = '{}.{}'.format(self.ch_type, self.channel) + function = self.controls[_id]['function'] + try: cb_channel = __import__(package, None, None, [package]) + except ImportError: logger.error('Unable to import ' + package) + values = {} + for control in self.controls: + values[control['id']] = control['control'] + results = getattr(cb_channel, function)(self.item, values) + for n, result in enumerate(results): + self.controls.insert(_id, result) class ControlEdit(xbmcgui.ControlButton): def __new__(cls, *args, **kwargs): del kwargs["isPassword"] diff --git a/platformcode/xbmc_info_window.py b/platformcode/xbmc_info_window.py index dac0d037..4f9d70a9 100644 --- a/platformcode/xbmc_info_window.py +++ b/platformcode/xbmc_info_window.py @@ -19,7 +19,7 @@ BACKSPACE = 92 def imagepath(image): if len(image.split('.')) == 1: image += '.png' - path = filetools.join(config.get_runtime_path(), 'resources', 'skins' , 'Default', 'media', 'Infoplus', image) + path = filetools.join(config.getRuntimePath(), 'resources', 'skins' , 'Default', 'media', 'Infoplus', image) return path class InfoWindow(xbmcgui.WindowXMLDialog): @@ -48,7 +48,7 @@ class InfoWindow(xbmcgui.WindowXMLDialog): return it def onInit(self): - if config.get_platform(True)['num_version'] < 18: + if config.getXBMCPlatform(True)['num_version'] < 18: self.setCoordinateResolution(2) results = [] with futures.ThreadPoolExecutor() as executor: diff --git a/platformcode/xbmc_videolibrary.py b/platformcode/xbmc_videolibrary.py index 8eeb83e8..62401b41 100644 --- a/platformcode/xbmc_videolibrary.py +++ b/platformcode/xbmc_videolibrary.py @@ -18,15 +18,16 @@ from core import scrapertools from xml.dom import minidom -def mark_auto_as_watched(item): +def mark_auto_as_watched(): def mark_as_watched_subThread(item): logger.debug() + # logger.dbg() actual_time = 0 total_time = 0 - time_limit = time.time() + 10 - while not platformtools.is_playing() and time.time() < time_limit: - time.sleep(1) + # time_limit = time.time() + 10 + # while not platformtools.isPlaying() and time.time() < time_limit: + # time.sleep(1) marked = False sync = False @@ -34,48 +35,46 @@ def mark_auto_as_watched(item): show_server = True mark_time = 100 - percentage = float(config.get_setting("watched_setting")) / 100 - time_from_end = config.get_setting('next_ep_seconds') + percentage = float(config.getSetting("watched_setting")) / 100 + time_from_end = config.getSetting('next_ep_seconds') - if item.contentType != 'movie' and 0 < config.get_setting('next_ep') < 3: + if item.contentType != 'movie' and 0 < config.getSetting('next_ep') < 3: next_dialogs = ['NextDialog.xml', 'NextDialogExtended.xml', 'NextDialogCompact.xml'] - next_ep_type = config.get_setting('next_ep_type') + next_ep_type = config.getSetting('next_ep_type') ND = next_dialogs[next_ep_type] try: next_episode = next_ep(item) except: next_episode = False logger.debug(next_episode) while not xbmc.Monitor().abortRequested(): - if not platformtools.is_playing(): break + if not platformtools.isPlaying(): break try: actual_time = xbmc.Player().getTime() except: actual_time = 0 try: total_time = xbmc.Player().getTotalTime() except: total_time = 0 - if item.played_time and xbmcgui.getCurrentWindowId() == 12005: + if actual_time and item.played_time and xbmcgui.getCurrentWindowId() == 12005: + logger.debug('VAI A', item.played_time) xbmc.Player().seekTime(item.played_time) - item.played_time = 0 # Fix for Slow Devices - + item.played_time = 0 mark_time = total_time * percentage difference = total_time - actual_time # Mark as Watched - if actual_time > mark_time and not marked: + if actual_time > mark_time and mark_time > 0 and not marked: logger.info("Marked as Watched") item.playcount = 1 marked = True item.played_time = 0 - platformtools.set_played_time(item) + platformtools.setPlayedTime(item) if item.options['strm'] : sync = True show_server = False - # from specials import videolibrary - # videolibrary.mark_content_as_watched(item) if not next_episode: break # check for next Episode if next_episode and marked and time_from_end >= difference: - nextdialog = NextDialog(ND, config.get_runtime_path(), item=next_episode) - while platformtools.is_playing() and not nextdialog.is_exit(): + nextdialog = NextDialog(ND, config.getRuntimePath(), item=next_episode) + while platformtools.isPlaying() and not nextdialog.is_exit(): xbmc.sleep(100) if nextdialog.continuewatching: next_episode.next_ep = True @@ -83,27 +82,32 @@ def mark_auto_as_watched(item): nextdialog.close() break - # if item.options['continue']: if actual_time < mark_time: item.played_time = actual_time else: item.played_time = 0 - platformtools.set_played_time(item) + if mark_time: + logger.debug('Set Played Time', item.played_time) + platformtools.setPlayedTime(item) # Silent sync with Trakt - if sync and config.get_setting("trakt_sync"): sync_trakt_kodi() + if sync and config.getSetting("trakt_sync"): sync_trakt_kodi() - while platformtools.is_playing(): - xbmc.sleep(100) + while platformtools.isPlaying(): + xbmc.sleep(10) - if not show_server and not item.no_return and not item.window: - xbmc.sleep(700) - xbmc.executebuiltin('Action(ParentDir)') + if not show_server and not item.no_return: + if item.window: + # xbmc.executebuiltin('ActivateWindow({})'.format(filetools.join(config.getRuntimePath(), 'resources', 'skins', 'Default', '720p', 'Servers.xml'))) + xbmc.executebuiltin('Action(BackSpace)') + else: + xbmc.sleep(700) + xbmc.executebuiltin('Action(ParentDir)') if marked: from specials import videolibrary videolibrary.mark_content_as_watched(item) - if next_episode and next_episode.next_ep and config.get_setting('next_ep') == 1: + if next_episode and next_episode.next_ep and config.getSetting('next_ep') == 1: from platformcode.launcher import run run(next_episode) @@ -112,8 +116,15 @@ def mark_auto_as_watched(item): db.close() # If it is configured to mark as seen - if config.get_setting("mark_as_watched", "videolibrary"): - threading.Thread(target=mark_as_watched_subThread, args=[item]).start() + if config.getSetting("mark_as_watched", "videolibrary"): + from core import db + item = db['playitem'].get('item') + db.close() + imdb_id = xbmc.Player().getVideoInfoTag().getIMDBNumber() + if item.infoLabels['imdb_id'] == imdb_id: + # mark_as_watched_subThread(item) + threading.Thread(target=mark_as_watched_subThread, args=[item]).start() + logger.debug('EXIT MONITOR') def sync_trakt_addon(path_folder): @@ -242,14 +253,14 @@ def sync_trakt_kodi(silent=True): # So that the synchronization is not silent it is worth with silent = False if xbmc.getCondVisibility('System.HasAddon("script.trakt")'): notificacion = True - if not config.get_setting("sync_trakt_notification", "videolibrary") and platformtools.is_playing(): + if platformtools.isPlaying(): notificacion = False xbmc.executebuiltin('RunScript(script.trakt,action=sync,silent=%s)' % silent) logger.debug("Synchronization with Trakt started") if notificacion: - platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(60045), sound=False, time=2000) + platformtools.dialogNotification(config.getLocalizedString(20000), config.getLocalizedString(60045), sound=False, time=2000) def mark_content_as_watched_on_kodi(item, value=1): @@ -261,7 +272,7 @@ def mark_content_as_watched_on_kodi(item, value=1): @param value: > 0 for seen, 0 for not seen """ logger.debug() - logger.dbg() + # logger.dbg() if item.contentType == 'movie': path = '%{}%'.format(item.strm_path.split('\\')[0].split('/')[0] if item.strm_path else item.base_name) @@ -369,14 +380,14 @@ def mark_content_as_watched_on_kod(path): logger.debug() #logger.debug("path: " + path) - FOLDER_MOVIES = config.get_setting("folder_movies") - FOLDER_TVSHOWS = config.get_setting("folder_tvshows") - VIDEOLIBRARY_PATH = config.get_videolibrary_config_path() + FOLDER_MOVIES = config.getSetting("folder_movies") + FOLDER_TVSHOWS = config.getSetting("folder_tvshows") + VIDEOLIBRARY_PATH = config.getVideolibraryConfigPath() if not VIDEOLIBRARY_PATH: return # set_watched_on_kod # We can only mark the content as a view in the Kodi database if the database is local, in case of sharing database this functionality will not work - # if config.get_setting("db_mode", "videolibrary"): + # if config.getSetting("db_mode", "videolibrary"): # return path2 = '' @@ -465,14 +476,14 @@ def get_data(payload): # Required header for XBMC JSON-RPC calls, otherwise you'll get a 415 HTTP response code - Unsupported media type headers = {'content-type': 'application/json'} - if config.get_setting("db_mode", "videolibrary"): + if config.getSetting("db_mode", "videolibrary"): try: try: - xbmc_port = config.get_setting("xbmc_puerto", "videolibrary") + xbmc_port = config.getSetting("xbmc_puerto", "videolibrary") except: xbmc_port = 0 - xbmc_json_rpc_url = "http://" + config.get_setting("xbmc_host", "videolibrary") + ":" + str(xbmc_port) + "/jsonrpc" + xbmc_json_rpc_url = "http://" + config.getSetting("xbmc_host", "videolibrary") + ":" + str(xbmc_port) + "/jsonrpc" req = urllib2.Request(xbmc_json_rpc_url, data=jsontools.dump(payload), headers=headers) f = urllib.urlopen(req) response = f.read() @@ -499,7 +510,7 @@ def get_data(payload): return data -def update(folder_content=config.get_setting("folder_tvshows"), folder=""): +def update(folder_content=config.getSetting("folder_tvshows"), folder=""): """ Update the library depending on the type of content and the path passed to it. @@ -518,7 +529,7 @@ def update(folder_content=config.get_setting("folder_tvshows"), folder=""): if folder: folder = str(folder) - videolibrarypath = config.get_videolibrary_config_path() + videolibrarypath = config.getVideolibraryConfigPath() if folder.endswith('/') or folder.endswith('\\'): folder = folder[:-1] @@ -561,17 +572,17 @@ def search_local_path(item): for record in records: num_path, path_records = execute_sql_kodi('SELECT strPath FROM path WHERE idPath LIKE "%s"' % record[0]) for path in path_records: - if config.get_setting('videolibrarypath') not in path[0]: + if config.getSetting('videolibrarypath') not in path[0]: return path[0] return '' def set_content(silent=False): logger.debug() - videolibrarypath = config.get_setting("videolibrarypath") + videolibrarypath = config.getSetting("videolibrarypath") sep = '/' if '/' in videolibrarypath else '\\' - paths = {'movie': filetools.join(videolibrarypath, config.get_setting('folder_movies')) + sep, - 'tvshow': filetools.join(videolibrarypath, config.get_setting('folder_tvshows')) + sep} + paths = {'movie': filetools.join(videolibrarypath, config.getSetting('folder_movies')) + sep, + 'tvshow': filetools.join(videolibrarypath, config.getSetting('folder_tvshows')) + sep} for k, v in paths.items(): sql = 'SELECT idPath, strPath FROM path where strPath= "{}"'.format(v) n, records = execute_sql_kodi(sql) @@ -631,7 +642,7 @@ def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvsh return p = 80 - progress.update(p, config.get_localized_string(20000), config.get_localized_string(80013)) + progress.update(p, config.getLocalizedString(20000), config.getLocalizedString(80013)) for OldFolder, NewFolder in [[old_movies_folder, new_movies_folder], [old_tvshows_folder, new_tvshows_folder]]: sql_old_folder = sql_old_path + OldFolder @@ -694,7 +705,7 @@ def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvsh logger.debug('sql: ' + sql) nun_records, records = execute_sql_kodi(sql) p += 5 - progress.update(p, config.get_localized_string(20000), config.get_localized_string(80013)) + progress.update(p, config.getLocalizedString(20000), config.getLocalizedString(80013)) progress.update(100) xbmc.sleep(1000) @@ -718,14 +729,14 @@ def clean(path_list=[]): logger.debug() - progress = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(80025)) + progress = platformtools.dialogProgressBg(config.getLocalizedString(20000), config.getLocalizedString(80025)) progress.update(0) # if the path list is empty, clean the entire video library if not path_list: logger.debug('the path list is empty, clean the entire video library') - if not config.get_setting("videolibrary_kodi"): - sql_path, sep = sql_format(config.get_setting("videolibrarypath")) + if not config.getSetting("videolibrary_kodi"): + sql_path, sep = sql_format(config.getSetting("videolibrarypath")) if not sql_path.endswith(sep): sql_path += sep sql = 'SELECT idPath FROM path where strPath LIKE "%s"' % sql_path logger.debug('sql: ' + sql) @@ -742,13 +753,13 @@ def clean(path_list=[]): from core import videolibrarytools for path, folders, files in filetools.walk(videolibrarytools.MOVIES_PATH): for folder in folders: - path_list.append(filetools.join(config.get_setting("videolibrarypath"), videolibrarytools.FOLDER_MOVIES, folder)) + path_list.append(filetools.join(config.getSetting("videolibrarypath"), videolibrarytools.FOLDER_MOVIES, folder)) for path, folders, files in filetools.walk(videolibrarytools.TVSHOWS_PATH): for folder in folders: tvshow_nfo = filetools.join(path, folder, "tvshow.nfo") if filetools.exists(tvshow_nfo): - path_list.append(filetools.join(config.get_setting("videolibrarypath"), videolibrarytools.FOLDER_TVSHOWS, folder)) + path_list.append(filetools.join(config.getSetting("videolibrarypath"), videolibrarytools.FOLDER_TVSHOWS, folder)) logger.debug('path_list: ' + str(path_list)) if path_list: t = float(100) / len(path_list) @@ -781,7 +792,7 @@ def clean(path_list=[]): if records: payload = {"jsonrpc": "2.0", "method": "VideoLibrary.RemoveTVShow", "id": 1, "params": {"tvshowid": records[0][0]}} data = get_data(payload) - elif config.get_setting("folder_movies") in sql_path: + elif config.getSetting("folder_movies") in sql_path: # search movie in the DB sql = 'SELECT idMovie FROM movie where c22 LIKE "%s"' % sql_path logger.debug('sql: ' + sql) @@ -866,7 +877,7 @@ def get_file_db(): """ file_db = '' # We look for the archive of the video database according to the version of kodi - video_db = config.get_platform(True)['video_db'] + video_db = config.getXBMCPlatform(True)['video_db'] if video_db: file_db = filetools.join(xbmc.translatePath("special://userdata/Database"), video_db) @@ -1067,71 +1078,71 @@ def update_sources(new='', old=''): def ask_set_content(silent=False): logger.debug() - logger.debug("videolibrary_kodi %s" % config.get_setting("videolibrary_kodi")) + logger.debug("videolibrary_kodi %s" % config.getSetting("videolibrary_kodi")) def do_config(custom=False): if set_content("movie", True, custom) and set_content("tvshow", True, custom): - platformtools.dialog_ok(config.get_localized_string(80026), config.get_localized_string(70104)) - config.set_setting("videolibrary_kodi", True) + platformtools.dialogOk(config.getLocalizedString(80026), config.getLocalizedString(70104)) + config.setSetting("videolibrary_kodi", True) from specials import videolibrary videolibrary.update_videolibrary() update() else: - platformtools.dialog_ok(config.get_localized_string(80026), config.get_localized_string(80024)) - config.set_setting("videolibrary_kodi", False) + platformtools.dialogOk(config.getLocalizedString(80026), config.getLocalizedString(80024)) + config.setSetting("videolibrary_kodi", False) # configuration during installation if not silent: # ask to configure Kodi video library - if platformtools.dialog_yesno(config.get_localized_string(20000), config.get_localized_string(80015)): + if platformtools.dialogYesNo(config.getLocalizedString(20000), config.getLocalizedString(80015)): # ask for custom or default settings - if not platformtools.dialog_yesno(config.get_localized_string(80026), config.get_localized_string(80016), config.get_localized_string(80017), config.get_localized_string(80018)): + if not platformtools.dialogYesNo(config.getLocalizedString(80026), config.getLocalizedString(80016), config.getLocalizedString(80017), config.getLocalizedString(80018)): # input path and folders - path = platformtools.dialog_browse(3, config.get_localized_string(80019), config.get_setting("videolibrarypath")) - movies_folder = platformtools.dialog_input(config.get_setting("folder_movies"), config.get_localized_string(80020)) - tvshows_folder = platformtools.dialog_input(config.get_setting("folder_tvshows"), config.get_localized_string(80021)) + path = platformtools.dialogBrowse(3, config.getLocalizedString(80019), config.getSetting("videolibrarypath")) + movies_folder = platformtools.dialogInput(config.getSetting("folder_movies"), config.getLocalizedString(80020)) + tvshows_folder = platformtools.dialogInput(config.getSetting("folder_tvshows"), config.getLocalizedString(80021)) if path != "" and movies_folder != "" and tvshows_folder != "": movies_path, tvshows_path = check_sources(filetools.join(path, movies_folder), filetools.join(path, tvshows_folder)) # configure later if movies_path or tvshows_path: - platformtools.dialog_ok(config.get_localized_string(80026), config.get_localized_string(80029)) + platformtools.dialogOk(config.getLocalizedString(80026), config.getLocalizedString(80029)) # set path and folders else: - update_sources(path, config.get_setting("videolibrarypath")) - config.set_setting("videolibrarypath", path) - config.set_setting("folder_movies", movies_folder) - config.set_setting("folder_tvshows", tvshows_folder) - config.verify_directories_created() + update_sources(path, config.getSetting("videolibrarypath")) + config.setSetting("videolibrarypath", path) + config.setSetting("folder_movies", movies_folder) + config.setSetting("folder_tvshows", tvshows_folder) + config.verifyDirectoriesCreated() do_config(False) # default path and folders else: - platformtools.dialog_ok(config.get_localized_string(80026), config.get_localized_string(80030)) + platformtools.dialogOk(config.getLocalizedString(80026), config.getLocalizedString(80030)) do_config(False) # default settings else: - platformtools.dialog_ok(config.get_localized_string(80026), config.get_localized_string(80027)) + platformtools.dialogOk(config.getLocalizedString(80026), config.getLocalizedString(80027)) do_config(False) # configure later else: - platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(80022)) + platformtools.dialogOk(config.getLocalizedString(20000), config.getLocalizedString(80022)) # configuration from the settings menu else: - platformtools.dialog_ok(config.get_localized_string(80026), config.get_localized_string(80023)) + platformtools.dialogOk(config.getLocalizedString(80026), config.getLocalizedString(80023)) do_config(False) def next_ep(item): logger.debug(item) episode = '{}x{:02d}'.format(item.contentSeason, item.contentEpisodeNumber) - episodes = sorted(videolibrarydb.videolibrarydb['episode'][item.videolibrary_id].items()) - videolibrarydb.videolibrarydb.close() + episodes = sorted(videolibrarydb['episode'][item.videolibrary_id].items()) + videolibrarydb.close() nextIndex = [k for k, v in episodes].index(episode) + 1 if nextIndex == 0 or nextIndex == len(episodes): it = None else: it = episodes[nextIndex][1]['item'] - if item.from_library: it.action = 'play_from_library' + if item.from_library: it.action = 'playFromLibrary' logger.debug('Next File:' + '{}x{:02d}. {}'.format(it.contentSeason, it.contentEpisodeNumber, it.title)) return it @@ -1150,7 +1161,7 @@ class NextDialog(xbmcgui.WindowXMLDialog): info = kwargs.get('item').infoLabels if "fanart" in info: img = info["fanart"] elif "thumbnail" in info: img = info["thumbnail"] - else: img = filetools.join(config.get_runtime_path(), "resources", "noimage.png") + else: img = filetools.join(config.getRuntimePath(), "resources", "noimage.png") self.setProperty("next_img", img) self.setProperty("title", info["tvshowtitle"]) self.setProperty("ep_title", "{}x{:02d}. {}".format(info["season"], info["episode"], info["title"])) diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index f3018e3e..66a5e53a 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -973,7 +973,7 @@ msgid "AutoPlay Language (Optional)" msgstr "" msgctxt "#60081" -msgid " Favorite servers" +msgid "Favorite servers" msgstr "" msgctxt "#60082" @@ -981,7 +981,7 @@ msgid "Favorite server %s" msgstr "" msgctxt "#60083" -msgid " Preferred Qualities" +msgid "Preferred Qualities" msgstr "" msgctxt "#60084" @@ -989,7 +989,7 @@ msgid "Preferred Quality %s" msgstr "" msgctxt "#60085" -msgid " Priority (Indicates the order for AutoPlay)" +msgid "Priority (Indicates the order for AutoPlay)" msgstr "" msgctxt "#60086" @@ -1161,27 +1161,27 @@ msgid "Identifiers:" msgstr "" msgctxt "#60234" -msgid " The Movie Database ID" +msgid "The Movie Database ID" msgstr "" msgctxt "#60235" -msgid " URL Tmdb" +msgid "URL Tmdb" msgstr "" msgctxt "#60236" -msgid " The TVDB ID" +msgid "The TVDB ID" msgstr "" msgctxt "#60237" -msgid " URL TVDB" +msgid "URL TVDB" msgstr "" msgctxt "#60238" -msgid " IMDb ID" +msgid "IMDb ID" msgstr "" msgctxt "#60239" -msgid " Other ID" +msgid "Other ID" msgstr "" msgctxt "#60240" @@ -1189,11 +1189,11 @@ msgid "Images" msgstr "" msgctxt "#60241" -msgid " Background" +msgid "Background" msgstr "" msgctxt "#60242" -msgid " Thumbnail" +msgid "Thumbnail" msgstr "" msgctxt "#60243" @@ -1953,39 +1953,39 @@ msgid "Guide (opens the browser)" msgstr "" msgctxt "#60448" -msgid " - How do I report an error?" +msgid " - How do I report an error?" msgstr "" msgctxt "#60449" -msgid " - Is it possible to enable/disable channels?" +msgid " - Is it possible to enable/disable channels?" msgstr "" msgctxt "#60450" -msgid " - Is automatic synchronization with Trakt possible?" +msgid " - Is automatic synchronization with Trakt possible?" msgstr "" msgctxt "#60451" -msgid " - Is it possible to show all the results together in the global search?" +msgid " - Is it possible to show all the results together in the global search?" msgstr "" msgctxt "#60452" -msgid " - Links take too long to appear." +msgid " - Links take too long to appear." msgstr "" msgctxt "#60453" -msgid " - The content search is not performed correctly." +msgid " - The content search is not performed correctly." msgstr "" msgctxt "#60454" -msgid " - Some channels do not function properly." +msgid " - Some channels do not function properly." msgstr "" msgctxt "#60455" -msgid " - The library does not update correctly." +msgid " - The library does not update correctly." msgstr "" msgctxt "#60456" -msgid " - Links of interest" +msgid " - Links of interest" msgstr "" msgctxt "#60457" @@ -2265,23 +2265,23 @@ msgid "Included channels by category" msgstr "" msgctxt "#60526" -msgid " - Movies " +msgid " - Movies " msgstr "" msgctxt "#60527" -msgid " - Kids" +msgid " - Kids" msgstr "" msgctxt "#60528" -msgid " - TV show episodes" +msgid " - TV show episodes" msgstr "" msgctxt "#60529" -msgid " - Anime episodes" +msgid " - Anime episodes" msgstr "" msgctxt "#60530" -msgid " - Documentaries" +msgid " - Documentaries" msgstr "" msgctxt "#60531" @@ -2369,7 +2369,7 @@ msgid "Debriders settings" msgstr "" msgctxt "#60553" -msgid " Server configuration '%s'" +msgid "Server configuration '%s'" msgstr "" msgctxt "#60554" @@ -2409,7 +2409,7 @@ msgid "Channel Options" msgstr "" msgctxt "#60565" -msgid " Check the files * _data.json" +msgid "Check the files * _data.json" msgstr "" msgctxt "#60566" @@ -2445,7 +2445,7 @@ msgid "Order Servers" msgstr "" msgctxt "#60578" -msgid " Server #%s" +msgid "Server #%s" msgstr "" msgctxt "#60579" @@ -2521,7 +2521,7 @@ msgid "Channels" msgstr "" msgctxt "#60597" -msgid " Server #%s" +msgid "Server #%s" msgstr "" msgctxt "#60598" @@ -2557,7 +2557,7 @@ msgid "When Kodi starts and daily" msgstr "" msgctxt "#60606" -msgid " Update waiting time" +msgid "Update waiting time" msgstr "" msgctxt "#60607" @@ -2581,11 +2581,11 @@ msgid "60 sec" msgstr "" msgctxt "#60613" -msgid " Update time" +msgid "Update time" msgstr "" msgctxt "#60614" -msgid " Search for new episodes" +msgid "Search for new episodes" msgstr "" msgctxt "#60615" @@ -2601,7 +2601,7 @@ msgid "Based on airing" msgstr "" msgctxt "#60618" -msgid " Kodi video library update" +msgid "Kodi video library update" msgstr "" msgctxt "#60619" @@ -2625,7 +2625,7 @@ msgid "Pop-up window" msgstr "" msgctxt "#60624" -msgid " Maximum number of links to display" +msgid "Maximum number of links to display" msgstr "" msgctxt "#60625" @@ -2633,15 +2633,15 @@ msgid "All" msgstr "" msgctxt "#60626" -msgid " Sort by whitelist" +msgid "Sort by whitelist" msgstr "" msgctxt "#60627" -msgid " Remove the channel name at the beginning" +msgid "Remove the channel name at the beginning" msgstr "" msgctxt "#60628" -msgid " Replace \'View in\' with \'[V]\' and \'Download in\' with \'[D]\'" +msgid "Replace \'View in\' with \'[V]\' and \'Download in\' with \'[D]\'" msgstr "" msgctxt "#60629" @@ -2649,11 +2649,11 @@ msgid "Remote database" msgstr "Database remoto" msgctxt "#60632" -msgid " Server name" +msgid "Server name" msgstr "" msgctxt "#60633" -msgid " Server port" +msgid "Server port" msgstr "" msgctxt "#60634" @@ -2661,7 +2661,7 @@ msgid "Automatically mark as watched" msgstr "" msgctxt "#60635" -msgid " Video viewing time" +msgid "Video viewing time" msgstr "" msgctxt "#60636" @@ -2669,23 +2669,23 @@ msgid "0 seg" msgstr "" msgctxt "#60637" -msgid " Synchronizing with Trakt" +msgid "Synchronizing with Trakt" msgstr "" msgctxt "#60638" -msgid " After mark as watched the episode" +msgid "After mark as watched the episode" msgstr "" msgctxt "#60639" -msgid " Show notification" +msgid "Show notification" msgstr "" msgctxt "#60640" -msgid " On adding a TV show to the video library" +msgid "On adding a TV show to the video library" msgstr "" msgctxt "#60641" -msgid " Wait until the TV show is added" +msgid "Wait until the TV show is added" msgstr "" msgctxt "#60642" @@ -2713,19 +2713,19 @@ msgid "Never" msgstr "" msgctxt "#60650" -msgid " Video library information providers" +msgid "Video library information providers" msgstr "" msgctxt "#60651" -msgid " Movies" +msgid "Movies" msgstr "" msgctxt "#60652" -msgid " TV show" +msgid "TV show" msgstr "" msgctxt "#60653" -msgid " If there are no results search in English" +msgid "If there are no results search in English" msgstr "" msgctxt "#60654" @@ -2761,7 +2761,7 @@ msgid "News" msgstr "" msgctxt "#60662" -msgid " Language" +msgid "Language" msgstr "" msgctxt "#60663" @@ -3109,7 +3109,7 @@ msgid ">> Next Page" msgstr "" msgctxt "#70066" -msgid " Search title in spanish: %s" +msgid "Search title in spanish: %s" msgstr "" msgctxt "#70067" @@ -3201,11 +3201,11 @@ msgid "Show only links of %s" msgstr "" msgctxt "#70090" -msgid " Exclude all streams with specific words" +msgid "Exclude all streams with specific words" msgstr "" msgctxt "#70091" -msgid " Words" +msgid "Words" msgstr "" msgctxt "#70092" @@ -3521,7 +3521,7 @@ msgid "Torrent" msgstr "" msgctxt "#70172" -msgid " Plan B (If favourites fail try other links)" +msgid "Plan B (If favourites fail try other links)" msgstr "" msgctxt "#70173" @@ -3661,7 +3661,7 @@ msgid "Link found in %s" msgstr "" msgctxt "#70207" -msgid " - Movies 4K " +msgid " - Movies 4K " msgstr "" msgctxt "#70208" @@ -3681,15 +3681,15 @@ msgid " (In %s)" msgstr "" msgctxt "#70212" -msgid " - Castellan" +msgid " - Castellan" msgstr "" msgctxt "#70213" -msgid " - Latin" +msgid " - Latin" msgstr "" msgctxt "#70214" -msgid " - Torrent" +msgid " - Torrent" msgstr "" msgctxt "#70215" @@ -3765,19 +3765,19 @@ msgid "View downloaded files" msgstr "" msgctxt "#70233" -msgid " - Size per block" +msgid " - Size per block" msgstr "" msgctxt "#70234" -msgid " - Size by part" +msgid " - Size by part" msgstr "" msgctxt "#70235" -msgid " - Maximum number of simultaneous connections" +msgid " - Maximum number of simultaneous connections" msgstr "" msgctxt "#70236" -msgid " - Maximum number of parts in memory" +msgid " - Maximum number of parts in memory" msgstr "" msgctxt "#70237" @@ -3945,7 +3945,7 @@ msgid "You can try downloading the 'libtorrent' module from Kodi or installing s msgstr "" msgctxt "#70280" -msgid " - Torrent Links don't work." +msgid " - Torrent Links don't work." msgstr "" msgctxt "#70281" @@ -4257,7 +4257,7 @@ msgid "Recommendations MyAnimeList" msgstr "" msgctxt "#70360" -msgid " [Without subs in castellan]" +msgid " [Without subs in castellan]" msgstr "" msgctxt "#70361" @@ -4325,7 +4325,7 @@ msgid "Info in AniDB %s" msgstr "" msgctxt "#70377" -msgid " - Fansubs in spanish:" +msgid " - Fansubs in spanish:" msgstr "" msgctxt "#70378" diff --git a/resources/language/resource.language.it_it/strings.po b/resources/language/resource.language.it_it/strings.po index 0b517155..02b320e1 100644 --- a/resources/language/resource.language.it_it/strings.po +++ b/resources/language/resource.language.it_it/strings.po @@ -972,24 +972,24 @@ msgid "AutoPlay Language (Optional)" msgstr "Lingua per AutoPlay (opzionale)" msgctxt "#60081" -msgid " Favorite servers" -msgstr " Server Preferiti" +msgid " Favorite servers" +msgstr " Server Preferiti" msgctxt "#60082" msgid "Favorite server %s" msgstr "Server Preferito %s" msgctxt "#60083" -msgid " Preferred Qualities" -msgstr " Qualità Preferite" +msgid " Preferred Qualities" +msgstr " Qualità Preferite" msgctxt "#60084" msgid "Preferred Quality %s" msgstr "Qualità Preferita %s" msgctxt "#60085" -msgid " Priority (Indicates the order for AutoPlay)" -msgstr " Priorità (Indica l'ordine per la Riproduzione Automatica)" +msgid " Priority (Indicates the order for AutoPlay)" +msgstr " Priorità (Indica l'ordine per la Riproduzione Automatica)" msgctxt "#60086" msgid "It has been renamed to:" @@ -1160,40 +1160,40 @@ msgid "Identifiers:" msgstr "Identificatori:" msgctxt "#60234" -msgid " The Movie Database ID" -msgstr " The Movie Database ID" +msgid "The Movie Database ID" +msgstr "The Movie Database ID" msgctxt "#60235" -msgid " URL Tmdb" -msgstr " URL Tmdb" +msgid "URL Tmdb" +msgstr "URL Tmdb" msgctxt "#60236" -msgid " The TVDB ID" -msgstr " The TVDB ID" +msgid "The TVDB ID" +msgstr "The TVDB ID" msgctxt "#60237" -msgid " URL TVDB" -msgstr " URL TVDB" +msgid "URL TVDB" +msgstr "URL TVDB" msgctxt "#60238" -msgid " IMDb ID" -msgstr " IMDb ID" +msgid "IMDb ID" +msgstr "IMDb ID" msgctxt "#60239" -msgid " Other ID" -msgstr " Altro ID" +msgid "Other ID" +msgstr "Altro ID" msgctxt "#60240" msgid "Images" msgstr "Immagini" msgctxt "#60241" -msgid " Background" -msgstr " Fondo" +msgid "Background" +msgstr "Fondo" msgctxt "#60242" -msgid " Thumbnail" -msgstr " Miniatura" +msgid "Thumbnail" +msgstr "Miniatura" msgctxt "#60243" msgid "Type of content" @@ -1952,40 +1952,40 @@ msgid "Guide (opens the browser)" msgstr "Guida alle funzioni di KoD (apre il browser)" msgctxt "#60448" -msgid " - How do I report an error?" -msgstr " - Come segnalo un errore?" +msgid " - How do I report an error?" +msgstr " - Come segnalo un errore?" msgctxt "#60449" -msgid " - Is it possible to enable/disable channels?" -msgstr " - È Possibile attivare/disattivare i canali?" +msgid " - Is it possible to enable/disable channels?" +msgstr " - È Possibile attivare/disattivare i canali?" msgctxt "#60450" -msgid " - Is automatic synchronization with Trakt possible?" -msgstr " - È possibile la sincronizzazione automatica con Trakt?" +msgid " - Is automatic synchronization with Trakt possible?" +msgstr " - È possibile la sincronizzazione automatica con Trakt?" msgctxt "#60451" -msgid " - Is it possible to show all the results together in the global search?" -msgstr " - È Possibile mostrare tutti i risultati uniti nella ricerca globale?" +msgid " - Is it possible to show all the results together in the global search?" +msgstr " - È Possibile mostrare tutti i risultati uniti nella ricerca globale?" msgctxt "#60452" -msgid " - Links take too long to appear." -msgstr " - I link ci mettono troppo ad apparire." +msgid " - Links take too long to appear." +msgstr " - I link ci mettono troppo ad apparire." msgctxt "#60453" -msgid " - The content search is not performed correctly." -msgstr " - La ricerca dei contenuti non viene eseguita correttamente." +msgid " - The content search is not performed correctly." +msgstr " - La ricerca dei contenuti non viene eseguita correttamente." msgctxt "#60454" -msgid " - Some channels do not function properly." -msgstr " - Alcuni canali non funzionano correttamente." +msgid " - Some channels do not function properly." +msgstr " - Alcuni canali non funzionano correttamente." msgctxt "#60455" -msgid " - The library does not update correctly." -msgstr " - La libreria non viene aggiornata correttamente." +msgid " - The library does not update correctly." +msgstr " - La libreria non viene aggiornata correttamente." msgctxt "#60456" -msgid " - Links of interest" -msgstr " - Collegamenti di interesse" +msgid " - Links of interest" +msgstr " - Collegamenti di interesse" msgctxt "#60457" msgid "Kodi on Demand" @@ -2264,24 +2264,24 @@ msgid "Included channels by category" msgstr "Canali inclusi per categoria" msgctxt "#60526" -msgid " - Movies " -msgstr " - Film " +msgid " - Movies " +msgstr " - Film " msgctxt "#60527" -msgid " - Kids" -msgstr " - Bambini" +msgid " - Kids" +msgstr " - Bambini" msgctxt "#60528" -msgid " - TV show episodes" -msgstr " - Episodi serie TV" +msgid " - TV show episodes" +msgstr " - Episodi serie TV" msgctxt "#60529" -msgid " - Anime episodes" -msgstr " - Episodi anime" +msgid " - Anime episodes" +msgstr " - Episodi anime" msgctxt "#60530" -msgid " - Documentaries" -msgstr " - Documentari" +msgid " - Documentaries" +msgstr " - Documentari" msgctxt "#60531" msgid "Other settings" @@ -2368,8 +2368,8 @@ msgid "Debriders settings" msgstr "Impostazioni debrider" msgctxt "#60553" -msgid " Server configuration '%s'" -msgstr " Configurazione del server '%s'" +msgid " Server configuration '%s'" +msgstr " Configurazione del server '%s'" msgctxt "#60554" msgid "Server settings" @@ -2408,8 +2408,8 @@ msgid "Channel Options" msgstr "Opzioni dei canali" msgctxt "#60565" -msgid " Check the files * _data.json" -msgstr " Controlla i file * _data.json" +msgid " Check the files * _data.json" +msgstr " Controlla i file * _data.json" msgctxt "#60566" msgid "Video library options" @@ -2444,8 +2444,8 @@ msgid "Order Servers" msgstr "Ordina i server" msgctxt "#60578" -msgid " Server #%s" -msgstr " Server #%s" +msgid " Server #%s" +msgstr " Server #%s" msgctxt "#60579" msgid "Error" @@ -2520,8 +2520,8 @@ msgid "Channels" msgstr "Canali" msgctxt "#60597" -msgid " Server #%s" -msgstr " Server #%s" +msgid " Server #%s" +msgstr " Server #%s" msgctxt "#60598" msgid "Video library configuration" @@ -2556,8 +2556,8 @@ msgid "When Kodi starts and daily" msgstr "All'avvio di Kodi e giornaliero" msgctxt "#60606" -msgid " Update waiting time" -msgstr " Tempo di attesa aggiornamento" +msgid " Update waiting time" +msgstr " Tempo di attesa aggiornamento" msgctxt "#60607" msgid "When Kodi starts" @@ -2580,12 +2580,12 @@ msgid "60 sec" msgstr "60 sec" msgctxt "#60613" -msgid " Update time" -msgstr " Ora aggiornamento" +msgid "Update time" +msgstr "Ora aggiornamento" msgctxt "#60614" -msgid " Search for new episodes" -msgstr " Cerca nuovi episodi" +msgid "Search for new episodes" +msgstr "Cerca nuovi episodi" msgctxt "#60615" msgid "Never" @@ -2600,8 +2600,8 @@ msgid "Based on airing" msgstr "In base all'uscita" msgctxt "#60618" -msgid " Kodi video library update" -msgstr " Aggiornamento libreria di Kodi" +msgid "Kodi video library update" +msgstr "Aggiornamento libreria di Kodi" msgctxt "#60619" msgid "Each TV show" @@ -2624,68 +2624,68 @@ msgid "Pop-up window" msgstr "Finestra pop-up" msgctxt "#60624" -msgid " Maximum number of links to display" -msgstr " Numero massimo di link da visualizzare" +msgid "Maximum number of links to display" +msgstr "Numero massimo di link da visualizzare" msgctxt "#60625" msgid "All" msgstr "Tutti" msgctxt "#60626" -msgid " Sort by whitelist" -msgstr " Ordina per whitelist" +msgid "Sort by whitelist" +msgstr "Ordina per whitelist" msgctxt "#60627" -msgid " Remove the channel name at the beginning" -msgstr " Rimuovi il nome del canale all'inizio" +msgid "Remove the channel name at the beginning" +msgstr "Rimuovi il nome del canale all'inizio" msgctxt "#60628" -msgid " Replace \'View in\' with \'[V]\' and \'Download in\' with \'[D]\'" -msgstr " Sostituisci \'Vedi in\' con \'[V]\' e \'Scarica in\' con \'[D]\'" +msgid "Replace \'View in\' with \'[V]\' and \'Download in\' with \'[D]\'" +msgstr "Sostituisci \'Vedi in\' con \'[V]\' e \'Scarica in\' con \'[D]\'" msgctxt "#60629" msgid "Remote database" msgstr "Database remoto" msgctxt "#60632" -msgid " Server name" -msgstr " Nome server" +msgid "Server name" +msgstr "Nome server" msgctxt "#60633" -msgid " Server port" -msgstr " Porta server" +msgid "Server port" +msgstr "Porta server" msgctxt "#60634" msgid "Automatically mark as watched" msgstr "Segna automaticamente come visto" msgctxt "#60635" -msgid " Video viewing time" -msgstr " Tempo di visione del video" +msgid "Video viewing time" +msgstr "Tempo di visione del video" msgctxt "#60636" msgid "0 seg" msgstr "0 sec" msgctxt "#60637" -msgid " Synchronizing with Trakt" -msgstr " Sincronizzazione con Trakt" +msgid "Synchronizing with Trakt" +msgstr "Sincronizzazione con Trakt" msgctxt "#60638" -msgid " After mark as watched the episode" -msgstr " Dopo aver segnato come visto l'episodio" +msgid "After mark as watched the episode" +msgstr "Dopo aver segnato come visto l'episodio" msgctxt "#60639" -msgid " Show notification" -msgstr " Mostra notifica" +msgid "Show notification" +msgstr "Mostra notifica" msgctxt "#60640" -msgid " On adding a TV show to the video library" -msgstr " All'aggiunta di una serie TV alla videoteca" +msgid "On adding a TV show to the video library" +msgstr "All'aggiunta di una serie TV alla videoteca" msgctxt "#60641" -msgid " Wait until the TV show is added" -msgstr " Attendere finchè la serie TV sia aggiunta" +msgid "Wait until the TV show is added" +msgstr "Attendere finchè la serie TV sia aggiunta" msgctxt "#60642" msgid "Show option \'All Seasons\'" @@ -2712,20 +2712,20 @@ msgid "Never" msgstr "Mai" msgctxt "#60650" -msgid " Video library information providers" -msgstr " Provider informazioni videoteca" +msgid "Video library information providers" +msgstr "Provider informazioni videoteca" msgctxt "#60651" -msgid " Movies" -msgstr " Film" +msgid "Movies" +msgstr "Film" msgctxt "#60652" -msgid " TV show" -msgstr " Serie TV" +msgid "TV show" +msgstr "Serie TV" msgctxt "#60653" -msgid " If there are no results search in English" -msgstr " Se non ci sono risultati cerca in inglese" +msgid "If there are no results search in English" +msgstr "Se non ci sono risultati cerca in inglese" msgctxt "#60654" msgid "Include in blacklist" @@ -2760,8 +2760,8 @@ msgid "News" msgstr "Novità" msgctxt "#60662" -msgid " Language" -msgstr " Lingua" +msgid "Language" +msgstr "Lingua" msgctxt "#60663" msgid "Add the progress window" @@ -3108,7 +3108,7 @@ msgid ">> Next Page" msgstr ">> Pagina successiva" msgctxt "#70066" -msgid " Search title in spanish: %s" +msgid "Search title in spanish: %s" msgstr "Cerca il suo titolo in italiano: %s" msgctxt "#70067" @@ -3200,11 +3200,11 @@ msgid "Show only links of %s" msgstr "Mostra solo link di %s" msgctxt "#70090" -msgid " Exclude all streams with specific words" +msgid "Exclude all streams with specific words" msgstr "Escludi streams con specifiche parole" msgctxt "#70091" -msgid " Words" +msgid "Words" msgstr "Parole" msgctxt "#70092" @@ -3520,8 +3520,8 @@ msgid "Torrent" msgstr "Torrent" msgctxt "#70172" -msgid " Plan B (If favourites fail try other links)" -msgstr " Piano B (Se i preferiti non vanno prova altri link)" +msgid "Plan B (If favourites fail try other links)" +msgstr "Piano B (Se i preferiti non vanno prova altri link)" msgctxt "#70173" msgid "No working links" @@ -3660,8 +3660,8 @@ msgid "Link found in %s" msgstr "%s" msgctxt "#70207" -msgid " - Movies 4K " -msgstr " - Film 4K " +msgid " - Movies 4K " +msgstr " - Film 4K " msgctxt "#70208" msgid "Movies 4K" @@ -3680,16 +3680,16 @@ msgid " (In %s)" msgstr " (En %s)" msgctxt "#70212" -msgid " - Castellan" -msgstr " - Castigliano" +msgid " - Castellan" +msgstr " - Castigliano" msgctxt "#70213" -msgid " - Latin" -msgstr " - Latino" +msgid " - Latin" +msgstr " - Latino" msgctxt "#70214" -msgid " - Torrent" -msgstr " - Torrent" +msgid " - Torrent" +msgstr " - Torrent" msgctxt "#70215" msgid "TEST THIS CHANNEL" @@ -3764,20 +3764,20 @@ msgid "View downloaded files" msgstr "Visualizza file scaricati" msgctxt "#70233" -msgid " - Size per block" -msgstr " - Dimensione per blocco" +msgid " - Size per block" +msgstr " - Dimensione per blocco" msgctxt "#70234" -msgid " - Size by part" -msgstr " - Dimensione per parte" +msgid " - Size by part" +msgstr " - Dimensione per parte" msgctxt "#70235" -msgid " - Maximum number of simultaneous connections" -msgstr " - Numero massimo di connnessioni simultanee" +msgid " - Maximum number of simultaneous connections" +msgstr " - Numero massimo di connnessioni simultanee" msgctxt "#70236" -msgid " - Maximum number of parts in memory" -msgstr " - Numero massimo di parti in memoria" +msgid " - Maximum number of parts in memory" +msgstr " - Numero massimo di parti in memoria" msgctxt "#70237" msgid "Choice of the server" @@ -3785,7 +3785,7 @@ msgstr "Scelta del server" msgctxt "#70238" msgid "- Order of servers" -msgstr " - Ordine dei servers" +msgstr " - Ordine dei servers" msgctxt "#70240" msgid "Preferred quality" @@ -3944,8 +3944,8 @@ msgid "You can try downloading the 'libtorrent' module from Kodi or installing s msgstr "Puoi provare a scaricare il modulo 'libtorrent' da Kodi o installare alcuni addon come 'Quasar' o 'Torrenter', che appariranno tra le opzioni nel pop-up .Quando appare quando fai clic su un collegamento torrent. 'Torrenter' È più complesso ma anche più completo e funziona sempre." msgctxt "#70280" -msgid " - Torrent Links don't work." -msgstr " - I Link Torrent non funzionano." +msgid " - Torrent Links don't work." +msgstr " - I Link Torrent non funzionano." msgctxt "#70281" msgid "Do you want to show these links?" @@ -4256,8 +4256,8 @@ msgid "Recommendations MyAnimeList" msgstr "Raccomandazioni MyAnimeList" msgctxt "#70360" -msgid " [Without subs in castellan]" -msgstr " [Senza subs in castigliano]" +msgid " [Without subs in castellan]" +msgstr " [Senza subs in castigliano]" msgctxt "#70361" msgid ">> More Episodes" @@ -4324,8 +4324,8 @@ msgid "Info in AniDB %s" msgstr "Info in AniDB %s" msgctxt "#70377" -msgid " - Fansubs in spanish:" -msgstr " - Fansubs in spagnolo:" +msgid " - Fansubs in spanish:" +msgstr " - Fansubs in spagnolo:" msgctxt "#70378" msgid "Complete" diff --git a/resources/settings.xml b/resources/settings.xml index be5bbfbb..43b9cf7c 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -24,7 +24,7 @@ <setting id="servers_favorites" visible="true" type="action" label="60551" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiAic2VydmVyc19mYXZvcml0ZXMiLA0KICAgICJjaGFubmVsIjogInNldHRpbmciDQp9==)"/> <setting id="servers_blacklist" visible="true" type="action" label="60550" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiAic2VydmVyc19ibGFja2xpc3QiLA0KICAgICJjaGFubmVsIjogInNldHRpbmciDQp9==)"/> - <setting id="window_type" type="select" label="60621" lvalues="60623|60622" default="0"/> + <!-- <setting id="window_type" type="select" label="60621" lvalues="60623|60622" default="0"/> --> <!-- <setting id="hide_servers" type="bool" label="70747" default="false" visible="eq(-1,true)" subsetting="true"/> --> <setting id="checklinks" type="bool" label="30020" default="false"/> <setting id="checklinks_number" type="slider" option="int" range="5,5,20" label="30021" default="5" visible="eq(-1,true)" subsetting="true"/> @@ -163,8 +163,8 @@ <!-- <setting id="extended_info" type="bool" label="70152" default="false"/> --> <!-- Shortcut --> <setting label="30998" type="lsep"/> - <setting id="shortcut_key" type="action" label="30999" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiAia2V5bWFwIg0KfQ==)"/> - <setting id="delete_key" type="action" label="31000" action="RunPlugin(plugin://plugin.video.kod/?ewogICAgImFjdGlvbiI6ICJkZWxldGVfa2V5Igp9==)"/> + <setting id="shortcut_key" type="action" label="30999" action="RunPlugin(plugin://plugin.video.kod/?channel=shortcuts&action=shortcut_menu&add=true)"/> + <setting id="delete_key" type="action" label="31000" action="RunPlugin(plugin://plugin.video.kod/?channel=shortcuts&action=shortcut_menu&delete=true)"/> <!-- Others --> <setting label="70149" type="lsep"/> <setting id="icon_set" type="select" label="70108" values="default|light|dark|mike" default="default"/> diff --git a/resources/skins/Default/720p/ChSettings.xml b/resources/skins/Default/720p/ChSettings.xml new file mode 100644 index 00000000..17ef79c6 --- /dev/null +++ b/resources/skins/Default/720p/ChSettings.xml @@ -0,0 +1,380 @@ +<?xml version='1.0' encoding='utf-8' standalone='yes'?> +<window> + <zorder>0.52</zorder> + <coordinates> + <left>0</left> + <top>0</top> + </coordinates> + + <controls> + <control type='group'> + <top>0</top> + <left>0</left> + <width>100%</width> + <height>100%</height> + <control type='image'> + <description>Window Background</description> + <width>100%</width> + <height>100%</height> + <texture colordiffuse='FF232323'>white.png</texture> + </control> + <control type='group'> + <top>40</top> + <left>40</left> + <control type='image'> + <description>Divider</description> + <top>10</top> + <left>0</left> + <height>40</height> + <width>40</width> + <texture colordiffuse='FFFFFFFF'>gear.png</texture> + </control> + <control type='label' id='1'> + <description>Title</description> + <top>0</top> + <left>50</left> + <height>60</height> + <width>1070</width> + <font>font13</font> + <textcolor>FFFFFFFF</textcolor> + <label>[B]$ADDON[plugin.video.kod 70320][/B]</label> + <aligny>center</aligny> + <align>left</align> + <label/> + </control> + + </control> + <control type='list' id='100'> + <left>40</left> + <top>140</top> + <height>540</height> + <width>1100</width> + <pagecontrol>101</pagecontrol> + <itemlayout height='60' width='1100'> + <control type='group'> + <description>Enabled</description> + <visible>String.IsEqual(ListItem.Property(enabled), True)</visible> + <left>20</left> + <height>100%</height> + <width>1060</width> + <control type='Label'> + <description>Label</description> + <width min='30' max='500'>auto</width> + <height>100%</height> + <align>left</align> + <aligny>center</aligny> + <font>font13</font> + <textcolor>FFFFFFFF</textcolor> + <label>$INFO[ListItem.Label]</label> + </control> + <control type='image'> + <description>Bool Selector</description> + <visible>String.IsEqual(ListItem.Property(type), label)</visible> + <top>30</top> + <right>0</right> + <width>540</width> + <height>2</height> + <texture colordiffuse='FFFFFFFF'>white.png</texture> + </control> + <control type='Label'> + <description>Selection</description> + <visible>!ListItem.Property(insert) + !ListItem.Property(bool) + !String.IsEqual(ListItem.Label2, None)</visible> + <width min='30' max='500'>auto</width> + <right>0</right> + <height>100%</height> + <align>right</align> + <aligny>center</aligny> + <font>font13</font> + <textcolor>FFFFFFFF</textcolor> + <label>$INFO[ListItem.Label2]</label> + </control> + <control type='image'> + <description>Bool Selector</description> + <visible>ListItem.Property(bool)</visible> + <top>15</top> + <right>0</right> + <width>30</width> + <height>30</height> + <texture colordiffuse='FFFFFFFF'>$INFO[ListItem.Property(bool)]</texture> + </control> + <control type='image'> + <description>Add Button</description> + <visible>ListItem.Property(insert) + String.IsEmpty(ListItem.Label)</visible> + <top>5</top> + <right>0</right> + <width>100%</width> + <height>50</height> + <texture colordiffuse='FFFFFFFF'>add.png</texture> + <aspectratio>keep</aspectratio> + </control> + </control> + <control type='group'> + <description>Disabled</description> + <visible>String.IsEqual(ListItem.Property(enabled), False)</visible> + <left>20</left> + <height>100%</height> + <width>1060</width> + <control type='Label'> + <description>Label</description> + <width min='30' max='500'>auto</width> + <height>100%</height> + <align>left</align> + <aligny>center</aligny> + <font>font13</font> + <textcolor>55FFFFFF</textcolor> + <label>$INFO[ListItem.Label]</label> + </control> + <control type='Label'> + <description>Selection</description> + <visible>!ListItem.Property(insert) + !ListItem.Property(bool) + !String.IsEqual(ListItem.Label2, None)</visible> + <width min='30' max='500'>auto</width> + <right>0</right> + <height>100%</height> + <align>right</align> + <aligny>center</aligny> + <font>font13</font> + <textcolor>55FFFFFF</textcolor> + <label>$INFO[ListItem.Label2]</label> + </control> + <control type='image'> + <description>Bool Selector</description> + <visible>!String.IsEmpty(ListItem.Property(bool))</visible> + <top>15</top> + <right>0</right> + <width>30</width> + <height>30</height> + <texture colordiffuse='55FFFFFF'>$INFO[ListItem.Property(bool)]</texture> + <aspectratio>keep</aspectratio> + </control> + <control type='image'> + <description>Add Button</description> + <visible>!String.IsEmpty(ListItem.Property(insert)) + String.IsEmpty(ListItem.Label)</visible> + <top>5</top> + <right>0</right> + <width>100%</width> + <height>50</height> + <texture colordiffuse='55FFFFFF'>add.png</texture> + <aspectratio>keep</aspectratio> + </control> + </control> + </itemlayout> + <focusedlayout height='60' width='1100'> + <control type='image'> + <description>Bool Selector</description> + <width>100%</width> + <height>100%</height> + <texture colordiffuse='AAFFFFFF'>white.png</texture> + </control> + <control type='group'> + <visible>String.IsEqual(ListItem.Property(enabled), True)</visible> + <left>20</left> + <height>100%</height> + <width>1060</width> + <control type='Label'> + <description>Label</description> + <width min='30' max='500'>auto</width> + <height>100%</height> + <align>left</align> + <aligny>center</aligny> + <font>font13</font> + <textcolor>FF232323</textcolor> + <label>$INFO[ListItem.Label]</label> + </control> + <control type='Label'> + <description>Selection</description> + <visible>!ListItem.Property(insert) + !ListItem.Property(bool) + !String.IsEqual(ListItem.Label2, None)</visible> + <width min='30' max='500'>auto</width> + <right>0</right> + <height>100%</height> + <align>right</align> + <aligny>center</aligny> + <font>font13</font> + <textcolor>FF232323</textcolor> + <label>$INFO[ListItem.Label2]</label> + </control> + <control type='image'> + <description>Bool Selector</description> + <visible>!String.IsEmpty(ListItem.Property(bool))</visible> + <top>15</top> + <right>0</right> + <width>30</width> + <height>30</height> + <texture colordiffuse='FF232323'>$INFO[ListItem.Property(bool)]</texture> + <aspectratio>keep</aspectratio> + </control> + <control type='image'> + <description>Add Button</description> + <visible>!String.IsEmpty(ListItem.Property(insert)) + String.IsEmpty(ListItem.Label)</visible> + <top>5</top> + <right>0</right> + <width>100%</width> + <height>50</height> + <texture colordiffuse='FF232323'>add.png</texture> + <aspectratio>keep</aspectratio> + </control> + </control> + <control type='group'> + <visible>String.IsEqual(ListItem.Property(enabled), False)</visible> + <left>20</left> + <height>100%</height> + <width>1060</width> + <control type='Label'> + <description>Label</description> + <width min='30' max='500'>auto</width> + <height>100%</height> + <align>left</align> + <aligny>center</aligny> + <font>font13</font> + <textcolor>55232323</textcolor> + <label>$INFO[ListItem.Label]</label> + </control> + <control type='Label'> + <description>Selection</description> + <visible>!ListItem.Property(insert) + !ListItem.Property(bool) + !String.IsEqual(ListItem.Label2, None)</visible> + <width min='30' max='500'>auto</width> + <right>0</right> + <height>100%</height> + <align>right</align> + <aligny>center</aligny> + <font>font13</font> + <textcolor>55232323</textcolor> + <label>$INFO[ListItem.Label2]</label> + </control> + <control type='image'> + <description>Bool Selector</description> + <visible>!String.IsEmpty(ListItem.Property(bool))</visible> + <top>15</top> + <right>0</right> + <width>30</width> + <height>30</height> + <texture colordiffuse='55232323'>$INFO[ListItem.Property(bool)]</texture> + <aspectratio>keep</aspectratio> + </control> + <control type='image'> + <description>Add Button</description> + <visible>!String.IsEmpty(ListItem.Property(insert)) + String.IsEmpty(ListItem.Label)</visible> + <top>5</top> + <right>0</right> + <width>100%</width> + <height>50</height> + <texture colordiffuse='55232323'>add.png</texture> + <aspectratio>keep</aspectratio> + </control> + </control> + </focusedlayout> + </control> + <control type='scrollbar' id='101'> + <animation effect='zoom' center='1161,0' end='800,100' time='50' condition='Control.HasFocus(101)'>Conditional</animation> + <description>Scrollbar</description> + <left>1160</left> + <top>140</top> + <width>1</width> + <height>540</height> + <visible>true</visible> + <texturesliderbackground colordiffuse='22FFFFFF'>white.png</texturesliderbackground> + <texturesliderbar colordiffuse='55FFFFFF'>white.png</texturesliderbar> + <texturesliderbarfocus colordiffuse='FFFFFFFF'>white.png</texturesliderbarfocus> + <textureslidernib /> + <textureslidernibfocus/> + <pulseonselect></pulseonselect> + <orientation>vertical</orientation> + <onleft>100</onleft> + <onright>200</onright> + </control> + </control> + + <control type='list' id='200'> + <description>Buttons</description> + <top>140</top> + <right>40</right> + <width>40</width> + <height>540</height> + <itemlayout height='50' width='40'> + <control type='image'> + <height>40</height> + <width>40</width> + <aspectratio>scale</aspectratio> + <texture colordiffuse='FF555555'>$INFO[ListItem.Art(button)]</texture> + </control> + </itemlayout> + <focusedlayout height='50' width='40'> + <control type='image'> + <visible>!Control.HasFocus(200)</visible> + <height>40</height> + <width>40</width> + <aspectratio>scale</aspectratio> + <texture colordiffuse='FF555555'>$INFO[ListItem.Art(button)]</texture> + </control> + <control type='image'> + <visible>Control.HasFocus(200)</visible> + <height>40</height> + <width>40</width> + <aspectratio>scale</aspectratio> + <texture colordiffuse='FFFFFFFF'>$INFO[ListItem.Art(button)]</texture> + </control> + </focusedlayout> + </control> + + <control type='group'> + <description>Insert Controls</description> + <orientation>horizontal</orientation> + <top>90</top> + <right>480</right> + <height>40</height> + <width>120</width> + + <visible>!String.IsEmpty(Container(100).ListItem.Property(insert)) + !String.IsEmpty(Container(100).ListItem.Label)</visible> + <animation effect='slide' end='0,60' condition='Integer.IsGreater(Container(100).Position,0)'>Conditional</animation> + <animation effect='slide' end='0,60' condition='Integer.IsGreater(Container(100).Position,1)'>Conditional</animation> + <animation effect='slide' end='0,60' condition='Integer.IsGreater(Container(100).Position,2)'>Conditional</animation> + <animation effect='slide' end='0,60' condition='Integer.IsGreater(Container(100).Position,3)'>Conditional</animation> + <animation effect='slide' end='0,60' condition='Integer.IsGreater(Container(100).Position,4)'>Conditional</animation> + <animation effect='slide' end='0,60' condition='Integer.IsGreater(Container(100).Position,5)'>Conditional</animation> + <animation effect='slide' end='0,60' condition='Integer.IsGreater(Container(100).Position,6)'>Conditional</animation> + <animation effect='slide' end='0,60' condition='Integer.IsGreater(Container(100).Position,7)'>Conditional</animation> + <animation effect='slide' end='0,60' condition='Integer.IsGreater(Container(100).Position,8)'>Conditional</animation> + + <control type='button' id='300'> + <description>Move Up</description> + <top>0</top> + <left>0</left> + <height>40</height> + <width>40</width> + <onleft>100</onleft> + <onright>301</onright> + <onup>Control.Move(100,-1)</onup> + <ondown>Control.Move(100,1)</ondown> + <texturefocus colordiffuse='FF232323'>up.png</texturefocus> + <texturenofocus colordiffuse='80232323'>up.png</texturenofocus> + </control> + + <control type='button' id='301'> + <description>Move Down</description> + <top>0</top> + <left>40</left> + <height>40</height> + <width>40</width> + <onleft>300</onleft> + <onright>302</onright> + <onup>Control.Move(100,-1)</onup> + <ondown>Control.Move(100,1)</ondown> + <texturefocus colordiffuse='FF232323'>down.png</texturefocus> + <texturenofocus colordiffuse='80232323'>down.png</texturenofocus> + </control> + + <control type='button' id='302'> + <description>Remove</description> + <top>0</top> + <left>80</left> + <height>40</height> + <width>40</width> + <onleft>301</onleft> + <onright>200</onright> + <onup>Control.Move(100,-1)</onup> + <ondown>Control.Move(100,1)</ondown> + <texturefocus colordiffuse='FF232323'>delete.png</texturefocus> + <texturenofocus colordiffuse='80232323'>delete.png</texturenofocus> + </control> + </control> + </controls> +</window> \ No newline at end of file diff --git a/resources/skins/Default/720p/InfoPlus.xml b/resources/skins/Default/720p/InfoPlus.xml index d39a0abf..95e38d5f 100644 --- a/resources/skins/Default/720p/InfoPlus.xml +++ b/resources/skins/Default/720p/InfoPlus.xml @@ -698,7 +698,7 @@ <top>30</top> <right>30</right> <height>40</height> - <width>120</width> + <width>130</width> <orientation>horizontal</orientation> <control type="button" id="200"> <description>search</description> diff --git a/resources/skins/Default/720p/Servers.xml b/resources/skins/Default/720p/Servers.xml index 6a6a8475..2a3c78eb 100644 --- a/resources/skins/Default/720p/Servers.xml +++ b/resources/skins/Default/720p/Servers.xml @@ -62,6 +62,7 @@ <left>520</left> <width>700</width> <height>570</height> + <onup>101</onup> <onleft>101</onleft> <onright>101</onright> <animation type="WindowOpen" reversible="false"> @@ -165,19 +166,54 @@ </focusedlayout> </control> <!-- END Servers List --> - <control type="button" id="101"> - <description>Close</description> + <control type="group"> <top>30</top> <right>30</right> - <height>40</height> - <width>40</width> - <onup>100</onup> - <ondown>100</ondown> - <onleft>100</onleft> - <onright>100</onright> - <texturefocus colordiffuse="FFFFFFFF">close.png</texturefocus> - <texturenofocus colordiffuse="80FFFFFF">close.png</texturenofocus> - <onclick>Action(close)</onclick> + <control type="button" id="101"> + <description>Close</description> + <top>0</top> + <right>0</right> + <height>40</height> + <width>40</width> + <onup>100</onup> + <ondown>100</ondown> + <onleft condition="Control.IsVisible(102)">102</onleft> + <onleft condition="Control.IsVisible(103)">103</onleft> + <onleft>100</onleft> + <onright>100</onright> + <texturefocus colordiffuse="FFFFFFFF">close.png</texturefocus> + <texturenofocus colordiffuse="80FFFFFF">close.png</texturenofocus> + <onclick>Action(close)</onclick> + </control> + <control type="button" id="102"> + <description>videolibrary</description> + <top>0</top> + <right>40</right> + <height>40</height> + <width>40</width> + <onup>100</onup> + <ondown>100</ondown> + <onleft condition="Control.IsVisible(103)">103</onleft> + <onleft condition="Control.IsVisible(103)">100</onleft> + <onright>101</onright> + <texturefocus colordiffuse="FFFFFFFF">add.png</texturefocus> + <texturenofocus colordiffuse="80FFFFFF">add.png</texturenofocus> + </control> + <control type="button" id="103"> + <description>Download</description> + <top>0</top> + <right>40</right> + <animation effect="slide" end="-40,0" condition="Control.IsVisible(102)">Conditional</animation> + <height>40</height> + <width>40</width> + <onup>100</onup> + <ondown>100</ondown> + <onleft>100</onleft> + <onright condition="Control.IsVisible(102)">102</onright> + <onright>101</onright> + <texturefocus colordiffuse="FFFFFFFF">down.png</texturefocus> + <texturenofocus colordiffuse="80FFFFFF">down.png</texturenofocus> + </control> </control> </control> <!-- END SERVERS GROUP --> diff --git a/resources/skins/Default/media/gear.png b/resources/skins/Default/media/gear.png new file mode 100644 index 00000000..a65a4d75 Binary files /dev/null and b/resources/skins/Default/media/gear.png differ diff --git a/resources/skins/Default/media/off.png b/resources/skins/Default/media/off.png new file mode 100644 index 00000000..c71ffd98 Binary files /dev/null and b/resources/skins/Default/media/off.png differ diff --git a/resources/skins/Default/media/on.png b/resources/skins/Default/media/on.png new file mode 100644 index 00000000..9c816569 Binary files /dev/null and b/resources/skins/Default/media/on.png differ diff --git a/resources/skins/Default/media/subtract.png b/resources/skins/Default/media/subtract.png new file mode 100644 index 00000000..31837564 Binary files /dev/null and b/resources/skins/Default/media/subtract.png differ diff --git a/servers/akvideo.py b/servers/akvideo.py index c8909e64..701023d5 100644 --- a/servers/akvideo.py +++ b/servers/akvideo.py @@ -24,7 +24,7 @@ def test_video_exists(page_url): if code: page = httptools.downloadpage('http://akvideo.stream/video/' + code, headers=headers) else: - return False, config.get_localized_string(70449) % "Akvideo" + return False, config.getLocalizedString(70449) % "Akvideo" if 'video.php?file_code=' in page.url: page = httptools.downloadpage(page.url.replace('video.php?file_code=', 'video/'), headers=headers) @@ -34,23 +34,23 @@ def test_video_exists(page_url): # post = urllib.urlencode({ID: code}) # logger.debug('PAGE DATA' + data) if "File Not Found" in data: - return False, config.get_localized_string(70449) % "Akvideo" + return False, config.getLocalizedString(70449) % "Akvideo" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug(" url=" + page_url) - video_urls = [] + videoUrls = [] global data # logger.debug('PAGE DATA' + data) # sitekey = scrapertools.find_single_match(data, 'data-sitekey="([^"]+)') - # captcha = platformtools.show_recaptcha(sitekey, page_url) if sitekey else '' + # captcha = platformtools.showRecaptcha(sitekey, page_url) if sitekey else '' # # if captcha: # data = httptools.downloadpage(page_url, post={'g-recaptcha-response': captcha}).data - vres = scrapertools.find_multiple_matches(data, 'nowrap[^>]+>([^,]+)') - if not vres: vres = scrapertools.find_multiple_matches(data, '<td>(\d+x\d+)') + vres = scrapertools.findMultipleMatches(data, 'nowrap[^>]+>([^,]+)') + if not vres: vres = scrapertools.findMultipleMatches(data, '<td>(\d+x\d+)') data_pack = scrapertools.find_single_match(data, "</div>\n\s*<script[^>]+>(eval.function.p,a,c,k,e,.*?)\s*</script>") if data_pack != "": @@ -58,7 +58,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= data = jsunpack.unpack(data_pack) _headers = urllib.urlencode(httptools.default_headers) - video_urls = support.get_jwplayer_mediaurl(data, 'akvideo', onlyHttp=True) + videoUrls = support.get_jwplayer_mediaUrl(data, 'akvideo', onlyHttp=True) - return video_urls + return videoUrls diff --git a/servers/anavids.py b/servers/anavids.py index dd506dd3..305b7081 100644 --- a/servers/anavids.py +++ b/servers/anavids.py @@ -10,12 +10,12 @@ def test_video_exists(page_url): global data data = httptools.downloadpage(page_url, cookies=False).data if 'File you are looking for is not found.' in data: - return False, config.get_localized_string(70449) % "AvaVids" + return False, config.getLocalizedString(70449) % "AvaVids" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): global data - video_urls = support.get_jwplayer_mediaurl(data, 'AvaVids') - return video_urls + videoUrls = support.get_jwplayer_mediaUrl(data, 'AvaVids') + return videoUrls diff --git a/servers/animeid.py b/servers/animeid.py index 4e3a3392..b04a9cc2 100644 --- a/servers/animeid.py +++ b/servers/animeid.py @@ -9,18 +9,18 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data if "no longer exists" in data or "to copyright issues" in data: - return False, config.get_localized_string(70449) % "animeid" + return False, config.getLocalizedString(70449) % "animeid" if "please+try+again+later." in data: return False, "[animeid] Error de animeid, no se puede generar el enlace al video" return True, "" -def get_video_url(page_url, user="", password="", video_password=""): +def get_videoUrl(page_url, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data - video_urls = [] + videoUrls = [] label, videourl = scrapertools.find_single_match(data, 'label":"([^"]+)".*?file":"([^"]+)') if "animeid.tv" in videourl: videourl = httptools.downloadpage(videourl, follow_redirects=False, only_headers=True).headers.get("location", "") - video_urls.append({'type':'mp4', 'res':label, 'url':videourl}) - return video_urls + videoUrls.append({'type':'mp4', 'res':label, 'url':videourl}) + return videoUrls diff --git a/servers/anonfile.py b/servers/anonfile.py index bf857228..7210a935 100644 --- a/servers/anonfile.py +++ b/servers/anonfile.py @@ -12,17 +12,17 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) response = httptools.downloadpage(page_url) if not response.success or "Not Found" in response.data or "File was deleted" in response.data or "is no longer available" in response.data: - return False, config.get_localized_string(70449) % "anonfile" + return False, config.getLocalizedString(70449) % "anonfile" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url).data patron = 'download-url.*?href="([^"]+)"' - match = scrapertools.find_multiple_matches(data, patron) + match = scrapertools.findMultipleMatches(data, patron) for media_url in match: media_url += "|Referer=%s" %page_url - video_urls.append({'type':'mp4', 'url':media_url}) - return video_urls + videoUrls.append({'type':'mp4', 'url':media_url}) + return videoUrls diff --git a/servers/archiveorg.py b/servers/archiveorg.py index fff81723..ef805964 100644 --- a/servers/archiveorg.py +++ b/servers/archiveorg.py @@ -12,16 +12,16 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url) if data.code == 404: - return False, config.get_localized_string(70449) % "ArchiveOrg" + return False, config.getLocalizedString(70449) % "ArchiveOrg" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url).data patron = '<meta property="og:video" content="([^"]+)">' - matches = scrapertools.find_multiple_matches(data, patron) + matches = scrapertools.findMultipleMatches(data, patron) for url in matches: - video_urls.append({'type':'mp4', 'url':url}) - return video_urls + videoUrls.append({'type':'mp4', 'url':url}) + return videoUrls diff --git a/servers/backin.py b/servers/backin.py index 27ff3a94..525cd74c 100644 --- a/servers/backin.py +++ b/servers/backin.py @@ -18,15 +18,15 @@ def test_video_exists(page_url): data = httptools.downloadpage(page_url).data if 'File Not Found' in data: - return False, config.get_localized_string(70449) % "backin" + return False, config.getLocalizedString(70449) % "backin" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("page_url=" + page_url) - video_urls = [] + videoUrls = [] headers = [["User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:54.0) Gecko/20100101 Firefox/54.0"]] @@ -45,9 +45,9 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= logger.debug("URL=" + str(url)) # URL del vídeo - video_urls.append({'type':'mp4', 'url':url}) + videoUrls.append({'type':'mp4', 'url':url}) - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], httptools.get_url_headers(video_url[1]))) + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], httptools.get_url_headers(videoUrl[1]))) - return video_urls + return videoUrls diff --git a/servers/badshare.py b/servers/badshare.py index d319956c..b8b49028 100644 --- a/servers/badshare.py +++ b/servers/badshare.py @@ -15,19 +15,19 @@ def test_video_exists(page_url): global page page = httptools.downloadpage(page_url) if not page.success: - return False, config.get_localized_string(70449) % "Badshare" + return False, config.getLocalizedString(70449) % "Badshare" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] ext = '.mp4' data = page.data data = re.sub(r'\n|\r|\t|\s{2,}', "", data) media_url, ext = scrapertools.find_single_match(data, r'file:\s*"([^"]+)",type:\s*"([^"]+)"') - video_urls.append({'type':ext, 'url':media_url}) + videoUrls.append({'type':ext, 'url':media_url}) - return video_urls + return videoUrls diff --git a/servers/bdupload.py b/servers/bdupload.py index ff39256b..7138f528 100644 --- a/servers/bdupload.py +++ b/servers/bdupload.py @@ -13,17 +13,17 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data if "Archive no Encontrado" in data: - return False, config.get_localized_string(70449) % "bdupload" + return False, config.getLocalizedString(70449) % "bdupload" return True, "" -def get_video_url(page_url, user="", password="", video_password=""): +def get_videoUrl(page_url, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data post = "" patron = '(?s)type="hidden" name="([^"]+)".*?value="([^"]*)"' - match = scrapertools.find_multiple_matches(data, patron) + match = scrapertools.findMultipleMatches(data, patron) for nombre, valor in match: post += nombre + "=" + valor + "&" time.sleep(1) @@ -32,7 +32,7 @@ def get_video_url(page_url, user="", password="", video_password=""): file = scrapertools.find_single_match(data1, patron).replace(" ","%20") file += "|User-Agent=" + httptools.get_user_agent() file += "&Host=fs30.indifiles.com:182" - video_urls = [] + videoUrls = [] videourl = file - video_urls.append({'type':'mp4', 'url':videourl}) - return video_urls + videoUrls.append({'type':'mp4', 'url':videourl}) + return videoUrls diff --git a/servers/cinemaupload.py b/servers/cinemaupload.py index 88e2507f..f32cc210 100644 --- a/servers/cinemaupload.py +++ b/servers/cinemaupload.py @@ -14,18 +14,18 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url) if data.code == 404: - return False, config.get_localized_string(70449) % "CinemaUpload" + return False, config.getLocalizedString(70449) % "CinemaUpload" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url).data data = re.sub(r'\n|\r|\t| |<br>|\s{2,}', "", data) patron = 'file: "([^"]+)",' - matches = scrapertools.find_multiple_matches(data, patron) + matches = scrapertools.findMultipleMatches(data, patron) for url in matches: url += "|Referer=%s" %page_url - video_urls.append({'type':'m3u8', 'url':url}) - return video_urls + videoUrls.append({'type':'m3u8', 'url':url}) + return videoUrls diff --git a/servers/clicknupload.py b/servers/clicknupload.py index 2a415dde..f786e752 100755 --- a/servers/clicknupload.py +++ b/servers/clicknupload.py @@ -25,35 +25,35 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = get_data(page_url.replace(".org", ".me")) - if "File Not Found" in data: return False, config.get_localized_string(70449) % "Clicknupload" + if "File Not Found" in data: return False, config.getLocalizedString(70449) % "Clicknupload" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) data = get_data(page_url.replace(".org", ".me")) post = "" block = scrapertools.find_single_match(data, '(?i)<Form method="POST"(.*?)</Form>') - matches = scrapertools.find_multiple_matches(block, 'input.*?name="([^"]+)".*?value="([^"]*)"') + matches = scrapertools.findMultipleMatches(block, 'input.*?name="([^"]+)".*?value="([^"]*)"') for inputname, inputvalue in matches: post += inputname + "=" + inputvalue + "&" post = post.replace("download1", "download2") data = get_data(page_url, post) - video_urls = [] + videoUrls = [] media = scrapertools.find_single_match(data, "onClick=\"window.open\('([^']+)'") # Solo es necesario codificar la ultima parte de la url url_strip = urllib.quote(media.rsplit('/', 1)[1]) media_url = media.rsplit('/', 1)[0] + "/" + url_strip - video_urls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url}) - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) + videoUrls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url}) + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) - return video_urls + return videoUrls def get_data(url_orig, req_post=""): diff --git a/servers/clipwatching.py b/servers/clipwatching.py index d6878b93..f393f8da 100644 --- a/servers/clipwatching.py +++ b/servers/clipwatching.py @@ -11,13 +11,13 @@ def test_video_exists(page_url): global data data = httptools.downloadpage(page_url).data if "File Not Found" in data or "File was deleted" in data: - return False, config.get_localized_string(70292) % "ClipWatching" + return False, config.getLocalizedString(70292) % "ClipWatching" return True, "" -def get_video_url(page_url, user="", password="", video_password=""): +def get_videoUrl(page_url, user="", password="", video_password=""): logger.info("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] multires = False try: @@ -26,7 +26,7 @@ def get_video_url(page_url, user="", password="", video_password=""): except: unpacked = scrapertools.find_single_match(data,"window.hola_player.*") - videos = scrapertools.find_multiple_matches(unpacked if unpacked else data, r'(?:file|src|sources):\s*(?:\[)?"([^"]+).*?(?:label:\s*"([^"]+))?') + videos = scrapertools.findMultipleMatches(unpacked if unpacked else data, r'(?:file|src|sources):\s*(?:\[)?"([^"]+).*?(?:label:\s*"([^"]+))?') for video, label in videos: if ".jpg" not in video: if label and not label.endswith('p'): @@ -35,7 +35,7 @@ def get_video_url(page_url, user="", password="", video_password=""): else: label = video.split('.')[-1] multires = False - video_urls.append({'type':label, 'url':video}) + videoUrls.append({'type':label, 'url':video}) # if multires: - # video_urls.sort(key=lambda it: int(it[0].split("p ", 1)[0])) - return video_urls + # videoUrls.sort(key=lambda it: int(it[0].split("p ", 1)[0])) + return videoUrls diff --git a/servers/cloudvideo.py b/servers/cloudvideo.py index acf10512..8b9a691e 100644 --- a/servers/cloudvideo.py +++ b/servers/cloudvideo.py @@ -13,29 +13,29 @@ def test_video_exists(page_url): global data data = html.data if html.code == 404 or 'No Signal 404 Error Page' in data: - return False, config.get_localized_string(70449) % "CloudVideo" + return False, config.getLocalizedString(70449) % "CloudVideo" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] global data # data = httptools.downloadpage(page_url).data enc_data = scrapertools.find_single_match(data, r'text/javascript">(eval.+?)(?:\n|\s*</script>)') if enc_data: dec_data = jsunpack.unpack(enc_data) - matches = scrapertools.find_multiple_matches(dec_data, r'src:"([^"]+)"') + matches = scrapertools.findMultipleMatches(dec_data, r'src:"([^"]+)"') else: sources = scrapertools.find_single_match(data, r"<source(.*?)</source") patron = r'src="([^"]+)' - matches = scrapertools.find_multiple_matches(sources, patron) + matches = scrapertools.findMultipleMatches(sources, patron) for url in matches: Type = 'm3u8' - video_url = url + videoUrl = url if 'label' in url: url = url.split(',') - video_url = url[0] + videoUrl = url[0] Type = url[1].replace('label:','') - video_urls.append({'type':Type, 'url':video_url}) - return video_urls + videoUrls.append({'type':Type, 'url':videoUrl}) + return videoUrls diff --git a/servers/crunchyroll.py b/servers/crunchyroll.py index 84087bfb..985a0f23 100755 --- a/servers/crunchyroll.py +++ b/servers/crunchyroll.py @@ -42,10 +42,10 @@ def test_video_exists(page_url): return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): #page_url='https://www.crunchyroll.com/es-es/one-piece/episode-891-climbing-up-a-waterfall-a-great-journey-through-the-land-of-wanos-sea-zone-786643' logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] if "crunchyroll.com" in page_url: media_id = page_url.rsplit("-", 1)[1] else: @@ -62,7 +62,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= data = httptools.downloadpage(get, post=post, headers=GLOBAL_HEADER).data media_url = scrapertools.find_single_match(data, '<file>(.*?)</file>').replace("&", "&") if not media_url: - return video_urls + return videoUrls elif not media_url.startswith("http"): rtmp = scrapertools.find_single_match(data, '<host>(.*?)</host>').replace("&", "&") media_url = rtmp + " playpath=%s" % media_url @@ -73,7 +73,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= try: #idiomas = ['Español \(España\)', 'Español\]', 'English', 'Italiano', 'Français', 'Português', 'Deutsch'] idiomas = ['Deutsch', 'Português', 'Français', 'Italiano', 'English', 'Español\]', 'Español \(España\)'] - index_sub = int(config.get_setting("crunchyrollsub", "crunchyroll")) + index_sub = int(config.getSetting("crunchyrollsub", "crunchyroll")) idioma_sub = idiomas[index_sub] link_sub = scrapertools.find_single_match(data, "link='([^']+)' title='\[%s" % idioma_sub) @@ -92,16 +92,16 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= import traceback logger.error(traceback.format_exc()) file_sub = "" - video_urls.append({'type':filename, 'res':quality, 'url':media_url, 'sub':file_sub}) - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) - return video_urls + videoUrls.append({'type':filename, 'res':quality, 'url':media_url, 'sub':file_sub}) + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) + return videoUrls def login(page_url): login_page = "https://www.crunchyroll.com/login" - user = config.get_setting("user", server="crunchyroll") - password = config.get_setting("password", server="crunchyroll") + user = config.getSetting("user", server="crunchyroll") + password = config.getSetting("password", server="crunchyroll") data = httptools.downloadpage(login_page, headers=GLOBAL_HEADER).data if not "<title>Redirecting" in data: token = scrapertools.find_single_match(data, 'name="login_form\[_token\]" value="([^"]+)"') @@ -159,7 +159,7 @@ def decrypt_subs(iv, data, id): import xml.etree.ElementTree as ET raiz = ET.fromstring(data) ass_sub = convert_to_ass(raiz) - file_sub = filetools.join(config.get_data_path(), 'crunchyroll_sub.ass') + file_sub = filetools.join(config.getDataPath(), 'crunchyroll_sub.ass') filetools.write(file_sub, ass_sub) return file_sub diff --git a/servers/dailymotion.py b/servers/dailymotion.py index 798a9e8a..af0d0906 100644 --- a/servers/dailymotion.py +++ b/servers/dailymotion.py @@ -11,22 +11,22 @@ def test_video_exists(page_url): response = httptools.downloadpage(page_url, cookies=False) if "Pagina non trovata" in response.data: - return False, config.get_localized_string(70449) % "dailymotion" + return False, config.getLocalizedString(70449) % "dailymotion" if response.code == 404: - return False, config.get_localized_string(70449) % "dailymotion" + return False, config.getLocalizedString(70449) % "dailymotion" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] cookie = {'Cookie': response.headers["set-cookie"]} data = response.data.replace("\\", "") subtitle = scrapertools.find_single_match(data, '"subtitles":.*?"es":.*?urls":\["([^"]+)"') - qualities = scrapertools.find_multiple_matches(data, '"([^"]+)":(\[\{"type":".*?\}\])') + qualities = scrapertools.findMultipleMatches(data, '"([^"]+)":(\[\{"type":".*?\}\])') for calidad, urls in qualities: patron = '"type":"(?:video|application)\\/([^"]+)","url":"([^"]+)"' - matches = scrapertools.find_multiple_matches(urls, patron) + matches = scrapertools.findMultipleMatches(urls, patron) for stream_type, stream_url in matches: stream_type = stream_type.replace('x-mpegURL', 'm3u8') if stream_type == "mp4": @@ -38,7 +38,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= stream_url_http = scrapertools.find_single_match(data_m3u8, r'PROGRESSIVE-URI="([^"]+)"') if stream_url_http: stream_url = stream_url_http - video_urls.append({'type':calidad, 'res':stream_type, 'url':stream_url, 'sub':subtitle}) - for video_url in video_urls: - logger.debug("%s - %s" % (video_url[0], video_url[1])) - return video_urls \ No newline at end of file + videoUrls.append({'type':calidad, 'res':stream_type, 'url':stream_url, 'sub':subtitle}) + for videoUrl in videoUrls: + logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) + return videoUrls \ No newline at end of file diff --git a/servers/debriders/alldebrid.py b/servers/debriders/alldebrid.py index 3818fffd..99165031 100644 --- a/servers/debriders/alldebrid.py +++ b/servers/debriders/alldebrid.py @@ -6,7 +6,7 @@ from platformcode import logger # Returns an array of possible video url's from the page_url -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug() page_url = correct_url(page_url) dd1 = httptools.downloadpage("https://api.alldebrid.com/user/login?agent=mySoft&username=%s&password=%s" %(user, password)).data @@ -14,10 +14,10 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= dd2 = httptools.downloadpage("https://api.alldebrid.com/link/unlock?agent=mySoft&token=%s&link=%s" %(token, page_url)).data link = scrapertools.find_single_match(dd2, 'link":"([^"]+)') link = link.replace("\\","") - video_urls = [] + videoUrls = [] if link: extension = "mp4 [alldebrid]" - video_urls.append([extension, link]) + videoUrls.append([extension, link]) else: try: server_error = "Alldebrid: " + data["error"].decode("utf-8", "ignore") @@ -27,8 +27,8 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= "Servidor no soportado o en mantenimiento") except: server_error = "Alldebrid: Error en el usuario/password o en la web" - video_urls.append([server_error, '']) - return video_urls + videoUrls.append([server_error, '']) + return videoUrls def correct_url(url): diff --git a/servers/debriders/realdebrid.py b/servers/debriders/realdebrid.py index d8e6d4f5..72e73ac7 100755 --- a/servers/debriders/realdebrid.py +++ b/servers/debriders/realdebrid.py @@ -21,11 +21,11 @@ headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:65.0) Gecko/20 # Returns an array of possible video url's from the page_url -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s' , video_password=%s)" % (page_url, video_password)) page_url = page_url.replace(".nz/embed", ".nz/") # Se comprueba si existe un token guardado y sino se ejecuta el proceso de autentificación - token_auth = config.get_setting("token", server="realdebrid") + token_auth = config.getSetting("token", server="realdebrid") if token_auth is None or token_auth == "": if config.is_xbmc(): token_auth = authentication() @@ -40,7 +40,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= data = httptools.downloadpage(url, post=post_link, headers=list(headers.items())).json logger.error(data) - check = config.get_setting("secret", server="realdebrid") + check = config.getSetting("secret", server="realdebrid") #Se ha usado la autentificación por urlresolver (Bad Idea) if "error" in data and data["error"] == "bad_token" and not check: token_auth = authentication() @@ -50,9 +50,9 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= # Si el token es erróneo o ha caducado, se solicita uno nuevo elif "error" in data and data["error"] == "bad_token": - debrid_id = config.get_setting("id", server="realdebrid") - secret = config.get_setting("secret", server="realdebrid") - refresh = config.get_setting("refresh", server="realdebrid") + debrid_id = config.getSetting("id", server="realdebrid") + secret = config.getSetting("secret", server="realdebrid") + refresh = config.getSetting("refresh", server="realdebrid") post_token = urllib.urlencode({"client_id": debrid_id, "client_secret": secret, "code": refresh, "grant_type": "http://oauth.net/grant_type/device/1.0"}) @@ -60,7 +60,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= headers=list(headers.items())).json if not "error" in renew_token: token_auth = renew_token["access_token"] - config.set_setting("token", token_auth, server="realdebrid") + config.setSetting("token", token_auth, server="realdebrid") headers["Authorization"] = "Bearer %s" % token_auth data = httptools.downloadpage(url, post=post_link, headers=list(headers.items())).json else: @@ -85,15 +85,15 @@ def get_enlaces(data): itemlist = [] if "alternative" in data: for link in data["alternative"]: - video_url = link["download"].encode("utf-8") - title = video_url.rsplit(".", 1)[1] + videoUrl = link["download"].encode("utf-8") + title = videoUrl.rsplit(".", 1)[1] if "quality" in link: title += " (" + link["quality"] + ") [realdebrid]" - itemlist.append([title, video_url]) + itemlist.append([title, videoUrl]) else: - video_url = data["download"].encode("utf-8") - title = video_url.rsplit(".", 1)[1] + " [realdebrid]" - itemlist.append([title, video_url]) + videoUrl = data["download"].encode("utf-8") + title = videoUrl.rsplit(".", 1)[1] + " [realdebrid]" + itemlist.append([title, videoUrl]) return itemlist @@ -111,10 +111,10 @@ def authentication(): device_code = data["device_code"] intervalo = data["interval"] - dialog_auth = platformtools.dialog_progress(config.get_localized_string(70414), - config.get_localized_string(60252) % verify_url + '\n' + - config.get_localized_string(70413) % user_code + '\n' + - config.get_localized_string(60254)) + dialog_auth = platformtools.dialogProgress(config.getLocalizedString(70414), + config.getLocalizedString(60252) % verify_url + '\n' + + config.getLocalizedString(70413) % user_code + '\n' + + config.getLocalizedString(60254)) # Generalmente cada 5 segundos se intenta comprobar si el usuario ha introducido el código while True: @@ -149,10 +149,10 @@ def authentication(): token = data["access_token"] refresh = data["refresh_token"] - config.set_setting("id", debrid_id, server="realdebrid") - config.set_setting("secret", secret, server="realdebrid") - config.set_setting("token", token, server="realdebrid") - config.set_setting("refresh", refresh, server="realdebrid") + config.setSetting("id", debrid_id, server="realdebrid") + config.setSetting("secret", secret, server="realdebrid") + config.setSetting("token", token, server="realdebrid") + config.setSetting("refresh", refresh, server="realdebrid") return token except: diff --git a/servers/deltabit.py b/servers/deltabit.py index 859c777c..d30a5852 100644 --- a/servers/deltabit.py +++ b/servers/deltabit.py @@ -15,17 +15,17 @@ def test_video_exists(page_url): real_url = page.url if "Not Found" in data or "File Does not Exist" in data: - return False, config.get_localized_string(70449) % "DeltaBit" + return False, config.getLocalizedString(70449) % "DeltaBit" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(deltabit page_url='%s')" % page_url) global data, real_url - post = {k: v for k, v in scrapertools.find_multiple_matches(data, "name='([^']+)' value='([^']*)'")} + post = {k: v for k, v in scrapertools.findMultipleMatches(data, "name='([^']+)' value='([^']*)'")} time.sleep(2.5) data = httptools.downloadpage(real_url, post=post).data # videos_packed = scrapertools.find_single_match(data, r"<script type='text/javascript'>(eval.function.p,a,c,k,e,.*?)\s*</script>") # video_unpacked = jsunpack.unpack(videos_packed) - return support.get_jwplayer_mediaurl(data, 'DeltaBit', True) + return support.get_jwplayer_mediaUrl(data, 'DeltaBit', True) diff --git a/servers/directo.py b/servers/directo.py index f11ec674..e3ff370d 100644 --- a/servers/directo.py +++ b/servers/directo.py @@ -8,8 +8,8 @@ def test_video_exists(page_url): return True, "" # Returns an array of possible video url's from the page_url -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls=[{'type':scrapertools.get_filename_from_url(page_url).split('.')[-1], 'url':page_url}] + videoUrls=[{'type':scrapertools.get_filename_from_url(page_url).split('.')[-1], 'url':page_url}] - return video_urls + return videoUrls diff --git a/servers/doodstream.py b/servers/doodstream.py index 36f4ab5d..54b493f4 100644 --- a/servers/doodstream.py +++ b/servers/doodstream.py @@ -13,17 +13,17 @@ def test_video_exists(page_url): response = scraper.get(page_url) if response.status_code == 404 or 'File you are looking for is not found' in response.text: - return False, config.get_localized_string(70449) % 'DooD Stream' + return False, config.getLocalizedString(70449) % 'DooD Stream' else: data = response.text return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): global data logger.debug("URL", page_url) - video_urls = [] + videoUrls = [] host = 'https://dood.to' headers = {'User-Agent': httptools.get_user_agent(), 'Referer': page_url} @@ -31,10 +31,10 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= if match: url, token = match ret = scraper.get(host + url, headers=headers).text - video_urls.append({'type':'mp4', 'url':'{}{}{}{}|Referer={}'.format(randomize(ret), url, token, int(time.time() * 1000), host)}) + videoUrls.append({'type':'mp4', 'url':'{}{}{}{}|Referer={}'.format(randomize(ret), url, token, int(time.time() * 1000), host)}) - return video_urls + return videoUrls def randomize(data): t = string.ascii_letters + string.digits diff --git a/servers/dostream.py b/servers/dostream.py index d27b6d49..f902a0a3 100644 --- a/servers/dostream.py +++ b/servers/dostream.py @@ -12,18 +12,18 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url) if data.code == 404: - return False, config.get_localized_string(70449) % "Dostream" + return False, config.getLocalizedString(70449) % "Dostream" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url, headers={"Referer":page_url}).data patron = '"label":"([^"]+)".*?' patron += '"src":"(http.*?)".*?' - matches = scrapertools.find_multiple_matches(data, patron) + matches = scrapertools.findMultipleMatches(data, patron) for label, url in matches: - video_urls.append({'type':label, 'url':url}) - # video_urls.sort(key=lambda it: int(it[0].split("p ")[0])) - return video_urls + videoUrls.append({'type':label, 'url':url}) + # videoUrls.sort(key=lambda it: int(it[0].split("p ")[0])) + return videoUrls diff --git a/servers/downace.py b/servers/downace.py index ab41d855..c0fa3bb8 100644 --- a/servers/downace.py +++ b/servers/downace.py @@ -13,15 +13,15 @@ def test_video_exists(page_url): if "please+try+again+later." in data: return False, "[Downace] Error de downace, no se puede generar el enlace al video" if "File has been removed due to inactivity" in data: - return False, config.get_localized_string(70449) % "Downace" + return False, config.getLocalizedString(70449) % "Downace" return True, "" -def get_video_url(page_url, user="", password="", video_password=""): +def get_videoUrl(page_url, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data - video_urls = [] + videoUrls = [] videourl = scrapertools.find_single_match(data, 'controls preload.*?src="([^"]+)') - video_urls.append({'type':'mp4', 'url':videourl}) + videoUrls.append({'type':'mp4', 'url':videourl}) - return video_urls + return videoUrls diff --git a/servers/facebook.py b/servers/facebook.py index 7d83537e..8fcd3700 100755 --- a/servers/facebook.py +++ b/servers/facebook.py @@ -18,12 +18,12 @@ from core import scrapertools from platformcode import logger -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) page_url = page_url.replace("amp;", "") data = httptools.downloadpage(page_url).data logger.debug("data=" + data) - video_urls = [] + videoUrls = [] patron = "video_src.*?(http.*?)%22%2C%22video_timestamp" matches = re.compile(patron, re.DOTALL).findall(data) scrapertools.printMatches(matches) @@ -31,7 +31,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= videourl = match videourl = videourl.replace('%5C', '') videourl = urllib.unquote(videourl) - video_urls.append({'url':videourl}) - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) - return video_urls + videoUrls.append({'url':videourl}) + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) + return videoUrls diff --git a/servers/fastplay.py b/servers/fastplay.py index 40278689..e8466e95 100644 --- a/servers/fastplay.py +++ b/servers/fastplay.py @@ -11,33 +11,33 @@ def test_video_exists(page_url): data = httptools.downloadpage(page_url) if "Object not found" in data.data or "longer exists on our servers" in data.data: - return False, config.get_localized_string(70449) % "Fastplay" + return False, config.getLocalizedString(70449) % "Fastplay" if data.code == 500: return False, "[Fastplay] Error interno del servidor" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data if "p,a,c,k,e,d" in data: data = jsunpack.unpack(data).replace("\\", "") - video_urls = [] - videos = scrapertools.find_multiple_matches(data, 'file\s*:\s*"([^"]+)",label:"(.*?)"') + videoUrls = [] + videos = scrapertools.findMultipleMatches(data, 'file\s*:\s*"([^"]+)",label:"(.*?)"') # Detección de subtítulos subtitulo = scrapertools.find_single_match(data, 'tracks:\s*\[{file:"(.*?)"') if "http" not in subtitulo: subtitulo = "http://fastplay.cc" + subtitulo - for video_url, video_calidad in videos: - extension = scrapertools.get_filename_from_url(video_url)[-4:] + for videoUrl, video_calidad in videos: + extension = scrapertools.get_filename_from_url(videoUrl)[-4:] if extension not in [".vtt", ".srt"]: - video_urls.append({'type':extension, 'res':video_calidad, 'url':video_url, 'sub':subtitulo}) + videoUrls.append({'type':extension, 'res':video_calidad, 'url':videoUrl, 'sub':subtitulo}) try: - video_urls.sort(key=lambda it: int(it[0].split("p ", 1)[0].rsplit(" ")[1])) + videoUrls.sort(key=lambda it: int(it[0].split("p ", 1)[0].rsplit(" ")[1])) except: pass - for video_url in video_urls: - logger.debug(" %s - %s" % (video_url[0], video_url[1])) + for videoUrl in videoUrls: + logger.debug(" %s - %s" % (videoUrl[0], videoUrl[1])) - return video_urls + return videoUrls diff --git a/servers/fembed.py b/servers/fembed.py index 94d84a71..87eab856 100644 --- a/servers/fembed.py +++ b/servers/fembed.py @@ -13,7 +13,7 @@ def test_video_exists(page_url): page = httptools.downloadpage(page_url) data = page.data if "Sorry 404 not found" in data or "This video is unavailable" in data or "Sorry this video is unavailable:" in data: - return False, config.get_localized_string(70449) % "fembed" + return False, config.getLocalizedString(70449) % "fembed" page_url = page.url page_url = page_url.replace("/f/", "/v/") @@ -21,17 +21,17 @@ def test_video_exists(page_url): data = httptools.downloadpage(page_url, post={}).json logger.debug(data) if "Video not found or" in data or "We are encoding this video" in data: - return False, config.get_localized_string(70449) % "Fembed" + return False, config.getLocalizedString(70449) % "Fembed" return True, "" -def get_video_url(page_url, user="", password="", video_password=""): +def get_videoUrl(page_url, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] for file in data['data']: media_url = file['file'] label = file['label'] extension = file['type'] - video_urls.append({'type':extension, 'res':label, 'url':media_url}) - # video_urls.sort(key=lambda x: int(x[0].split()[1].replace('p',''))) - return video_urls + videoUrls.append({'type':extension, 'res':label, 'url':media_url}) + # videoUrls.sort(key=lambda x: int(x[0].split()[1].replace('p',''))) + return videoUrls diff --git a/servers/fex.py b/servers/fex.py index ca4a928b..f1930444 100644 --- a/servers/fex.py +++ b/servers/fex.py @@ -13,15 +13,15 @@ def test_video_exists(page_url): data = httptools.downloadpage(page_url, follow_redirects=False) if data.code == 404: - return False, config.get_localized_string(70449) % "Fex" + return False, config.getLocalizedString(70449) % "Fex" return True, "" -def get_video_url(page_url, user="", password="", video_password=""): +def get_videoUrl(page_url, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url, follow_redirects=False, only_headers=True) logger.debug(data.headers) url = data.headers['location'] - video_urls.append({'url':url}) - return video_urls + videoUrls.append({'url':url}) + return videoUrls diff --git a/servers/filefactory.py b/servers/filefactory.py index d7e04be2..15adeaab 100644 --- a/servers/filefactory.py +++ b/servers/filefactory.py @@ -9,7 +9,7 @@ def test_video_exists(page_url): return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] - return video_urls + videoUrls = [] + return videoUrls diff --git a/servers/filepup.py b/servers/filepup.py index 864a961a..3cc6d657 100644 --- a/servers/filepup.py +++ b/servers/filepup.py @@ -12,18 +12,18 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) response = httptools.downloadpage(page_url) if "File was deleted" in response.data or "is no longer available" in response.data: - return False, config.get_localized_string(70449) % "filepup" + return False, config.getLocalizedString(70449) % "filepup" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] page_url = page_url.replace("https","http") + "?wmode=transparent" data = httptools.downloadpage(page_url).data media_url = scrapertools.find_single_match(data, 'src: "([^"]+)"') qualities = scrapertools.find_single_match(data, 'qualities: (\[.*?\])') - qualities = scrapertools.find_multiple_matches(qualities, ' "([^"]+)') + qualities = scrapertools.findMultipleMatches(qualities, ' "([^"]+)') for calidad in qualities: media = media_url # title = "%s [filepup]" % (calidad) @@ -32,9 +32,9 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= media = med[0] + "-%s.mp4" % calidad + med[1] media += "|Referer=%s" %page_url media += "&User-Agent=" + httptools.get_user_agent() - video_urls.append({'type':'mp4', 'res':calidad, 'url':media}) - # video_urls.sort(key=lambda x: x[2]) - # for video_url in video_urls: - # video_url[2] = 0 - # logger.debug("%s - %s" % (video_url[0], video_url[1])) - return video_urls + videoUrls.append({'type':'mp4', 'res':calidad, 'url':media}) + # videoUrls.sort(key=lambda x: x[2]) + # for videoUrl in videoUrls: + # videoUrl[2] = 0 + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) + return videoUrls diff --git a/servers/filescdn.py b/servers/filescdn.py index a3e29dbc..54fdb9f4 100644 --- a/servers/filescdn.py +++ b/servers/filescdn.py @@ -10,17 +10,17 @@ def test_video_exists(page_url): data = httptools.downloadpage(page_url).data if "File was deleted" in data: - return False, config.get_localized_string(70449) % "FilesCDN" + return False, config.getLocalizedString(70449) % "FilesCDN" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url).data url = scrapertools.find_single_match(data, '(?i)link:\s*"(https://.*?filescdn\.com.*?mp4)"') url = url.replace(':443', '') - video_urls.append({'url':url}) + videoUrls.append({'url':url}) - return video_urls + return videoUrls diff --git a/servers/filesmonster.py b/servers/filesmonster.py index d4ea7d2a..1fdc0699 100644 --- a/servers/filesmonster.py +++ b/servers/filesmonster.py @@ -5,9 +5,9 @@ from core import scrapertools from platformcode import logger -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("( page_url='%s')") - video_urls = [] + videoUrls = [] itemlist = [] data1 = '' data2 = '' @@ -34,6 +34,6 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= alerta = filename + " " + alerta if "http" not in url: alerta = "[error de filesmonster premium]: " + url - video_urls.append([alerta, url]) + videoUrls.append([alerta, url]) - return video_urls + return videoUrls diff --git a/servers/flashx.py b/servers/flashx.py index a2d1dc19..b2b422a2 100644 --- a/servers/flashx.py +++ b/servers/flashx.py @@ -31,7 +31,7 @@ def test_video_exists(page_url): try: flashx_data = httptools.downloadpage(page_url).data except: - return False, config.get_localized_string(70296) % "FlashX" + return False, config.getLocalizedString(70296) % "FlashX" bloque = scrapertools.find_single_match(flashx_data, '(?s)Form method="POST" action(.*?)span') flashx_id = scrapertools.find_single_match(bloque, 'name="id" value="([^"]+)"') fname = scrapertools.find_single_match(bloque, 'name="fname" value="([^"]+)"') @@ -42,17 +42,17 @@ def test_video_exists(page_url): flashx_post = 'op=download1&usr_login=&id=%s&fname=%s&referer=&hash=%s&imhuman=%s' % ( flashx_id, urllib.quote(fname), flashx_hash_f, imhuman) if 'file was deleted' in flashx_data or 'File Not Found (Deleted or Abused)' in flashx_data: - return False, config.get_localized_string(70292) % "FlashX" + return False, config.getLocalizedString(70292) % "FlashX" elif 'Video is processing now' in flashx_data: - return False, config.get_localized_string(70293) % "FlashX" + return False, config.getLocalizedString(70293) % "FlashX" elif 'Too many views per minute' in flashx_data: - return False, config.get_localized_string(70300) % "FlashX" + return False, config.getLocalizedString(70300) % "FlashX" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) pfxfx = "" data = flashx_data @@ -67,7 +67,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= if len(js_fxfx) > 15: data_fxfx = httptools.downloadpage(js_fxfx).data mfxfx = scrapertools.find_single_match(data_fxfx, 'get.*?({.*?})').replace("'", "").replace(" ", "") - matches = scrapertools.find_multiple_matches(mfxfx, '(\w+):(\w+)') + matches = scrapertools.findMultipleMatches(mfxfx, '(\w+):(\w+)') for f, v in matches: pfxfx += f + "=" + v + "&" logger.debug("mfxfxfx1= %s" % js_fxfx) @@ -83,7 +83,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= ts = int(time.time()) flash_ts = scrapertools.find_single_match(flashx_hash_f, '-(\d{10})-') wait_time = int(flash_ts) - ts - platformtools.dialog_notification('Cargando flashx', 'Espera de %s segundos requerida' % wait_time) + platformtools.dialogNotification('Cargando flashx', 'Espera de %s segundos requerida' % wait_time) try: time.sleep(wait_time) @@ -102,20 +102,20 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= except: pass - matches = scrapertools.find_multiple_matches(data, "(eval\(function\(p,a,c,k.*?)\s+</script>") - video_urls = [] + matches = scrapertools.findMultipleMatches(data, "(eval\(function\(p,a,c,k.*?)\s+</script>") + videoUrls = [] for match in matches: try: match = jsunpack.unpack(match) match = match.replace("\\'", "'") - media_urls = scrapertools.find_multiple_matches(match, "{src:'([^']+)'.*?,label:'([^']+)'") + media_urls = scrapertools.findMultipleMatches(match, "{src:'([^']+)'.*?,label:'([^']+)'") subtitle = "" for media_url, label in media_urls: if media_url.endswith(".srt") and label == "Spanish": try: from core import filetools data = httptools.downloadpage(media_url) - subtitle = os.path.join(config.get_data_path(), 'sub_flashx.srt') + subtitle = os.path.join(config.getDataPath(), 'sub_flashx.srt') filetools.write(subtitle, data) except: import traceback @@ -123,12 +123,12 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= for media_url, label in media_urls: if not media_url.endswith("png") and not media_url.endswith(".srt"): - video_urls.append({'type':media_url.rsplit('.', 1)[1], 'url':media_url, 'sub':subtitle}) + videoUrls.append({'type':media_url.rsplit('.', 1)[1], 'url':media_url, 'sub':subtitle}) - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) except: pass - return video_urls + return videoUrls diff --git a/servers/fourshared.py b/servers/fourshared.py index c96ead9b..ae385eb8 100644 --- a/servers/fourshared.py +++ b/servers/fourshared.py @@ -7,10 +7,10 @@ from platformcode import logger # Returns an array of possible video url's from the page_url -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] if page_url.startswith("http://www.4shared"): # http://www.4shared.com/embed/392975628/ff297d3f @@ -22,13 +22,13 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= matches = re.compile(patron, re.DOTALL).findall(page_url) try: - video_urls.append({'url':matches[0]}) + videoUrls.append({'url':matches[0]}) except: pass else: - video_urls.append({'url':page_url}) + videoUrls.append({'url':page_url}) - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) - return video_urls + return videoUrls diff --git a/servers/gamovideo.py b/servers/gamovideo.py index 97948114..d413c7c2 100755 --- a/servers/gamovideo.py +++ b/servers/gamovideo.py @@ -34,18 +34,18 @@ def test_video_exists(page_url): global DATA DATA = data if "images/proced.png" in data: - return False, config.get_localized_string(70449) % "Gamovideo" + return False, config.getLocalizedString(70449) % "Gamovideo" if "File was deleted" in data or ("Not Found" in data and not "|mp4|" in data) or "File was locked by administrator" in data: - return False, config.get_localized_string(70449) % "Gamovideo" + return False, config.getLocalizedString(70449) % "Gamovideo" if "Video is processing now" in data: return False, "[Gamovideo] El video está procesándose en estos momentos. Inténtelo mas tarde." if "File is awaiting for moderation" in data: - return False, config.get_localized_string(70449) % "Gamovideo" + return False, config.getLocalizedString(70449) % "Gamovideo" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) data = DATA @@ -73,23 +73,23 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= data = re.sub(r'\n|\t|\s+', '', data) host = scrapertools.find_single_match(data, r'\[\{image:"(http://[^/]+/)') - mediaurl = scrapertools.find_single_match(data, r',\{file:"([^"]+)"') - if not mediaurl.startswith(host): - mediaurl = host + mediaurl + mediaUrl = scrapertools.find_single_match(data, r',\{file:"([^"]+)"') + if not mediaUrl.startswith(host): + mediaUrl = host + mediaUrl rtmp_url = scrapertools.find_single_match(data, 'file:"(rtmp[^"]+)"') playpath = scrapertools.find_single_match(rtmp_url, 'mp4:.*$') rtmp_url = rtmp_url.split(playpath)[ 0] + " playpath=" + playpath + " swfUrl=http://gamovideo.com/player61/jwplayer.flash.swf" - video_urls = [] - video_urls.append({'type':'rtmp', 'url':rtmp_url}) - video_urls.append({'type':scrapertools.get_filename_from_url(mediaurl).split('.')[-1], 'url':mediaurl}) + videoUrls = [] + videoUrls.append({'type':'rtmp', 'url':rtmp_url}) + videoUrls.append({'type':scrapertools.get_filename_from_url(mediaUrl).split('.')[-1], 'url':mediaUrl}) - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) - return video_urls + return videoUrls def get_gcookie(data, realcheck=False): packer = scrapertools.find_single_match(data, diff --git a/servers/gigasize.py b/servers/gigasize.py index 25b2c1a2..81f57319 100644 --- a/servers/gigasize.py +++ b/servers/gigasize.py @@ -12,8 +12,8 @@ def test_video_exists(page_url): return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] - return video_urls + return videoUrls diff --git a/servers/googlevideo.py b/servers/googlevideo.py index 7a13a2da..fccd5aed 100755 --- a/servers/googlevideo.py +++ b/servers/googlevideo.py @@ -6,9 +6,9 @@ from core import httptools from platformcode import logger -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] # Lo extrae a partir de flashvideodownloader.org if page_url.startswith("http://"): url = 'http://www.flashvideodownloader.org/download.php?u=' + page_url @@ -21,9 +21,9 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= newpatron = '</script>.*?<a href="(.*?)" title="Click to Download">' newmatches = re.compile(newpatron, re.DOTALL).findall(data) if len(newmatches) > 0: - video_urls.append({'url':newmatches[0]}) + videoUrls.append({'url':newmatches[0]}) - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) - return video_urls + return videoUrls diff --git a/servers/gounlimited.py b/servers/gounlimited.py index 0a54fa79..824d083f 100644 --- a/servers/gounlimited.py +++ b/servers/gounlimited.py @@ -15,13 +15,13 @@ def test_video_exists(page_url): global data data = httptools.downloadpage(page_url, use_requests=True, verify=False).data if data == "File was deleted": - return False, config.get_localized_string(70449) % "Go Unlimited" + return False, config.getLocalizedString(70449) % "Go Unlimited" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] global data data = re.sub(r'"|\n|\r|\t| |<br>|\s{2,}', "", data) # logger.debug('GOUN DATA= '+data) @@ -36,5 +36,5 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= for url in matches: if url.startswith('//'): url= 'http:' + url url += "|Referer=%s" %page_url - video_urls.append({'type':'mp4', 'url':url}) - return video_urls + videoUrls.append({'type':'mp4', 'url':url}) + return videoUrls diff --git a/servers/gvideo.py b/servers/gvideo.py index bce41623..72f4069c 100644 --- a/servers/gvideo.py +++ b/servers/gvideo.py @@ -27,7 +27,7 @@ def test_video_exists(page_url): page = response if "no+existe" in response.data or 'no existe.</p>' in response.data: - return False, config.get_localized_string(70449) % "gvideo" + return False, config.getLocalizedString(70449) % "gvideo" if "Se+ha+excedido+el" in response.data: return False, "[gvideo] Se ha excedido el número de reproducciones permitidas" if "No+tienes+permiso" in response.data: @@ -41,9 +41,9 @@ def test_video_exists(page_url): return True, "" -def get_video_url(page_url, user="", password="", video_password=""): +def get_videoUrl(page_url, user="", password="", video_password=""): logger.debug() - video_urls = [] + videoUrls = [] urls = [] streams =[] logger.debug('page_url: %s'%page_url) @@ -70,15 +70,15 @@ def get_video_url(page_url, user="", password="", video_password=""): data = urllib.unquote_plus(urllib.unquote_plus(data)) headers_string = httptools.get_url_headers(page_url, forced=True) - streams = scrapertools.find_multiple_matches(data, + streams = scrapertools.findMultipleMatches(data, 'itag=(\d+)&url=(.*?)(?:;.*?quality=.*?(?:,|&)|&quality=.*?(?:,|&))') itags = {'18': '360p', '22': '720p', '34': '360p', '35': '480p', '37': '1080p', '43': '360p', '59': '480p'} - for itag, video_url in streams: - if not video_url in urls: - video_url += headers_string - video_urls.append({'res':itags.get(itag, ''), 'type':video_url.split('.')[-1], 'url':video_url}) - urls.append(video_url) - # video_urls.sort(key=lambda video_urls: int(video_urls[0].replace("p", ""))) + for itag, videoUrl in streams: + if not videoUrl in urls: + videoUrl += headers_string + videoUrls.append({'res':itags.get(itag, ''), 'type':videoUrl.split('.')[-1], 'url':videoUrl}) + urls.append(videoUrl) + # videoUrls.sort(key=lambda videoUrls: int(videoUrls[0].replace("p", ""))) - return video_urls + return videoUrls diff --git a/servers/hdload.py b/servers/hdload.py index 72403e5f..d27f33cc 100644 --- a/servers/hdload.py +++ b/servers/hdload.py @@ -11,12 +11,12 @@ def test_video_exists(page_url): data = httptools.downloadpage(page_url, cookies=False).data if 'Not found id' in data: - return False, config.get_localized_string(70449) % "HDLoad" + return False, config.getLocalizedString(70449) % "HDLoad" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug() itemlist = [] diff --git a/servers/hdmario.py b/servers/hdmario.py index a5c1d559..32984cb5 100644 --- a/servers/hdmario.py +++ b/servers/hdmario.py @@ -16,37 +16,37 @@ def test_video_exists(page_url): logger.debug(page.url) if "the page you are looking for could not be found" in data: - return False, config.get_localized_string(70449) % "HDmario" + return False, config.getLocalizedString(70449) % "HDmario" return True, "" def login(): r = httptools.downloadpage(page.url.replace('/unauthorized', '/login'), - post={'email': config.get_setting('username', server='hdmario'), - 'password': config.get_setting('password', server='hdmario')}) + post={'email': config.getSetting('username', server='hdmario'), + 'password': config.getSetting('password', server='hdmario')}) if not r.success or 'Email o Password non validi' in r.data: - platformtools.dialog_ok('HDmario', 'Username/password non validi') + platformtools.dialogOk('HDmario', 'Username/password non validi') return False return True def registerOrLogin(page_url): - if config.get_setting('username', server='hdmario') and config.get_setting('password', server='hdmario'): + if config.getSetting('username', server='hdmario') and config.getSetting('password', server='hdmario'): if login(): return True - action = platformtools.dialog_yesno('HDmario', + action = platformtools.dialogYesNo('HDmario', 'Questo server necessita di un account, ne hai già uno oppure vuoi tentare una registrazione automatica?', yeslabel='Accedi', nolabel='Tenta registrazione', customlabel='Annulla') if action == 1: # accedi from specials import setting from core.item import Item - user_pre = config.get_setting('username', server='hdmario') - password_pre = config.get_setting('password', server='hdmario') + user_pre = config.getSetting('username', server='hdmario') + password_pre = config.getSetting('password', server='hdmario') setting.server_config(Item(config='hdmario')) - user_post = config.get_setting('username', server='hdmario') - password_post = config.get_setting('password', server='hdmario') + user_post = config.getSetting('username', server='hdmario') + password_post = config.getSetting('password', server='hdmario') if user_pre != user_post or password_pre != password_post: return registerOrLogin(page_url) @@ -61,7 +61,7 @@ def registerOrLogin(page_url): # captcha = httptools.downloadpage(baseUrl + '/captchaInfo').json logger.debug('email: ' + mailbox.address) logger.debug('pass: ' + randPsw) - reg = platformtools.dialog_register(baseUrl + '/register/', email=True, password=True, email_default=mailbox.address, password_default=randPsw) + reg = platformtools.dialogRegister(baseUrl + '/register/', email=True, password=True, email_default=mailbox.address, password_default=randPsw) if not reg: return False regPost = httptools.downloadpage(baseUrl + '/register/', @@ -73,27 +73,27 @@ def registerOrLogin(page_url): if '/register' in regPost.url: error = scrapertools.htmlclean(scrapertools.find_single_match(regPost.data, 'Impossibile proseguire.*?</div>')) error = scrapertools.unescape(scrapertools.re.sub('\n\s+', ' ', error)) - platformtools.dialog_ok('HDmario', error) + platformtools.dialogOk('HDmario', error) return False if reg['email'] == mailbox.address: if "L'indirizzo email è già stato utilizzato" in regPost.data: # httptools.downloadpage(baseUrl + '/forgotPassword', post={'email': reg['email']}) - platformtools.dialog_ok('HDmario', 'Indirizzo mail già utilizzato') + platformtools.dialogOk('HDmario', 'Indirizzo mail già utilizzato') return False mail = mailbox.waitForMail() if mail: checkUrl = scrapertools.find_single_match(mail.body, 'href="([^"]+)">Premi qui').replace(r'\/', '/') logger.debug('CheckURL: ' + checkUrl) httptools.downloadpage(checkUrl) - config.set_setting('username', mailbox.address, server='hdmario') - config.set_setting('password', randPsw, server='hdmario') - platformtools.dialog_ok('HDmario', + config.setSetting('username', mailbox.address, server='hdmario') + config.setSetting('password', randPsw, server='hdmario') + platformtools.dialogOk('HDmario', 'Registrato automaticamente con queste credenziali:\nemail:' + mailbox.address + '\npass: ' + randPsw) else: - platformtools.dialog_ok('HDmario', 'Impossibile registrarsi automaticamente') + platformtools.dialogOk('HDmario', 'Impossibile registrarsi automaticamente') return False else: - platformtools.dialog_ok('HDmario', 'Hai modificato la mail quindi KoD non sarà in grado di effettuare la verifica in autonomia, apri la casella ' + reg['email'] + platformtools.dialogOk('HDmario', 'Hai modificato la mail quindi KoD non sarà in grado di effettuare la verifica in autonomia, apri la casella ' + reg['email'] + ' e clicca sul link. Premi ok quando fatto') logger.debug('Registrazione completata') else: @@ -102,7 +102,7 @@ def registerOrLogin(page_url): return True -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): global page, data page_url = page_url.replace('?', '') logger.debug("url=" + page_url) @@ -125,7 +125,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= if '/unauthorized' in page.url or '/not-active' in page.url: httptools.set_cookies({'domain': 'hdmario.live'}, True) # clear cookies if not registerOrLogin(page_url): - platformtools.play_canceled = True + platformtools.playCanceled = True return [] page = httptools.downloadpage(page_url) data = page.data @@ -140,6 +140,6 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= data = httptools.downloadpage(baseUrl + '/pl/' + page_url.split('/')[-1].replace('?', ''), headers=[['X-Secure-Proof', secureProof]]).data filetools.write(xbmc.translatePath('special://temp/hdmario.m3u8'), data, 'w') - video_urls = [{'type':'hls', 'url':baseUrl + '/pl/' + page_url.split('/')[-1].replace('?', '')}] + videoUrls = [{'type':'hls', 'url':baseUrl + '/pl/' + page_url.split('/')[-1].replace('?', '')}] - return video_urls + return videoUrls diff --git a/servers/highload.py b/servers/highload.py index 5e738f52..d32a97f4 100644 --- a/servers/highload.py +++ b/servers/highload.py @@ -15,17 +15,17 @@ def test_video_exists(page_url): global data data = httptools.downloadpage(page_url) if data.code == 404 or "We can't find the video" in data.data or 'sorry' in data.data: - return False, config.get_localized_string(70449) % "HighLoad" + return False, config.getLocalizedString(70449) % "HighLoad" data = data.data return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.info("url=" + page_url) global data media_url = '' - video_urls = [] + videoUrls = [] host = 'https://' + urlparse(page_url).netloc @@ -41,8 +41,8 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= media_url = base64.b64decode(match.replace(r1, '').replace(r2, '')).decode('utf-8') if media_url: - video_urls.append([media_url.split('.')[-1] +' [HighLoad]', media_url]) - return video_urls + videoUrls.append([media_url.split('.')[-1] +' [HighLoad]', media_url]) + return videoUrls def unhunt(source): diff --git a/servers/hugefiles.py b/servers/hugefiles.py index ba38d135..400623b6 100755 --- a/servers/hugefiles.py +++ b/servers/hugefiles.py @@ -19,7 +19,7 @@ from lib import jsunpack from platformcode import logger -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data post = {} @@ -31,7 +31,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= # Get link sPattern = '''<div id="player_code">.*?<script type='text/javascript'>(eval.+?)</script>''' r = re.findall(sPattern, data, re.DOTALL | re.I) - mediaurl = "" + mediaUrl = "" if r: sUnpacked = jsunpack.unpack(r[0]) sUnpacked = sUnpacked.replace("\\'", "") @@ -39,12 +39,12 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= if not r: r = re.findall('"src"value="(.+?)"/><embed', sUnpacked) - mediaurl = r[0] + mediaUrl = r[0] - video_urls = [] - video_urls.append({'type':scrapertools.get_filename_from_url(mediaurl).split('.')[-1], 'url':mediaurl}) + videoUrls = [] + videoUrls.append({'type':scrapertools.get_filename_from_url(mediaUrl).split('.')[-1], 'url':mediaUrl}) - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) - return video_urls + return videoUrls diff --git a/servers/hxfile.py b/servers/hxfile.py index 487463c8..5dffcda5 100644 --- a/servers/hxfile.py +++ b/servers/hxfile.py @@ -10,16 +10,16 @@ def test_video_exists(page_url): global data data = httptools.downloadpage(page_url).data if "Can't create video code" in data: - return False, config.get_localized_string(70292) % 'HxFile' + return False, config.getLocalizedString(70292) % 'HxFile' return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) global data - video_urls = [] + videoUrls = [] packed = scrapertools.find_single_match(data, r'(eval\s?\(function\(p,a,c,k,e,d\).*?\n)') data = jsunpack.unpack(packed) - video_urls.extend(support.get_jwplayer_mediaurl(data, 'HxFile')) + videoUrls.extend(support.get_jwplayer_mediaUrl(data, 'HxFile')) - return video_urls + return videoUrls diff --git a/servers/idtbox.py b/servers/idtbox.py index 08be1bd1..2464705b 100644 --- a/servers/idtbox.py +++ b/servers/idtbox.py @@ -15,16 +15,16 @@ def test_video_exists(page_url): data = httptools.downloadpage(page_url) if not data.success or "Not Found" in data.data or "File was deleted" in data.data or "is no longer available" in data.data: - return False, config.get_localized_string(70449) % "Idtbox" + return False, config.getLocalizedString(70449) % "Idtbox" data = data.data return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) logger.error(data) - video_urls = [] + videoUrls = [] patron = 'source src="([^"]+)" type="([^"]+)" res=(\d+)' matches = re.compile(patron, re.DOTALL).findall(data) @@ -34,6 +34,6 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= ext = ext.split("/")[1] except: ext = ".mp4" - video_urls.append({'type':ext, 'res':res, 'url':url}) + videoUrls.append({'type':ext, 'res':res, 'url':url}) - return video_urls + return videoUrls diff --git a/servers/jawcloud.py b/servers/jawcloud.py index 49d496ca..3e1f6d70 100644 --- a/servers/jawcloud.py +++ b/servers/jawcloud.py @@ -9,15 +9,15 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data if "The file you were looking for could not be found" in data: - return False, config.get_localized_string(70449) % "jawcloud" + return False, config.getLocalizedString(70449) % "jawcloud" return True, "" -def get_video_url(page_url, user="", password="", video_password=""): +def get_videoUrl(page_url, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data - video_urls = [] + videoUrls = [] videourl = scrapertools.find_single_match(data, 'source src="([^"]+)') - video_urls.append({'type':'mp4', 'url':videourl}) + videoUrls.append({'type':'mp4', 'url':videourl}) - return video_urls + return videoUrls diff --git a/servers/jetload.py b/servers/jetload.py index b77b454b..95cbd8f9 100644 --- a/servers/jetload.py +++ b/servers/jetload.py @@ -7,7 +7,7 @@ from core import scrapertools from platformcode import config from platformcode import logger -video_urls = [] +videoUrls = [] def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) @@ -16,18 +16,18 @@ def test_video_exists(page_url): global data data = response.data if not response.success or "Not Found" in data or "File was deleted" in data or "is no longer available" in data: - return False, config.get_localized_string(70449) % "jetload" + return False, config.getLocalizedString(70449) % "jetload" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] media_url = scrapertools.find_single_match(data, '<video src="([^"]+)"') if media_url: ext = media_url.split('.')[-1] if ext == 'm3u8': media_url = '' - video_urls.append({'type':ext, 'url':media_url}) + videoUrls.append({'type':ext, 'url':media_url}) - return video_urls + return videoUrls diff --git a/servers/mailru.py b/servers/mailru.py index 9b10cc3a..e65f873d 100644 --- a/servers/mailru.py +++ b/servers/mailru.py @@ -16,10 +16,10 @@ def test_video_exists(page_url): return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % (page_url)) - video_urls = [] + videoUrls = [] # Carga la página para coger las cookies data = httptools.downloadpage(page_url).data @@ -38,13 +38,13 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= if not media_url.startswith("http"): media_url = "http:" + media_url quality = " %s" % videos['key'] - video_urls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'res':quality, 'url',media_url}) + videoUrls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'res':quality, 'url',media_url}) # try: - # video_urls.sort(key=lambda video_urls: int(video_urls[0].rsplit(" ", 2)[1][:-1])) + # videoUrls.sort(key=lambda videoUrls: int(videoUrls[0].rsplit(" ", 2)[1][:-1])) # except: # pass - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) - return video_urls + return videoUrls diff --git a/servers/maxstream.py b/servers/maxstream.py index b6b6fbd4..fbd65d64 100644 --- a/servers/maxstream.py +++ b/servers/maxstream.py @@ -19,15 +19,15 @@ def test_video_exists(page_url): data = httptools.downloadpage(page_url).data if "file was deleted" in data: - return False, config.get_localized_string(70449) % "MaxStream" + return False, config.getLocalizedString(70449) % "MaxStream" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] url_video = '' lastIndexStart = data.rfind('<script>') @@ -49,16 +49,16 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= if url_video: import random, string parse = urlparse.urlparse(url_video) - video_urls.append({'type':'mp4', 'url':url_video}) + videoUrls.append({'type':'mp4', 'url':url_video}) try: r1 = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(19)) r2 = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(19)) r3 = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(19)) - video_urls.append({'type':'m3u8', 'url':'{}://{}/hls/{},{},{},{},.urlset/master.m3u8'.format(parse.scheme, parse.netloc, parse.path.split('/')[1], r1, r2, r3)}) - # video_urls.append(['m3u8 [MaxStream]', '{}://{}/hls/{},wpsc2hllm5g5fkjvslq,4jcc2hllm5gzykkkgha,fmca2hllm5jtpb7cj5q,.urlset/master.m3u8'.format(parse.scheme, parse.netloc, parse.path.split('/')[1])]) + videoUrls.append({'type':'m3u8', 'url':'{}://{}/hls/{},{},{},{},.urlset/master.m3u8'.format(parse.scheme, parse.netloc, parse.path.split('/')[1], r1, r2, r3)}) + # videoUrls.append(['m3u8 [MaxStream]', '{}://{}/hls/{},wpsc2hllm5g5fkjvslq,4jcc2hllm5gzykkkgha,fmca2hllm5jtpb7cj5q,.urlset/master.m3u8'.format(parse.scheme, parse.netloc, parse.path.split('/')[1])]) except: logger.debug('Something wrong: Impossible get HLS stream') - return video_urls + return videoUrls diff --git a/servers/mediafire.py b/servers/mediafire.py index 16023d29..eee012cb 100755 --- a/servers/mediafire.py +++ b/servers/mediafire.py @@ -9,23 +9,23 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data if "Invalid or Deleted File" in data or "Well, looks like we" in data: - return False, config.get_localized_string(70449) % "Mediafire" + return False, config.getLocalizedString(70449) % "Mediafire" if "File Removed for Violation" in data: return False, "[Mediafire] Archivo eliminado por infracción" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url).data patron = "DownloadButtonAd-startDownload gbtnSecondary.*?href='([^']+)'" - matches = scrapertools.find_multiple_matches(data, patron) + matches = scrapertools.findMultipleMatches(data, patron) if len(matches) == 0: patron = 'Download file.*?href="([^"]+)"' - matches = scrapertools.find_multiple_matches(data, patron) + matches = scrapertools.findMultipleMatches(data, patron) if len(matches) > 0: - video_urls.append({'type':matches[0].split('.')[-1], 'url':matches[0]}) - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) - return video_urls + videoUrls.append({'type':matches[0].split('.')[-1], 'url':matches[0]}) + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) + return videoUrls diff --git a/servers/mega.py b/servers/mega.py index ca85805c..5db146e8 100755 --- a/servers/mega.py +++ b/servers/mega.py @@ -66,7 +66,7 @@ def test_video_exists(page_url): #Comprobación limite cuota restante from lib.megaserver import Client global c - c = Client(url=page_url, is_playing_fnc=platformtools.is_playing) + c = Client(url=page_url, isPlaying_fnc=platformtools.isPlaying) global files files = c.get_files() if files == 509: @@ -77,19 +77,19 @@ def test_video_exists(page_url): return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): page_url = page_url.replace('/embed#', '/#') logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] # If there are more than 5 files create a playlist with all # This function (the playlist) does not go, you have to browse megaserver / handler.py although the call is in client.py if len(files) > 5: media_url = c.get_play_list() - video_urls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url}) + videoUrls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url}) else: for f in files: media_url = f["url"] - video_urls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url}) + videoUrls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url}) - return video_urls + return videoUrls diff --git a/servers/mixdrop.py b/servers/mixdrop.py index b5fcfd3e..b55dcf2b 100644 --- a/servers/mixdrop.py +++ b/servers/mixdrop.py @@ -20,13 +20,13 @@ def test_video_exists(page_url): data = httptools.downloadpage(url).data if "<h2>WE ARE SORRY</h2>" in data or '<title>404 Not Found' in data: - return False, config.get_localized_string(70449) % "MixDrop" + return False, config.getLocalizedString(70449) % "MixDrop" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] ext = 'mp4' global data @@ -34,7 +34,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= unpacked = jsunpack.unpack(packed) # mixdrop like to change var name very often, hoping that will catch every - list_vars = scrapertools.find_multiple_matches(unpacked, r'MDCore\.\w+\s*=\s*"([^"]+)"') + list_vars = scrapertools.findMultipleMatches(unpacked, r'MDCore\.\w+\s*=\s*"([^"]+)"') for var in list_vars: if '.mp4' in var: media_url = var @@ -43,6 +43,6 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= media_url = '' if not media_url.startswith('http'): media_url = 'http:' + media_url - video_urls.append({'type':ext, 'url': media_url}) + videoUrls.append({'type':ext, 'url': media_url}) - return video_urls + return videoUrls diff --git a/servers/mp4upload.py b/servers/mp4upload.py index 4817586c..a55e6e05 100644 --- a/servers/mp4upload.py +++ b/servers/mp4upload.py @@ -11,10 +11,10 @@ from platformcode import logger def test_video_exists(page_url): data = httptools.downloadpage(page_url).data if data == "File was deleted" or data == '': - return False, config.get_localized_string(70449) % "mp4upload" + return False, config.getLocalizedString(70449) % "mp4upload" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) data = re.sub(r"\n|\r|\t|\s{2}", "", httptools.downloadpage(page_url).data) match = scrapertools.find_single_match(data, "") @@ -24,8 +24,8 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= if not media_url: media_url = scrapertools.find_single_match(data, '"file":"([^"]+)') logger.debug("media_url=" + media_url) - video_urls = list() - video_urls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url}) - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) - return video_urls + videoUrls = list() + videoUrls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url}) + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) + return videoUrls diff --git a/servers/mydaddy.py b/servers/mydaddy.py index b898b9c6..9f33ad79 100644 --- a/servers/mydaddy.py +++ b/servers/mydaddy.py @@ -16,19 +16,19 @@ def test_video_exists(page_url): "Not Found" in response.data \ or "File was deleted" in response.data \ or "is no longer available" in response.data: - return False, config.get_localized_string(70449) % "mydaddy" + return False, config.getLocalizedString(70449) % "mydaddy" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug() - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url).data data = scrapertools.find_single_match(data, 'var srca = \[(.*?)\]') - matches = scrapertools.find_multiple_matches(data, 'file: "([^"]+)", label: "([^"]+)"') + matches = scrapertools.findMultipleMatches(data, 'file: "([^"]+)", label: "([^"]+)"') for url,quality in matches: if not url.startswith("http"): url = "http:%s" % url if not "Default" in quality: - video_urls.append({'res':quality, 'url':url}) - return video_urls \ No newline at end of file + videoUrls.append({'res':quality, 'url':url}) + return videoUrls \ No newline at end of file diff --git a/servers/mystream.py b/servers/mystream.py index d81dd0d4..7e3c9bd3 100644 --- a/servers/mystream.py +++ b/servers/mystream.py @@ -15,18 +15,18 @@ def test_video_exists(page_url): global page_data page_data = data.data if data.code == 404: - return False, config.get_localized_string(70449) % "mystream" + return False, config.getLocalizedString(70449) % "mystream" if "video is no longer available" in data.data or "<title>Video not found" in data.data or "We are unable to find the video" in data.data: - return False, config.get_localized_string(70449) % "mystream" + return False, config.getLocalizedString(70449) % "mystream" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] global page_data - video_url = scrapertools.find_single_match(decode(page_data), r"'src',\s*'([^']+)") - video_urls.append({'type':video_url.split('.')[-1], 'url':video_url}) - return video_urls + videoUrl = scrapertools.find_single_match(decode(page_data), r"'src',\s*'([^']+)") + videoUrls.append({'type':videoUrl.split('.')[-1], 'url':videoUrl}) + return videoUrls def decode(data): # adapted from ResolveURL code - https://github.com/jsergio123/script.module.resolveurl diff --git a/servers/myupload.py b/servers/myupload.py index d0d264ad..b4388a48 100644 --- a/servers/myupload.py +++ b/servers/myupload.py @@ -18,16 +18,16 @@ def test_video_exists(page_url): "Not Found" in response.data \ or "File was deleted" in response.data \ or "is no longer available" in response.data: - return False, config.get_localized_string(70449) % "myupload" + return False, config.getLocalizedString(70449) % "myupload" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug() - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url).data - matches = scrapertools.find_multiple_matches(data, 'tracker: "([^"]+)"') + matches = scrapertools.findMultipleMatches(data, 'tracker: "([^"]+)"') for scrapedurl in matches: url = base64.b64decode(scrapedurl) - video_urls.append({'url':url}) - return video_urls \ No newline at end of file + videoUrls.append({'url':url}) + return videoUrls \ No newline at end of file diff --git a/servers/netutv.py b/servers/netutv.py index 673a4665..2ae9a58d 100755 --- a/servers/netutv.py +++ b/servers/netutv.py @@ -32,13 +32,13 @@ def test_video_exists(page_url): page_url = page_url.replace("/watch_video.php?v=", "/player/embed_player.php?vid=") data = httptools.downloadpage(page_url).data if "var userid = '';" in data.lower(): - return False, config.get_localized_string(70449) % "netutv" + return False, config.getLocalizedString(70449) % "netutv" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] if "hash=" in page_url: data = urllib.unquote(httptools.downloadpage(page_url).data) @@ -73,7 +73,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= data = httptools.downloadpage('http://hqq.watch'+url, headers=headers).data # ~ logger.debug(data) - codigo_js = scrapertools.find_multiple_matches(data, '<script>document.write\(unescape\("([^"]+)') + codigo_js = scrapertools.findMultipleMatches(data, '<script>document.write\(unescape\("([^"]+)') # ~ logger.debug(codigo_js) js_aux = urllib.unquote(codigo_js[0]) @@ -90,7 +90,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= data = jswise(js_wise).replace("\\", "") # ~ logger.debug(data) - variables = scrapertools.find_multiple_matches(data, 'var ([a-zA-Z0-9]+) = "([^"]+)";') + variables = scrapertools.findMultipleMatches(data, 'var ([a-zA-Z0-9]+) = "([^"]+)";') # ~ logger.debug(variables) for nombre, valor in variables: @@ -101,9 +101,9 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= link_m3u8 = 'http://hqq.watch/player/get_md5.php?ver=2&at=%s&adb=0&b=1&link_1=%s&server_2=%s&vid=%s&ext=%s' % (at, link_1, server_2, vid, ext) # ~ logger.debug(link_m3u8) - video_urls.append({'type':'m3u8', 'url':link_m3u8}) + videoUrls.append({'type':'m3u8', 'url':link_m3u8}) - return video_urls + return videoUrls ## -------------------------------------------------------------------------------- diff --git a/servers/ninjastream.py b/servers/ninjastream.py index dd9a8419..055e506a 100644 --- a/servers/ninjastream.py +++ b/servers/ninjastream.py @@ -9,16 +9,16 @@ def test_video_exists(page_url): response = httptools.downloadpage(page_url) if response.code == 404: - return False, config.get_localized_string(70449) % 'NinjaStream' + return False, config.getLocalizedString(70449) % 'NinjaStream' else: data = response.data return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): global data logger.debug("URL", page_url) - video_urls = [] + videoUrls = [] # logger.dbg() headers = {'User-Agent': httptools.get_user_agent(), @@ -34,9 +34,9 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= # logger.dbg() url = data.get('result',{}).get('playlist') - video_urls.append({'type':url.split('.')[-1], 'url':url + '|Referer:' + page_url}) + videoUrls.append({'type':url.split('.')[-1], 'url':url + '|Referer:' + page_url}) - return video_urls + return videoUrls # def decode(host): # Host = '' diff --git a/servers/nowvideo.py b/servers/nowvideo.py index c965371c..1bce6e19 100644 --- a/servers/nowvideo.py +++ b/servers/nowvideo.py @@ -15,21 +15,21 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data if "Not Found" in data or "File was deleted" in data or "The file is being converted" in data or "Please try again later" in data: - return False, config.get_localized_string(70293) % "NowVideo" + return False, config.getLocalizedString(70293) % "NowVideo" elif "no longer exists" in data: - return False, config.get_localized_string(70292) % "NowVideo" + return False, config.getLocalizedString(70292) % "NowVideo" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): host = 'http://nowvideo.club' logger.debug("(nowvideo page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url).data page_url_post = scrapertools.find_single_match(data, '<Form id="[^"]+" method="POST" action="([^"]+)">') page_url_post = page_url_post.replace('..', '') imhuman = '&imhuman=' + scrapertools.find_single_match(data, 'name="imhuman" value="([^"]+)"').replace(" ", "+") - post = urllib.urlencode({k: v for k, v in scrapertools.find_multiple_matches(data, 'name="([^"]+)" value="([^"]*)"')}) + imhuman + post = urllib.urlencode({k: v for k, v in scrapertools.findMultipleMatches(data, 'name="([^"]+)" value="([^"]*)"')}) + imhuman data = httptools.downloadpage(host + page_url_post, post=post).data logger.debug("nowvideo data page_url2 ='%s'" % data) @@ -42,17 +42,17 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= block = scrapertools.find_single_match(data, 'sources:\s*\[[^\]]+\]') if block: data = block - media_urls = scrapertools.find_multiple_matches(data, '(http.*?\.mp4)') + media_urls = scrapertools.findMultipleMatches(data, '(http.*?\.mp4)') _headers = urllib.urlencode(dict(headers)) for media_url in media_urls: #logger.debug("nowvideo data page_url2 ='%s'" % media_url) - video_urls.append([" mp4 [nowvideo] ", media_url + '|' + _headers]) + videoUrls.append([" mp4 [nowvideo] ", media_url + '|' + _headers]) - for video_url in media_urls: - logger.debug("[nowvideo.py] %s - %s" % (video_url[0], video_url[1])) + for videoUrl in media_urls: + logger.debug("[nowvideo.py] %s - %s" % (videoUrl[0], videoUrl[1])) - return video_urls + return videoUrls def find_videos(data): diff --git a/servers/okru.py b/servers/okru.py index cd31741b..764cf9a3 100644 --- a/servers/okru.py +++ b/servers/okru.py @@ -12,22 +12,22 @@ def test_video_exists(page_url): data = httptools.downloadpage(page_url).data if "copyrightsRestricted" in data or "COPYRIGHTS_RESTRICTED" in data: - return False, config.get_localized_string(70449) % "OKru" + return False, config.getLocalizedString(70449) % "OKru" elif "notFound" in data: - return False, config.get_localized_string(70449) % "OKru" + return False, config.getLocalizedString(70449) % "OKru" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url).data data = scrapertools.decodeHtmlentities(data).replace('\\', '') # URL del vídeo for type, url in re.findall(r'\{"name":"([^"]+)","url":"([^"]+)"', data, re.DOTALL): url = url.replace("%3B", ";").replace("u0026", "&") - video_urls.append({'type':type, 'url':url}) + videoUrls.append({'type':type, 'url':url}) - return video_urls + return videoUrls diff --git a/servers/okstream.py b/servers/okstream.py index d5f69a5d..3cc5ba3a 100644 --- a/servers/okstream.py +++ b/servers/okstream.py @@ -9,20 +9,20 @@ def test_video_exists(page_url): response = httptools.downloadpage(page_url) if response.code == 404 or 'File has been removed or does not exist!' in response.data: - return False, config.get_localized_string(70449) % 'OkStream' + return False, config.getLocalizedString(70449) % 'OkStream' else: data = response.data return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): global data logger.debug("URL", page_url) - video_urls = [] + videoUrls = [] keys = support.match(data, patron=r'>var keys="([^"]+)"').match protection = support.match(data, patron=r'>var protection="([^"]+)"').match url = httptools.downloadpage("https://www.okstream.cc/request/", post='&morocco={}&mycountry={}'.format(keys, protection), headers={'Referer':page_url}).data url = url.strip() - video_urls.append({'type':url.split('.')[-1], 'url':url}) + videoUrls.append({'type':url.split('.')[-1], 'url':url}) - return video_urls \ No newline at end of file + return videoUrls \ No newline at end of file diff --git a/servers/onefichier.py b/servers/onefichier.py index 58e78806..9a577914 100644 --- a/servers/onefichier.py +++ b/servers/onefichier.py @@ -20,11 +20,11 @@ def test_video_exists(page_url): return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - if config.get_setting("premium", server="onefichier"): - user = config.get_setting("user", server="onefichier") - password = config.get_setting("password", server="onefichier") + if config.getSetting("premium", server="onefichier"): + user = config.getSetting("user", server="onefichier") + password = config.getSetting("password", server="onefichier") url = "https://1fichier.com/login.pl" logger.debug("url=" + url) post_parameters = {"mail": user, "pass": password, "lt": "on", "purge": "on", "valider": "Send"} @@ -34,7 +34,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= data = httptools.downloadpage(url, post=post).data # logger.debug("data="+data) - cookies = config.get_cookie_data() + cookies = config.getCookieData() logger.debug("cookies=" + cookies) # 1fichier.com TRUE / FALSE 1443553315 SID imC3q8MQ7cARw5tkXeWvKyrH493rR=1yvrjhxDAA0T0iEmqRfNF9GXwjrwPHssAQ @@ -56,11 +56,11 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= location = page_url + "|Cookie=" + cookie logger.debug("location=" + location) - video_urls = [] - # video_urls.append([filename[-4:] + " (Premium) [1fichier]", location]) - video_urls.append({'type':filename.split('.')[-1], 'url':location}) + videoUrls = [] + # videoUrls.append([filename[-4:] + " (Premium) [1fichier]", location]) + videoUrls.append({'type':filename.split('.')[-1], 'url':location}) - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) - return video_urls + return videoUrls diff --git a/servers/onlystream.py b/servers/onlystream.py index 02adebfc..4d300e1f 100644 --- a/servers/onlystream.py +++ b/servers/onlystream.py @@ -11,15 +11,15 @@ def test_video_exists(page_url): global data data = httptools.downloadpage(page_url).data if 'File you are looking for is not found.' in data: - return False, config.get_localized_string(70449) % "Onlystream" + return False, config.getLocalizedString(70449) % "Onlystream" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) global data # logger.debug(data) block = scrapertools.find_single_match(data, 'player.updateSrc\(([^\)]+)') - video_urls = support.get_jwplayer_mediaurl(block, 'Onlystream', dataIsBlock=True) - return video_urls + videoUrls = support.get_jwplayer_mediaUrl(block, 'Onlystream', dataIsBlock=True) + return videoUrls diff --git a/servers/paramount_server.py b/servers/paramount_server.py index 668aa4d9..ac70a7f8 100644 --- a/servers/paramount_server.py +++ b/servers/paramount_server.py @@ -10,16 +10,16 @@ def test_video_exists(page_url): response = httptools.downloadpage(page_url) if response.code == 404: - return False, config.get_localized_string(70449) % 'Paramount' + return False, config.getLocalizedString(70449) % 'Paramount' else: data = response.data return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) qualities = [] - video_urls = [] + videoUrls = [] mgid = support.match(data, patron=r'uri":"([^"]+)"').match url = 'https://media.mtvnservices.com/pmt/e1/access/index.html?uri=' + mgid + '&configtype=edge&ref=' + page_url ID, rootUrl = support.match(url, patron=[r'"id":"([^"]+)",',r'brightcove_mediagenRootURL":"([^"]+)"']).matches @@ -29,6 +29,6 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= quality = quality.split('x')[0] if quality not in qualities: qualities.append(quality) - video_urls.append({'type':'m3u8', 'res':quality, 'url':url}) - # video_urls.sort(key=lambda url: int(support.match(url[0], patron=r'(\d+)p').match)) - return video_urls + videoUrls.append({'type':'m3u8', 'res':quality, 'url':url}) + # videoUrls.sort(key=lambda url: int(support.match(url[0], patron=r'(\d+)p').match)) + return videoUrls diff --git a/servers/playtube.py b/servers/playtube.py index 4cb4d479..5704a848 100644 --- a/servers/playtube.py +++ b/servers/playtube.py @@ -13,15 +13,15 @@ def test_video_exists(page_url): global data data = httptools.downloadpage(page_url) if data.code == 404 or "File is no longer available" in data.data: - return False, config.get_localized_string(70449) % 'PlayTube' + return False, config.getLocalizedString(70449) % 'PlayTube' return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.info("url=" + page_url) - video_urls = [] + videoUrls = [] pack = scrapertools.find_single_match(data.data, 'p,a,c,k,e,d.*?</script>') unpacked = jsunpack.unpack(pack) url = scrapertools.find_single_match(unpacked, 'file:"([^"]+)') + "|Referer=%s" % page_url - video_urls.append({'type':'m3u8', 'url':url}) - return video_urls \ No newline at end of file + videoUrls.append({'type':'m3u8', 'url':url}) + return videoUrls \ No newline at end of file diff --git a/servers/rapidgator.py b/servers/rapidgator.py index fdc262e3..746ed9f3 100644 --- a/servers/rapidgator.py +++ b/servers/rapidgator.py @@ -7,7 +7,7 @@ def test_video_exists(page_url): return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] - return video_urls + videoUrls = [] + return videoUrls diff --git a/servers/rcdnme.py b/servers/rcdnme.py index 15205bf4..b642ced4 100644 --- a/servers/rcdnme.py +++ b/servers/rcdnme.py @@ -14,36 +14,36 @@ def test_video_exists(page_url): data = httptools.downloadpage(page_url) if "Object not found" in data.data or "longer exists on our servers" in data.data: - return False, config.get_localized_string(70449) % "Rcdnme" + return False, config.getLocalizedString(70449) % "Rcdnme" if data.code == 500: return False, "[Rcdnme] Error interno del servidor" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data if "p,a,c,k,e,d" in data: data = jsunpack.unpack(data).replace("\\", "") - video_urls = [] - videos = scrapertools.find_multiple_matches(data, 'file":"([^"]+)","label":"(.*?)"') + videoUrls = [] + videos = scrapertools.findMultipleMatches(data, 'file":"([^"]+)","label":"(.*?)"') subtitulo = scrapertools.find_single_match(data, 'tracks:\s*\[{"file":"(.*?)"') if "http" not in subtitulo and subtitulo != "": subtitulo = "https://rcdn.me" + subtitulo - for video_url, video_calidad in videos: - extension = scrapertools.get_filename_from_url(video_url)[-4:] + for videoUrl, video_calidad in videos: + extension = scrapertools.get_filename_from_url(videoUrl)[-4:] - video_url = video_url.replace("\\", "") + videoUrl = videoUrl.replace("\\", "") if extension not in [".vtt", ".srt"]: - video_urls.append({'type':extension, 'res':video_calidad, 'url':video_url, 'sub':subtitulo}) + videoUrls.append({'type':extension, 'res':video_calidad, 'url':videoUrl, 'sub':subtitulo}) # try: - # video_urls.sort(key=lambda it: int(it[0].split("p ", 1)[0].rsplit(" ")[1])) + # videoUrls.sort(key=lambda it: int(it[0].split("p ", 1)[0].rsplit(" ")[1])) # except: # pass - # for video_url in video_urls: - # logger.debug(" %s - %s" % (video_url[0], video_url[1])) + # for videoUrl in videoUrls: + # logger.debug(" %s - %s" % (videoUrl[0], videoUrl[1])) - return video_urls + return videoUrls diff --git a/servers/rutube.py b/servers/rutube.py index 0d78fec4..52b58a1d 100644 --- a/servers/rutube.py +++ b/servers/rutube.py @@ -34,15 +34,15 @@ def test_video_exists(page_url): data = get_source(page_url) if "File was deleted" in data or "File Not Found" in data: - return False, config.get_localized_string(70449) % "Rutube" + return False, config.getLocalizedString(70449) % "Rutube" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] referer = '' id = '' if "|" in page_url: @@ -55,5 +55,5 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= new_link = base_link + '/?format=json&sqr4374_compat=1&no_404=true&%s&%s' % (referer, id) data = httptools.downloadpage(new_link).data json_data = jsontools.load(data) - video_urls.append({'type':'m3u8', 'url':json_data['video_balancer']['m3u8']}) - return video_urls + videoUrls.append({'type':'m3u8', 'url':json_data['video_balancer']['m3u8']}) + return videoUrls diff --git a/servers/samaup.py b/servers/samaup.py index 48379eec..97825e67 100644 --- a/servers/samaup.py +++ b/servers/samaup.py @@ -14,13 +14,13 @@ def test_video_exists(page_url): global data data = httptools.downloadpage(page_url).data if "Not Found" in data or "File was deleted" in data: - return False, config.get_localized_string(70449) % "Samaup" + return False, config.getLocalizedString(70449) % "Samaup" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] ext = 'mp4' packed = scrapertools.find_single_match(data, "text/javascript'>(eval.*?)\s*</script>") @@ -30,6 +30,6 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= #media_url += "|Referer=%s" %page_url if "m3u8" in media_url: ext = "m3u8" - video_urls.append({'type':ext, 'url':media_url}) + videoUrls.append({'type':ext, 'url':media_url}) - return video_urls + return videoUrls diff --git a/servers/sendvid.py b/servers/sendvid.py index 0aa18549..a06c216f 100755 --- a/servers/sendvid.py +++ b/servers/sendvid.py @@ -8,19 +8,19 @@ def test_video_exists(page_url): return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] data = scrapertools.httptools.downloadpage(page_url).data media_url = scrapertools.find_single_match(data, 'var\s+video_source\s+\=\s+"([^"]+)"') if "cache-1" in media_url: - video_urls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url}) - video_urls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url.replace("cache-1", "cache-2")}) + videoUrls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url}) + videoUrls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url.replace("cache-1", "cache-2")}) elif "cache-2" in media_url: - video_urls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url.replace("cache-2", "cache-1")}) - video_urls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url}) + videoUrls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url.replace("cache-2", "cache-1")}) + videoUrls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url}) else: - video_urls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url}) - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) - return video_urls + videoUrls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url}) + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) + return videoUrls diff --git a/servers/speedvideo.py b/servers/speedvideo.py index 48f3b774..72098ef3 100644 --- a/servers/speedvideo.py +++ b/servers/speedvideo.py @@ -12,30 +12,30 @@ def test_video_exists(page_url): if "File was deleted" in data or "Video is transfer on streaming server now." in data \ or 'Conversione video in corso' in data: - return False, config.get_localized_string(70449) % "Speedvideo" + return False, config.getLocalizedString(70449) % "Speedvideo" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] quality ={'MOBILE':1, 'NORMAL':2, 'HD':3} data = httptools.downloadpage(page_url).data # logger.debug('SPEEDVIDEO DATA '+ data) - media_urls = scrapertools.find_multiple_matches(data, r"file:[^']'([^']+)',\s*label:[^\"]\"([^\"]+)\"") + media_urls = scrapertools.findMultipleMatches(data, r"file:[^']'([^']+)',\s*label:[^\"]\"([^\"]+)\"") logger.debug("speed video - media urls: %s " % media_urls) for media_url, label in media_urls: media_url = httptools.downloadpage(media_url, only_headers=True, follow_redirects=False).headers.get("location", "") if media_url: - video_urls.append({'type':media_url.split('.')[-1], 'res':label, 'url':media_url}) - # logger.debug("speed video - media urls: %s " % video_urls) + videoUrls.append({'type':media_url.split('.')[-1], 'res':label, 'url':media_url}) + # logger.debug("speed video - media urls: %s " % videoUrls) - return video_urls + return videoUrls ##, diff --git a/servers/streamingcommunityws.py b/servers/streamingcommunityws.py index dad18823..469b8774 100644 --- a/servers/streamingcommunityws.py +++ b/servers/streamingcommunityws.py @@ -16,15 +16,15 @@ def test_video_exists(page_url): # page_url is the {VIDEO_ID}. Es: 5957 return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): - video_urls = [] + videoUrls = [] global c - c = SCClient("",video_id=page_url, is_playing_fnc=platformtools.is_playing) + c = SCClient("",video_id=page_url, isPlaying_fnc=platformtools.isPlaying) media_url = c.get_manifest_url() - video_urls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1] , 'url':media_url}) + videoUrls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1] , 'url':media_url}) - return video_urls + return videoUrls diff --git a/servers/streamon.py b/servers/streamon.py index d93621da..3a4af8c7 100644 --- a/servers/streamon.py +++ b/servers/streamon.py @@ -12,12 +12,12 @@ def test_video_exists(page_url): htmldata = httptools.downloadpage(page_url).data if 'Oops! video not found' in htmldata: - return False, config.get_localized_string(70449) % "Streamon" + return False, config.getLocalizedString(70449) % "Streamon" else: return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): tabbler = httptools.downloadpage('https://streamon.to/assets/js/tabber.js').data params_tabber = scrapertools.find_single_match(tabbler, r'\}\(([^\)]+)') @@ -54,11 +54,11 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= res2 = res.replace(decoder[2], "") media_url = base64.b64decode( res2 ).decode('ascii') - video_urls = [] + videoUrls = [] - video_urls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url}) + videoUrls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url}) - return video_urls + return videoUrls diff --git a/servers/streamtape.py b/servers/streamtape.py index 5add7cc2..d492121b 100644 --- a/servers/streamtape.py +++ b/servers/streamtape.py @@ -21,17 +21,17 @@ def test_video_exists(page_url): data = httptools.downloadpage(page_url, headers=referer).data if "Video not found" in data or 'Streamtape - Error' in data: - return False, config.get_localized_string(70449) % 'Streamtape' + return False, config.getLocalizedString(70449) % 'Streamtape' return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] find_url = match(data, patron=r'innerHTML = ([^;]+)').matches[-1] possible_url = js2py.eval_js(find_url) url = "https:" + possible_url url = httptools.downloadpage(url, follow_redirects=False, only_headers=True).headers.get("location", "") - video_urls.append({'type':'mp4', 'url':url}) - return video_urls + videoUrls.append({'type':'mp4', 'url':url}) + return videoUrls diff --git a/servers/streamz.py b/servers/streamz.py index 73730aab..90ecf272 100644 --- a/servers/streamz.py +++ b/servers/streamz.py @@ -15,14 +15,14 @@ def test_video_exists(page_url): data = httptools.downloadpage(page_url) if "<b>File not found, sorry!</b" in data.data: - return False, config.get_localized_string(70449) % "streamZ" + return False, config.getLocalizedString(70449) % "streamZ" return True, "" -def get_video_url(page_url, video_password=""): +def get_videoUrl(page_url, video_password=""): logger.info("(page_url='%s')" % page_url) - video_urls = [] - packed_data = scrapertools.find_multiple_matches(data.data, r'(eval.*?video(\d).*?video_(\d)[^<]+)') + videoUrls = [] + packed_data = scrapertools.findMultipleMatches(data.data, r'(eval.*?video(\d).*?video_(\d)[^<]+)') if packed_data: for p, index, control in packed_data: if index == control: @@ -35,6 +35,6 @@ def get_video_url(page_url, video_password=""): else: url = re.sub(r'(\.\w{2,3})/\w', '\\1/getl1nk-', data.url) + '.dll' url += "|Referer=https://streamz.ws/&User-Agent=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14'" - video_urls.append({'type':'mp4', 'url':url}) + videoUrls.append({'type':'mp4', 'url':url}) - return video_urls \ No newline at end of file + return videoUrls \ No newline at end of file diff --git a/servers/supervideo.py b/servers/supervideo.py index d1f96ea5..c31c2e88 100644 --- a/servers/supervideo.py +++ b/servers/supervideo.py @@ -16,14 +16,14 @@ def test_video_exists(page_url): headers = {'Referer': ''} data = httptools.downloadpage(page_url, headers=headers, cookies=False).data if 'File is no longer available as it expired or has been deleted' in data or 'fake-' in data: - return False, config.get_localized_string(70449) % "SuperVideo" + return False, config.getLocalizedString(70449) % "SuperVideo" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] # data = httptools.downloadpage(page_url).data global data @@ -43,15 +43,15 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= for source in lSrc: quality = source['label'] if 'label' in source else 'auto' - video_urls.append({'type':source['file'].split('.')[-1], 'res':quality, 'url':source['file']}) + videoUrls.append({'type':source['file'].split('.')[-1], 'res':quality, 'url':source['file']}) else: - matches = scrapertools.find_multiple_matches(data, r'src:\s*"([^"]+)",\s*type:\s*"[^"]+"(?:\s*, res:\s(\d+))?') + matches = scrapertools.findMultipleMatches(data, r'src:\s*"([^"]+)",\s*type:\s*"[^"]+"(?:\s*, res:\s(\d+))?') for url, quality in matches: if url.split('.')[-1] != 'm3u8': - video_urls.append({'type':url.split('.')[-1], 'res':quality, 'url':url}) + videoUrls.append({'type':url.split('.')[-1], 'res':quality, 'url':url}) else: - video_urls.append({'type':url.split('.')[-1], 'url':url}) + videoUrls.append({'type':url.split('.')[-1], 'url':url}) - # video_urls.sort(key=lambda x: x[0].split()[-2]) - return video_urls + # videoUrls.sort(key=lambda x: x[0].split()[-2]) + return videoUrls diff --git a/servers/thevid.py b/servers/thevid.py index 3b75eff5..7239298d 100644 --- a/servers/thevid.py +++ b/servers/thevid.py @@ -11,25 +11,25 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data if "Video not found..." in data or "Video removed due to copyright" in data: - return False, config.get_localized_string(70292) % "Thevid" + return False, config.getLocalizedString(70292) % "Thevid" if "Video removed for inactivity..." in data: - return False, config.get_localized_string(70449) % "Thevid" + return False, config.getLocalizedString(70449) % "Thevid" return True, "" -def get_video_url(page_url, user="", password="", video_password=""): +def get_videoUrl(page_url, user="", password="", video_password=""): logger.error("(page_url='%s')" % page_url) videos = [] data = httptools.downloadpage(page_url).data packed = scrapertools.find_single_match(data, "</script>\s*<script>\s*(eval.*?)\s*</script>") unpacked = jsunpack.unpack(packed) logger.error(unpacked) - videos = scrapertools.find_multiple_matches(unpacked, 'vldAb="([^"]+)') - video_urls = [] + videos = scrapertools.findMultipleMatches(unpacked, 'vldAb="([^"]+)') + videoUrls = [] for video in videos: if not video.startswith("//"): continue video = "https:" + video - video_urls.append({'type':'mp4', 'url':video}) + videoUrls.append({'type':'mp4', 'url':video}) # logger.debug("Url: %s" % videos) - return video_urls + return videoUrls diff --git a/servers/thevideobee.py b/servers/thevideobee.py index 6be96ebd..e2c40f37 100644 --- a/servers/thevideobee.py +++ b/servers/thevideobee.py @@ -12,15 +12,15 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data if "no longer exists" in data or "to copyright issues" in data: - return False, config.get_localized_string(70449) % "thevideobee" + return False, config.getLocalizedString(70449) % "thevideobee" return True, "" -def get_video_url(page_url, user="", password="", video_password=""): +def get_videoUrl(page_url, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data - video_urls = [] + videoUrls = [] videourl = scrapertools.find_single_match(data, 'src: "([^"]+)') - video_urls.append({'type':'mp4', 'url':videourl}) + videoUrls.append({'type':'mp4', 'url':videourl}) - return video_urls + return videoUrls diff --git a/servers/torrent.py b/servers/torrent.py index a708489b..6e0497ad 100755 --- a/servers/torrent.py +++ b/servers/torrent.py @@ -12,7 +12,7 @@ if sys.version_info[0] >= 3: else: import urllib -monitor = filetools.join(config.get_data_path(), 'elementum_monitor.json') +monitor = filetools.join(config.getDataPath(), 'elementum_monitor.json') extensions_list = ['.aaf', '.3gp', '.asf', '.avi', '.flv', '.mpeg', '.m1v', '.m2v', '.m4v', '.mkv', '.mov', '.mpg', '.mpe', '.mp4', '.ogg', '.wmv'] @@ -21,19 +21,19 @@ def test_video_exists(page_url): # Returns an array of possible video url's from the page_url -def get_video_url(page_url, premium=False, user='', password='', video_password=''): - torrent_options = platformtools.torrent_client_installed(show_tuple=True) - if len(torrent_options) == 0: +def get_videoUrl(page_url, premium=False, user='', password='', video_password=''): + torrentOptions = platformtools.torrentClientInstalled(showTuple=True) + if len(torrentOptions) == 0: from platformcode import elementum_download elementum_download.download() logger.debug('server=torrent, the url is the good') if page_url.startswith('magnet:'): - video_urls = [{'type':'magnet', 'url':page_url}] + videoUrls = [{'type':'magnet', 'url':page_url}] else: - video_urls = [{'type':'torrent', 'url':page_url}] + videoUrls = [{'type':'torrent', 'url':page_url}] - return video_urls + return videoUrls class XBMCPlayer(xbmc.Player): @@ -46,13 +46,13 @@ xbmc_player = XBMCPlayer() def mark_auto_as_watched(item): time_limit = time.time() + 150 - while not platformtools.is_playing() and time.time() < time_limit: + while not platformtools.isPlaying() and time.time() < time_limit: time.sleep(5) if item.subtitle: time.sleep(5) xbmc_player.setSubtitles(item.subtitle) - if item.strm_path and platformtools.is_playing(): + if item.strm_path and platformtools.isPlaying(): from platformcode import xbmc_videolibrary xbmc_videolibrary.mark_auto_as_watched(item) @@ -78,8 +78,8 @@ def elementum_download(item): if elementum_setting: set_elementum(True) time.sleep(3) - if config.get_setting('downloadpath').startswith('smb'): - select = platformtools.dialog_yesno('Elementum', config.get_localized_string(70807)) + if config.getSetting('downloadpath').startswith('smb'): + select = platformtools.dialogYesNo('Elementum', config.getLocalizedString(70807)) if select: xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?eyJjaGFubmVsIjoic2hvcnRjdXRzIiwgImFjdGlvbiI6IlNldHRpbmdPblBvc2l0aW9uIiwgImNhdGVnb3J5Ijo2LCAic2V0dGluZyI6MX0=)") else: @@ -93,7 +93,7 @@ def elementum_download(item): def elementum_monitor(): - path = xbmc.translatePath(config.get_setting('downloadlistpath')) + path = xbmc.translatePath(config.getSetting('downloadlistpath')) elementum_setting, elementum_host, TorrentPath = setting() # active_torrent = filetools.listdir(TorrentPath) @@ -119,15 +119,15 @@ def elementum_monitor(): status = it['status'] name = it['id'] if name in Monitor: - jsontools.update_node(progress, Monitor[name]['file'], 'downloadProgress', path, silent=True) - jsontools.update_node(4, Monitor[name]['file'], 'downloadStatus', path, silent=True) + jsontools.updateNode(progress, Monitor[name]['file'], 'downloadProgress', path, silent=True) + jsontools.updateNode(4, Monitor[name]['file'], 'downloadStatus', path, silent=True) if status in ['Paused']: - jsontools.update_node(0, Monitor[name]['file'], 'downloadStatus', path, silent=True) - if status in ['Seeding', 'Finished'] and not config.get_setting('elementum_on_seed'): + jsontools.updateNode(0, Monitor[name]['file'], 'downloadStatus', path, silent=True) + if status in ['Seeding', 'Finished'] and not config.getSetting('elementum_on_seed'): monitor_update(TorrentPath, name, remove=True) dlJson = jsontools.load(open(filetools.join(path, Monitor[name]['file']), "r").read()) - jsontools.update_node(dlJson['downloadSize'], Monitor[name]['file'], 'downloadCompleted', path, silent=True) - jsontools.update_node(2, Monitor[name]['file'], 'downloadStatus', path, silent=True) + jsontools.updateNode(dlJson['downloadSize'], Monitor[name]['file'], 'downloadCompleted', path, silent=True) + jsontools.updateNode(2, Monitor[name]['file'], 'downloadStatus', path, silent=True) requests.get(elementum_host + 'pause/' + name) filetools.remove(filetools.join(TorrentPath, name + '.torrent')) filetools.remove(filetools.join(TorrentPath, name + '.fastresume')) @@ -140,7 +140,7 @@ def monitor_update(TorrentPath, value, remove=False): json = jsontools.load(open(monitor, "r").read()) Monitor = json['monitor'] info = Torrent.from_file(filetools.join(TorrentPath, value + '.torrent')) - path = xbmc.translatePath(config.get_setting('downloadlistpath')) + path = xbmc.translatePath(config.getSetting('downloadlistpath')) if not value in Monitor: Monitor[value]={} @@ -152,10 +152,10 @@ def monitor_update(TorrentPath, value, remove=False): filetools.write(monitor, json, silent=True) backupFilename = jsontools.load(open(filetools.join(path, File), "r").read())['downloadFilename'] - jsontools.update_node(value, File, 'TorrentName', path, silent=True) - jsontools.update_node(info.total_size, File, 'downloadSize', path, silent=True) - jsontools.update_node(backupFilename, File, 'backupFilename', path, silent=True) - jsontools.update_node(info.name, File, 'downloadFilename', path, silent=True) + jsontools.updateNode(value, File, 'TorrentName', path, silent=True) + jsontools.updateNode(info.total_size, File, 'downloadSize', path, silent=True) + jsontools.updateNode(backupFilename, File, 'backupFilename', path, silent=True) + jsontools.updateNode(info.name, File, 'downloadFilename', path, silent=True) elif remove: Monitor.pop(value) @@ -179,9 +179,9 @@ def set_elementum(SET=False): backup_setting['download_storage'] = elementum_setting.getSetting('download_storage') # Backup Setting elementum_setting.setSetting('download_storage', '0') # Set Setting - if elementum_setting.getSetting('download_path') != config.get_setting('downloadpath') or not 'download_path' in backup_setting: + if elementum_setting.getSetting('download_path') != config.getSetting('downloadpath') or not 'download_path' in backup_setting: backup_setting['download_path'] = elementum_setting.getSetting('download_path') # Backup Setting - elementum_setting.setSetting('download_path', config.get_setting('downloadpath')) # Set Setting + elementum_setting.setSetting('download_path', config.getSetting('downloadpath')) # Set Setting write = True elif backup_setting: @@ -197,7 +197,7 @@ def set_elementum(SET=False): def find_file(hash): - path = xbmc.translatePath(config.get_setting('downloadlistpath')) + path = xbmc.translatePath(config.getSetting('downloadlistpath')) files = filetools.listdir(path) for f in files: filepath = filetools.join(path, f) @@ -231,9 +231,9 @@ def process_filename(filename, Title, ext=True): else: episode += 'x' + str(parsedTitle.get('episode')).zfill(2) elif parsedTitle.get('season') and type(parsedTitle.get('season')) == list: - episode += s + config.get_localized_string(30140) + " " +str(parsedTitle.get('season')[0]) + '-' + str(parsedTitle.get('season')[-1]) + episode += s + config.getLocalizedString(30140) + " " +str(parsedTitle.get('season')[0]) + '-' + str(parsedTitle.get('season')[-1]) elif parsedTitle.get('season'): - episode += s + config.get_localized_string(60027) % str(parsedTitle.get('season')) + episode += s + config.getLocalizedString(60027) % str(parsedTitle.get('season')) if parsedTitle.get('episode_title'): episode += s + parsedTitle.get('episode_title') title = (t if t else Title) + s + episode + (extension if ext else '') @@ -241,9 +241,9 @@ def process_filename(filename, Title, ext=True): def rename(File): - jsonPath = xbmc.translatePath(config.get_setting('downloadlistpath')) + jsonPath = xbmc.translatePath(config.getSetting('downloadlistpath')) json = jsontools.load(open(filetools.join(jsonPath, File), "r").read()) - filePath = filetools.join(xbmc.translatePath(config.get_setting('downloadpath')), json['downloadFilename']) + filePath = filetools.join(xbmc.translatePath(config.getSetting('downloadpath')), json['downloadFilename']) if json['infoLabels']['mediatype'] == 'movie': if filetools.isdir(filePath): @@ -256,13 +256,13 @@ def rename(File): if ext in extensions_list: extension = ext filetools.rename(filetools.join(filePath, f), f.replace(oldName, newName)) filetools.rename(filePath, newName) - jsontools.update_node(filetools.join(newName, newName + extension), File, 'downloadFilename', jsonPath) + jsontools.updateNode(filetools.join(newName, newName + extension), File, 'downloadFilename', jsonPath) else: oldName = json['downloadFilename'] newName = json['backupFilename'] + os.path.splitext(oldName)[-1] filetools.rename(filePath, newName) - jsontools.update_node(newName, File, 'downloadFilename', jsonPath) + jsontools.updateNode(newName, File, 'downloadFilename', jsonPath) else: sep = '/' if filePath.lower().startswith("smb://") else os.sep FolderName = json['backupFilename'].split(sep)[0] @@ -283,14 +283,14 @@ def rename(File): filetools.rename(filetools.join(filePath, f), f.replace(name, title)) filetools.rename(filePath, FolderName) - jsontools.update_node(FolderName, File, 'downloadFilename', jsonPath) + jsontools.updateNode(FolderName, File, 'downloadFilename', jsonPath) else: filename = filetools.split(filePath)[-1] title = process_filename(filename, Title) - NewFolder = filetools.join(config.get_setting('downloadpath'), FolderName) + NewFolder = filetools.join(config.getSetting('downloadpath'), FolderName) if not filetools.isdir(NewFolder): filetools.mkdir(NewFolder) - from_folder = filetools.join(config.get_setting('downloadpath'), filename) - to_folder = filetools.join(config.get_setting('downloadpath'), FolderName, title) + from_folder = filetools.join(config.getSetting('downloadpath'), filename) + to_folder = filetools.join(config.getSetting('downloadpath'), FolderName, title) filetools.move(from_folder, to_folder) - jsontools.update_node(filetools.join(FolderName, title), File, 'downloadFilename', jsonPath) \ No newline at end of file + jsontools.updateNode(filetools.join(FolderName, title), File, 'downloadFilename', jsonPath) \ No newline at end of file diff --git a/servers/turbobit.py b/servers/turbobit.py index 9f254dc9..8bfbb75a 100644 --- a/servers/turbobit.py +++ b/servers/turbobit.py @@ -3,7 +3,7 @@ from platformcode import logger -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] - return video_urls + videoUrls = [] + return videoUrls diff --git a/servers/turbovid.py b/servers/turbovid.py index d1f1e19c..116cc0ad 100644 --- a/servers/turbovid.py +++ b/servers/turbovid.py @@ -15,22 +15,22 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data if "Not Found" in data or "File Does not Exist" in data: - return False, config.get_localized_string(70449) % "Turbovid" + return False, config.getLocalizedString(70449) % "Turbovid" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password="", server='Turbovid'): +def get_videoUrl(page_url, premium=False, user="", password="", video_password="", server='Turbovid'): logger.debug("(turbovid page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url).data data = data.replace('"', "'") page_url_post = scrapertools.find_single_match(data, "<Form method='POST' action='([^']+)'>") imhuman = "&imhuman=" + scrapertools.find_single_match(data, "name='imhuman' value='([^']+)'").replace(" ", "+") - post = urllib.urlencode({k: v for k, v in scrapertools.find_multiple_matches(data, "name='([^']+)' value='([^']*)'")}) + imhuman + post = urllib.urlencode({k: v for k, v in scrapertools.findMultipleMatches(data, "name='([^']+)' value='([^']*)'")}) + imhuman time.sleep(6) data = httptools.downloadpage(page_url_post, post=post).data logger.debug("(data page_url='%s')" % data) - video_urls = support.get_jwplayer_mediaurl(data, 'Turbovid') - return video_urls + videoUrls = support.get_jwplayer_mediaUrl(data, 'Turbovid') + return videoUrls diff --git a/servers/tusfiles.py b/servers/tusfiles.py index d058427a..9fd93a06 100644 --- a/servers/tusfiles.py +++ b/servers/tusfiles.py @@ -12,15 +12,15 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data if "no longer exists" in data or "to copyright issues" in data: - return False, config.get_localized_string(70449) % "tusfiles" + return False, config.getLocalizedString(70449) % "tusfiles" return True, "" -def get_video_url(page_url, user="", password="", video_password=""): +def get_videoUrl(page_url, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data - video_urls = [] + videoUrls = [] videourl = scrapertools.find_single_match(data, 'source src="([^"]+)') - video_urls.append({'type':'mp4', 'url':videourl}) + videoUrls.append({'type':'mp4', 'url':videourl}) - return video_urls + return videoUrls diff --git a/servers/uploadedto.py b/servers/uploadedto.py index 51a53e4a..de891426 100755 --- a/servers/uploadedto.py +++ b/servers/uploadedto.py @@ -15,9 +15,9 @@ def test_video_exists(page_url): else: return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] if premium: #Si no hay almacenada una cookie activa, hacemos login if check_cookie("uploaded.net", "login") != True: @@ -71,17 +71,17 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= logger.error(traceback.format_exc()) extension = "" - video_urls.append({'type':extension, 'url':location}) + videoUrls.append({'type':extension, 'url':location}) - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) - return video_urls + return videoUrls def check_cookie(domain, cname): from platformcode import config #cargamos las cookies - cookies = config.get_cookie_data() + cookies = config.getCookieData() #buscamos el valor de la cookie "cname" del dominio "domain" cookie_value = scrapertools.find_single_match(cookies, domain + ".*?" + cname + "\s+([A-Za-z0-9\+\=\%\_]+)") if cookie_value: diff --git a/servers/uppom.py b/servers/uppom.py index 44cd9996..9fd6b3d6 100644 --- a/servers/uppom.py +++ b/servers/uppom.py @@ -13,20 +13,20 @@ def test_video_exists(page_url): data = get_source(page_url) if "File was deleted" in data or "File Not Found" in data: - return False, config.get_localized_string(70449) % "Uppom" + return False, config.getLocalizedString(70449) % "Uppom" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug() - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url).data fid = scrapertools.find_single_match(data, ' name="id" value="([^"]+)"') post = "op=download2&id=%s&rand=&referer=%s&method_free=Liberta+Descarga+>>&method_premium=" % (fid, page_url) data = httptools.downloadpage(page_url, post=post).data media_url = scrapertools.find_single_match(data, '<a href="([^"]+)">http') ext = scrapertools.get_filename_from_url(media_url) - video_urls.append({'type':ext, 'url':media_url}) + videoUrls.append({'type':ext, 'url':media_url}) - return video_urls + return videoUrls diff --git a/servers/upstream.py b/servers/upstream.py index 299f7e89..0135ffb0 100644 --- a/servers/upstream.py +++ b/servers/upstream.py @@ -13,18 +13,18 @@ def test_video_exists(page_url): global data data = httptools.downloadpage(page_url).data if "as it expired or has been deleted" in data: - return False, config.get_localized_string(70449) % "UPstream" + return False, config.getLocalizedString(70449) % "UPstream" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): - video_urls = [] +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): + videoUrls = [] global data new_data = scrapertools.find_single_match(data, r"<script type='text/javascript'>(eval.function.p,a,c,k,e,.*?)\s*</script>") if new_data != "": from lib import jsunpack data = jsunpack.unpack(new_data) media_url = scrapertools.find_single_match(data, r'file:"([^"]+)"') - video_urls.append({'type':media_url.split('.')[-1], 'url':media_url + '|Referer=' + page_url}) + videoUrls.append({'type':media_url.split('.')[-1], 'url':media_url + '|Referer=' + page_url}) - return video_urls + return videoUrls diff --git a/servers/uptobox.py b/servers/uptobox.py index cd9fe71e..698b1e61 100755 --- a/servers/uptobox.py +++ b/servers/uptobox.py @@ -21,7 +21,7 @@ def test_video_exists(page_url): if "Streaming link:" in data: return True, "" elif "Unfortunately, the file you want is not available." in data or "Unfortunately, the video you want to see is not available" in data or "This stream doesn" in data or "Page not found" in data or "Archivo no encontrado" in data: - return False, config.get_localized_string(70449) % "UPtoStream" + return False, config.getLocalizedString(70449) % "UPtoStream" wait = scrapertools.find_single_match(data, "You have to wait ([0-9]+) (minute|second)") if len(wait) > 0: return False, "[UPtoStream] Limite di download raggiunto. <br/> Attendi " + wait[0] + " " + wait[1] @@ -29,25 +29,25 @@ def test_video_exists(page_url): return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.info("(page_url='%s')" % page_url) global data # If the link is direct from upstream if "uptobox" not in page_url: if "Video not found" in data: page_url = page_url.replace("uptostream.com/iframe/", "uptobox.com/") - video_urls = uptobox(page_url, httptools.downloadpage(page_url).data) + videoUrls = uptobox(page_url, httptools.downloadpage(page_url).data) else: - video_urls = uptostream(data) + videoUrls = uptostream(data) else: # If the file has a streaming link, it is redirected to upstream if "Streaming link:" in data: page_url = "http://uptostream.com/iframe/" + scrapertools.find_single_match(page_url, 'uptobox.com/([a-z0-9]+)') - video_urls = uptostream(httptools.downloadpage(page_url).data) + videoUrls = uptostream(httptools.downloadpage(page_url).data) else: # If you don't have it, the normal download is used - video_urls = uptobox(page_url, data) - return video_urls + videoUrls = uptobox(page_url, data) + return videoUrls def uptostream(data): @@ -55,7 +55,7 @@ def uptostream(data): subtitle = match(data, patron=r'kind="subtitles" src="([^"]+)"').match if subtitle and not '://' in subtitle: subtitle = "http://" + subtitle - video_urls = [] + videoUrls = [] api_url = "https://uptostream.com/api/streaming/source/get?token=null&file_code=%s" % video_id api_data = httptools.downloadpage(api_url).json js_code = api_data.get('data', '').get('sources', '') @@ -74,16 +74,16 @@ def uptostream(data): tipo = tipo.replace("video/","") if lang: extension = "{} - {} [{}]".format(tipo, res, lang.upper()) else: extension = "{} - {}".format(tipo, res) - video_urls.append({'type':extension, 'url':media_url, 'sub':subtitle}) - # video_urls.sort(key=lambda url: int(match(url[0], patron=r'(\d+)p').match)) - return video_urls + videoUrls.append({'type':extension, 'url':media_url, 'sub':subtitle}) + # videoUrls.sort(key=lambda url: int(match(url[0], patron=r'(\d+)p').match)) + return videoUrls def atob(s): import base64 return base64.b64decode('{}'.format(s)).decode('utf-8') def uptobox(url, data): - video_urls = [] + videoUrls = [] post = "" matches = match(data, patron=r'name="([^"]+)".*?value="([^"]*)"').matches @@ -93,6 +93,6 @@ def uptobox(url, data): media = match(url, post=post[:-1], patron=r'<a href="([^"]+)">\s*<span class="button_upload green">').match url_strip = media.rsplit('/', 1)[1] media_url = media.rsplit('/', 1)[0] + "/" + url_strip - video_urls.append({'type':media_url.split('.')[-1], 'url':media_url}) + videoUrls.append({'type':media_url.split('.')[-1], 'url':media_url}) - return video_urls \ No newline at end of file + return videoUrls \ No newline at end of file diff --git a/servers/upvid.py b/servers/upvid.py index efc0e048..486aea48 100644 --- a/servers/upvid.py +++ b/servers/upvid.py @@ -16,15 +16,15 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url) if data.code == 404: - return False, config.get_localized_string(70449) % "upvid" + return False, config.getLocalizedString(70449) % "upvid" if "<title>video is no longer available" in data.data: - return False, config.get_localized_string(70449) % "upvid" + return False, config.getLocalizedString(70449) % "upvid" return True, "" -def get_video_url(page_url, premium = False, user = "", password = "", video_password = ""): +def get_videoUrl(page_url, premium = False, user = "", password = "", video_password = ""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] headers = {'referer': page_url} for i in range(0, 3): data = httptools.downloadpage(page_url, headers=headers).data @@ -43,8 +43,8 @@ def get_video_url(page_url, premium = False, user = "", password = "", video_pas oculto = re.findall('<input type=hidden value=([^ ]+) id=func', data, flags=re.DOTALL)[0] funciones = resuelve(clave, base64.b64decode(oculto)) url, type = scrapertools.find_single_match(funciones, "setAttribute\('src', '(.*?)'\);\s.*?type', 'video/(.*?)'") - video_urls.append({'type':type ,'url':url}) - return video_urls + videoUrls.append({'type':type ,'url':url}) + return videoUrls def resuelve(r, o): diff --git a/servers/uqload.py b/servers/uqload.py index fa64c3b1..aebf6d14 100644 --- a/servers/uqload.py +++ b/servers/uqload.py @@ -15,15 +15,15 @@ def test_video_exists(page_url): data = httptools.downloadpage(page_url) if data.code == 404: - return False, config.get_localized_string(70449) % "Uqload" + return False, config.getLocalizedString(70449) % "Uqload" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url).data data = re.sub(r'\n|\r|\t| |<br>|\s{2,}', "", data) patron = 'sources:.?\["([^"]+)"\]' @@ -31,6 +31,6 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= for url in matches: url = url+'|Referer='+page_url - video_urls.append({'url':url}) + videoUrls.append({'url':url}) - return video_urls + return videoUrls diff --git a/servers/userload.py b/servers/userload.py index ff56ffe5..5a91a33e 100644 --- a/servers/userload.py +++ b/servers/userload.py @@ -11,16 +11,16 @@ def test_video_exists(page_url): response = httptools.downloadpage(page_url) if response.code == 404 or 'We’re Sorry' in response.data: - return False, config.get_localized_string(70449) % 'Userload' + return False, config.getLocalizedString(70449) % 'Userload' else: data = response.data return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): global data logger.debug("URL", page_url) - video_urls = [] + videoUrls = [] packed = support.match(data, patron=r"(eval\(function\(p,a,c,k,e,d\).*?)\s*<").match unpack = jsunpack.unpack(packed) for m in support.match(unpack, patron='var (\w+)="([^"]+)').matches: @@ -32,6 +32,6 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= logger.debug(post) url = support.match('https://userload.co/api/request/', post=post, patron=r'([^\s\r\n]+)').match if url: - video_urls.append({'type':url.split('.')[-1], 'url':url}) + videoUrls.append({'type':url.split('.')[-1], 'url':url}) - return video_urls \ No newline at end of file + return videoUrls \ No newline at end of file diff --git a/servers/userscloud.py b/servers/userscloud.py index 38e5ddd3..4835f853 100644 --- a/servers/userscloud.py +++ b/servers/userscloud.py @@ -12,14 +12,14 @@ def test_video_exists(page_url): response = httptools.downloadpage(page_url) if not response.success or "Not Found" in response.data or "File was deleted" in response.data or "is no longer available" in response.data: - return False, config.get_localized_string(70449) % "Userscloud" + return False, config.getLocalizedString(70449) % "Userscloud" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] unpacked = "" data = httptools.downloadpage(page_url).data packed = scrapertools.find_single_match(data, "function\(p,a,c,k.*?</script>") @@ -34,9 +34,9 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= media_url = scrapertools.find_single_match(data, 'name="down_script".*?<a href="([^"]+)"') ext = scrapertools.get_filename_from_url(media_url).split('.')[-1] - video_urls.append({'type':ext, 'url':media_url}) + videoUrls.append({'type':ext, 'url':media_url}) - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) - return video_urls + return videoUrls diff --git a/servers/vevio.py b/servers/vevio.py index b1f1a432..c1829bd6 100644 --- a/servers/vevio.py +++ b/servers/vevio.py @@ -21,20 +21,20 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data if "File was deleted" in data or "Page Cannot Be Found" in data or "<title>Video not found" in data: - return False, config.get_localized_string(70449) % "vevio" + return False, config.getLocalizedString(70449) % "vevio" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] post = {} post = urllib.urlencode(post) url = page_url data = httptools.downloadpage("https://vev.io/api/serve/video/" + scrapertools.find_single_match(url, "embed/([A-z0-9]+)"), post=post).data bloque = scrapertools.find_single_match(data, 'qualities":\{(.*?)\}') - matches = scrapertools.find_multiple_matches(bloque, '"([^"]+)":"([^"]+)') + matches = scrapertools.findMultipleMatches(bloque, '"([^"]+)":"([^"]+)') for res, media_url in matches: - video_urls.append( + videoUrls.append( {'type':scrapertools.get_filename_from_url(media_url).split('.')[-1],'res':res, 'url':media_url}) - return video_urls + return videoUrls diff --git a/servers/vidcloud.py b/servers/vidcloud.py index ecc80807..a205a0df 100644 --- a/servers/vidcloud.py +++ b/servers/vidcloud.py @@ -16,15 +16,15 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data if "We're Sorry" in data: - return False, config.get_localized_string(70292) % "Vidcloud" + return False, config.getLocalizedString(70292) % "Vidcloud" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url).data @@ -47,15 +47,15 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= data = httptools.downloadpage(page_url, headers=headers).data data = data.replace('\\\\', '\\').replace('\\','') - media_urls = scrapertools.find_multiple_matches(data, '\{"file"\s*:\s*"([^"]+)"\}') + media_urls = scrapertools.findMultipleMatches(data, '\{"file"\s*:\s*"([^"]+)"\}') for media_url in media_urls: ext = "mp4" if "m3u8" in media_url: ext = "m3u8" - video_urls.append({'type':ext, 'url':media_url}) + videoUrls.append({'type':ext, 'url':media_url}) - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) - return video_urls + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) + return videoUrls diff --git a/servers/videobin.py b/servers/videobin.py index 647e5e71..76abc54c 100644 --- a/servers/videobin.py +++ b/servers/videobin.py @@ -14,17 +14,17 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data if "borrado" in data or "Deleted" in data: - return False, config.get_localized_string(70449) % "videobin" + return False, config.getLocalizedString(70449) % "videobin" return True, "" -def get_video_url(page_url, user="", password="", video_password=""): +def get_videoUrl(page_url, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url).data bloque = scrapertools.find_single_match(data, 'sources:.\[.*?]') - matches = scrapertools.find_multiple_matches(bloque, '(http.*?)"') + matches = scrapertools.findMultipleMatches(bloque, '(http.*?)"') for videourl in matches: extension = extension = scrapertools.get_filename_from_url(videourl).split('.')[-1] - video_urls.append({'type':extension, 'url':videourl}) - return video_urls + videoUrls.append({'type':extension, 'url':videourl}) + return videoUrls diff --git a/servers/videomega.py b/servers/videomega.py index ee1dbb23..09286830 100644 --- a/servers/videomega.py +++ b/servers/videomega.py @@ -4,9 +4,9 @@ from core import scrapertools from platformcode import logger -def get_video_url(page_url, video_password): +def get_videoUrl(page_url, video_password): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url).data m= scrapertools.find_single_match(data, '<link href="(Br74.*?==.css)"') url= "https://www.videomega.co/streamurl/JaV1laMGUzNzJjYzg2ZTZhYzg2NzdjNzNhYThlMTAwNTQxMTVzZWN1cmUZaoKJEa.css/" @@ -15,6 +15,6 @@ def get_video_url(page_url, video_password): url = url.replace(" ", "") data=httptools.downloadpage(url).data url = scrapertools.find_single_match(data, '<source src="([^"]+)"') - video_urls.append({'url':url}) - return video_urls + videoUrls.append({'url':url}) + return videoUrls diff --git a/servers/vidfast.py b/servers/vidfast.py index a7a06222..96b034a8 100644 --- a/servers/vidfast.py +++ b/servers/vidfast.py @@ -7,7 +7,7 @@ from core import scrapertools from platformcode import config from platformcode import logger -video_urls = [] +videoUrls = [] def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) @@ -16,17 +16,17 @@ def test_video_exists(page_url): global data data = response.data if not response.success or "Not Found" in data or "File was deleted" in data or "is no longer available" in data: - return False, config.get_localized_string(70449) % "vidfast" + return False, config.getLocalizedString(70449) % "vidfast" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] logger.debug("Intel11 %s" %data) media_url = scrapertools.find_single_match(data, 'file:"([^"]+)') if media_url: ext = media_url.split('.')[-1] - video_urls.append({'type':ext, 'url':media_url}) + videoUrls.append({'type':ext, 'url':media_url}) - return video_urls + return videoUrls diff --git a/servers/vidlox.py b/servers/vidlox.py index e76779e0..b1580f41 100644 --- a/servers/vidlox.py +++ b/servers/vidlox.py @@ -15,21 +15,21 @@ def test_video_exists(page_url): global data data = httptools.downloadpage(page_url).data if "borrado" in data or "Deleted" in data: - return False, config.get_localized_string(70449) % "vidlox" + return False, config.getLocalizedString(70449) % "vidlox" return True, "" -def get_video_url(page_url, user="", password="", video_password=""): +def get_videoUrl(page_url, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] bloque = scrapertools.find_single_match(data, 'sources:.\[.*?]') - matches = scrapertools.find_multiple_matches(bloque, '(http.*?)"') + matches = scrapertools.findMultipleMatches(bloque, '(http.*?)"') for videourl in matches: extension = videourl.split('.')[-1] if extension == 'm3u8': continue - video_urls.append({'type':extension, 'url':videourl}) - # video_urls.reverse() - return video_urls + videoUrls.append({'type':extension, 'url':videourl}) + # videoUrls.reverse() + return videoUrls diff --git a/servers/vidmoly.py b/servers/vidmoly.py index b1c9c56b..7c18c751 100644 --- a/servers/vidmoly.py +++ b/servers/vidmoly.py @@ -10,16 +10,16 @@ def test_video_exists(page_url): resp = httptools.downloadpage(page_url) data = resp.data if resp.code == 404 or 'Video is processing now' in data: - return False, config.get_localized_string(70449) % "Vidmoly" + return False, config.getLocalizedString(70449) % "Vidmoly" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) global data - video_urls = support.get_jwplayer_mediaurl(data, 'Vidmoly') - for url in video_urls.items: + videoUrls = support.get_jwplayer_mediaUrl(data, 'Vidmoly') + for url in videoUrls.items: logger.debug(url) url[url] = url['url'].replace(',','').replace('.urlset','').replace('/hls','') + '|Referer=' + page_url - return video_urls + return videoUrls diff --git a/servers/vidoza.py b/servers/vidoza.py index f4744d6e..ed363589 100644 --- a/servers/vidoza.py +++ b/servers/vidoza.py @@ -12,17 +12,17 @@ def test_video_exists(page_url): global data data = httptools.downloadpage(page_url).data if "Page not found" in data or "File was deleted" in data: - return False, config.get_localized_string(70449) % "vidoza" + return False, config.getLocalizedString(70449) % "vidoza" elif "processing" in data: - return False, config.get_localized_string(70449) % "Vidoza" + return False, config.getLocalizedString(70449) % "Vidoza" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) global data - video_urls = [] + videoUrls = [] s = scrapertools.find_single_match(data, r'sourcesCode\s*:\s*(\[\{.*?\}\])') s = s.replace('src:', '"src":').replace('file:', '"file":').replace('type:', '"type":').replace('label:', '"label":').replace('res:', '"res":') @@ -38,11 +38,11 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= if 'res' in enlace: res = enlace['res'] elif 'label' in enlace: res = enlace['label'] - video_urls.append({'type':tit, 'res':res, 'url':url}) + videoUrls.append({'type':tit, 'res':res, 'url':url}) except: logger.debug('No se detecta json %s' % s) pass - video_urls.reverse() + videoUrls.reverse() - return video_urls + return videoUrls diff --git a/servers/vidtodo.py b/servers/vidtodo.py index 9a7708a3..2f4416b3 100755 --- a/servers/vidtodo.py +++ b/servers/vidtodo.py @@ -18,18 +18,18 @@ def test_video_exists(page_url): return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] data = response.data packed_data = scrapertools.find_single_match(data, "javascript'>(eval.*?)</script>") unpacked = jsunpack.unpack(packed_data) - matches = scrapertools.find_multiple_matches(unpacked, 'src:"([^"]+)",type:"video/(.*?)",res:(.*?),') + matches = scrapertools.findMultipleMatches(unpacked, 'src:"([^"]+)",type:"video/(.*?)",res:(.*?),') for media_url, type, res in matches: if media_url.endswith(".mp4"): - video_urls.append(["[%s][%s]" % (type, res), media_url]) + videoUrls.append(["[%s][%s]" % (type, res), media_url]) if media_url.endswith(".m3u8"): - video_urls.append(["M3U8 [%s][%s]" % (type, res), media_url]) + videoUrls.append(["M3U8 [%s][%s]" % (type, res), media_url]) if media_url.endswith(".smil"): smil_data = httptools.downloadpage(media_url).data rtmp = scrapertools.find_single_match(smil_data, 'base="([^"]+)"') @@ -38,8 +38,8 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= scrapertools.find_single_match(data, '"Watch video ([^"]+")').replace(' ', '.') + ".mp4" for playpath, inf in playpaths: h = scrapertools.find_single_match(playpath, 'h=([a-z0-9]+)') - video_urls.append({'type':'mp4', 'res':inf, 'url':mp4 % h}) - video_urls.append({'type':'rtmp', 'res':inf, 'url':"%s playpath=%s" % (rtmp, playpath)}) - # for video_url in video_urls: - # logger.debug("video_url: %s - %s" % (video_url[0], video_url[1])) - return video_urls + videoUrls.append({'type':'mp4', 'res':inf, 'url':mp4 % h}) + videoUrls.append({'type':'rtmp', 'res':inf, 'url':"%s playpath=%s" % (rtmp, playpath)}) + # for videoUrl in videoUrls: + # logger.debug("videoUrl: %s - %s" % (videoUrl[0], videoUrl[1])) + return videoUrls diff --git a/servers/vidtome.py b/servers/vidtome.py index c4b89b2c..af107c73 100644 --- a/servers/vidtome.py +++ b/servers/vidtome.py @@ -10,23 +10,23 @@ def test_video_exists(page_url): global data data = httptools.downloadpage(page_url).data if "Not Found" in data or "File Does not Exist" in data: - return False, config.get_localized_string(70292) % 'Vidto.me' + return False, config.getLocalizedString(70292) % 'Vidto.me' return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) global data - video_urls = [] + videoUrls = [] code = scrapertools.find_single_match(data, 'name="code" value="([^"]+)') hash = scrapertools.find_single_match(data, 'name="hash" value="([^"]+)') post = "op=download1&code=%s&hash=%s&imhuman=Proceed+to+video" %(code, hash) data = httptools.downloadpage("http://%s/playvideos/%s" % (servertools.get_server_host("vidtome")[0], code), post=post).data - packed = scrapertools.find_multiple_matches(data, r'(eval\s?\(function\(p,a,c,k,e,d\).*?\n)') + packed = scrapertools.findMultipleMatches(data, r'(eval\s?\(function\(p,a,c,k,e,d\).*?\n)') for p in packed: data = jsunpack.unpack(p) - video_urls.extend(support.get_jwplayer_mediaurl(data, 'vidtome')) + videoUrls.extend(support.get_jwplayer_mediaUrl(data, 'vidtome')) # media_url = scrapertools.find_single_match(data, r"source:\\'([^\\']+)") # if media_url: - # video_urls.append([media_url.split('.')[-1] + ' [Vidto.me]', media_url]) - return video_urls + # videoUrls.append([media_url.split('.')[-1] + ' [Vidto.me]', media_url]) + return videoUrls diff --git a/servers/vidup.py b/servers/vidup.py index e386de14..4f937e0d 100755 --- a/servers/vidup.py +++ b/servers/vidup.py @@ -24,13 +24,13 @@ def test_video_exists(page_url): page = httptools.downloadpage(page_url) url = page.url if "Not Found" in page.data or "/404" in url: - return False, config.get_localized_string(70449) % "Vidup" + return False, config.getLocalizedString(70449) % "Vidup" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] post= {} post = urllib.urlencode(post) headers = {"Referer":page_url} @@ -38,8 +38,8 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= logger.error(url) data = httptools.downloadpage("https://vidup.io/api/serve/video/" + scrapertools.find_single_match(url, "embed.([A-z0-9]+)"), post=post).data bloque = scrapertools.find_single_match(data, 'qualities":\{(.*?)\}') - matches = scrapertools.find_multiple_matches(bloque, '"([^"]+)":"([^"]+)') + matches = scrapertools.findMultipleMatches(bloque, '"([^"]+)":"([^"]+)') for res, media_url in matches: - video_urls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'res':res, 'url':media_url}) - # video_urls.reverse() - return video_urls + videoUrls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'res':res, 'url':media_url}) + # videoUrls.reverse() + return videoUrls diff --git a/servers/vimeo.py b/servers/vimeo.py index e0e071f6..a922d5b3 100644 --- a/servers/vimeo.py +++ b/servers/vimeo.py @@ -17,27 +17,27 @@ def test_video_exists(page_url): data = httptools.downloadpage(page_url, headers=headers).data if "Private Video on Vimeo" in data or "Sorry" in data: - return False, config.get_localized_string(70449) % 'Vimeo' + return False, config.getLocalizedString(70449) % 'Vimeo' else: return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] global data patron = 'mime":"([^"]+)"' patron += '.*?url":"([^"]+)"' patron += '.*?quality":"([^"]+)"' - match = scrapertools.find_multiple_matches(data, patron) + match = scrapertools.findMultipleMatches(data, patron) for mime, media_url, calidad in match: # title = "%s (%s) [Vimeo]" % (mime.replace("video/", "."), calidad) - video_urls.append({'type':mime.replace("video/", ""), 'url':media_url, 'res':calidad}) + videoUrls.append({'type':mime.replace("video/", ""), 'url':media_url, 'res':calidad}) - # video_urls.sort(key=lambda x: x[2]) - # for video_url in video_urls: - # video_url[2] = 0 - # logger.debug("%s - %s" % (video_url[0], video_url[1])) + # videoUrls.sort(key=lambda x: x[2]) + # for videoUrl in videoUrls: + # videoUrl[2] = 0 + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) - return video_urls + return videoUrls diff --git a/servers/vimpleru.py b/servers/vimpleru.py index 31db584e..e198ba31 100644 --- a/servers/vimpleru.py +++ b/servers/vimpleru.py @@ -10,18 +10,18 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data if '"title":"Video Not Found"' in data: - return False, config.get_localized_string(70449) % "Vimple" + return False, config.getLocalizedString(70449) % "Vimple" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url=%s)" % page_url) data = httptools.downloadpage(page_url).data media_url = scrapertools.find_single_match(data, '"video"[^,]+,"url":"([^"]+)"').replace('\\', '') - data_cookie = config.get_cookie_data() + data_cookie = config.getCookieData() cfduid = scrapertools.find_single_match(data_cookie, '.vimple.ru.*?(__cfduid\t[a-f0-9]+)') \ .replace('\t', '=') univid = scrapertools.find_single_match(data_cookie, '.vimple.ru.*?(UniversalUserID\t[a-f0-9]+)') \ @@ -30,10 +30,10 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= media_url += "|User-Agent=Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0" \ "&Cookie=%s; %s" % (cfduid, univid) - video_urls = [] - video_urls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url}) + videoUrls = [] + videoUrls.append({'type':scrapertools.get_filename_from_url(media_url).split('.')[-1], 'url':media_url}) - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) - return video_urls + return videoUrls diff --git a/servers/vivo.py b/servers/vivo.py index 882b01af..a9abfcaf 100644 --- a/servers/vivo.py +++ b/servers/vivo.py @@ -12,15 +12,15 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url) if data.code == 404: - return False, config.get_localized_string(70449) % "Vivo" + return False, config.getLocalizedString(70449) % "Vivo" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url).data enc_data = scrapertools.find_single_match(data, 'data-stream="([^"]+)') dec_data = base64.b64decode(enc_data) - video_urls.append({'url':dec_data}) - return video_urls + videoUrls.append({'url':dec_data}) + return videoUrls diff --git a/servers/vk.py b/servers/vk.py index dd74f2e6..a02561ad 100755 --- a/servers/vk.py +++ b/servers/vk.py @@ -27,18 +27,18 @@ def test_video_exists(page_url): # Returns an array of possible video url's from the page_url -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url).data - matches = scrapertools.find_multiple_matches(data, '<source src="([^"]+)" type="video/(\w+)') + matches = scrapertools.findMultipleMatches(data, '<source src="([^"]+)" type="video/(\w+)') for media_url, ext in matches: calidad = scrapertools.find_single_match(media_url, '(\d+)\.%s' % ext) - video_urls.append({'res':calidad, 'type':ext, 'url':media_url}) - # video_urls.sort(key=lambda it: int(it[0].split("p ", 1)[0])) - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) - return video_urls + videoUrls.append({'res':calidad, 'type':ext, 'url':media_url}) + # videoUrls.sort(key=lambda it: int(it[0].split("p ", 1)[0])) + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) + return videoUrls def login(): @@ -47,8 +47,8 @@ def login(): return True ip_h = scrapertools.find_single_match(data, 'ip_h=(\w+)') lg_h = scrapertools.find_single_match(data, 'lg_h=(\w+)') - vkemail = config.get_setting("vkemail",server="vk") - vkpassword = config.get_setting("vkpassword",server="vk") + vkemail = config.getSetting("vkemail",server="vk") + vkpassword = config.getSetting("vkpassword",server="vk") post = {"act":"login","role":"al_frame","expire":"","recaptcha":"","captcha_sid":"","captcha_key":"","_origin":"https://vk.com","email":vkemail,"pass":vkpassword, "ip_h":ip_h, "lg_h":lg_h} url = "https://login.vk.com/?act=login" url = httptools.downloadpage(url, follow_redirects=False, only_headers=True, post=urllib.urlencode(post)).headers.get("location", "") diff --git a/servers/voe.py b/servers/voe.py index cfc780a9..72fa38c6 100644 --- a/servers/voe.py +++ b/servers/voe.py @@ -19,18 +19,18 @@ def test_video_exists(page_url): data = httptools.downloadpage(page_url).data if "File not found" in data or "File is no longer available" in data: - return False, config.get_localized_string(70449) % "VOE" + return False, config.getLocalizedString(70449) % "VOE" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.info("(page_url='%s')" % page_url) - video_urls = [] - video_srcs = scrapertools.find_multiple_matches(data, r"src: '([^']+)'") + videoUrls = [] + video_srcs = scrapertools.findMultipleMatches(data, r"src: '([^']+)'") if not video_srcs: bloque = scrapertools.find_single_match(data, "sources.*?\}") - video_srcs = scrapertools.find_multiple_matches(bloque, ': "([^"]+)') + video_srcs = scrapertools.findMultipleMatches(bloque, ': "([^"]+)') for url in video_srcs: - video_urls.append([" [Voe]", url]) + videoUrls.append([" [Voe]", url]) - return video_urls + return videoUrls diff --git a/servers/vshare.py b/servers/vshare.py index aecedb5b..bab58292 100644 --- a/servers/vshare.py +++ b/servers/vshare.py @@ -12,19 +12,19 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) response = httptools.downloadpage(page_url) if response.code != 200 or "No longer available!" in response.data: - return False, config.get_localized_string(70449) % "vshare" + return False, config.getLocalizedString(70449) % "vshare" else: return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url = " + page_url) headers = {"Referer":page_url} data = httptools.downloadpage(page_url, headers=headers).data flowplayer = re.search("url: [\"']([^\"']+)", data) if flowplayer: return [["FLV", flowplayer.group(1)]] - video_urls = [] + videoUrls = [] try: jsUnpack = jsunpack.unpack(data) logger.debug(jsUnpack) @@ -39,9 +39,9 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= videoSources = re.findall("<source[\s]+src=[\"'](?P<url>[^\"']+)[^>]+label=[\"'](?P<label>[^\"']+)", strResult) for url, label in videoSources: url += "|Referer=%s" %page_url - video_urls.append({'type':label, 'url':url}) - # video_urls.sort(key=lambda i: int(i[0].replace("p",""))) + videoUrls.append({'type':label, 'url':url}) + # videoUrls.sort(key=lambda i: int(i[0].replace("p",""))) except: url = scrapertools.find_single_match(data,'<source src="([^"]+)') - video_urls.append({'type':'mp4', 'url':url}) - return video_urls + videoUrls.append({'type':'mp4', 'url':url}) + return videoUrls diff --git a/servers/vudeo.py b/servers/vudeo.py index c8ad45f3..2bb22c0b 100644 --- a/servers/vudeo.py +++ b/servers/vudeo.py @@ -10,13 +10,13 @@ def test_video_exists(page_url): response = httptools.downloadpage(page_url) if response.code == 404: - return False, support.config.get_localized_string(70449) % "Vudeo" + return False, support.config.getLocalizedString(70449) % "Vudeo" else: data = response.data return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): global data logger.debug("url=" + page_url) - return support.get_jwplayer_mediaurl(data, 'Vudeo') + return support.get_jwplayer_mediaUrl(data, 'Vudeo') diff --git a/servers/vupplayer.py b/servers/vupplayer.py index 8ea795f6..423aff99 100644 --- a/servers/vupplayer.py +++ b/servers/vupplayer.py @@ -10,20 +10,20 @@ def test_video_exists(page_url): global data data = page.data if page.code == 404 or 'File is no longer available' in data or "We're sorry!" in data: - return False, config.get_localized_string(70449) % "VUP Player" + return False, config.getLocalizedString(70449) % "VUP Player" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) global data - matches = support.get_jwplayer_mediaurl(data, 'VUP') + matches = support.get_jwplayer_mediaUrl(data, 'VUP') if not matches: data = scrapertools.find_single_match(data, r"<script type='text/javascript'>(eval.function.p,a,c,k,e,.*?)\s*</script>") if data: from lib import jsunpack data = jsunpack.unpack(data) - matches = support.get_jwplayer_mediaurl(data, 'VUP') + matches = support.get_jwplayer_mediaUrl(data, 'VUP') return matches diff --git a/servers/vvvvid.py b/servers/vvvvid.py index 09368980..9a35e30f 100644 --- a/servers/vvvvid.py +++ b/servers/vvvvid.py @@ -28,17 +28,17 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data if "Not Found" in data or "File was deleted" in data: - return False, config.get_localized_string(70449) % "VVVVID" + return False, config.getLocalizedString(70449) % "VVVVID" else: page_url = page_url.replace("/show/","/#!show/") show_id = re.findall("#!show/([0-9]+)/", page_url)[0] name = re.findall(show_id + "/(.+?)/", page_url) - if not name: return False, config.get_localized_string(70449) % "VVVVID" + if not name: return False, config.getLocalizedString(70449) % "VVVVID" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): - video_urls = [] +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): + videoUrls = [] page_url = page_url.replace("/show/","/#!show/") @@ -62,6 +62,6 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= key_url = 'https://www.vvvvid.it/kenc?action=kt&conn_id=' + conn_id + '&url=' + embed_info.replace(':','%3A').replace('/','%2F') key = vvvvid_decoder.dec_ei(current_session.get(key_url, headers=headers, params=payload).json()['message']) - video_urls.append({'type':'m3u8', 'url':str(embed_info) + '?' + key}) + videoUrls.append({'type':'m3u8', 'url':str(embed_info) + '?' + key}) - return video_urls \ No newline at end of file + return videoUrls \ No newline at end of file diff --git a/servers/watchanimestream.py b/servers/watchanimestream.py index f363448b..438251ed 100644 --- a/servers/watchanimestream.py +++ b/servers/watchanimestream.py @@ -4,15 +4,15 @@ from core import scrapertools from platformcode import logger -def get_video_url(page_url, video_password): +def get_videoUrl(page_url, video_password): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] url = page_url.replace("/v/", "/api/source/") post = "r=&d=watchanimestream.net" data = httptools.downloadpage(url, post=post).data - matches = scrapertools.find_multiple_matches(data, '"file":"([^"]+)","label":"([^"]+)"') + matches = scrapertools.findMultipleMatches(data, '"file":"([^"]+)","label":"([^"]+)"') for url, quality in matches: url = url.replace("\/", "/") - video_urls.append({'res':quality, 'url':url}) - return video_urls + videoUrls.append({'res':quality, 'url':url}) + return videoUrls diff --git a/servers/watchvideo.py b/servers/watchvideo.py index 33b5a364..f094d466 100644 --- a/servers/watchvideo.py +++ b/servers/watchvideo.py @@ -11,18 +11,18 @@ def test_video_exists(page_url): global data data = httptools.downloadpage(page_url).data if "Not Found" in data or "File was deleted" in data: - return False, config.get_localized_string(70449) % "Watchvideo" + return False, config.getLocalizedString(70449) % "Watchvideo" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("url=" + page_url) - video_urls = [] - media_urls = scrapertools.find_multiple_matches(data, 'file:"([^"]+)"') + videoUrls = [] + media_urls = scrapertools.findMultipleMatches(data, 'file:"([^"]+)"') if not media_urls: packed = scrapertools.find_single_match(data, "text/javascript'>(.*?)\s*</script>") unpacked = jsunpack.unpack(packed) - media_urls = scrapertools.find_multiple_matches(unpacked, 'file:\s*"([^"]+)"') + media_urls = scrapertools.findMultipleMatches(unpacked, 'file:\s*"([^"]+)"') for media_url in media_urls: media_url += "|Referer=%s" %page_url @@ -31,8 +31,8 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= ext = "mp4" if "m3u8" in media_url: ext = "m3u8" - video_urls.append({'type':ext, 'url':media_url}) - # video_urls.reverse() - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) - return video_urls + videoUrls.append({'type':ext, 'url':media_url}) + # videoUrls.reverse() + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) + return videoUrls diff --git a/servers/wstream.py b/servers/wstream.py index 5d33f622..a98039ee 100644 --- a/servers/wstream.py +++ b/servers/wstream.py @@ -51,12 +51,12 @@ def test_video_exists(page_url): real_url = page_url for e in errorsStr: if e in data: - return False, config.get_localized_string(70449) % 'Wstream' + return False, config.getLocalizedString(70449) % 'Wstream' return True, "" # Returns an array of possible video url's from the page_url -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): def int_bckup_method(): global data,headers @@ -69,7 +69,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= data = httptools.downloadpage(page_url, follow_redirects=True, post={'g-recaptcha-response': captcha}, verify=False).data def getSources(data): - possibileSources = scrapertools.find_multiple_matches(data, r'sources:\s*(\[[^\]]+\])') + possibileSources = scrapertools.findMultipleMatches(data, r'sources:\s*(\[[^\]]+\])') for data in possibileSources: try: data = re.sub('([A-z]+):(?!/)', '"\\1":', data) @@ -81,28 +81,28 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= if not 'src' in key and 'file' in key: key['src'] = key['file'] if '?' in key['src']: key['src'] = key['src'].split('?')[0] - video_urls.append(['%s [%s]' % (key['type'].replace('video/', ''), key['label']), key['src'].replace('https', 'http') + '|' + _headers]) + videoUrls.append(['%s [%s]' % (key['type'].replace('video/', ''), key['label']), key['src'].replace('https', 'http') + '|' + _headers]) elif type(key) != dict: filetype = key.split('.')[-1] if '?' in filetype: filetype = filetype.split('?')[0] - video_urls.append([filetype, key.replace('https', 'http') + '|' + _headers]) + videoUrls.append([filetype, key.replace('https', 'http') + '|' + _headers]) else: if not 'src' in key and 'file' in key: key['src'] = key['file'] if '?' in key['src']: key['src'] = key['src'].split('?')[0] if key['src'].split('.')[-1] == 'mpd': pass - video_urls.append([key['src'].split('.')[-1], key['src'].replace('https', 'http') + '|' + _headers]) + videoUrls.append([key['src'].split('.')[-1], key['src'].replace('https', 'http') + '|' + _headers]) except: pass logger.debug("[Wstream] url=" + page_url) - video_urls = [] + videoUrls = [] global data, real_url, headers - sitekey = scrapertools.find_multiple_matches(data, """data-sitekey=['"] *([^"']+)""") + sitekey = scrapertools.findMultipleMatches(data, """data-sitekey=['"] *([^"']+)""") if sitekey: sitekey = sitekey[-1] - captcha = platformtools.show_recaptcha(sitekey, page_url) if sitekey else '' + captcha = platformtools.showRecaptcha(sitekey, page_url) if sitekey else '' - possibleParam = scrapertools.find_multiple_matches(data,r"""<input.*?(?:name=["']([^'"]+).*?value=["']([^'"]*)['"]>|>)""") + possibleParam = scrapertools.findMultipleMatches(data,r"""<input.*?(?:name=["']([^'"]+).*?value=["']([^'"]*)['"]>|>)""") if possibleParam and possibleParam[0][0]: post = {param[0]: param[1] for param in possibleParam if param[0]} if captcha: post['g-recaptcha-response'] = captcha @@ -113,7 +113,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= elif captcha or not sitekey: int_bckup_method() else: - platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(707434)) + platformtools.dialogOk(config.getLocalizedString(20000), config.getLocalizedString(707434)) return [] headers = [['Referer', real_url]] @@ -127,10 +127,10 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= else: getSources(data) - if not video_urls: - media_urls = scrapertools.find_multiple_matches(data, r'(http[^\s]*?\.(?:mp4|m3u8))') + if not videoUrls: + media_urls = scrapertools.findMultipleMatches(data, r'(http[^\s]*?\.(?:mp4|m3u8))') for media_url in media_urls: - video_urls.append([media_url.split('.')[-1] + " [Wstream] ", media_url + '|' + _headers]) - video_urls.sort(key=lambda x: x[0]) - return video_urls + videoUrls.append([media_url.split('.')[-1] + " [Wstream] ", media_url + '|' + _headers]) + videoUrls.sort(key=lambda x: x[0]) + return videoUrls diff --git a/servers/youdbox.py b/servers/youdbox.py index 517d9fe1..e2982f77 100644 --- a/servers/youdbox.py +++ b/servers/youdbox.py @@ -10,14 +10,14 @@ def test_video_exists(page_url): global data data = httptools.downloadpage(page_url).data if 'File was deleted' in data: - return False, config.get_localized_string(70449) % 'YouDbox' + return False, config.getLocalizedString(70449) % 'YouDbox' return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.info("(page_url='%s')" % page_url) global data - video_urls = [] + videoUrls = [] list = scrapertools.find_single_match(data, 'var [a-zA-Z0-9]+ = ([^\]]+)').replace('[', '').replace('"', '').replace('\\x', '').replace(',', ' ') list = list.split()[::-1] url ="" @@ -25,5 +25,5 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= decoded = codecs.decode(elem, "hex") url += decoded.decode("utf8") url = scrapertools.find_single_match(url, '<source src="([^"]+)"') - video_urls.append({'url':url}) - return video_urls + videoUrls.append({'url':url}) + return videoUrls diff --git a/servers/yourupload.py b/servers/yourupload.py index 9a95db4a..26db618e 100755 --- a/servers/yourupload.py +++ b/servers/yourupload.py @@ -11,14 +11,14 @@ def test_video_exists(page_url): data = httptools.downloadpage(page_url).data if "File was deleted" in data or "File not found" in data or 'og:video">' in data: - return False, config.get_localized_string(70449) % "Yourupload" + return False, config.getLocalizedString(70449) % "Yourupload" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] referer = {'Referer': page_url} url = scrapertools.find_single_match(data, '<meta property="og:video" content="([^"]+)"') @@ -39,6 +39,6 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= ext = url[-4:] media_url = url +"|Referer=%s" % page_url - video_urls.append({'type':ext, 'url':media_url}) + videoUrls.append({'type':ext, 'url':media_url}) - return video_urls + return videoUrls diff --git a/servers/youtube.py b/servers/youtube.py index b6705bf0..7c7f5721 100644 --- a/servers/youtube.py +++ b/servers/youtube.py @@ -11,28 +11,28 @@ def test_video_exists(page_url): data = httptools.downloadpage(page_url).data if "File was deleted" in data or "Video non disponibile" in data: - return False, config.get_localized_string(70449) % "YouTube" + return False, config.getLocalizedString(70449) % "YouTube" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): import xbmc from xbmcaddon import Addon logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] video_id = scrapertools.find_single_match(page_url, '(?:v=|embed/)([A-z0-9_-]{11})') - inputstream = platformtools.install_inputstream() + inputstream = platformtools.installInputstream() try: __settings__ = Addon(name) if inputstream: __settings__.setSetting('kodion.video.quality.mpd', 'true') else: __settings__.setSetting('kodion.video.quality.mpd', 'false') - # video_urls = [['con YouTube', 'plugin://plugin.video.youtube/play/?video_id=' + video_id ]] + # videoUrls = [['con YouTube', 'plugin://plugin.video.youtube/play/?video_id=' + video_id ]] except: path = xbmc.translatePath('special://home/addons/' + name) if filetools.exists(path): - if platformtools.dialog_yesno(config.get_localized_string(70784), config.get_localized_string(70818)): + if platformtools.dialogYesNo(config.getLocalizedString(70784), config.getLocalizedString(70818)): xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id":1, "method": "Addons.SetAddonEnabled", "params": { "addonid": "' + name + '", "enabled": true }}') else: return [['','']] else: @@ -47,10 +47,10 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= for stream in resolve(page_url): r,t = scrapertools.find_single_match(stream['title'], r'(\d+p)[^\(]+\(([^;]+)') if r: - video_urls.append({'type':t, 'res':r, 'url':stream['url']}) - # video_urls.sort(key=lambda it: int(it[0].split("p", 1)[0])) + videoUrls.append({'type':t, 'res':r, 'url':stream['url']}) + # videoUrls.sort(key=lambda it: int(it[0].split("p", 1)[0])) except: pass - return video_urls + return videoUrls diff --git a/servers/youwatch.py b/servers/youwatch.py index e5523a33..9280d170 100644 --- a/servers/youwatch.py +++ b/servers/youwatch.py @@ -9,17 +9,17 @@ def test_video_exists(page_url): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data if "File Not Found" in data: - return False, config.get_localized_string(70449) % "Youwatch" + return False, config.getLocalizedString(70449) % "Youwatch" url_redirect = scrapertools.find_single_match(data, '<iframe src="([^"]+)"') data = httptools.downloadpage(url_redirect).data if "We're sorry, this video is no longer available" in data: - return False, config.get_localized_string(70449) % "Youwatch" + return False, config.getLocalizedString(70449) % "Youwatch" return True, "" -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data @@ -27,10 +27,10 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= data = httptools.downloadpage(url_redirect).data url = scrapertools.find_single_match(data, '{file:"([^"]+)"') - video_url = "%s|Referer=%s" % (url, url_redirect) - video_urls = [{'typr':scrapertools.get_filename_from_url(url).split('.')[-1], 'url':video_url}] + videoUrl = "%s|Referer=%s" % (url, url_redirect) + videoUrls = [{'typr':scrapertools.get_filename_from_url(url).split('.')[-1], 'url':videoUrl}] - # for video_url in video_urls: - # logger.debug("%s - %s" % (video_url[0], video_url[1])) + # for videoUrl in videoUrls: + # logger.debug("%s - %s" % (videoUrl[0], videoUrl[1])) - return video_urls + return videoUrls diff --git a/servers/zippyshare.py b/servers/zippyshare.py index 32e25616..0de679ea 100755 --- a/servers/zippyshare.py +++ b/servers/zippyshare.py @@ -28,9 +28,9 @@ def test_video_exists(page_url): return result, message -def get_video_url(page_url, premium=False, user="", password="", video_password=""): +def get_videoUrl(page_url, premium=False, user="", password="", video_password=""): logger.debug("(page_url='%s')" % page_url) - video_urls = [] + videoUrls = [] data = httptools.downloadpage(page_url).data match = re.search('(.+)/v/(\w+)/file.html', page_url) @@ -40,8 +40,8 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= numbers = scrapertools.find_single_match(media_url, '\((.*?)\)') url = media_url.replace('" + (' + numbers + ') + "', '%s' %eval(numbers)) - mediaurl = '%s%s' % (domain, url) - extension = "." + mediaurl.split('.')[-1] - video_urls.append({'type':extension, 'url':mediaurl}) - # logger.debug("url=%s" %video_urls) - return video_urls + mediaUrl = '%s%s' % (domain, url) + extension = "." + mediaUrl.split('.')[-1] + videoUrls.append({'type':extension, 'url':mediaUrl}) + # logger.debug("url=%s" %videoUrls) + return videoUrls diff --git a/service.py b/service.py index a9f09252..44704481 100644 --- a/service.py +++ b/service.py @@ -16,7 +16,7 @@ try: xbmc.translatePath = xbmcvfs.translatePath except: pass -librerias = xbmc.translatePath(os.path.join(config.get_runtime_path(), 'lib')) +librerias = xbmc.translatePath(os.path.join(config.getRuntimePath(), 'lib')) sys.path.insert(0, librerias) from core import filetools, httptools, jsontools, scrapertools, db, support @@ -32,7 +32,7 @@ threads = [] def check_for_update(): - if config.get_setting("update", "videolibrary"): + if config.getSetting("update", "videolibrary"): videolibrary.update_videolibrary() @@ -48,16 +48,16 @@ def get_ua_list(): url = "http://omahaproxy.appspot.com/all?csv=1" try: - current_ver = config.get_setting("chrome_ua_version", default="").split(".") + current_ver = config.getSetting("chrome_ua_version", default="").split(".") data = httptools.downloadpage(url, alfa_s=True).data new_ua_ver = scrapertools.find_single_match(data, "win64,stable,([^,]+),") if not current_ver: - config.set_setting("chrome_ua_version", new_ua_ver) + config.setSetting("chrome_ua_version", new_ua_ver) else: for pos, val in enumerate(new_ua_ver.split('.')): if int(val) > int(current_ver[pos]): - config.set_setting("chrome_ua_version", new_ua_ver) + config.setSetting("chrome_ua_version", new_ua_ver) break except: logger.error(traceback.format_exc()) @@ -80,7 +80,7 @@ def join_threads(): class AddonMonitor(xbmc.Monitor): def __init__(self): - self.settings_pre = config.get_all_settings_addon() + self.settings_pre = config.getAllSettingsAddon() self.updaterPeriod = None self.update_setting = None @@ -92,17 +92,17 @@ class AddonMonitor(xbmc.Monitor): if not needsReload: # do not run videolibrary update if service needs to be reloaded # videolibrary wait update_wait = [0, 10000, 20000, 30000, 60000] - wait = update_wait[int(config.get_setting("update_wait", "videolibrary"))] + wait = update_wait[int(config.getSetting("update_wait", "videolibrary"))] if wait > 0: xbmc.sleep(wait) - if not config.get_setting("update", "videolibrary") == 2: + if not config.getSetting("update", "videolibrary") == 2: run_threaded(check_for_update, []) self.scheduleVideolibrary() super(AddonMonitor, self).__init__() def onSettingsChanged(self): logger.debug('settings changed') - settings_post = config.get_all_settings_addon() + settings_post = config.getAllSettingsAddon() # sometimes kodi randomly return default settings (rare but happens), this if try to workaround this if settings_post and settings_post.get('show_once', True): @@ -133,29 +133,32 @@ class AddonMonitor(xbmc.Monitor): schedule.clear('updater') self.scheduleUpdater() - if self.update_setting != config.get_setting("update", "videolibrary") or self.update_hour != config.get_setting("everyday_delay", "videolibrary") * 4: + if self.update_setting != config.getSetting("update", "videolibrary") or self.update_hour != config.getSetting("everyday_delay", "videolibrary") * 4: schedule.clear('videolibrary') self.scheduleVideolibrary() if self.settings_pre.get('elementum_on_seed') != settings_post.get('elementum_on_seed') and settings_post.get('elementum_on_seed'): - if not platformtools.dialog_yesno(config.get_localized_string(70805), config.get_localized_string(70806)): - config.set_setting('elementum_on_seed', False) + if not platformtools.dialogYesNo(config.getLocalizedString(70805), config.getLocalizedString(70806)): + config.setSetting('elementum_on_seed', False) if self.settings_pre.get("shortcut_key", '') != settings_post.get("shortcut_key", ''): xbmc.executebuiltin('Action(reloadkeymaps)') # backup settings - filetools.copy(os.path.join(config.get_data_path(), "settings.xml"), - os.path.join(config.get_data_path(), "settings.bak"), True) + filetools.copy(os.path.join(config.getDataPath(), "settings.xml"), + os.path.join(config.getDataPath(), "settings.bak"), True) logger.debug({k: self.settings_pre[k] for k in self.settings_pre if k in settings_post and self.settings_pre[k] != settings_post[k]}) - self.settings_pre = config.get_all_settings_addon() + self.settings_pre = config.getAllSettingsAddon() def onNotification(self, sender, method, data): logger.debug('METODO', method) if method == 'VideoLibrary.OnUpdate': xbmc_videolibrary.set_watched_on_kod(data) logger.debug('AGGIORNO') + if method == 'Player.OnAVStart': + logger.debug('CONTROLLO VIDEO IN PLAY') + xbmc_videolibrary.mark_auto_as_watched() def onScreensaverActivated(self): logger.debug('screensaver activated, un-scheduling screen-on jobs') @@ -166,9 +169,9 @@ class AddonMonitor(xbmc.Monitor): self.scheduleScreenOnJobs() def scheduleUpdater(self): - if not config.dev_mode(): + if not config.devMode(): updaterCheck() - self.updaterPeriod = config.get_setting('addon_update_timer') + self.updaterPeriod = config.getSetting('addon_update_timer') schedule.every(self.updaterPeriod).hours.do(updaterCheck).tag('updater') logger.debug('scheduled updater every ' + str(self.updaterPeriod) + ' hours') @@ -177,16 +180,16 @@ class AddonMonitor(xbmc.Monitor): schedule.every(1).day.do(get_ua_list) def scheduleVideolibrary(self): - self.update_setting = config.get_setting("update", "videolibrary") + self.update_setting = config.getSetting("update", "videolibrary") # 2= daily 3=daily and when kodi starts if self.update_setting == 2 or self.update_setting == 3: - self.update_hour = config.get_setting("everyday_delay", "videolibrary") * 4 + self.update_hour = config.getSetting("everyday_delay", "videolibrary") * 4 schedule.every().day.at(str(self.update_hour).zfill(2) + ':00').do(check_for_update).tag('videolibrary') logger.debug('scheduled videolibrary at ' + str(self.update_hour).zfill(2) + ':00') def scheduleScreenOnJobs(self): # pass - schedule.every().second.do(platformtools.viewmodeMonitor).tag('screenOn') + schedule.every().second.do(platformtools.viewModeMonitor).tag('screenOn') # schedule.every().second.do(torrent.elementum_monitor).tag('screenOn') def onDPMSActivated(self): @@ -202,27 +205,27 @@ if __name__ == "__main__": logger.info('Starting KoD service') # Test if all the required directories are created - config.verify_directories_created() + config.verifyDirectoriesCreated() import glob, xbmc from core import videolibrarytools, tmdb from core.item import Item - if config.get_setting('videolibrary_kodi') and config.get_setting('show_once'): + if config.getSetting('videolibrary_kodi') and config.getSetting('show_once'): nun_records, records = xbmc_videolibrary.execute_sql_kodi('select * from path where strPath = "' + - filetools.join(config.get_setting('videolibrarypath'), - config.get_setting('folder_tvshows')) + + filetools.join(config.getSetting('videolibrarypath'), + config.getSetting('folder_tvshows')) + '/" and strScraper<>"metadata.local"') if nun_records: videolibrarytools.convert_videolibrary() - if config.get_setting('autostart'): + if config.getSetting('autostart'): xbmc.executebuiltin('RunAddon(plugin.video.' + config.PLUGIN_NAME + ')') # check if the user has any connection problems from platformcode.checkhost import test_conn - run_threaded(test_conn, (True, not config.get_setting('resolver_dns'), True, [], [], True)) + run_threaded(test_conn, (True, not config.getSetting('resolver_dns'), True, [], [], True)) monitor = AddonMonitor() diff --git a/specials/classicsearch.py b/specials/classicsearch.py index fb47e9a8..540f1823 100644 --- a/specials/classicsearch.py +++ b/specials/classicsearch.py @@ -25,32 +25,32 @@ from core.support import typo, thumb from specials.search import channel_selections, set_context, save_search info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json -def_lang = info_language[config.get_setting("info_language", "videolibrary")] +def_lang = info_language[config.getSetting("info_language", "videolibrary")] def new_search(item): logger.debug() - temp_search_file = config.get_temp_file('temp-search') + temp_search_file = config.getTempFile('temp-search') if filetools.isfile(temp_search_file): filetools.remove(temp_search_file) itemlist = [] - if config.get_setting('last_search'): - last_search = channeltools.get_channel_setting('Last_searched', 'search', '') + if config.getSetting('last_search'): + last_search = channeltools.getChannelSetting('Last_searched', 'search', '') else: last_search = '' if item.search_text: searched_text = item.search_text else: - searched_text = platformtools.dialog_input(default=last_search, heading='') + searched_text = platformtools.dialogInput(default=last_search, heading='') save_search(searched_text) if not searched_text: return - channeltools.set_channel_setting('Last_searched', searched_text, 'search') + channeltools.setChannelSetting('Last_searched', searched_text, 'search') searched_text = searched_text.replace("+", " ") if item.mode == 'person': @@ -116,7 +116,7 @@ def channel_search(item): item.text = item.infoLabels['title'].split(' - ')[0] item.title = item.text - temp_search_file = config.get_temp_file('temp-search') + temp_search_file = config.getTempFile('temp-search') if filetools.isfile(temp_search_file): itemlist = [] f = filetools.read(temp_search_file) @@ -135,13 +135,13 @@ def channel_search(item): searching += channel_list searching_titles += channel_titles cnt = 0 - progress = platformtools.dialog_progress(config.get_localized_string(30993) % item.title, config.get_localized_string(70744) % len(channel_list) + '\n' + ', '.join(searching_titles)) - config.set_setting('tmdb_active', False) + progress = platformtools.dialogProgress(config.getLocalizedString(30993) % item.title, config.getLocalizedString(70744) % len(channel_list) + '\n' + ', '.join(searching_titles)) + config.setSetting('tmdb_active', False) search_action_list = [] module_dict = {} for ch in channel_list: try: - module = platformtools.channel_import(ch) + module = platformtools.channelImport(ch) mainlist = getattr(module, 'mainlist')(Item(channel=ch, global_search=True)) module_dict[ch] = module @@ -184,20 +184,20 @@ def channel_search(item): cnt += 1 searching_titles.remove(searching_titles[searching.index(channel)]) searching.remove(channel) - progress.update(old_div(((total_search_actions - len(search_action_list)) * 100), total_search_actions), config.get_localized_string(70744) % str(len(channel_list) - cnt) + '\n' + ', '.join(searching_titles)) + progress.update(old_div(((total_search_actions - len(search_action_list)) * 100), total_search_actions), config.getLocalizedString(70744) % str(len(channel_list) - cnt) + '\n' + ', '.join(searching_titles)) progress.close() cnt = 0 - progress = platformtools.dialog_progress(config.get_localized_string(30993) % item.title, config.get_localized_string(60295) + '\n' + config.get_localized_string(60293)) + progress = platformtools.dialogProgress(config.getLocalizedString(30993) % item.title, config.getLocalizedString(60295) + '\n' + config.getLocalizedString(60293)) - config.set_setting('tmdb_active', True) + config.setSetting('tmdb_active', True) # res_count = 0 for key, value in ch_list.items(): ch_name = channel_titles[channel_list.index(key)] grouped = list() cnt += 1 - progress.update(old_div((cnt * 100), len(ch_list)), config.get_localized_string(60295)) + progress.update(old_div((cnt * 100), len(ch_list)), config.getLocalizedString(60295)) for it in value: if it.channel == item.channel: @@ -205,8 +205,8 @@ def channel_search(item): if it in valid: continue if mode == 'all' or (it.contentType and mode == it.contentType): - if config.get_setting('result_mode') != 0: - if config.get_localized_string(30992) not in it.title: + if config.getSetting('result_mode') != 0: + if config.getLocalizedString(30992) not in it.title: it.title += typo(ch_name,'_ [] color kod bold') results.append(it) else: @@ -219,11 +219,11 @@ def channel_search(item): if not grouped: continue # to_temp[key] = grouped - if config.get_setting('result_mode') == 0: - if not config.get_setting('unify'): + if config.getSetting('result_mode') == 0: + if not config.getSetting('unify'): title = typo(ch_name,'bold') + typo(str(len(grouped)), '_ [] color kod bold') else: - title = typo('%s %s' % (len(grouped), config.get_localized_string(70695)), 'bold') + title = typo('%s %s' % (len(grouped), config.getLocalizedString(70695)), 'bold') # res_count += len(grouped) plot='' @@ -235,8 +235,8 @@ def channel_search(item): progress.close() # "All Together" and movie mode -> search servers - if config.get_setting('result_mode') == 1 and mode == 'movie': - progress = platformtools.dialog_progress(config.get_localized_string(30993) % item.title, config.get_localized_string(60683)) + if config.getSetting('result_mode') == 1 and mode == 'movie': + progress = platformtools.dialogProgress(config.getLocalizedString(30993) % item.title, config.getLocalizedString(60683)) valid_servers = [] with futures.ThreadPoolExecutor(max_workers=set_workers()) as executor: c_results = [executor.submit(get_servers, v, module_dict) for v in valid] @@ -255,15 +255,15 @@ def channel_search(item): # send_to_temp(to_temp) results = sorted(results, key=lambda it: it.title) - results_statistic = config.get_localized_string(59972) % (item.title, time.time() - start) + results_statistic = config.getLocalizedString(59972) % (item.title, time.time() - start) if mode == 'all': results.insert(0, Item(title=typo(results_statistic, 'color kod bold'), thumbnail=thumb('search'))) else: if not valid: - valid.append(Item(title=config.get_localized_string(60347), thumbnail=thumb('nofolder'))) + valid.append(Item(title=config.getLocalizedString(60347), thumbnail=thumb('nofolder'))) valid.insert(0, Item(title=typo(results_statistic, 'color kod bold'), thumbnail=thumb('search'))) - results.insert(0, Item(title=typo(config.get_localized_string(30025), 'color kod bold'), thumbnail=thumb('search'))) + results.insert(0, Item(title=typo(config.getLocalizedString(30025), 'color kod bold'), thumbnail=thumb('search'))) # logger.debug(results_statistic) itlist = valid + results @@ -285,7 +285,7 @@ def get_channel_results(item, module_dict, search_action): try: results.extend(module.search(search_action, item.text)) if len(results) == 1: - if not results[0].action or config.get_localized_string(70006).lower() in results[0].title.lower(): + if not results[0].action or config.getLocalizedString(70006).lower() in results[0].title.lower(): results.clear() if item.mode != 'all': for elem in results: @@ -294,14 +294,14 @@ def get_channel_results(item, module_dict, search_action): tmdb.set_infoLabels_item(elem) if elem.infoLabels['tmdb_id'] == searched_id: elem.from_channel = ch - if not config.get_setting('unify'): + if not config.getSetting('unify'): elem.title += ' [%s]' % ch valid.append(elem) # if len(results) < 0 and len(results) < max_results and item.mode != 'all': # # if len(results) == 1: - # if not results[0].action or config.get_localized_string(30992).lower() in results[0].title.lower(): + # if not results[0].action or config.getLocalizedString(30992).lower() in results[0].title.lower(): # return [ch, []] # # results = get_info(results) @@ -353,7 +353,7 @@ def get_channels(item): list_cat[n] = 'tvshow' if item.mode == 'all' or (item.mode in list_cat): - if config.get_setting("include_in_global_search", channel) and ch_param.get("active", False): + if config.getSetting("include_in_global_search", channel) and ch_param.get("active", False): channels_list.append(channel) title_list.append(ch_param.get('title', channel)) @@ -361,11 +361,11 @@ def get_channels(item): def settings(item): - return platformtools.show_channel_settings(caption=config.get_localized_string(59993)) + return platformtools.showChannelSettings(caption=config.getLocalizedString(59993)) def set_workers(): - workers = config.get_setting('thread_number') if config.get_setting('thread_number') > 0 else None + workers = config.getSetting('thread_number') if config.getSetting('thread_number') > 0 else None return workers @@ -396,7 +396,7 @@ def years_menu(item): mode = item.mode.replace('show', '') par_year = 'primary_release_year' - thumb = thumb('movie_year') + thumb = support.thumb('movie_year') if mode != 'movie': par_year = 'first_air_date_year' @@ -413,7 +413,7 @@ def years_menu(item): itemlist.append(Item(channel=item.channel, title=str(year), action='discover_list', discovery=discovery, mode=item.mode, year_=str(year), thumbnail=thumb)) itemlist.reverse() - itemlist.append(Item(channel=item.channel, title=typo(config.get_localized_string(70745),'color kod bold'), url='', + itemlist.append(Item(channel=item.channel, title=typo(config.getLocalizedString(70745),'color kod bold'), url='', action="year_cus", mode=item.mode, par_year=par_year)) return itemlist @@ -422,8 +422,8 @@ def years_menu(item): def year_cus(item): mode = item.mode.replace('show', '') - heading = config.get_localized_string(70042) - year = platformtools.dialog_numeric(0, heading, default="") + heading = config.getLocalizedString(70042) + year = platformtools.dialogNumeric(0, heading, default="") item.discovery = {'url': 'discover/%s' % mode, 'page': '1', '%s' % item.par_year: '%s' % year, 'sort_by': 'popularity.desc', 'language': def_lang} @@ -475,9 +475,9 @@ def actor_list(item): itemlist.append(Item(channel=item.channel, title=title, action='discover_list', cast_='cast', discovery=discovery, thumbnail=thumbnail, plot=plot, page=1)) - if len(results) >= config.get_setting('pagination', default=20): + if len(results) >= config.getSetting('pagination', default=20): next_ = item.page + 1 - itemlist.append(Item(channel=item.channel, title=typo(config.get_localized_string(90006),'bold color kod'), action='actor_list', + itemlist.append(Item(channel=item.channel, title=typo(config.getLocalizedString(90006),'bold color kod'), action='actor_list', page=next_, thumbnail=thumbnail, searched_text=item.searched_text)) return itemlist @@ -512,11 +512,11 @@ def discover_list(item): year = scrapertools.find_single_match(release, r'(\d{4})') if not item.cast_ or (item.cast_ and (int(year) <= int(datetime.datetime.today().year))): - if config.get_setting('new_search'): + if config.getSetting('new_search'): new_item = Item(channel='globalsearch', title=title, infoLabels=elem, - action='Search', text=title, + action='new_search', text=title, thumbnail=thumbnail, fanart=fanart, - context='', mode='search', type = mode, contentType=mode, + context='', mode = 'search/' + mode, contentType=mode, release_date=year, folder = False) else: new_item = Item(channel='search', title=title, infoLabels=elem, @@ -538,42 +538,17 @@ def discover_list(item): itemlist.sort(key=lambda it: int(it.release_date), reverse=True) return itemlist - elif config.get_setting('pagination', default=20): + elif config.getSetting('pagination', default=20): if item.discovery: page = item.discovery['page'] = int(item.discovery['page']) + 1 else: - page = item.page + 1 + page = int(item.page) + 1 support.nextPage(itemlist, item, page=page, total_pages=total_pages) return itemlist -def from_context(item): - logger.debug() - select = channel_selections(item) - - if not select: - return - - if 'infoLabels' in item and 'mediatype' in item.infoLabels: - item.mode = item.infoLabels['mediatype'] - else: - return - - if config.get_setting('new_search'): - from specials import globalsearch - if item.infoLabels['tmdb_id']: - item.type = item.mode - item.mode = 'search' - return globalsearch.Search(item) - - if 'list_type' not in item: - if 'wanted' in item: - item.title = item.wanted - return channel_search(item) - - return discover_list(item) def get_from_temp(item): @@ -587,7 +562,7 @@ def get_from_temp(item): results = [Item().fromurl(elem) for elem in item.itemlist[prevp:nextp]] if nextp < nTotal: - results.append(Item(channel='search', title=typo(config.get_localized_string(30992), 'bold color kod'), + results.append(Item(channel='search', title=typo(config.getLocalizedString(30992), 'bold color kod'), action='get_from_temp', itemlist=item.itemlist, page=item.page + 1, nextPage=True)) tmdb.set_infoLabels_itemlist(results, True) diff --git a/specials/community.py b/specials/community.py index 02be7402..2dd5c690 100644 --- a/specials/community.py +++ b/specials/community.py @@ -13,14 +13,14 @@ from core import servertools info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json try: - lang = info_language[config.get_setting("info_language", "videolibrary")] + lang = info_language[config.getSetting("info_language", "videolibrary")] except: lang = 'it' defpage = ["", "20", "40", "60", "80", "100"] -defp = defpage[config.get_setting('pagination', 'community')] +defp = defpage[config.getSetting('pagination', 'community')] disable_pagination = False -show_seasons = config.get_setting('show_seasons', 'community') +show_seasons = config.getSetting('show_seasons', 'community') tmdb_api = 'a1ab8b8669da03637a4b98fa39c39228' @@ -28,7 +28,7 @@ tmdb_api = 'a1ab8b8669da03637a4b98fa39c39228' def mainlist(item): logger.debug() - path = filetools.join(config.get_data_path(), 'community_channels.json') + path = filetools.join(config.getDataPath(), 'community_channels.json') if not filetools.exists(path): with open(path, "w") as file: file.write('{"channels":{}}') @@ -42,13 +42,13 @@ def show_channels(item): itemlist = [] # add context menu - context = [{"title": config.get_localized_string(50005), "action": "remove_channel", "channel": "community"}] + context = [{"title": config.getLocalizedString(50005), "action": "remove_channel", "channel": "community"}] # read json json = load_and_check(item) itemlist.append(Item(channel=item.channel, - title=support.typo(config.get_localized_string(70676), 'bold color kod'), + title=support.typo(config.getLocalizedString(70676), 'bold color kod'), action='add_channel', thumbnail=support.thumb('add'))) @@ -240,7 +240,7 @@ def movies(item, json='', key='', itemlist=[]): itemlist.sort(key=lambda x: x.title, reverse=False) if Pagination and len(itemlist) >= Pagination: if inspect.stack()[1][3] != 'get_newest': - item.title = support.typo(config.get_localized_string(30992), 'color kod bold') + item.title = support.typo(config.getLocalizedString(30992), 'color kod bold') item.page = pag + 1 item.thumbnail = support.thumb() itemlist.append(item) @@ -258,7 +258,7 @@ def get_seasons(item): return show_menu(item) for option in json: infoLabels['season'] = option['season'] - title = config.get_localized_string(60027) % option['season'] + title = config.getLocalizedString(60027) % option['season'] extra = set_extra_values(item, option, item.path) # url = relative('link', option, item.path) @@ -380,7 +380,7 @@ def episodes(item, json='', key='', itemlist=[]): itemlist = [] for season in season_list: itemlist.append(Item(channel=item.channel, - title=set_title(config.get_localized_string(60027) % season), + title=set_title(config.getLocalizedString(60027) % season), fulltitle=itm.fulltitle, show=itm.show, thumbnails=itm.thumbnails, @@ -395,7 +395,7 @@ def episodes(item, json='', key='', itemlist=[]): elif defp and inspect.stack()[1][3] not in ['get_seasons'] and not item.disable_pagination: if Pagination and len(itemlist) >= Pagination: if inspect.stack()[1][3] != 'get_newest': - item.title = support.typo(config.get_localized_string(30992), 'color kod bold') + item.title = support.typo(config.getLocalizedString(30992), 'color kod bold') item.page = pag + 1 item.thumbnail = support.thumb() itemlist.append(item) @@ -611,7 +611,7 @@ def submenu(item, json, key, itemlist=[], filter_list=[]): itemlist.append(res.result()) if Pagination and len(itemlist) >= Pagination: - item.title = support.typo(config.get_localized_string(30992), 'color kod bold') + item.title = support.typo(config.getLocalizedString(30992), 'color kod bold') item.page = pag + 1 item.thumb = item.thumbnail item.thumbnail = support.thumb() @@ -698,7 +698,7 @@ def load_json(item, no_order=False): # Load Channels json and check that the paths and channel titles are correct def load_and_check(item): logger.debug() - path = filetools.join(config.get_data_path(), 'community_channels.json') + path = filetools.join(config.getDataPath(), 'community_channels.json') file = open(path, "r") json = jsontools.load(file.read()) @@ -834,7 +834,7 @@ def pagination(item, itemlist=[]): Item(channel=item.channel, action='pagination', contentType=item.contentType, - title=support.typo(config.get_localized_string(30992), 'color kod bold'), + title=support.typo(config.getLocalizedString(30992), 'color kod bold'), fulltitle=item.fulltitle, show=item.show, url=item.url, @@ -851,12 +851,12 @@ def add_channel(item): logger.debug() channel_to_add = {} json_file = '' - result = platformtools.dialog_select(config.get_localized_string(70676), - [config.get_localized_string(70678), config.get_localized_string(70679)]) + result = platformtools.dialogSelect(config.getLocalizedString(70676), + [config.getLocalizedString(70678), config.getLocalizedString(70679)]) if result == -1: return if result == 0: - file_path = xbmcgui.Dialog().browseSingle(1, config.get_localized_string(70680), 'files') + file_path = xbmcgui.Dialog().browseSingle(1, config.getLocalizedString(70680), 'files') try: channel_to_add['path'] = file_path channel_to_add['url'] = file_path @@ -866,7 +866,7 @@ def add_channel(item): pass elif result == 1: - url = platformtools.dialog_input("", config.get_localized_string(70681), False) + url = platformtools.dialogInput("", config.getLocalizedString(70681), False) try: if url[:4] != 'http': url = 'http://' + url @@ -878,12 +878,12 @@ def add_channel(item): if len(json_file) == 0: return if "episodes_list" in json_file: - platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(70682)) + platformtools.dialogOk(config.getLocalizedString(20000), config.getLocalizedString(70682)) return channel_to_add['channel_name'] = json_file['channel_name'] if 'thumbnail' in json_file: channel_to_add['thumbnail'] = json_file['thumbnail'] if 'fanart' in json_file: channel_to_add['fanart'] = json_file['fanart'] - path = filetools.join(config.get_data_path(), 'community_channels.json') + path = filetools.join(config.getDataPath(), 'community_channels.json') community_json = open(path, "r") community_json = jsontools.load(community_json.read()) @@ -896,18 +896,18 @@ def add_channel(item): file.write(jsontools.dump(community_json)) file.close() - platformtools.dialog_notification(config.get_localized_string(20000), - config.get_localized_string(70683) % json_file['channel_name']) + platformtools.dialogNotification(config.getLocalizedString(20000), + config.getLocalizedString(70683) % json_file['channel_name']) import xbmc xbmc.sleep(1000) - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() return def remove_channel(item): logger.debug() - path = filetools.join(config.get_data_path(), 'community_channels.json') + path = filetools.join(config.getDataPath(), 'community_channels.json') community_json = open(path, "r") community_json = jsontools.load(community_json.read()) @@ -919,7 +919,7 @@ def remove_channel(item): file.write(jsontools.dump(community_json)) file.close() - platformtools.dialog_notification(config.get_localized_string(20000), - config.get_localized_string(70684) % to_delete) - platformtools.itemlist_refresh() + platformtools.dialogNotification(config.getLocalizedString(20000), + config.getLocalizedString(70684) % to_delete) + platformtools.itemlistRefresh() return diff --git a/specials/downloads.py b/specials/downloads.py index 62e10d3f..6a815629 100644 --- a/specials/downloads.py +++ b/specials/downloads.py @@ -27,12 +27,12 @@ ky = '0xFFDAAB65' STATUS_COLORS = {0: '', 1: '', 2: kg, 3: kr, 4: kb} STATUS_CODES = type("StatusCode", (), {"stoped": 0, "canceled": 1, "completed": 2, "error": 3, "downloading": 4 }) -DOWNLOAD_LIST_PATH = config.get_setting("downloadlistpath") -DOWNLOAD_PATH = config.get_setting("downloadpath") -STATS_FILE = filetools.join(config.get_data_path(), "servers.json") +DOWNLOAD_LIST_PATH = config.getSetting("downloadlistpath") +DOWNLOAD_PATH = config.getSetting("downloadpath") +STATS_FILE = filetools.join(config.getDataPath(), "servers.json") -FOLDER_MOVIES = config.get_setting("folder_movies") -FOLDER_TVSHOWS = config.get_setting("folder_tvshows") +FOLDER_MOVIES = config.getSetting("folder_movies") +FOLDER_TVSHOWS = config.getSetting("folder_tvshows") TITLE_FILE = "[COLOR %s]| %i%% |[/COLOR] - %s" TITLE_TVSHOW = "[COLOR %s]| %i%% |[/COLOR] - %s [%s]" extensions_list = ['.aaf', '.3gp', '.asf', '.avi', '.flv', '.mpeg', '.m1v', '.m2v', '.m4v', '.mkv', '.mov', '.mpg', '.mpe', '.mp4', '.ogg', '.wmv'] @@ -92,43 +92,43 @@ def mainlist(item): # If there is any completed if 2 in estados: - itemlist.insert(0, Item(channel=item.channel, action="clean_ready", title=config.get_localized_string(70218), + itemlist.insert(0, Item(channel=item.channel, action="clean_ready", title=config.getLocalizedString(70218), contentType=item.contentType, contentChannel=item.contentChannel, thumbnail=thumb('delete'), contentSerieName=item.contentSerieName, text_color=STATUS_COLORS[STATUS_CODES.completed])) # If there is any error if 3 in estados: - itemlist.insert(0, Item(channel=item.channel, action="restart_error", title=config.get_localized_string(70219), + itemlist.insert(0, Item(channel=item.channel, action="restart_error", title=config.getLocalizedString(70219), contentType=item.contentType, contentChannel=item.contentChannel, thumbnail=thumb('update'), contentSerieName=item.contentSerieName, text_color=STATUS_COLORS[STATUS_CODES.error])) # If there is any pending if 1 in estados or 0 in estados: - itemlist.insert(0, Item(channel=item.channel, action="download_all", title=support.typo(config.get_localized_string(70220),'bold'), + itemlist.insert(0, Item(channel=item.channel, action="download_all", title=support.typo(config.getLocalizedString(70220),'bold'), contentType=item.contentType, contentChannel=item.contentChannel, thumbnail=thumb('download'), contentSerieName=item.contentSerieName)) if len(itemlist): - itemlist.insert(0, Item(channel=item.channel, action="clean_all", title=support.typo(config.get_localized_string(70221),'bold'), + itemlist.insert(0, Item(channel=item.channel, action="clean_all", title=support.typo(config.getLocalizedString(70221),'bold'), contentType=item.contentType, contentChannel=item.contentChannel, thumbnail=thumb('delete'), contentSerieName=item.contentSerieName)) # if there's at least one downloading if 4 in estados: - itemlist.insert(0, Item(channel=item.channel, action="stop_all", title=config.get_localized_string(60222), + itemlist.insert(0, Item(channel=item.channel, action="stop_all", title=config.getLocalizedString(60222), contentType=item.contentType, contentChannel=item.contentChannel, contentSerieName=item.contentSerieName, thumbnail=thumb('stop'), text_color=STATUS_COLORS[STATUS_CODES.downloading])) - if not item.contentType == "tvshow" and config.get_setting("browser") == True: - itemlist.insert(0, Item(channel=item.channel, action="browser", title=support.typo(config.get_localized_string(70222),'bold'), thumbnail=thumb('search'), url=DOWNLOAD_PATH)) + if not item.contentType == "tvshow" and config.getSetting("browser") == True: + itemlist.insert(0, Item(channel=item.channel, action="browser", title=support.typo(config.getLocalizedString(70222),'bold'), thumbnail=thumb('search'), url=DOWNLOAD_PATH)) if not item.contentType == "tvshow": - itemlist.append(Item(channel='shortcuts', action="SettingOnPosition", category=6, setting=0, title= support.typo(config.get_localized_string(70288),'bold color kod'), thumbnail=thumb('setting'))) + itemlist.append(Item(channel='shortcuts', action="SettingOnPosition", category=6, setting=0, title= support.typo(config.getLocalizedString(70288),'bold color kod'), thumbnail=thumb('setting'))) # Reload if estados: - itemlist.insert(0, Item(channel=item.channel, action="reload", title= support.typo(config.get_localized_string(70008),'bold color kod'), + itemlist.insert(0, Item(channel=item.channel, action="reload", title= support.typo(config.getLocalizedString(70008),'bold color kod'), contentType=item.contentType, contentChannel=item.contentChannel, thumbnail=thumb('update'), contentSerieName=item.contentSerieName)) @@ -136,8 +136,8 @@ def mainlist(item): def settings(item): - ret = platformtools.show_channel_settings(caption=config.get_localized_string(70224)) - platformtools.itemlist_refresh() + ret = platformtools.showChannelSettings(caption=config.getLocalizedString(70224)) + platformtools.itemlistRefresh() return ret @@ -148,38 +148,38 @@ def browser(item): for file in filetools.listdir(item.url): if file == "list": continue if filetools.isdir(filetools.join(item.url, file)): - itemlist.append(Item(channel=item.channel, title=file, action=item.action, url=filetools.join(item.url, file), context=[{ 'title': config.get_localized_string(30037), 'channel': 'downloads', 'action': "del_dir"}])) + itemlist.append(Item(channel=item.channel, title=file, action=item.action, url=filetools.join(item.url, file), context=[{ 'title': config.getLocalizedString(30037), 'channel': 'downloads', 'action': "del_dir"}])) else: if not item.infoLabels: infoLabels = {"mediatype":"video"} else: infoLabels = item.infoLabels - itemlist.append(Item(channel=item.channel, title=file, action="play", infoLabels=infoLabels, url=filetools.join(item.url, file), context=[{ 'title': config.get_localized_string(30039), 'channel': 'downloads', 'action': "del_file"}])) + itemlist.append(Item(channel=item.channel, title=file, action="play", infoLabels=infoLabels, url=filetools.join(item.url, file), context=[{ 'title': config.getLocalizedString(30039), 'channel': 'downloads', 'action': "del_file"}])) return itemlist def del_file(item): - ok = platformtools.dialog_yesno(config.get_localized_string(30039),config.get_localized_string(30040) % item.title) + ok = platformtools.dialogYesNo(config.getLocalizedString(30039),config.getLocalizedString(30040) % item.title) if ok: filetools.remove(item.url) xbmc.sleep(100) - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() def del_dir(item): - ok = platformtools.dialog_yesno(config.get_localized_string(30037),config.get_localized_string(30038)) + ok = platformtools.dialogYesNo(config.getLocalizedString(30037),config.getLocalizedString(30038)) if ok: filetools.rmdirtree(item.url) xbmc.sleep(100) - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() def clean_all(item): logger.debug() stop_all() removeFiles = False - if platformtools.dialog_yesno(config.get_localized_string(20000), config.get_localized_string(30300)): + if platformtools.dialogYesNo(config.getLocalizedString(20000), config.getLocalizedString(30300)): removeFiles = True for File in sorted(filetools.listdir(DOWNLOAD_LIST_PATH)): @@ -194,11 +194,11 @@ def clean_all(item): filetools.rmdir(dirName) xbmc.sleep(100) - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() def reload(item): - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() def stop_all(item=None): @@ -216,7 +216,7 @@ def stop_all(item=None): update_json(filetools.join(DOWNLOAD_LIST_PATH, fichero), {"downloadStatus": STATUS_CODES.stoped}) xbmc.sleep(300) if item: - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() def clean_ready(item): @@ -228,7 +228,7 @@ def clean_ready(item): if download_item.downloadStatus == STATUS_CODES.completed: filetools.remove(filetools.join(DOWNLOAD_LIST_PATH, fichero)) - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() def restart_error(item): @@ -246,14 +246,14 @@ def restart_error(item): update_json(item.path, {"downloadStatus": STATUS_CODES.stoped, "downloadComplete": 0, "downloadProgress": 0}) - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() def download_all(item): time.sleep(0.5) item.action = "download_all_background" xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + item.tourl() + ")") - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() def download_all_background(item): @@ -265,7 +265,7 @@ def download_all_background(item): if not item.contentType == "tvshow" or ( item.contentSerieName == download_item.contentSerieName and item.contentChannel == download_item.contentChannel): if download_item.downloadStatus in [STATUS_CODES.stoped, STATUS_CODES.canceled]: res = start_download(download_item) - # platformtools.itemlist_refresh() + # platformtools.itemlistRefresh() # If canceled, we stop if res == STATUS_CODES.canceled: break @@ -277,9 +277,9 @@ def menu(item): else: servidor = "Auto" # Options available for the menu - op = [config.get_localized_string(70225), config.get_localized_string(70226), config.get_localized_string(70227), - config.get_localized_string(30165) % (servidor.capitalize()), config.get_localized_string(60220), - config.get_localized_string(60221)] + op = [config.getLocalizedString(70225), config.getLocalizedString(70226), config.getLocalizedString(70227), + config.getLocalizedString(30165) % (servidor.capitalize()), config.getLocalizedString(60220), + config.getLocalizedString(60221)] opciones = [] @@ -310,7 +310,7 @@ def menu(item): opciones.append(op[1]) # Remove from the list # Show Dialog - seleccion = platformtools.dialog_select(config.get_localized_string(30163), opciones) + seleccion = platformtools.dialogSelect(config.getLocalizedString(30163), opciones) logger.debug('SELECTION: '+ op[seleccion]) # -1 is cancel @@ -322,7 +322,7 @@ def menu(item): if item.TorrentName: torrent.elementum_actions('delete', item.TorrentName) else: - if platformtools.dialog_yesno(config.get_localized_string(20000), config.get_localized_string(30300)): + if platformtools.dialogYesNo(config.getLocalizedString(20000), config.getLocalizedString(30300)): filetools.remove(filetools.join(DOWNLOAD_PATH, item.downloadFilename)) # Start Download @@ -355,7 +355,7 @@ def menu(item): if os.path.splitext(f)[-1] in extensions_list: videos.append(f) if len(videos) > 1: - selection = platformtools.dialog_select(config.get_localized_string(30034), files) + selection = platformtools.dialogSelect(config.getLocalizedString(30034), files) else: selection = 0 xbmc.executebuiltin('PlayMedia(' + filetools.join(path, files[selection]) + ',resume)') @@ -363,7 +363,7 @@ def menu(item): xbmc.executebuiltin('PlayMedia(' + path + ',resume)') if opciones[seleccion] != op[5]: - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() def move_to_libray(item): @@ -372,12 +372,12 @@ def move_to_libray(item): if item.contentType == 'movie': FOLDER = FOLDER_MOVIES path_title = "%s [%s]" % (item.contentTitle.strip() if item.contentTitle else item.fulltitle.strip() , item.infoLabels['IMDBNumber']) - move_path = filetools.join(config.get_videolibrary_path(), FOLDER, path_title) + move_path = filetools.join(config.getVideolibraryPath(), FOLDER, path_title) else: FOLDER = FOLDER_TVSHOWS path_title = os.path.dirname(item.downloadFilename) - move_path = filetools.join(config.get_videolibrary_path(), FOLDER) + move_path = filetools.join(config.getVideolibraryPath(), FOLDER) download_path = filetools.join(DOWNLOAD_PATH, item.downloadFilename) library_path = filetools.join(move_path, *filetools.split(item.downloadFilename)) @@ -411,7 +411,7 @@ def move_to_libray(item): filetools.rmdir(filetools.dirname(download_path)) name = item.contentTitle if item.contentType == 'movie' else str(item.infoLabels['season']) + 'x' + str(item.infoLabels['episode']).zfill(2) - list_item = filetools.listdir(filetools.join(config.get_videolibrary_path(), FOLDER, path_title)) + list_item = filetools.listdir(filetools.join(config.getVideolibraryPath(), FOLDER, path_title)) clean = False for File in list_item: @@ -420,13 +420,13 @@ def move_to_libray(item): if filename.startswith(name) and (filename.endswith('.strm') or (filename.endswith('.json') and 'downloads' not in filename)): clean = True - file_path = filetools.join(config.get_setting("videolibrarypath"), FOLDER, path_title, File) + file_path = filetools.join(config.getSetting("videolibrarypath"), FOLDER, path_title, File) logger.debug('Delete File:', str(file_path)) filetools.remove(file_path) if file_path.endswith('.strm'): file_strm_path = file_path - if config.is_xbmc() and config.get_setting("videolibrary_kodi"): + if config.is_xbmc() and config.getSetting("videolibrary_kodi"): from platformcode import xbmc_videolibrary if clean == True: path_list = [file_strm_path] @@ -554,12 +554,12 @@ def sort_method(item): quality_orders[2] = ["HD", "480P", "360P", "240P", "FULLHD", "BLURAY"] quality_orders[3] = ["480P", "360P", "240P", "BLURAY", "FULLHD", "HD"] - order_list_idiomas = lang_orders[config.get_setting("language")] + order_list_idiomas = lang_orders[config.getSetting("language")] match_list_idimas = {"ITA": ["ITA", "IT", "Italiano", "italiano", "ITALIANO"], "Sub-ITA": ["Sottotitolato", "SUB", "sub-ita", "SUB-ITA", "Sub-ITA", "Sub-Ita"]} order_list_calidad = ["BLURAY", "FULLHD", "HD", "480P", "360P", "240P"] - order_list_calidad = quality_orders[int(config.get_setting("quality"))] + order_list_calidad = quality_orders[int(config.getSetting("quality"))] match_list_calidad = {"BLURAY": ["BR", "BLURAY", '4K'], "FULLHD": ["FULLHD", "FULL HD", "1080", "HD1080", "HD 1080", "1080p"], "HD": ["HD", "HD REAL", "HD 720", "720", "HDTV", "720p"], @@ -570,7 +570,7 @@ def sort_method(item): value = (get_match_list(item.title, match_list_idimas, order_list_idiomas, ignorecase=True, only_ascii=True).index, \ get_match_list(item.title, match_list_calidad, order_list_calidad, ignorecase=True, only_ascii=True).index) - if config.get_setting("server_speed"): + if config.getSetting("server_speed"): value += tuple([get_server_position(item.server)]) return value @@ -580,7 +580,7 @@ def download_from_url(url, item): logger.debug("Attempting to download:", url) if '.m3u8' in url.lower().split('|')[0] or url.lower().startswith("rtmp"): save_server_statistics(item.server, 0, False) - platformtools.dialog_notification('m3u8 Download',config.get_localized_string(60364), sound=False) + platformtools.dialogNotification('m3u8 Download',config.getLocalizedString(60364), sound=False) return {"downloadStatus": STATUS_CODES.error} # We get the download path and the file name @@ -595,10 +595,10 @@ def download_from_url(url, item): # We launch the download d = Downloader(url, download_path, file_name, - max_connections=1 + int(config.get_setting("max_connections", "downloads")), - block_size=2 ** (17 + int(config.get_setting("block_size", "downloads"))), - part_size=2 ** (20 + int(config.get_setting("part_size", "downloads"))), - max_buffer=2 * int(config.get_setting("max_buffer", "downloads")), + max_connections=1 + int(config.getSetting("max_connections", "downloads")), + block_size=2 ** (17 + int(config.getSetting("block_size", "downloads"))), + part_size=2 ** (20 + int(config.getSetting("part_size", "downloads"))), + max_buffer=2 * int(config.getSetting("max_buffer", "downloads")), json_path=item.path) dir = filetools.dirname(item.downloadFilename) file = filetools.join(dir, d.filename) @@ -606,7 +606,7 @@ def download_from_url(url, item): update_json(item.path, {"downloadUrl": d.download_url, "downloadStatus": STATUS_CODES.downloading, "downloadSize": d.size[0], "downloadProgress": d.progress, "downloadCompleted": d.downloaded[0], "downloadFilename": file}) - d.start_dialog(config.get_localized_string(30006)) + d.start_dialog(config.getLocalizedString(30006)) # Download stopped. We get the state: # Download failed @@ -629,7 +629,7 @@ def download_from_url(url, item): save_server_statistics(item.server, d.speed[0], d.state != d.states.error) - if status == STATUS_CODES.completed and config.get_setting("library_move"): + if status == STATUS_CODES.completed and config.getSetting("library_move"): move_to_libray(item.clone(downloadFilename=file)) return {"downloadUrl": d.download_url, "downloadStatus": status, "downloadSize": d.size[0], @@ -643,13 +643,13 @@ def download_from_server(item): if item.contentChannel == 'local': return {"downloadStatus": STATUS_CODES.completed} - progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70178) % item.server) + progreso = platformtools.dialogProgressBg(config.getLocalizedString(30101), config.getLocalizedString(70178) % item.server) try: - channel = platformtools.channel_import(item.contentChannel) + channel = platformtools.channelImport(item.contentChannel) if hasattr(channel, "play") and not item.play_menu: - progreso.update(50, config.get_localized_string(70178) % item.server + '\n' + config.get_localized_string(70180) % item.contentChannel) + progreso.update(50, config.getLocalizedString(70178) % item.server + '\n' + config.getLocalizedString(70180) % item.contentChannel) try: itemlist = getattr(channel, "play")(item.clone(channel=item.contentChannel, action=item.contentAction)) except: @@ -661,7 +661,7 @@ def download_from_server(item): download_item.infoLabels = item.infoLabels item = download_item elif len(itemlist) and isinstance(itemlist[0], list): - item.video_urls = itemlist + item.videoUrls = itemlist if not item.server: item.server = "directo" else: logger.debug("There is nothing to reproduce") @@ -674,17 +674,17 @@ def download_from_server(item): import xbmcgui xlistitem = xbmcgui.ListItem(path=item.url) xlistitem.setArt({'icon': item.thumbnail, 'thumb': item.thumbnail, 'poster': item.thumbnail, 'fanart': item.thumbnail}) - platformtools.set_infolabels(xlistitem, item) - platformtools.play_torrent(item, xlistitem, item.url) + platformtools.setInfolabels(xlistitem, item) + platformtools.playTorrent(item, xlistitem, item.url) if not item.server or not item.url or not item.contentAction == "play" or item.server in unsupported_servers: logger.error("The Item does not contain the necessary parameters.") return {"downloadStatus": STATUS_CODES.error} - if not item.video_urls: - video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing(item.server, item.url, item.password, True, True) + if not item.videoUrls: + videoUrls, puedes, motivo = servertools.resolve_videoUrls_for_playing(item.server, item.url, item.password, True, True) else: - video_urls, puedes, motivo = item.video_urls, True, "" + videoUrls, puedes, motivo = item.videoUrls, True, "" # If it is not available, we go out if not puedes: @@ -697,9 +697,9 @@ def download_from_server(item): result = {} # Go through all the options until I can download one correctly - for video_url in reversed(video_urls): + for videoUrl in reversed(videoUrls): - result = download_from_url(video_url[1], item) + result = download_from_url(videoUrl[1], item) if result["downloadStatus"] in [STATUS_CODES.canceled, STATUS_CODES.completed]: break @@ -716,16 +716,16 @@ def download_from_best_server(item): logger.debug("contentAction: %s | contentChannel: %s | url: %s" % (item.contentAction, item.contentChannel, item.url)) result = {"downloadStatus": STATUS_CODES.error} - progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70179)) + progreso = platformtools.dialogProgressBg(config.getLocalizedString(30101), config.getLocalizedString(70179)) try: if item.downloadItemlist: logger.debug('using cached servers') play_items = [Item().fromurl(i) for i in item.downloadItemlist] else: - channel = platformtools.channel_import(item.contentChannel) + channel = platformtools.channelImport(item.contentChannel) - progreso.update(50, config.get_localized_string(70184) + '\n' + config.get_localized_string(70180) % item.contentChannel) + progreso.update(50, config.getLocalizedString(70184) + '\n' + config.getLocalizedString(70180) % item.contentChannel) if hasattr(channel, item.contentAction): play_items = getattr(channel, item.contentAction)(item.clone(action=item.contentAction, channel=item.contentChannel)) @@ -734,9 +734,9 @@ def download_from_best_server(item): play_items = [x for x in play_items if x.action == "play" and not "trailer" in x.title.lower()] - progreso.update(100, config.get_localized_string(70183) + '\n' + config.get_localized_string(70181) % len(play_items)) + progreso.update(100, config.getLocalizedString(70183) + '\n' + config.getLocalizedString(70181) % len(play_items)) - # if config.get_setting("server_reorder", "downloads") == 1: + # if config.getSetting("server_reorder", "downloads") == 1: play_items.sort(key=sort_method) # if progreso.iscanceled(): @@ -767,14 +767,14 @@ def select_server(item): if item.server: return "Auto" logger.debug("contentAction: %s | contentChannel: %s | url: %s" % (item.contentAction, item.contentChannel, item.url)) - progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70179)) + progreso = platformtools.dialogProgressBg(config.getLocalizedString(30101), config.getLocalizedString(70179)) try: if item.downloadItemlist: logger.debug('using cached servers') play_items = [Item().fromurl(i) for i in item.downloadItemlist] else: - channel = platformtools.channel_import(item.contentChannel) - progreso.update(50, config.get_localized_string(70184) + '\n' + config.get_localized_string(70180) % item.contentChannel) + channel = platformtools.channelImport(item.contentChannel) + progreso.update(50, config.getLocalizedString(70184) + '\n' + config.getLocalizedString(70180) % item.contentChannel) if hasattr(channel, item.contentAction): play_items = getattr(channel, item.contentAction)( @@ -783,7 +783,7 @@ def select_server(item): play_items = servertools.find_video_items(item.clone(action=item.contentAction, channel=item.contentChannel)) play_items = [x for x in play_items if x.action == "play" and not "trailer" in x.title.lower()] - progreso.update(100, config.get_localized_string(70183) + '\n' + config.get_localized_string(70181) % len(play_items)) + progreso.update(100, config.getLocalizedString(70183) + '\n' + config.getLocalizedString(70181) % len(play_items)) finally: progreso.close() @@ -796,7 +796,7 @@ def select_server(item): seleccion = 1 else: # otherwise it shows the selection window - seleccion = platformtools.dialog_select(config.get_localized_string(70192), ["Auto"] + [s.title for s in play_items]) + seleccion = platformtools.dialogSelect(config.getLocalizedString(70192), ["Auto"] + [s.title for s in play_items]) if seleccion >= 1: update_json(item.path, { @@ -805,7 +805,7 @@ def select_server(item): elif seleccion == 0: update_json(item.path, {"downloadServer": {}}) return 'Auto' - # platformtools.itemlist_refresh() + # platformtools.itemlistRefresh() def start_download(item): @@ -821,7 +821,7 @@ def start_download(item): else: ret = download_from_best_server(item) - if ret["downloadStatus"] == STATUS_CODES.completed and config.get_setting("library_move"): + if ret["downloadStatus"] == STATUS_CODES.completed and config.getSetting("library_move"): filetools.remove(item.path) else: update_json(item.path, ret) @@ -845,7 +845,7 @@ def get_episodes(item): if item.downloadItemlist: episodes = [Item().fromurl(i) for i in item.downloadItemlist] else: - channel = platformtools.channel_import(item.contentChannel) + channel = platformtools.channelImport(item.contentChannel) # We get the list of episodes episodes = getattr(channel, item.contentAction)(item) @@ -920,7 +920,7 @@ def write_json(item): item.downloadProgress = 0 item.downloadSize = 0 item.downloadCompleted = 0 - title = re.sub(r'(?:\[[^\]]+\]|%s[^-]+-\s*)' %config.get_localized_string(60356), '', item.title).strip() + title = re.sub(r'(?:\[[^\]]+\]|%s[^-]+-\s*)' %config.getLocalizedString(60356), '', item.title).strip() if not item.contentThumbnail: item.contentThumbnail = item.thumbnail @@ -990,9 +990,9 @@ def save_download_background(item): save_download_movie(parent) else: if item.contentType in ["tvshow", "episode", "season"]: - if ('download' in item and item.channel != 'community') or (item.channel == 'community' and config.get_setting('show_seasons',item.channel) == False): - heading = config.get_localized_string(70594) # <- Enter the season number - item.dlseason = platformtools.dialog_numeric(0, heading, '') + if ('download' in item and item.channel != 'community') or (item.channel == 'community' and config.getSetting('show_seasons',item.channel) == False): + heading = config.getLocalizedString(70594) # <- Enter the season number + item.dlseason = platformtools.dialogNumeric(0, heading, '') if item.dlseason: save_download_tvshow(item) else: @@ -1022,8 +1022,8 @@ def save_download_video(item): write_json(item) - if not platformtools.dialog_yesno(config.get_localized_string(30101), config.get_localized_string(70189)): - platformtools.dialog_ok(config.get_localized_string(30101), item.contentTitle + '\n' + config.get_localized_string(30109)) + if not platformtools.dialogYesNo(config.getLocalizedString(30101), config.getLocalizedString(70189)): + platformtools.dialogOk(config.getLocalizedString(30101), item.contentTitle + '\n' + config.getLocalizedString(30109)) else: start_download(item) @@ -1031,7 +1031,7 @@ def save_download_video(item): def save_download_movie(item): logger.debug("contentAction: %s | contentChannel: %s | contentTitle: %s" % ( item.contentAction, item.contentChannel, item.contentTitle)) - progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70191)) + progreso = platformtools.dialogProgressBg(config.getLocalizedString(30101), config.getLocalizedString(70191)) set_movie_title(item) @@ -1040,7 +1040,7 @@ def save_download_movie(item): progreso.close() return save_download_video(item) - progreso.update(0, config.get_localized_string(60062)) + progreso.update(0, config.getLocalizedString(60062)) item.downloadFilename = filetools.validate_path("%s [%s]" % (item.contentTitle.strip(), item.infoLabels['IMDBNumber'])) item.backupFilename = filetools.validate_path("%s [%s]" % (item.contentTitle.strip(), item.infoLabels['IMDBNumber'])) @@ -1049,8 +1049,8 @@ def save_download_movie(item): progreso.close() - if not platformtools.dialog_yesno(config.get_localized_string(30101), config.get_localized_string(70189)): - platformtools.dialog_ok(config.get_localized_string(30101), item.contentTitle + '\n' + config.get_localized_string(30109)) + if not platformtools.dialogYesNo(config.getLocalizedString(30101), config.getLocalizedString(70189)): + platformtools.dialogOk(config.getLocalizedString(30101), item.contentTitle + '\n' + config.getLocalizedString(30109)) else: play_item = select_server(item) if play_item == 'Auto': @@ -1064,7 +1064,7 @@ def save_download_movie(item): def save_download_tvshow(item): logger.debug("contentAction: %s | contentChannel: %s | contentType: %s | contentSerieName: %s" % (item.contentAction, item.contentChannel, item.contentType, item.contentSerieName)) - progreso = platformtools.dialog_progress_bg(config.get_localized_string(30101), config.get_localized_string(70188)) + progreso = platformtools.dialogProgressBg(config.getLocalizedString(30101), config.getLocalizedString(70188)) try: item.show = item.fulltitle if item.channel not in ['videolibrary']: @@ -1075,14 +1075,14 @@ def save_download_tvshow(item): if item.strm_path: item.downloadFilename = filetools.validate_path(item.strm_path.split(os.sep)[-2]) else: item.downloadFilename = filetools.validate_path("%s [%s]" % (item.contentSerieName, item.infoLabels['IMDBNumber'])) - if config.get_setting("lowerize_title", "videolibrary"): + if config.getSetting("lowerize_title", "videolibrary"): item.downloadFilename = item.downloadFilename.lower() - progreso.update(0, config.get_localized_string(70186) + '\n' + config.get_localized_string(70180) % item.contentChannel) + progreso.update(0, config.getLocalizedString(70186) + '\n' + config.getLocalizedString(70180) % item.contentChannel) episodes = get_episodes(item) - progreso.update(0, config.get_localized_string(70190)) + progreso.update(0, config.getLocalizedString(70190)) for x, i in enumerate(episodes): progreso.update(old_div(x * 100, len(episodes)), "%dx%0.2d: %s" % (i.contentSeason, i.contentEpisodeNumber, i.contentTitle)) @@ -1090,8 +1090,8 @@ def save_download_tvshow(item): finally: progreso.close() - if not platformtools.dialog_yesno(config.get_localized_string(30101), config.get_localized_string(70189)): - platformtools.dialog_ok(config.get_localized_string(30101), str(len(episodes)) + config.get_localized_string(30110) + '\n' + item.contentSerieName + '\n' + config.get_localized_string(30109)) + if not platformtools.dialogYesNo(config.getLocalizedString(30101), config.getLocalizedString(70189)): + platformtools.dialogOk(config.getLocalizedString(30101), str(len(episodes)) + config.getLocalizedString(30110) + '\n' + item.contentSerieName + '\n' + config.getLocalizedString(30109)) else: if len(episodes) == 1: @@ -1121,7 +1121,7 @@ def set_movie_title(item): def show_disclaimer(): - line1 = config.get_localized_string(70690) - line2 = config.get_localized_string(70691) - line3 = config.get_localized_string(70692) - platformtools.dialog_ok(config.get_localized_string(20000), line1 + '\n' + line2 + '\n' + line3) + line1 = config.getLocalizedString(70690) + line2 = config.getLocalizedString(70691) + line3 = config.getLocalizedString(70692) + platformtools.dialogOk(config.getLocalizedString(20000), line1 + '\n' + line2 + '\n' + line3) diff --git a/specials/favorites.py b/specials/favorites.py index 60634bb5..2ac60c69 100644 --- a/specials/favorites.py +++ b/specials/favorites.py @@ -16,7 +16,7 @@ try: FAVOURITES_PATH = xbmc.translatePath("special://profile/favourites.xml") else: - FAVOURITES_PATH = os.path.join(config.get_data_path(), "favourites.xml") + FAVOURITES_PATH = os.path.join(config.getDataPath(), "favourites.xml") except: import traceback @@ -41,11 +41,11 @@ def mainlist(item): elif type(item.context) != list: item.context = [] - item.context.extend([{"title": config.get_localized_string(30154), # "Remove from favorites " + item.context.extend([{"title": config.getLocalizedString(30154), # "Remove from favorites " "action": "delFavourite", "channel": "favorites", "from_title": item.title}, - {"title": config.get_localized_string(70278), # Rename + {"title": config.getLocalizedString(70278), # Rename "action": "renameFavourite", "channel": "favorites", "from_title": item.title} @@ -61,7 +61,7 @@ def read_favourites(): if filetools.exists(FAVOURITES_PATH): data = filetools.read(FAVOURITES_PATH) - matches = scrapertools.find_multiple_matches(data, "<favourite([^<]*)</favourite>") + matches = scrapertools.findMultipleMatches(data, "<favourite([^<]*)</favourite>") for match in matches: name = scrapertools.find_single_match(match, 'name="([^"]*)') thumb = scrapertools.find_single_match(match, 'thumb="([^"]*)') @@ -96,7 +96,7 @@ def addFavourite(item): favourites_list.append((titulo, item.thumbnail, data)) if save_favourites(favourites_list): - platformtools.dialog_ok(config.get_localized_string(30102), titulo + '\n' + config.get_localized_string(30108)) # 'added to favorites' + platformtools.dialogOk(config.getLocalizedString(30102), titulo + '\n' + config.getLocalizedString(30108)) # 'added to favorites' def delFavourite(item): @@ -112,8 +112,8 @@ def delFavourite(item): favourites_list.remove(fav) if save_favourites(favourites_list): - platformtools.dialog_ok(config.get_localized_string(30102), item.title + '\n' + config.get_localized_string(30105).lower()) # 'Removed from favorites' - platformtools.itemlist_refresh() + platformtools.dialogOk(config.getLocalizedString(30102), item.title + '\n' + config.getLocalizedString(30105).lower()) # 'Removed from favorites' + platformtools.itemlistRefresh() break @@ -126,12 +126,12 @@ def renameFavourite(item): for i, fav in enumerate(favourites_list): if fav[0] == item.from_title: # open keyboard - new_title = platformtools.dialog_input(item.from_title, item.title) + new_title = platformtools.dialogInput(item.from_title, item.title) if new_title: favourites_list[i] = (new_title, fav[1], fav[2]) if save_favourites(favourites_list): - platformtools.dialog_ok(config.get_localized_string(30102), item.from_title + '\n' + config.get_localized_string(60086) + '\n' + new_title) # 'Removed from favorites' - platformtools.itemlist_refresh() + platformtools.dialogOk(config.getLocalizedString(30102), item.from_title + '\n' + config.getLocalizedString(60086) + '\n' + new_title) # 'Removed from favorites' + platformtools.itemlistRefresh() ################################################## @@ -230,8 +230,8 @@ def check_bookmark(readpath): # This will only work when migrating from previous versions, there is no longer a "bookmarkpath" try: - if config.get_setting("bookmarkpath") != "": - check_bookmark(config.get_setting("bookmarkpath")) + if config.getSetting("bookmarkpath") != "": + check_bookmark(config.getSetting("bookmarkpath")) else: logger.debug("No path to old version favorites") except: diff --git a/specials/filmontv.py b/specials/filmontv.py index 4a24d488..af8b34cd 100644 --- a/specials/filmontv.py +++ b/specials/filmontv.py @@ -25,52 +25,52 @@ def mainlist(item): action='live', thumbnail=support.thumb('tvshow_live')), Item(channel=item.channel, - title=config.get_setting("film1", channel="filmontv"), + title=config.getSetting("film1", channel="filmontv"), action="now_on_tv", url="%s/film-in-tv/" % host, thumbnail=item.thumbnail), Item(channel=item.channel, - title=config.get_setting("film2", channel="filmontv"), + title=config.getSetting("film2", channel="filmontv"), action="now_on_tv", url="%s/film-in-tv/oggi/premium/" % host, thumbnail=item.thumbnail), Item(channel=item.channel, - title=config.get_setting("film3", channel="filmontv"), + title=config.getSetting("film3", channel="filmontv"), action="now_on_tv", url="%s/film-in-tv/oggi/sky-intrattenimento/" % host, thumbnail=item.thumbnail), Item(channel=item.channel, - title=config.get_setting("film4", channel="filmontv"), + title=config.getSetting("film4", channel="filmontv"), action="now_on_tv", url="%s/film-in-tv/oggi/sky-cinema/" % host, thumbnail=item.thumbnail), Item(channel=item.channel, - title=config.get_setting("film5", channel="filmontv"), + title=config.getSetting("film5", channel="filmontv"), action="now_on_tv", url="%s/film-in-tv/oggi/sky-primafila/" % host, thumbnail=item.thumbnail), Item(channel=item.channel, - title=config.get_setting("now1", channel="filmontv"), + title=config.getSetting("now1", channel="filmontv"), action="now_on_misc", url="%s/ora-in-onda/" % host, thumbnail=item.thumbnail), Item(channel=item.channel, - title=config.get_setting("now2", channel="filmontv"), + title=config.getSetting("now2", channel="filmontv"), action="now_on_misc", url="%s/ora-in-onda/premium/" % host, thumbnail=item.thumbnail), Item(channel=item.channel, - title=config.get_setting("now3", channel="filmontv"), + title=config.getSetting("now3", channel="filmontv"), action="now_on_misc", url="%s/ora-in-onda/sky-intrattenimento/" % host, thumbnail=item.thumbnail), Item(channel=item.channel, - title=config.get_setting("now4", channel="filmontv"), + title=config.getSetting("now4", channel="filmontv"), action="now_on_misc", url="%s/ora-in-onda/sky-doc-e-lifestyle/" % host, thumbnail=item.thumbnail), Item(channel=item.channel, - title=config.get_setting("now5", channel="filmontv"), + title=config.getSetting("now5", channel="filmontv"), action="now_on_misc_film", url="%s/ora-in-onda/sky-cinema/" % host, thumbnail=item.thumbnail), @@ -84,7 +84,7 @@ def mainlist(item): return itemlist def server_config(item): - return platformtools.show_channel_settings(channelpath=filetools.join(config.get_runtime_path(), "specials", item.config)) + return platformtools.showChannelSettings(channelpath=filetools.join(config.getRuntimePath(), "specials", item.config)) def now_on_misc_film(item): logger.debug("filmontv tvoggi") @@ -264,7 +264,7 @@ def live(item): def load_live(channel_name): try: - channel = platformtools.channel_import(item.contentChannel) + channel = platformtools.channelImport(item.contentChannel) itemlist = channel.live(channel.mainlist(Item())[0]) except: itemlist = [] diff --git a/specials/globalsearch.py b/specials/globalsearch.py index f20e75c1..1c7ae91b 100644 --- a/specials/globalsearch.py +++ b/specials/globalsearch.py @@ -19,16 +19,18 @@ else: from concurrent_py2 import futures info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json -def_lang = info_language[config.get_setting("info_language", "videolibrary")] +def_lang = info_language[config.getSetting("info_language", "videolibrary")] close_action = False update_lock = threading.Lock() +moduleDict = {} +searchActions = [] -workers = config.get_setting('thread_number') if config.get_setting('thread_number') > 0 else None +workers = config.getSetting('thread_number') if config.getSetting('thread_number') > 0 else None def new_search(*args): xbmc.executebuiltin('Dialog.Close(all)') - w = SearchWindow('GlobalSearch.xml', config.get_runtime_path()) + w = SearchWindow('GlobalSearch.xml', config.getRuntimePath()) w.start(*args) del w @@ -90,7 +92,7 @@ class SearchWindow(xbmcgui.WindowXML): self.next = None self.previous = None self.FOCUS = False - self.mode = self.item.mode.split('_')[-1] + self.mode = self.item.mode.split('/')[-1] if not thActions and not self.searchActions: self.thActions = Thread(target=self.getActionsThread) @@ -112,11 +114,11 @@ class SearchWindow(xbmcgui.WindowXML): self.item.text = self.item.contentSerieName if not self.item.text: - if config.get_setting('last_search'): last_search = channeltools.get_channel_setting('Last_searched', 'search', '') + if config.getSetting('last_search'): last_search = channeltools.getChannelSetting('Last_searched', 'search', '') else: last_search = '' - if not self.item.text: self.item.text = platformtools.dialog_input(default=last_search, heading='') + if not self.item.text: self.item.text = platformtools.dialogInput(default=last_search, heading='') if self.item.text: - channeltools.set_channel_setting('Last_searched', self.item.text, 'search') + channeltools.setChannelSetting('Last_searched', self.item.text, 'search') from specials.search import save_search save_search(self.item.text) @@ -127,7 +129,7 @@ class SearchWindow(xbmcgui.WindowXML): for channel in self.channelsList: logger.debug(channel) try: - module = platformtools.channel_import(channel) + module = platformtools.channelImport(channel) mainlist = getattr(module, 'mainlist')(Item(channel=channel, global_search=True)) actions = [elem for elem in mainlist if elem.action == "search" and (self.mode in ['all', 'person'] or elem.contentType in [self.mode, 'undefined'])] self.moduleDict[channel] = module @@ -198,7 +200,7 @@ class SearchWindow(xbmcgui.WindowXML): it = xbmcgui.ListItem('[B]{}[/B]'.format(title) + ('\n[I]{}[/I]'.format(tagline if tagline else ''))) it.setArt({'poster':result.get('thumbnail', noThumb), 'fanart':result.get('fanart', '')}) - platformtools.set_infolabels(it, new_item) + platformtools.setInfolabels(it, new_item) color = 'FFFFFFFF' if not rating else 'FFDB2360' if rating < 4 else 'FFD2D531' if rating < 7 else 'FF21D07A' it.setProperties({'rating': str(int(rating) * 10) if rating else 100, 'color':color, 'item': new_item.tourl(), 'search': 'search'}) @@ -259,17 +261,17 @@ class SearchWindow(xbmcgui.WindowXML): mode='search_filmography') it = xbmcgui.ListItem(name) - platformtools.set_infolabels(it, new_item) + platformtools.setInfolabels(it, new_item) it.setArt({'poster':thumb}) it.setProperties({'search': 'persons', 'item': new_item.tourl()}) items.append(it) if len(results) > 19: - it = xbmcgui.ListItem(config.get_localized_string(70006)) + it = xbmcgui.ListItem(config.getLocalizedString(70006)) it.setArt({'poster':'Infoplus/next_focus.png'}) it.setProperty('search','next') items.append(it) if self.page > 1: - it = xbmcgui.ListItem(config.get_localized_string(70005)) + it = xbmcgui.ListItem(config.getLocalizedString(70005)) it.setArt({'poster':'Infoplus/previous_focus.png'}) it.setProperty('search','previous') items.insert(0, it) @@ -303,7 +305,7 @@ class SearchWindow(xbmcgui.WindowXML): list_cat[n] = 'tvshow' if self.mode in ['all', 'person'] or self.mode in list_cat: - if config.get_setting("include_in_global_search", channel) and ch_param.get("active", False): + if config.getSetting("include_in_global_search", channel) and ch_param.get("active", False): channels_list.append(channel) logger.debug('search in channels:', channels_list) @@ -438,8 +440,8 @@ class SearchWindow(xbmcgui.WindowXML): thumb = item.thumbnail if item.thumbnail else 'Infoplus/' + item.contentType.replace('show', '') + '.png' it = xbmcgui.ListItem(title) - it.setArt({'poster':thumb, 'fanart':item.fanart, 'thumb':thumb if config.get_setting('episode_info') else ''}) - platformtools.set_infolabels(it, item) + it.setArt({'poster':thumb, 'fanart':item.fanart, 'thumb':thumb if config.getSetting('episode_info') else ''}) + platformtools.setInfolabels(it, item) # logger.debug(item) rating = info.get('rating') @@ -490,7 +492,7 @@ class SearchWindow(xbmcgui.WindowXML): self.NORESULTS.setVisible(False) self.time = time.time() - self.mainTitle = config.get_localized_string(30993).replace('...', '') % '"%s"' % self.item.text + self.mainTitle = config.getLocalizedString(30993).replace('...', '') % '"%s"' % self.item.text # collect controls self.NEXT = self.getControl(NEXT) @@ -507,7 +509,7 @@ class SearchWindow(xbmcgui.WindowXML): self.EPISODESLIST = self.getControl(EPISODESLIST) self.Focus(self.focus) - if self.item.mode.split('_')[0] in ['all', 'search']: + if self.item.mode.split('/')[0] in ['all', 'search']: if 'search' in self.item.mode: self.item.text = scrapertools.title_unify(self.item.text) self.thread = Thread(target=self.search) @@ -541,9 +543,9 @@ class SearchWindow(xbmcgui.WindowXML): if action in [RIGHT]: item = self.next if item: - platformtools.dialog_busy(True) + platformtools.dialogBusy(True) self.loadEpisodes(item) - platformtools.dialog_busy(False) + platformtools.dialogBusy(False) elif action in [SWIPEUP] and self.CHANNELS.isVisible(): self.setFocusId(CHANNELS) @@ -620,7 +622,7 @@ class SearchWindow(xbmcgui.WindowXML): elif control_id in [RESULTS, EPISODESLIST]: - platformtools.dialog_busy(True) + platformtools.dialogBusy(True) if control_id in [RESULTS]: name = self.CHANNELS.getSelectedItem().getLabel() self.pos = self.RESULTS.getSelectedPosition() @@ -631,19 +633,19 @@ class SearchWindow(xbmcgui.WindowXML): item = Item().fromurl(item_url) else: # no results item - platformtools.dialog_busy(False) + platformtools.dialogBusy(False) return if item.action: item.window = True item.folder = False xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + item.tourl() + ")") - platformtools.dialog_busy(False) + platformtools.dialogBusy(False) return self.loadEpisodes(item) - platformtools.dialog_busy(False) + platformtools.dialogBusy(False) def channelItems(self): items = [] @@ -658,7 +660,7 @@ class SearchWindow(xbmcgui.WindowXML): def loadEpisodes(self ,item): try: - self.channel = platformtools.channel_import(item.channel) + self.channel = platformtools.channelImport(item.channel) self.itemsResult = getattr(self.channel, item.action)(item) except: import traceback @@ -690,7 +692,7 @@ class SearchWindow(xbmcgui.WindowXML): self.PREV.setVisible(True if self.previous else False) if not ep: - ep = [xbmcgui.ListItem(config.get_localized_string(60347))] + ep = [xbmcgui.ListItem(config.getLocalizedString(60347))] ep[0].setArt({'poster', support.thumb('nofolder')}) self.Focus(EPISODES) @@ -710,11 +712,11 @@ class SearchWindow(xbmcgui.WindowXML): def Close(self): self.exit = True if self.thread: - platformtools.dialog_busy(True) + platformtools.dialogBusy(True) for th in self.search_threads: th.cancel() self.thread.join() - platformtools.dialog_busy(False) + platformtools.dialogBusy(False) self.close() def context(self): @@ -727,7 +729,7 @@ class SearchWindow(xbmcgui.WindowXML): parent = self.item item = Item().fromurl(item_url) parent.noMainMenu = True - commands = platformtools.set_context_commands(item, item_url, parent) + commands = platformtools.setContextCommands(item, item_url, parent) context = [c[0] for c in commands] context_commands = [c[1].replace('Container.Refresh', 'RunPlugin').replace('Container.Update', 'RunPlugin').replace(')','&no_reload=True)') for c in commands] index = xbmcgui.Dialog().contextmenu(context) diff --git a/specials/help.py b/specials/help.py index 8a00fd35..438354a7 100644 --- a/specials/help.py +++ b/specials/help.py @@ -10,14 +10,14 @@ def mainlist(item): itemlist = [] if config.is_xbmc(): - itemlist.append(Item(title=config.get_localized_string(707429), channel="setting", action="report_menu", + itemlist.append(Item(title=config.getLocalizedString(707429), channel="setting", action="report_menu", thumbnail=thumb("error"), viewmode="list",folder=True)) - itemlist.append(Item(action="open_browser", title=config.get_localized_string(60447), + itemlist.append(Item(action="open_browser", title=config.getLocalizedString(60447), thumbnail=thumb("help"), url=guideUrl, plot=guideUrl, folder=False)) itemlist.append(Item(channel="setting", action="check_quickfixes", folder=False, thumbnail=thumb("update"), - title=config.get_localized_string(30001), plot=config.get_addon_version(with_fix=True))) + title=config.getLocalizedString(30001), plot=config.getAddonVersion(with_fix=True))) return itemlist diff --git a/specials/kodfavorites.py b/specials/kodfavorites.py index cd0697b0..07d458cd 100644 --- a/specials/kodfavorites.py +++ b/specials/kodfavorites.py @@ -8,11 +8,11 @@ # - kodfavourites-default.json can be copied to other devices since the only local dependency is the thumbnail associated with the links, # but it is detected by code and adjusts to the current device. # - You can have different alphabet files and alternate between them, but only one of them is the "active list". -# - Files must be in config.get_data_path () and start with kodfavourites- and end in .json +# - Files must be in config.getDataPath () and start with kodfavourites- and end in .json # Requirements in other modules to run this channel: # - Add a link to this channel in channelselector.py -# - Modify platformtools.py to control the context menu and add "Save link" in set_context_commands +# - Modify platformtools.py to control the context menu and add "Save link" in setContextCommands # ------------------------------------------------------------ # from builtins import str @@ -38,7 +38,7 @@ PREFIJO_LISTA = 'kodfavorites-' # Returns the name of the active list (Ex: kodfavourites-default.json) def get_lista_activa(): - return config.get_setting('lista_activa', default = PREFIJO_LISTA + 'default.json') + return config.getSetting('lista_activa', default = PREFIJO_LISTA + 'default.json') # Extract list name from file, removing prefix and suffix (Ex: kodfavourites-Test.json => Test) def get_name_from_filename(filename): @@ -51,7 +51,7 @@ def get_filename_from_name(name): # Record the codes of the files that have been shared in a log file def save_log_lista_shared(msg): msg = fechahora_actual() + ': ' + msg + os.linesep - fullfilename = os.path.join(config.get_data_path(), 'kodfavorites_shared.log') + fullfilename = os.path.join(config.getDataPath(), 'kodfavorites_shared.log') with open(fullfilename, 'a') as f: f.write(msg); f.close() # Clean text to use as file name @@ -78,10 +78,10 @@ class KodfavouritesData(object): if filename == None: filename = get_lista_activa() - self.user_favorites_file = os.path.join(config.get_data_path(), filename) + self.user_favorites_file = os.path.join(config.getDataPath(), filename) if not os.path.exists(self.user_favorites_file): - fichero_anterior = os.path.join(config.get_data_path(), 'user_favorites.json') + fichero_anterior = os.path.join(config.getDataPath(), 'user_favorites.json') if os.path.exists(fichero_anterior): # old format, convert (to delete after some versions) jsondata = jsontools.load(filetools.read(fichero_anterior)) self.user_favorites = jsondata @@ -103,9 +103,9 @@ class KodfavouritesData(object): self.info_lista = {} # Create some default folders - self.user_favorites.append({ 'title': config.get_localized_string(30122), 'items': [] }) - self.user_favorites.append({ 'title': config.get_localized_string(30123), 'items': [] }) - self.user_favorites.append({ 'title': config.get_localized_string(70149), 'items': [] }) + self.user_favorites.append({ 'title': config.getLocalizedString(30122), 'items': [] }) + self.user_favorites.append({ 'title': config.getLocalizedString(30123), 'items': [] }) + self.user_favorites.append({ 'title': config.getLocalizedString(70149), 'items': [] }) self.save() @@ -118,7 +118,7 @@ class KodfavouritesData(object): jsondata['user_favorites'] = self.user_favorites jsondata['info_lista'] = self.info_lista if not filetools.write(self.user_favorites_file, jsontools.dump(jsondata)): - platformtools.dialog_ok('KoD', config.get_localized_string(70614) + '\n' + os.path.basename(self.user_favorites_file)) + platformtools.dialogOk('KoD', config.getLocalizedString(70614) + '\n' + os.path.basename(self.user_favorites_file)) # ============================ @@ -127,7 +127,7 @@ class KodfavouritesData(object): def addFavourite(item): logger.debug() - alfav = KodfavouritesData() + kodfav = KodfavouritesData() # If you get here through the context menu, you must retrieve the action and channel parameters if item.from_action: @@ -141,12 +141,12 @@ def addFavourite(item): item.__dict__.pop('text_color') # Dialog to choose / create folder - i_perfil = _selecciona_perfil(alfav, config.get_localized_string(70546)) + i_perfil = _selecciona_perfil(kodfav, config.getLocalizedString(70546)) if i_perfil == -1: return False # Detect that the same link does not already exist in the folder campos = ['channel','action','url','extra','list_type'] # if all these fields match the link is considered to already exist - for enlace in alfav.user_favorites[i_perfil]['items']: + for enlace in kodfav.user_favorites[i_perfil]['items']: it = Item().fromurl(enlace) repe = True for prop in campos: @@ -154,11 +154,11 @@ def addFavourite(item): repe = False break if repe: - platformtools.dialog_notification(config.get_localized_string(70615), config.get_localized_string(70616)) + platformtools.dialogNotification(config.getLocalizedString(70615), config.getLocalizedString(70616)) return False # If it is a movie / series, fill in tmdb information if tmdb_plus_info is not activated (for season / episode it is not necessary because the "second pass" will have already been done) - if (item.contentType == 'movie' or item.contentType == 'tvshow') and not config.get_setting('tmdb_plus_info', default=False): + if (item.contentType == 'movie' or item.contentType == 'tvshow') and not config.getSetting('tmdb_plus_info', default=False): from core import tmdb tmdb.set_infoLabels(item, True) # get more data in "second pass" (actors, duration, ...) @@ -166,10 +166,10 @@ def addFavourite(item): item.date_added = fechahora_actual() # save - alfav.user_favorites[i_perfil]['items'].append(item.tourl()) - alfav.save() + kodfav.user_favorites[i_perfil]['items'].append(item.tourl()) + kodfav.save() - platformtools.dialog_notification(config.get_localized_string(70531), config.get_localized_string(70532) % alfav.user_favorites[i_perfil]['title']) + platformtools.dialogNotification(config.getLocalizedString(70531), config.getLocalizedString(70532) % kodfav.user_favorites[i_perfil]['title']) return True @@ -180,56 +180,56 @@ def addFavourite(item): def mainlist(item): logger.debug() - alfav = KodfavouritesData() - item.category = get_name_from_filename(os.path.basename(alfav.user_favorites_file)) + kodfav = KodfavouritesData() + item.category = get_name_from_filename(os.path.basename(kodfav.user_favorites_file)) itemlist = [] - last_i = len(alfav.user_favorites) - 1 + last_i = len(kodfav.user_favorites) - 1 - for i_perfil, perfil in enumerate(alfav.user_favorites): + for i_perfil, perfil in enumerate(kodfav.user_favorites): context = [] - context.append({'title': config.get_localized_string(70533), 'channel': item.channel, 'action': 'editar_perfil_titulo', 'i_perfil': i_perfil}) - context.append({'title': config.get_localized_string(70534), 'channel': item.channel, 'action': 'eliminar_perfil', 'i_perfil': i_perfil}) + context.append({'title': config.getLocalizedString(70533), 'channel': item.channel, 'action': 'editar_perfil_titulo', 'i_perfil': i_perfil}) + context.append({'title': config.getLocalizedString(70534), 'channel': item.channel, 'action': 'eliminar_perfil', 'i_perfil': i_perfil}) if i_perfil > 0: - context.append({'title': config.get_localized_string(70535), 'channel': item.channel, 'action': 'mover_perfil', 'i_perfil': i_perfil, 'direccion': 'top'}) - context.append({'title': config.get_localized_string(70536), 'channel': item.channel, 'action': 'mover_perfil', 'i_perfil': i_perfil, 'direccion': 'arriba'}) + context.append({'title': config.getLocalizedString(70535), 'channel': item.channel, 'action': 'mover_perfil', 'i_perfil': i_perfil, 'direccion': 'top'}) + context.append({'title': config.getLocalizedString(70536), 'channel': item.channel, 'action': 'mover_perfil', 'i_perfil': i_perfil, 'direccion': 'arriba'}) if i_perfil < last_i: - context.append({'title': config.get_localized_string(70537), 'channel': item.channel, 'action': 'mover_perfil', 'i_perfil': i_perfil, 'direccion': 'abajo'}) - context.append({'title': config.get_localized_string(70538), 'channel': item.channel, 'action': 'mover_perfil', 'i_perfil': i_perfil, 'direccion': 'bottom'}) + context.append({'title': config.getLocalizedString(70537), 'channel': item.channel, 'action': 'mover_perfil', 'i_perfil': i_perfil, 'direccion': 'abajo'}) + context.append({'title': config.getLocalizedString(70538), 'channel': item.channel, 'action': 'mover_perfil', 'i_perfil': i_perfil, 'direccion': 'bottom'}) - plot = str(len(perfil['items'])) + " " + config.get_localized_string(70723) + plot = str(len(perfil['items'])) + " " + config.getLocalizedString(70723) itemlist.append(Item(channel=item.channel, action='mostrar_perfil', title=perfil['title'], plot=plot, i_perfil=i_perfil, context=context, thumbnail=support.thumb('mylink'))) support.thumb(itemlist) - itemlist.append(item.clone(action='crear_perfil', title=config.get_localized_string(70542), folder=False, thumbnail=support.thumb('more'))) - itemlist.append(item.clone(action='mainlist_listas', title=config.get_localized_string(70603), thumbnail=support.thumb('setting'))) + itemlist.append(item.clone(action='crear_perfil', title=config.getLocalizedString(70542), folder=False, thumbnail=support.thumb('more'))) + itemlist.append(item.clone(action='mainlist_listas', title=config.getLocalizedString(70603), thumbnail=support.thumb('setting'))) return itemlist def mostrar_perfil(item): logger.debug() - alfav = KodfavouritesData() + kodfav = KodfavouritesData() itemlist = [] i_perfil = item.i_perfil - if not alfav.user_favorites[i_perfil]: return itemlist - last_i = len(alfav.user_favorites[i_perfil]['items']) - 1 + if not kodfav.user_favorites[i_perfil]: return itemlist + last_i = len(kodfav.user_favorites[i_perfil]['items']) - 1 - ruta_runtime = config.get_runtime_path() + ruta_runtime = config.getRuntimePath() - for i_enlace, enlace in enumerate(alfav.user_favorites[i_perfil]['items']): + for i_enlace, enlace in enumerate(kodfav.user_favorites[i_perfil]['items']): it = Item().fromurl(enlace) - it.context = [ {'title': config.get_localized_string(70617), 'channel': item.channel, 'action': 'acciones_enlace', + it.context = [ {'title': config.getLocalizedString(70617), 'channel': item.channel, 'action': 'acciones_enlace', 'i_enlace': i_enlace, 'i_perfil': i_perfil} ] - it.plot += '[CR][CR]' + config.get_localized_string(70724) + ': ' + it.channel + ' ' + config.get_localized_string(60266) + ': ' + it.action + it.plot += '[CR][CR]' + config.getLocalizedString(70724) + ': ' + it.channel + ' ' + config.getLocalizedString(60266) + ': ' + it.action if it.extra != '': it.plot += ' Extra: ' + it.extra it.plot += '[CR]Url: ' + it.url if isinstance(it.url, str) else '...' - if it.date_added != '': it.plot += '[CR]' + config.get_localized_string(70469) + ': ' + it.date_added + if it.date_added != '': it.plot += '[CR]' + config.getLocalizedString(70469) + ': ' + it.date_added # If it is not a url, nor does it have the system path, convert the path since it will have been copied from another device. # It would be more optimal if the conversion was done with an import menu, but at the moment it is controlled in run-time. @@ -250,31 +250,31 @@ def mostrar_perfil(item): # Shared internal routines # Dialog to select / create a folder. Returns index of folder on user_favorites (-1 if cancel) -def _selecciona_perfil(alfav, titulo=config.get_localized_string(70549), i_actual=-1): - acciones = [(perfil['title'] if i_p != i_actual else '[I][COLOR pink]%s[/COLOR][/I]' % perfil['title']) for i_p, perfil in enumerate(alfav.user_favorites)] - acciones.append(config.get_localized_string(70542)) +def _selecciona_perfil(kodfav, titulo=config.getLocalizedString(70549), i_actual=-1): + acciones = [(perfil['title'] if i_p != i_actual else '[I][COLOR pink]%s[/COLOR][/I]' % perfil['title']) for i_p, perfil in enumerate(kodfav.user_favorites)] + acciones.append(config.getLocalizedString(70542)) i_perfil = -1 while i_perfil == -1: # repeat until a folder is selected or cancel - ret = platformtools.dialog_select(titulo, acciones) + ret = platformtools.dialogSelect(titulo, acciones) if ret == -1: return -1 # order cancel - if ret < len(alfav.user_favorites): + if ret < len(kodfav.user_favorites): i_perfil = ret else: # create new folder - if _crea_perfil(alfav): - i_perfil = len(alfav.user_favorites) - 1 + if _crea_perfil(kodfav): + i_perfil = len(kodfav.user_favorites) - 1 return i_perfil # Dialog to create a folder -def _crea_perfil(alfav): - titulo = platformtools.dialog_input(default='', heading=config.get_localized_string(70551)) +def _crea_perfil(kodfav): + titulo = platformtools.dialogInput(default='', heading=config.getLocalizedString(70551)) if titulo is None or titulo == '': return False - alfav.user_favorites.append({'title': titulo, 'items': []}) - alfav.save() + kodfav.user_favorites.append({'title': titulo, 'items': []}) + kodfav.save() return True @@ -283,55 +283,55 @@ def _crea_perfil(alfav): def crear_perfil(item): logger.debug() - alfav = KodfavouritesData() + kodfav = KodfavouritesData() - if not _crea_perfil(alfav): return False + if not _crea_perfil(kodfav): return False - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() return True def editar_perfil_titulo(item): logger.debug() - alfav = KodfavouritesData() + kodfav = KodfavouritesData() - if not alfav.user_favorites[item.i_perfil]: return False + if not kodfav.user_favorites[item.i_perfil]: return False - titulo = platformtools.dialog_input(default=alfav.user_favorites[item.i_perfil]['title'], heading=config.get_localized_string(70533)) - if titulo is None or titulo == '' or titulo == alfav.user_favorites[item.i_perfil]['title']: + titulo = platformtools.dialogInput(default=kodfav.user_favorites[item.i_perfil]['title'], heading=config.getLocalizedString(70533)) + if titulo is None or titulo == '' or titulo == kodfav.user_favorites[item.i_perfil]['title']: return False - alfav.user_favorites[item.i_perfil]['title'] = titulo - alfav.save() + kodfav.user_favorites[item.i_perfil]['title'] = titulo + kodfav.save() - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() return True def eliminar_perfil(item): logger.debug() - alfav = KodfavouritesData() + kodfav = KodfavouritesData() - if not alfav.user_favorites[item.i_perfil]: return False + if not kodfav.user_favorites[item.i_perfil]: return False # Ask for confirmation - if not platformtools.dialog_yesno(config.get_localized_string(70618), config.get_localized_string(70619)): return False + if not platformtools.dialogYesNo(config.getLocalizedString(70618), config.getLocalizedString(70619)): return False - del alfav.user_favorites[item.i_perfil] - alfav.save() + del kodfav.user_favorites[item.i_perfil] + kodfav.save() - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() return True def acciones_enlace(item): logger.debug() - acciones = [config.get_localized_string(70620), config.get_localized_string(70621), config.get_localized_string(70622), config.get_localized_string(70623), - config.get_localized_string(70624), config.get_localized_string(70548), config.get_localized_string(70625), - config.get_localized_string(70626), config.get_localized_string(70627), config.get_localized_string(70628)] + acciones = [config.getLocalizedString(70620), config.getLocalizedString(70621), config.getLocalizedString(70622), config.getLocalizedString(70623), + config.getLocalizedString(70624), config.getLocalizedString(70548), config.getLocalizedString(70625), + config.getLocalizedString(70626), config.getLocalizedString(70627), config.getLocalizedString(70628)] - ret = platformtools.dialog_select('Action to execute', acciones) + ret = platformtools.dialogSelect('Action to execute', acciones) if ret == -1: return False # order cancel elif ret == 0: @@ -358,61 +358,61 @@ def acciones_enlace(item): def editar_enlace_titulo(item): logger.debug() - alfav = KodfavouritesData() + kodfav = KodfavouritesData() - if not alfav.user_favorites[item.i_perfil]: return False - if not alfav.user_favorites[item.i_perfil]['items'][item.i_enlace]: return False + if not kodfav.user_favorites[item.i_perfil]: return False + if not kodfav.user_favorites[item.i_perfil]['items'][item.i_enlace]: return False - it = Item().fromurl(alfav.user_favorites[item.i_perfil]['items'][item.i_enlace]) + it = Item().fromurl(kodfav.user_favorites[item.i_perfil]['items'][item.i_enlace]) - titulo = platformtools.dialog_input(default=it.title, heading=config.get_localized_string(70553)) + titulo = platformtools.dialogInput(default=it.title, heading=config.getLocalizedString(70553)) if titulo is None or titulo == '' or titulo == it.title: return False it.title = titulo - alfav.user_favorites[item.i_perfil]['items'][item.i_enlace] = it.tourl() - alfav.save() + kodfav.user_favorites[item.i_perfil]['items'][item.i_enlace] = it.tourl() + kodfav.save() - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() return True def editar_enlace_color(item): logger.debug() - alfav = KodfavouritesData() + kodfav = KodfavouritesData() - if not alfav.user_favorites[item.i_perfil]: return False - if not alfav.user_favorites[item.i_perfil]['items'][item.i_enlace]: return False + if not kodfav.user_favorites[item.i_perfil]: return False + if not kodfav.user_favorites[item.i_perfil]['items'][item.i_enlace]: return False - it = Item().fromurl(alfav.user_favorites[item.i_perfil]['items'][item.i_enlace]) + it = Item().fromurl(kodfav.user_favorites[item.i_perfil]['items'][item.i_enlace]) colores = ['green','yellow','red','blue','white','orange','lime','aqua','pink','violet','purple','tomato','olive','antiquewhite','gold'] opciones = ['[COLOR %s]%s[/COLOR]' % (col, col) for col in colores] - ret = platformtools.dialog_select(config.get_localized_string(70558), opciones) + ret = platformtools.dialogSelect(config.getLocalizedString(70558), opciones) if ret == -1: return False # order cancel it.text_color = colores[ret] - alfav.user_favorites[item.i_perfil]['items'][item.i_enlace] = it.tourl() - alfav.save() + kodfav.user_favorites[item.i_perfil]['items'][item.i_enlace] = it.tourl() + kodfav.save() - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() return True def editar_enlace_thumbnail(item): logger.debug() - alfav = KodfavouritesData() + kodfav = KodfavouritesData() - if not alfav.user_favorites[item.i_perfil]: return False - if not alfav.user_favorites[item.i_perfil]['items'][item.i_enlace]: return False + if not kodfav.user_favorites[item.i_perfil]: return False + if not kodfav.user_favorites[item.i_perfil]['items'][item.i_enlace]: return False - it = Item().fromurl(alfav.user_favorites[item.i_perfil]['items'][item.i_enlace]) + it = Item().fromurl(kodfav.user_favorites[item.i_perfil]['items'][item.i_enlace]) # Starting with Kodi 17, you can use xbmcgui.Dialog (). Select with thumbnails (ListItem & useDetails = True) - is_kodi17 = (config.get_platform(True)['num_version'] >= 17.0) + is_kodi17 = (config.getXBMCPlatform(True)['num_version'] >= 17.0) if is_kodi17: import xbmcgui @@ -434,7 +434,7 @@ def editar_enlace_thumbnail(item): except: pass - resource_path = os.path.join(config.get_runtime_path(), 'resources', 'media', 'themes', 'default') + resource_path = os.path.join(config.getRuntimePath(), 'resources', 'media', 'themes', 'default') for f in sorted(os.listdir(resource_path)): if f.startswith('thumb_') and not f.startswith('thumb_intervenido') and f != 'thumb_back.png': nombre = f.replace('thumb_', '').replace('_', ' ').replace('.png', '') @@ -447,46 +447,46 @@ def editar_enlace_thumbnail(item): ids.append(os.path.join(resource_path, f)) if is_kodi17: - ret = xbmcgui.Dialog().select(config.get_localized_string(70554), opciones, useDetails=True) + ret = xbmcgui.Dialog().select(config.getLocalizedString(70554), opciones, useDetails=True) else: - ret = platformtools.dialog_select(config.get_localized_string(70554), opciones) + ret = platformtools.dialogSelect(config.getLocalizedString(70554), opciones) if ret == -1: return False # order cancel it.thumbnail = ids[ret] - alfav.user_favorites[item.i_perfil]['items'][item.i_enlace] = it.tourl() - alfav.save() + kodfav.user_favorites[item.i_perfil]['items'][item.i_enlace] = it.tourl() + kodfav.save() - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() return True def editar_enlace_carpeta(item): logger.debug() - alfav = KodfavouritesData() + kodfav = KodfavouritesData() - if not alfav.user_favorites[item.i_perfil]: return False - if not alfav.user_favorites[item.i_perfil]['items'][item.i_enlace]: return False + if not kodfav.user_favorites[item.i_perfil]: return False + if not kodfav.user_favorites[item.i_perfil]['items'][item.i_enlace]: return False # Dialog to choose / create folder - i_perfil = _selecciona_perfil(alfav, config.get_localized_string(70555), item.i_perfil) + i_perfil = _selecciona_perfil(kodfav, config.getLocalizedString(70555), item.i_perfil) if i_perfil == -1 or i_perfil == item.i_perfil: return False - alfav.user_favorites[i_perfil]['items'].append(alfav.user_favorites[item.i_perfil]['items'][item.i_enlace]) - del alfav.user_favorites[item.i_perfil]['items'][item.i_enlace] - alfav.save() + kodfav.user_favorites[i_perfil]['items'].append(kodfav.user_favorites[item.i_perfil]['items'][item.i_enlace]) + del kodfav.user_favorites[item.i_perfil]['items'][item.i_enlace] + kodfav.save() - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() return True def editar_enlace_lista(item): logger.debug() - alfav = KodfavouritesData() + kodfav = KodfavouritesData() - if not alfav.user_favorites[item.i_perfil]: return False - if not alfav.user_favorites[item.i_perfil]['items'][item.i_enlace]: return False + if not kodfav.user_favorites[item.i_perfil]: return False + if not kodfav.user_favorites[item.i_perfil]['items'][item.i_enlace]: return False # Dialog to choose list opciones = [] @@ -496,63 +496,63 @@ def editar_enlace_lista(item): opciones.append(it.lista) if len(opciones) == 0: - platformtools.dialog_ok('KoD', 'There are no other lists where to move the link.\nYou can create them from the Manage link lists menu') + platformtools.dialogOk('KoD', 'There are no other lists where to move the link.\nYou can create them from the Manage link lists menu') return False - ret = platformtools.dialog_select('Select destination list', opciones) + ret = platformtools.dialogSelect('Select destination list', opciones) if ret == -1: return False # order cancel - alfav_destino = KodfavouritesData(opciones[ret]) + kodfav_destino = KodfavouritesData(opciones[ret]) # Dialog to choose / create folder in the destination list - i_perfil = _selecciona_perfil(alfav_destino, 'Select destination folder', -1) + i_perfil = _selecciona_perfil(kodfav_destino, 'Select destination folder', -1) if i_perfil == -1: return False - alfav_destino.user_favorites[i_perfil]['items'].append(alfav.user_favorites[item.i_perfil]['items'][item.i_enlace]) - del alfav.user_favorites[item.i_perfil]['items'][item.i_enlace] - alfav_destino.save() - alfav.save() + kodfav_destino.user_favorites[i_perfil]['items'].append(kodfav.user_favorites[item.i_perfil]['items'][item.i_enlace]) + del kodfav.user_favorites[item.i_perfil]['items'][item.i_enlace] + kodfav_destino.save() + kodfav.save() - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() return True def eliminar_enlace(item): logger.debug() - alfav = KodfavouritesData() + kodfav = KodfavouritesData() - if not alfav.user_favorites[item.i_perfil]: return False - if not alfav.user_favorites[item.i_perfil]['items'][item.i_enlace]: return False + if not kodfav.user_favorites[item.i_perfil]: return False + if not kodfav.user_favorites[item.i_perfil]['items'][item.i_enlace]: return False - del alfav.user_favorites[item.i_perfil]['items'][item.i_enlace] - alfav.save() + del kodfav.user_favorites[item.i_perfil]['items'][item.i_enlace] + kodfav.save() - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() return True # Move profiles and links (up, down, top, bottom) def mover_perfil(item): logger.debug() - alfav = KodfavouritesData() + kodfav = KodfavouritesData() - alfav.user_favorites = _mover_item(alfav.user_favorites, item.i_perfil, item.direccion) - alfav.save() + kodfav.user_favorites = _mover_item(kodfav.user_favorites, item.i_perfil, item.direccion) + kodfav.save() - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() return True def mover_enlace(item): logger.debug() - alfav = KodfavouritesData() + kodfav = KodfavouritesData() - if not alfav.user_favorites[item.i_perfil]: return False - alfav.user_favorites[item.i_perfil]['items'] = _mover_item(alfav.user_favorites[item.i_perfil]['items'], item.i_enlace, item.direccion) - alfav.save() + if not kodfav.user_favorites[item.i_perfil]: return False + kodfav.user_favorites[item.i_perfil]['items'] = _mover_item(kodfav.user_favorites[item.i_perfil]['items'], item.i_enlace, item.direccion) + kodfav.save() - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() return True @@ -598,7 +598,7 @@ def mainlist_listas(item): import glob - path = os.path.join(config.get_data_path(), PREFIJO_LISTA+'*.json') + path = os.path.join(config.getDataPath(), PREFIJO_LISTA+'*.json') for fichero in glob.glob(path): lista = os.path.basename(fichero) nombre = get_name_from_filename(lista) @@ -606,7 +606,7 @@ def mainlist_listas(item): itemlist.append(item.clone(action='acciones_lista', lista=lista, title=titulo, folder=False)) - itemlist.append(item.clone(action='acciones_nueva_lista', title=config.get_localized_string(70642), folder=False)) + itemlist.append(item.clone(action='acciones_nueva_lista', title=config.getLocalizedString(70642), folder=False)) return itemlist @@ -614,10 +614,10 @@ def mainlist_listas(item): def acciones_lista(item): logger.debug() - acciones = [config.get_localized_string(70604), config.get_localized_string(70629), - config.get_localized_string(70605), config.get_localized_string(70606), config.get_localized_string(70607)] + acciones = [config.getLocalizedString(70604), config.getLocalizedString(70629), + config.getLocalizedString(70605), config.getLocalizedString(70606), config.getLocalizedString(70607)] - ret = platformtools.dialog_select(item.lista, acciones) + ret = platformtools.dialogSelect(item.lista, acciones) if ret == -1: return False # pedido cancel @@ -636,113 +636,113 @@ def acciones_lista(item): def activar_lista(item): logger.debug() - fullfilename = os.path.join(config.get_data_path(), item.lista) + fullfilename = os.path.join(config.getDataPath(), item.lista) if not os.path.exists(fullfilename): - platformtools.dialog_ok('KoD', config.get_localized_string(70630) + '\n' + item.lista) + platformtools.dialogOk('KoD', config.getLocalizedString(70630) + '\n' + item.lista) return False - config.set_setting('lista_activa', item.lista) + config.setSetting('lista_activa', item.lista) from core.support import thumb - item_inicio = Item(title=config.get_localized_string(70527), channel="kodfavorites", action="mainlist", + item_inicio = Item(title=config.getLocalizedString(70527), channel="kodfavorites", action="mainlist", thumbnail=thumb("mylink"), - category=config.get_localized_string(70527), viewmode="thumbnails") - platformtools.itemlist_update(item_inicio, replace=True) + category=config.getLocalizedString(70527), viewmode="thumbnails") + platformtools.itemlistUpdate(item_inicio, replace=True) return True def renombrar_lista(item): logger.debug() - fullfilename_current = os.path.join(config.get_data_path(), item.lista) + fullfilename_current = os.path.join(config.getDataPath(), item.lista) if not os.path.exists(fullfilename_current): - platformtools.dialog_ok('KoD', config.get_localized_string(70630) + '\n' + fullfilename_current) + platformtools.dialogOk('KoD', config.getLocalizedString(70630) + '\n' + fullfilename_current) return False nombre = get_name_from_filename(item.lista) - titulo = platformtools.dialog_input(default=nombre, heading=config.get_localized_string(70612)) + titulo = platformtools.dialogInput(default=nombre, heading=config.getLocalizedString(70612)) if titulo is None or titulo == '' or titulo == nombre: return False titulo = text_clean(titulo, blank_char='_') filename = get_filename_from_name(titulo) - fullfilename = os.path.join(config.get_data_path(), filename) + fullfilename = os.path.join(config.getDataPath(), filename) # Check that the new name does not exist if os.path.exists(fullfilename): - platformtools.dialog_ok('KoD', config.get_localized_string(70613) + '\n' + fullfilename) + platformtools.dialogOk('KoD', config.getLocalizedString(70613) + '\n' + fullfilename) return False # Rename the file if not filetools.rename(fullfilename_current, filename): - platformtools.dialog_ok('KoD', config.get_localized_string(70631) + '\n' + fullfilename) + platformtools.dialogOk('KoD', config.getLocalizedString(70631) + '\n' + fullfilename) return False # Update settings if it is the active list if item.lista == get_lista_activa(): - config.set_setting('lista_activa', filename) + config.setSetting('lista_activa', filename) - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() return True def eliminar_lista(item): logger.debug() - fullfilename = os.path.join(config.get_data_path(), item.lista) + fullfilename = os.path.join(config.getDataPath(), item.lista) if not os.path.exists(fullfilename): - platformtools.dialog_ok('KoD', config.get_localized_string(70630) + '\n' + item.lista) + platformtools.dialogOk('KoD', config.getLocalizedString(70630) + '\n' + item.lista) return False if item.lista == get_lista_activa(): - platformtools.dialog_ok('KoD', config.get_localized_string(70632) + '\n' + item.lista) + platformtools.dialogOk('KoD', config.getLocalizedString(70632) + '\n' + item.lista) return False - if not platformtools.dialog_yesno(config.get_localized_string(70606), config.get_localized_string(70633) + ' %s ?' % item.lista): return False + if not platformtools.dialogYesNo(config.getLocalizedString(70606), config.getLocalizedString(70633) + ' %s ?' % item.lista): return False filetools.remove(fullfilename) - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() return True def informacion_lista(item): logger.debug() - fullfilename = os.path.join(config.get_data_path(), item.lista) + fullfilename = os.path.join(config.getDataPath(), item.lista) if not os.path.exists(fullfilename): - platformtools.dialog_ok('KoD', config.get_localized_string(70630) + '\n' + item.lista) + platformtools.dialogOk('KoD', config.getLocalizedString(70630) + '\n' + item.lista) return False - alfav = KodfavouritesData(item.lista) + kodfav = KodfavouritesData(item.lista) txt = 'Lista: %s' % item.lista - txt += '[CR]' + config.get_localized_string(70634) + ' ' + alfav.info_lista['created'] + ' ' + config.get_localized_string(70635) + ' ' + alfav.info_lista['updated'] + txt += '[CR]' + config.getLocalizedString(70634) + ' ' + kodfav.info_lista['created'] + ' ' + config.getLocalizedString(70635) + ' ' + kodfav.info_lista['updated'] - if 'downloaded_date' in alfav.info_lista: - txt += '[CR]' + config.get_localized_string(70636) + ' ' + alfav.info_lista['downloaded_date'] + ' ' + alfav.info_lista['downloaded_from'] + ' ' + config.get_localized_string(70637) + if 'downloaded_date' in kodfav.info_lista: + txt += '[CR]' + config.getLocalizedString(70636) + ' ' + kodfav.info_lista['downloaded_date'] + ' ' + kodfav.info_lista['downloaded_from'] + ' ' + config.getLocalizedString(70637) - if 'tinyupload_date' in alfav.info_lista: - txt += '[CR]' + config.get_localized_string(70638) + ' ' + alfav.info_lista['tinyupload_date'] + ' ' + config.get_localized_string(70639) + ' [COLOR blue]' + alfav.info_lista['tinyupload_code'] + '[/COLOR]' + if 'tinyupload_date' in kodfav.info_lista: + txt += '[CR]' + config.getLocalizedString(70638) + ' ' + kodfav.info_lista['tinyupload_date'] + ' ' + config.getLocalizedString(70639) + ' [COLOR blue]' + kodfav.info_lista['tinyupload_code'] + '[/COLOR]' - txt += '[CR]' + config.get_localized_string(70640) + ' ' + str(len(alfav.user_favorites)) - for perfil in alfav.user_favorites: - txt += '[CR]- %s (%d %s)' % (perfil['title'], len(perfil['items']), config.get_localized_string(70641)) + txt += '[CR]' + config.getLocalizedString(70640) + ' ' + str(len(kodfav.user_favorites)) + for perfil in kodfav.user_favorites: + txt += '[CR]- %s (%d %s)' % (perfil['title'], len(perfil['items']), config.getLocalizedString(70641)) - platformtools.dialog_textviewer(config.get_localized_string(70607), txt) + platformtools.dialogTextviewer(config.getLocalizedString(70607), txt) return True def compartir_lista(item): logger.debug() - fullfilename = os.path.join(config.get_data_path(), item.lista) + fullfilename = os.path.join(config.getDataPath(), item.lista) if not os.path.exists(fullfilename): - platformtools.dialog_ok('KoD', config.get_localized_string(70630) + '\n' + fullfilename) + platformtools.dialogOk('KoD', config.getLocalizedString(70630) + '\n' + fullfilename) return False try: - progreso = platformtools.dialog_progress_bg(config.get_localized_string(70643), config.get_localized_string(70644)) + progreso = platformtools.dialogProgressBg(config.getLocalizedString(70643), config.getLocalizedString(70644)) # Access to the tinyupload home page to obtain necessary data from core import httptools, scrapertools @@ -750,7 +750,7 @@ def compartir_lista(item): upload_url = scrapertools.find_single_match(data, 'form action="([^"]+)') sessionid = scrapertools.find_single_match(upload_url, 'sid=(.+)') - progreso.update(10, config.get_localized_string(70645) + '\n' + config.get_localized_string(70646)) + progreso.update(10, config.getLocalizedString(70645) + '\n' + config.getLocalizedString(70646)) # Sending the file to tinyupload using multipart / form-data from future import standard_library @@ -766,24 +766,24 @@ def compartir_lista(item): if not 'File was uploaded successfuly' in data: logger.debug(data) - platformtools.dialog_ok('KoD', config.get_localized_string(70647)) + platformtools.dialogOk('KoD', config.getLocalizedString(70647)) return False codigo = scrapertools.find_single_match(data, 'href="index\.php\?file_id=([^"]+)') except: - platformtools.dialog_ok('KoD', config.get_localized_string(70647) + '\n' + item.lista) + platformtools.dialogOk('KoD', config.getLocalizedString(70647) + '\n' + item.lista) return False # Point code in log file and inside the list - save_log_lista_shared(config.get_localized_string(70648) + ' ' + item.lista + ' ' + codigo + ' ' + config.get_localized_string(70649)) + save_log_lista_shared(config.getLocalizedString(70648) + ' ' + item.lista + ' ' + codigo + ' ' + config.getLocalizedString(70649)) - alfav = KodfavouritesData(item.lista) - alfav.info_lista['tinyupload_date'] = fechahora_actual() - alfav.info_lista['tinyupload_code'] = codigo - alfav.save() + kodfav = KodfavouritesData(item.lista) + kodfav.info_lista['tinyupload_date'] = fechahora_actual() + kodfav.info_lista['tinyupload_code'] = codigo + kodfav.save() - platformtools.dialog_ok('KoD', config.get_localized_string(70650) + '\n' + codigo) + platformtools.dialogOk('KoD', config.getLocalizedString(70650) + '\n' + codigo) return True @@ -791,12 +791,12 @@ def compartir_lista(item): def acciones_nueva_lista(item): logger.debug() - acciones = [config.get_localized_string(70651), - config.get_localized_string(70652), - config.get_localized_string(70653), - config.get_localized_string(70654)] + acciones = [config.getLocalizedString(70651), + config.getLocalizedString(70652), + config.getLocalizedString(70653), + config.getLocalizedString(70654)] - ret = platformtools.dialog_select(config.get_localized_string(70608), acciones) + ret = platformtools.dialogSelect(config.getLocalizedString(70608), acciones) if ret == -1: return False # order cancel @@ -805,43 +805,43 @@ def acciones_nueva_lista(item): return crear_lista(item) elif ret == 1: - codigo = platformtools.dialog_input(default='', heading=config.get_localized_string(70609)) # 05370382084539519168 + codigo = platformtools.dialogInput(default='', heading=config.getLocalizedString(70609)) # 05370382084539519168 if codigo is None or codigo == '': return False return descargar_lista(item, 'http://s000.tinyupload.com/?file_id=' + codigo) elif ret == 2: - url = platformtools.dialog_input(default='https://', heading=config.get_localized_string(70610)) + url = platformtools.dialogInput(default='https://', heading=config.getLocalizedString(70610)) if url is None or url == '': return False return descargar_lista(item, url) elif ret == 3: - txt = config.get_localized_string(70611) - platformtools.dialog_textviewer(config.get_localized_string(70607), txt) + txt = config.getLocalizedString(70611) + platformtools.dialogTextviewer(config.getLocalizedString(70607), txt) return False def crear_lista(item): logger.debug() - titulo = platformtools.dialog_input(default='', heading=config.get_localized_string(70612)) + titulo = platformtools.dialogInput(default='', heading=config.getLocalizedString(70612)) if titulo is None or titulo == '': return False titulo = text_clean(titulo, blank_char='_') filename = get_filename_from_name(titulo) - fullfilename = os.path.join(config.get_data_path(), filename) + fullfilename = os.path.join(config.getDataPath(), filename) # Check that the file does not already exist if os.path.exists(fullfilename): - platformtools.dialog_ok('KoD', config.get_localized_string(70613) + '\n' + fullfilename) + platformtools.dialogOk('KoD', config.getLocalizedString(70613) + '\n' + fullfilename) return False # Cause it to be saved with empty folders by default - alfav = KodfavouritesData(filename) + kodfav = KodfavouritesData(filename) - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() return True @@ -857,17 +857,17 @@ def descargar_lista(item, url): down_url, url_name = scrapertools.find_single_match(data, ' href="(download\.php[^"]*)"><b>([^<]*)') url_json = '{uri.scheme}://{uri.netloc}/'.format(uri=urlparse(url)) + down_url except: - platformtools.dialog_ok('KoD', config.get_localized_string(70655) + '\n' + url) + platformtools.dialogOk('KoD', config.getLocalizedString(70655) + '\n' + url) return False elif 'zippyshare.com/' in url: from core import servertools - video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing('zippyshare', url) + videoUrls, puedes, motivo = servertools.resolve_videoUrls_for_playing('zippyshare', url) if not puedes: - platformtools.dialog_ok('KoD', config.get_localized_string(70655) + '\n' + motivo) + platformtools.dialogOk('KoD', config.getLocalizedString(70655) + '\n' + motivo) return False - url_json = video_urls[0][1] # https://www58.zippyshare.com/d/qPzzQ0UM/25460/kodfavourites-testeanding.json + url_json = videoUrls[0][1] # https://www58.zippyshare.com/d/qPzzQ0UM/25460/kodfavourites-testeanding.json url_name = url_json[url_json.rfind('/')+1:] elif 'friendpaste.com/' in url: @@ -886,7 +886,7 @@ def descargar_lista(item, url): jsondata = jsontools.load(data) if 'user_favorites' not in jsondata or 'info_lista' not in jsondata: logger.debug(data) - platformtools.dialog_ok('KoD', config.get_localized_string(70656)) + platformtools.dialogOk('KoD', config.getLocalizedString(70656)) return False jsondata['info_lista']['downloaded_date'] = fechahora_actual() @@ -895,22 +895,22 @@ def descargar_lista(item, url): # Ask for name for downloaded list nombre = get_name_from_filename(url_name) - titulo = platformtools.dialog_input(default=nombre, heading=config.get_localized_string(70657)) + titulo = platformtools.dialogInput(default=nombre, heading=config.getLocalizedString(70657)) if titulo is None or titulo == '': return False titulo = text_clean(titulo, blank_char='_') filename = get_filename_from_name(titulo) - fullfilename = os.path.join(config.get_data_path(), filename) + fullfilename = os.path.join(config.getDataPath(), filename) # If the new name already exists ask for confirmation to overwrite if os.path.exists(fullfilename): - if not platformtools.dialog_yesno('KoD', config.get_localized_string(70613), config.get_localized_string(70658), filename): + if not platformtools.dialogYesNo('KoD', config.getLocalizedString(70613), config.getLocalizedString(70658), filename): return False if not filetools.write(fullfilename, data): - platformtools.dialog_ok('KoD', config.get_localized_string(70659) + '\n' + filename) + platformtools.dialogOk('KoD', config.getLocalizedString(70659) + '\n' + filename) - platformtools.dialog_ok('KoD', config.get_localized_string(70660) + '\n' + filename) - platformtools.itemlist_refresh() + platformtools.dialogOk('KoD', config.getLocalizedString(70660) + '\n' + filename) + platformtools.itemlistRefresh() return True diff --git a/specials/news.py b/specials/news.py index c40e57ec..b4e3179c 100644 --- a/specials/news.py +++ b/specials/news.py @@ -13,7 +13,7 @@ if sys.version_info[0] >= 3: else: from concurrent_py2 import futures -mode = config.get_setting('result_mode', 'news') +mode = config.getSetting('result_mode', 'news') cacheTime = 10 def mainlist(item): @@ -21,18 +21,18 @@ def mainlist(item): itemlist = [] # list_canales, any_active = get_channels_list() - channel_language = config.get_setting("channel_language", default="auto") + channel_language = config.getSetting("channel_language", default="auto") if channel_language == 'auto': channel_language = auto_filter() - itemlist = [item.clone(action="news", extra="movie", title=config.get_localized_string(30122) + ' {news}'), - item.clone(action="news", extra="tvshow", title=config.get_localized_string(60511) + ' {news}'), - item.clone(action="news", extra="anime", title=config.get_localized_string(60512) + ' {news}')] + itemlist = [item.clone(action="news", extra="movie", title=config.getLocalizedString(30122) + ' {news}'), + item.clone(action="news", extra="tvshow", title=config.getLocalizedString(60511) + ' {news}'), + item.clone(action="news", extra="anime", title=config.getLocalizedString(60512) + ' {news}')] set_category_context(itemlist) itemlist.append(Item(channel='shortcuts', action="SettingOnPosition", category=7, setting=1, - title=support.typo(config.get_localized_string(70285), 'bold color kod'))) + title=support.typo(config.getLocalizedString(70285), 'bold color kod'))) support.thumb(itemlist) set_category_context(itemlist) @@ -43,11 +43,11 @@ def mainlist(item): def set_category_context(itemlist): for item in itemlist: if item.extra: - item.context = [{"title": config.get_localized_string(60514) % item.title, + item.context = [{"title": config.getLocalizedString(60514) % item.title, "extra": item.extra, "action": "setting_channel", "channel": item.channel}] - item.category = config.get_localized_string(60679) % item.title + item.category = config.getLocalizedString(60679) % item.title def get_channels(category='all'): @@ -63,7 +63,7 @@ def get_channels(category='all'): if not ch_param.get("active", False): continue - if not config.get_setting("include_in_newest_" + category, channel): + if not config.getSetting("include_in_newest_" + category, channel): continue channels.append([ch_param.get('title'), channel]) @@ -80,7 +80,7 @@ def news(item): itlist = [] results = cache(item.extra) if not results: - progress = platformtools.dialog_progress(item.category, config.get_localized_string(60519)) + progress = platformtools.dialogProgress(item.category, config.getLocalizedString(60519)) channels = get_channels(item.extra) channelNames = [c[0] for c in channels] @@ -156,7 +156,7 @@ def get_newest(channel, category, channels): _id = channel[1] list_newest = [] try: - module = platformtools.channel_import(_id) + module = platformtools.channelImport(_id) logger.debug('channel_id=', _id, 'category=', category) if not module: @@ -213,13 +213,13 @@ def cache(_type, results=None): return results def settings(item): - return platformtools.show_channel_settings(caption=config.get_localized_string(60532)) + return platformtools.showChannelSettings(caption=config.getLocalizedString(60532)) def setting_channel(item): import os, glob - channels_path = os.path.join(config.get_runtime_path(), "channels", '*.json') - channel_language = config.get_setting("channel_language", default="auto") + channels_path = os.path.join(config.getRuntimePath(), "channels", '*.json') + channel_language = config.getSetting("channel_language", default="auto") if channel_language == 'auto': channel_language = auto_filter() @@ -238,7 +238,7 @@ def setting_channel(item): continue # Do not include if the channel does not exist 'include_in_newest' in your configuration - include_in_newest = config.get_setting("include_in_newest_" + item.extra, channel_id) + include_in_newest = config.getSetting("include_in_newest_" + item.extra, channel_id) if include_in_newest is None or item.extra not in channel_parameters['categories']: continue @@ -251,37 +251,28 @@ def setting_channel(item): list_controls.append(control) - caption = config.get_localized_string(60533) + item.title.replace(config.get_localized_string(60525), "- ").strip() - if config.get_setting("custom_button_value_news", item.channel): - custom_button_label = config.get_localized_string(59992) + caption = config.getLocalizedString(60533) + item.title.replace(config.getLocalizedString(60525), "- ").strip() + if config.getSetting("custom_button_value_news", item.channel): + custom_button_icon = 'subtract' else: - custom_button_label = config.get_localized_string(59991) + custom_button_icon = 'add' - return platformtools.show_channel_settings(list_controls=list_controls, + return platformtools.showChannelSettings(list_controls=list_controls, caption=caption, callback="save_settings", item=item, - custom_button={'visible': True, - 'function': "cb_custom_button", - 'close': False, - 'label': custom_button_label}) + custom_buttons=[{'visible': True, 'function': "cb_custom_button", 'all':True, 'close': False, 'icon': 'add'}, + {'visible': True, 'function': "cb_custom_button", 'all':False, 'close': False, 'icon': 'subtract'}]) def save_settings(item, dict_values): - cache({}) + cache(item.extra, []) for v in dict_values: - config.set_setting("include_in_newest_" + item.extra, dict_values[v], v) + config.setSetting("include_in_newest_" + item.extra, dict_values[v], v) -def cb_custom_button(item, dict_values): - value = config.get_setting("custom_button_value_news", item.channel) - if value == "": - value = False - +def cb_custom_button(item, dict_values, button): for v in list(dict_values.keys()): - dict_values[v] = not value + dict_values[v] = button['all'] - if config.set_setting("custom_button_value_news", not value, item.channel) == True: - return {"label": config.get_localized_string(59992)} - else: - return {"label": config.get_localized_string(59991)} + return {'result':dict_values} diff --git a/specials/news.py.old.py b/specials/news.py.old.py index 8a144d82..1cf55719 100644 --- a/specials/news.py.old.py +++ b/specials/news.py.old.py @@ -22,7 +22,7 @@ from platformcode import config, logger, platformtools THUMBNAILS = {'0': 'posters', '1': 'banners', '2': 'squares'} -__perfil__ = config.get_setting('perfil', "news") +__perfil__ = config.getSetting('perfil', "news") # Set color profile perfil = [['0xFF0B7B92', '0xFF89FDFB', '0xFFACD5D4'], @@ -38,8 +38,8 @@ list_newest = [] list_newest_tourl = [] channels_id_name = {} -menu_cache_path = os.path.join(config.get_data_path(), "settings_channels", 'menu_cache_data.json') -menu_settings_path = os.path.join(config.get_data_path(), "settings_channels", 'menu_settings_data.json') +menu_cache_path = os.path.join(config.getDataPath(), "settings_channels", 'menu_cache_data.json') +menu_settings_path = os.path.join(config.getDataPath(), "settings_channels", 'menu_settings_data.json') def mainlist(item): @@ -47,79 +47,79 @@ def mainlist(item): itemlist = [] # list_canales, any_active = get_channels_list() - channel_language = config.get_setting("channel_language", default="auto") + channel_language = config.getSetting("channel_language", default="auto") if channel_language == 'auto': channel_language = auto_filter() #if list_canales['movies']: # thumbnail = thumb("movie") - new_item = Item(channel=item.channel, action="novedades", extra="movies", title=config.get_localized_string(30122) + '{news}') + new_item = Item(channel=item.channel, action="novedades", extra="movies", title=config.getLocalizedString(30122) + '{news}') set_category_context(new_item) itemlist.append(new_item) # thumbnail = thumb("movie_4k") - # new_item = Item(channel=item.channel, action="novedades", extra="4k", title=config.get_localized_string(70208), thumbnail=thumbnail) + # new_item = Item(channel=item.channel, action="novedades", extra="4k", title=config.getLocalizedString(70208), thumbnail=thumbnail) # # set_category_context(new_item) # itemlist.append(new_item) #if list_canales['terror']: # thumbnail = thumb("channels_horror") - # new_item = Item(channel=item.channel, action="novedades", extra="terror", title=config.get_localized_string(70209), + # new_item = Item(channel=item.channel, action="novedades", extra="terror", title=config.getLocalizedString(70209), # thumbnail=thumbnail) # set_category_context(new_item) # itemlist.append(new_item) #if list_canales['infantiles']: # thumbnail = thumb("children") - # new_item = Item(channel=item.channel, action="novedades", extra="infantiles", title=config.get_localized_string(60510), + # new_item = Item(channel=item.channel, action="novedades", extra="infantiles", title=config.getLocalizedString(60510), # thumbnail=thumbnail) # set_category_context(new_item) # itemlist.append(new_item) #if list_canales['series']: - new_item = Item(channel=item.channel, action="novedades", extra="series", title=config.get_localized_string(60511) + '{news}') + new_item = Item(channel=item.channel, action="novedades", extra="series", title=config.getLocalizedString(60511) + '{news}') set_category_context(new_item) itemlist.append(new_item) #if list_canales['anime']: - new_item = Item(channel=item.channel, action="novedades", extra="anime", title=config.get_localized_string(60512) + '{news}') + new_item = Item(channel=item.channel, action="novedades", extra="anime", title=config.getLocalizedString(60512) + '{news}') set_category_context(new_item) itemlist.append(new_item) # if channel_language == "all": # # if list_canales['Italiano']: # thumbnail = thumb("italian") - # new_item = Item(channel=item.channel, action="novedades", extra="italiano", title=config.get_localized_string(70563), + # new_item = Item(channel=item.channel, action="novedades", extra="italiano", title=config.getLocalizedString(70563), # thumbnail=thumbnail) # set_category_context(new_item) # itemlist.append(new_item) # if list_canales['Torrent']: # thumbnail = thumb("channels_torrent") - # new_item = Item(channel=item.channel, action="novedades", extra="torrent", title=config.get_localized_string(70171), thumbnail=thumbnail) + # new_item = Item(channel=item.channel, action="novedades", extra="torrent", title=config.getLocalizedString(70171), thumbnail=thumbnail) # set_category_context(new_item) # itemlist.append(new_item) #if list_canales['documentales']: # thumbnail = thumb("documentary") - # new_item = Item(channel=item.channel, action="novedades", extra="documentales", title=config.get_localized_string(60513), + # new_item = Item(channel=item.channel, action="novedades", extra="documentales", title=config.getLocalizedString(60513), # thumbnail=thumbnail) # set_category_context(new_item) # itemlist.append(new_item) itemlist.append(Item(channel='shortcuts', action="SettingOnPosition", category=7, setting=1, - title=typo(config.get_localized_string(70285), 'bold color kod'))) + title=typo(config.getLocalizedString(70285), 'bold color kod'))) support.thumb(itemlist) return itemlist def set_category_context(item): - item.context = [{"title": config.get_localized_string(60514) % item.title, + item.context = [{"title": config.getLocalizedString(60514) % item.title, "extra": item.extra, "action": "setting_channel", "channel": item.channel}] - item.category = config.get_localized_string(60679) % re.sub('\[[^\]]+\]','',item.title).strip() + item.category = config.getLocalizedString(60679) % re.sub('\[[^\]]+\]','',item.title).strip() def get_channels_list(): @@ -131,8 +131,8 @@ def get_channels_list(): any_active = False # Fill available channel lists - channels_path = os.path.join(config.get_runtime_path(), "channels", '*.json') - channel_language = config.get_setting("channel_language", default="all") + channels_path = os.path.join(config.getRuntimePath(), "channels", '*.json') + channel_language = config.getSetting("channel_language", default="all") if channel_language =="auto": channel_language = auto_filter() @@ -152,7 +152,7 @@ def get_channels_list(): # Include in each category, if in your configuration the channel is activated to show news for categoria in list_canales: - include_in_newest = config.get_setting("include_in_newest_" + categoria, channel_id) + include_in_newest = config.getSetting("include_in_newest_" + categoria, channel_id) if include_in_newest: channels_id_name[channel_id] = channel_parameters["title"] list_canales[categoria].append((channel_id, channel_parameters["title"])) @@ -170,7 +170,7 @@ def set_cache(item): def get_from_cache(item): logger.debug() itemlist=[] - cache_node = jsontools.get_node_from_file('menu_cache_data.json', 'cached') + cache_node = jsontools.getNodeFromFile('menu_cache_data.json', 'cached') first=item.last last = first+40 #if last >=len(cache_node[item.extra]): @@ -225,19 +225,19 @@ def novedades(item): if os.path.exists(menu_cache_path): return get_from_cache(item) - multithread = config.get_setting("multithread", "news") + multithread = config.getSetting("multithread", "news") logger.debug("multithread= " + str(multithread)) if not multithread: - if platformtools.dialog_yesno(config.get_localized_string(60515), - config.get_localized_string(60516) + '\n' + - config.get_localized_string(60517) + '\n' + - config.get_localized_string(60518)): - if config.set_setting("multithread", True, "news"): + if platformtools.dialogYesNo(config.getLocalizedString(60515), + config.getLocalizedString(60516) + '\n' + + config.getLocalizedString(60517) + '\n' + + config.getLocalizedString(60518)): + if config.setSetting("multithread", True, "news"): multithread = True if mode == 'normal': - progreso = platformtools.dialog_progress(item.category, config.get_localized_string(60519)) + progreso = platformtools.dialogProgress(item.category, config.getLocalizedString(60519)) list_canales, any_active = get_channels_list() @@ -274,13 +274,13 @@ def novedades(item): t.start() threads.append(t) if mode == 'normal': - progreso.update(percentage, config.get_localized_string(60520) % channel_title) + progreso.update(percentage, config.getLocalizedString(60520) % channel_title) # Modo single Thread else: if mode == 'normal': logger.debug("Obteniendo novedades de channel_id=" + channel_id) - progreso.update(percentage, config.get_localized_string(60520) % channel_title) + progreso.update(percentage, config.getLocalizedString(60520) % channel_title) get_newest(channel_id, item.extra) # Multi Thread mode: wait for all threads to finish @@ -293,8 +293,8 @@ def novedades(item): list_pendent_names = [a.getName() for a in pendent] if mode == 'normal': - mensaje = config.get_localized_string(30994) % (", ".join(list_pendent_names)) - progreso.update(percentage, config.get_localized_string(60521) % (len(threads) - len(pendent), len(threads)) + '\n' + + mensaje = config.getLocalizedString(30994) % (", ".join(list_pendent_names)) + progreso.update(percentage, config.getLocalizedString(60521) % (len(threads) - len(pendent), len(threads)) + '\n' + mensaje) logger.debug(mensaje) @@ -305,13 +305,13 @@ def novedades(item): time.sleep(0.5) pendent = [a for a in threads if a.is_alive()] if mode == 'normal': - mensaje = config.get_localized_string(60522) % (len(list_newest), time.time() - start_time) + mensaje = config.getLocalizedString(60522) % (len(list_newest), time.time() - start_time) progreso.update(100, mensaje) logger.debug(mensaje) start_time = time.time() # logger.debug(start_time) - result_mode = config.get_setting("result_mode", "news") + result_mode = config.getSetting("result_mode", "news") if mode != 'normal': result_mode=0 @@ -335,7 +335,7 @@ def novedades(item): return ret else: if mode != 'set_cache': - no_channels = platformtools.dialog_ok(config.get_localized_string(30130) + ' - ' + item.extra + '\n' + config.get_localized_string(70661) + '\n' + config.get_localized_string(70662)) + no_channels = platformtools.dialogOk(config.getLocalizedString(30130) + ' - ' + item.extra + '\n' + config.getLocalizedString(70661) + '\n' + config.getLocalizedString(70662)) return @@ -348,7 +348,7 @@ def get_newest(channel_id, categoria): # We request the news of the category (item.extra) searched in the channel channel # If there are no news for that category in the channel, it returns an empty list try: - modulo = platformtools.channel_import(channel_id) + modulo = platformtools.channelImport(channel_id) if not modulo: return @@ -357,7 +357,7 @@ def get_newest(channel_id, categoria): logger.debug("canal= %s %d resultados" % (channel_id, len(list_result))) exist=False if os.path.exists(menu_cache_path): - cache_node = jsontools.get_node_from_file('menu_cache_data.json', 'cached') + cache_node = jsontools.getNodeFromFile('menu_cache_data.json', 'cached') exist=True else: cache_node = {} @@ -370,7 +370,7 @@ def get_newest(channel_id, categoria): cache_node[categoria] = list_newest_tourl - jsontools.update_node(cache_node, 'menu_cache_data.json', "cached") + jsontools.updateNode(cache_node, 'menu_cache_data.json', "cached") except: logger.error("No se pueden recuperar novedades de: " + channel_id) @@ -422,7 +422,7 @@ def get_title(item): if item.quality: title += support.typo(item.quality, '_ [] color kod') - # season_ = support.typo(config.get_localized_string(70736), '_ [] color white bold') if (type(item.args) != bool and 'season_completed' in item.news and not item.episode) else '' + # season_ = support.typo(config.getLocalizedString(70736), '_ [] color white bold') if (type(item.args) != bool and 'season_completed' in item.news and not item.episode) else '' # if season_: # title += season_ return title @@ -440,7 +440,7 @@ def no_group(list_result_canal): # i.text_color = color3 itemlist.append(i.clone()) - if config.get_setting('order','news') == 1: + if config.getSetting('order','news') == 1: itemlist = sorted(itemlist, key=lambda it: it.title.lower()) return itemlist @@ -505,9 +505,9 @@ def group_by_content(list_result_canal): if len(canales_no_duplicados) > 1: canales = ', '.join([i for i in canales_no_duplicados[:-1]]) - title += config.get_localized_string(70210) % (canales, canales_no_duplicados[-1]) + title += config.getLocalizedString(70210) % (canales, canales_no_duplicados[-1]) else: - title += config.get_localized_string(70211) % (', '.join([i for i in canales_no_duplicados])) + title += config.getLocalizedString(70211) % (', '.join([i for i in canales_no_duplicados])) new_item = v[0].clone(channel="news", title=title, action="show_channels", sub_list=[i.tourl() for i in v], extra=channels_id_name) else: @@ -543,52 +543,52 @@ def show_channels(item): def menu_opciones(item): itemlist = list() - itemlist.append(Item(channel=item.channel, title=config.get_localized_string(60525), + itemlist.append(Item(channel=item.channel, title=config.getLocalizedString(60525), text_bold = True, thumbnail=thumb("setting"), folder=False)) - itemlist.append(Item(channel=item.channel, action="setting_channel", extra="movies", title=config.get_localized_string(60526), + itemlist.append(Item(channel=item.channel, action="setting_channel", extra="movies", title=config.getLocalizedString(60526), thumbnail=thumb("movie"), folder=False)) - # itemlist.append(Item(channel=item.channel, action="setting_channel", extra="4K", title=config.get_localized_string(70207), + # itemlist.append(Item(channel=item.channel, action="setting_channel", extra="4K", title=config.getLocalizedString(70207), # thumbnail=thumb("movie"), folder=False)) - # itemlist.append(Item(channel=item.channel, action="setting_channel", extra="infantiles", title=config.get_localized_string(60527), + # itemlist.append(Item(channel=item.channel, action="setting_channel", extra="infantiles", title=config.getLocalizedString(60527), # thumbnail=thumb("children"), # folder=False)) itemlist.append(Item(channel=item.channel, action="setting_channel", extra="series", - title=config.get_localized_string(60528), + title=config.getLocalizedString(60528), thumbnail=thumb("tvshow"), folder=False)) itemlist.append(Item(channel=item.channel, action="setting_channel", extra="anime", - title=config.get_localized_string(60529), + title=config.getLocalizedString(60529), thumbnail=thumb("anime"), folder=False)) # itemlist.append( - # Item(channel=item.channel, action="setting_channel", extra="castellano", title=config.get_localized_string(70212), + # Item(channel=item.channel, action="setting_channel", extra="castellano", title=config.getLocalizedString(70212), # thumbnail=thumb("documentary"), folder=False)) - # itemlist.append(Item(channel=item.channel, action="setting_channel", extra="latino", title=config.get_localized_string(70213), + # itemlist.append(Item(channel=item.channel, action="setting_channel", extra="latino", title=config.getLocalizedString(70213), # thumbnail=thumb("documentary"), folder=False)) - # itemlist.append(Item(channel=item.channel, action="setting_channel", extra="torrent", title=config.get_localized_string(70214), + # itemlist.append(Item(channel=item.channel, action="setting_channel", extra="torrent", title=config.getLocalizedString(70214), # thumbnail=thumb("documentary"), folder=False)) itemlist.append(Item(channel=item.channel, action="setting_channel", extra="documentales", - title=config.get_localized_string(60530), + title=config.getLocalizedString(60530), thumbnail=thumb("documentary"), folder=False)) - itemlist.append(Item(channel=item.channel, action="settings", title=config.get_localized_string(60531), + itemlist.append(Item(channel=item.channel, action="settings", title=config.getLocalizedString(60531), thumbnail=thumb("setting"), folder=False)) return itemlist def settings(item): - return platformtools.show_channel_settings(caption=config.get_localized_string(60532)) + return platformtools.showChannelSettings(caption=config.getLocalizedString(60532)) def setting_channel(item): - channels_path = os.path.join(config.get_runtime_path(), "channels", '*.json') - channel_language = config.get_setting("channel_language", default="auto") + channels_path = os.path.join(config.getRuntimePath(), "channels", '*.json') + channel_language = config.getSetting("channel_language", default="auto") if channel_language == 'auto': channel_language = auto_filter() @@ -608,7 +608,7 @@ def setting_channel(item): continue # Do not include if the channel does not exist 'include_in_newest' in your configuration - include_in_newest = config.get_setting("include_in_newest_" + item.extra, channel_id) + include_in_newest = config.getSetting("include_in_newest_" + item.extra, channel_id) if include_in_newest is None: continue @@ -621,13 +621,13 @@ def setting_channel(item): list_controls.append(control) - caption = config.get_localized_string(60533) + item.title.replace(config.get_localized_string(60525), "- ").strip() - if config.get_setting("custom_button_value_news", item.channel): - custom_button_label = config.get_localized_string(59992) + caption = config.getLocalizedString(60533) + item.title.replace(config.getLocalizedString(60525), "- ").strip() + if config.getSetting("custom_button_value_news", item.channel): + custom_button_label = config.getLocalizedString(59992) else: - custom_button_label = config.get_localized_string(59991) + custom_button_label = config.getLocalizedString(59991) - return platformtools.show_channel_settings(list_controls=list_controls, + return platformtools.showChannelSettings(list_controls=list_controls, caption=caption, callback="save_settings", item=item, custom_button={'visible': True, @@ -638,19 +638,19 @@ def setting_channel(item): def save_settings(item, dict_values): for v in dict_values: - config.set_setting("include_in_newest_" + item.extra, dict_values[v], v) + config.setSetting("include_in_newest_" + item.extra, dict_values[v], v) def cb_custom_button(item, dict_values): - value = config.get_setting("custom_button_value_news", item.channel) + value = config.getSetting("custom_button_value_news", item.channel) if value == "": value = False for v in list(dict_values.keys()): dict_values[v] = not value - if config.set_setting("custom_button_value_news", not value, item.channel) == True: - return {"label": config.get_localized_string(59992)} + if config.setSetting("custom_button_value_news", not value, item.channel) == True: + return {"label": config.getLocalizedString(59992)} else: - return {"label": config.get_localized_string(59991)} + return {"label": config.getLocalizedString(59991)} diff --git a/specials/search.py b/specials/search.py index 7486390a..0e453dd2 100644 --- a/specials/search.py +++ b/specials/search.py @@ -3,7 +3,7 @@ # Search Entry Point # ------------------------------------------------------------ -import xbmc +import xbmc, json from core.item import Item from core.support import typo, thumb from platformcode import logger, config, platformtools @@ -13,21 +13,21 @@ def mainlist(item): action = 'new_search' channel = 'classicsearch' folder = True - if platformtools.get_window() not in ('WINDOW_SETTINGS_MENU', 'WINDOW_SETTINGS_INTERFACE', 'WINDOW_SKIN_SETTINGS')\ - and xbmc.getInfoLabel('System.CurrentWindow') in ('Home', '') and config.get_setting('new_search'): + if platformtools.getWindow() not in ('WINDOW_SETTINGS_MENU', 'WINDOW_SETTINGS_INTERFACE', 'WINDOW_SKIN_SETTINGS')\ + and xbmc.getInfoLabel('System.CurrentWindow') in ('Home', '') and config.getSetting('new_search'): channel = 'globalsearch' folder = False - itemlist = [Item(channel=channel, title=config.get_localized_string(70276), action=action, mode='all', folder=folder), - Item(channel=channel, title=config.get_localized_string(70741) % config.get_localized_string(30122), action=action, mode='movie', folder=folder), - Item(channel=channel, title=config.get_localized_string(70741) % config.get_localized_string(30123), action=action, mode='tvshow', folder=folder), - Item(channel=channel, title=config.get_localized_string(70741) % config.get_localized_string(70314), action=action, page=1, mode='person', folder=folder), + itemlist = [Item(channel=channel, title=config.getLocalizedString(70276), action=action, mode='all', folder=folder), + Item(channel=channel, title=config.getLocalizedString(70741) % config.getLocalizedString(30122), action=action, mode='movie', folder=folder), + Item(channel=channel, title=config.getLocalizedString(70741) % config.getLocalizedString(30123), action=action, mode='tvshow', folder=folder), + Item(channel=channel, title=config.getLocalizedString(70741) % config.getLocalizedString(70314), action=action, page=1, mode='person', folder=folder), - Item(channel=item.channel, title=config.get_localized_string(59995), action='saved_search', thumbnail=thumb('search')), - Item(channel=item.channel, title=config.get_localized_string(60420), action='sub_menu', thumbnail=thumb('search')), - Item(channel="tvmoviedb", title=config.get_localized_string(70274), action="mainlist", thumbnail=thumb('search')), - Item(channel=item.channel, title=typo(config.get_localized_string(59994), 'bold'), action='channel_selections', folder=False), - Item(channel='shortcuts', title=typo(config.get_localized_string(70286), 'bold'), action='SettingOnPosition', category=5, setting=1, folder=False)] + Item(channel=item.channel, title=config.getLocalizedString(59995), action='saved_search', thumbnail=thumb('search')), + Item(channel=item.channel, title=config.getLocalizedString(60420), action='sub_menu', thumbnail=thumb('search')), + Item(channel="tvmoviedb", title=config.getLocalizedString(70274), action="mainlist", thumbnail=thumb('search')), + Item(channel=item.channel, title=typo(config.getLocalizedString(59994), 'bold'), action='channel_selections', folder=False), + Item(channel='shortcuts', title=typo(config.getLocalizedString(70286), 'bold'), action='SettingOnPosition', category=5, setting=1, folder=False)] thumb(itemlist) return itemlist @@ -36,16 +36,16 @@ def mainlist(item): def sub_menu(item): logger.debug() channel = 'classicsearch' - itemlist = [Item(channel=channel, action='genres_menu', title=config.get_localized_string(70306), mode='movie'), - Item(channel=channel, action='years_menu', title=config.get_localized_string(70742), mode='movie'), - Item(channel=channel, action='discover_list', title=config.get_localized_string(70307), search_type='list', list_type='movie/popular', mode='movie'), - Item(channel=channel, action='discover_list', title=config.get_localized_string(70308), search_type='list', list_type='movie/top_rated', mode='movie'), - Item(channel=channel, action='discover_list', title=config.get_localized_string(70309), search_type='list', list_type='movie/now_playing', mode='movie'), - Item(channel=channel, action='genres_menu', title=config.get_localized_string(70310), mode='tvshow'), - Item(channel=channel, action='years_menu', title=config.get_localized_string(70743), mode='tvshow'), - Item(channel=channel, action='discover_list', title=config.get_localized_string(70311), search_type='list', list_type='tv/popular', mode='tvshow'), - Item(channel=channel, action='discover_list', title=config.get_localized_string(70312), search_type='list', list_type='tv/on_the_air', mode='tvshow'), - Item(channel=channel, action='discover_list', title=config.get_localized_string(70313), search_type='list', list_type='tv/top_rated', mode='tvshow')] + itemlist = [Item(channel=channel, action='genres_menu', title=config.getLocalizedString(70306), mode='movie'), + Item(channel=channel, action='years_menu', title=config.getLocalizedString(70742), mode='movie'), + Item(channel=channel, action='discover_list', title=config.getLocalizedString(70307), search_type='list', list_type='movie/popular', mode='movie'), + Item(channel=channel, action='discover_list', title=config.getLocalizedString(70308), search_type='list', list_type='movie/top_rated', mode='movie'), + Item(channel=channel, action='discover_list', title=config.getLocalizedString(70309), search_type='list', list_type='movie/now_playing', mode='movie'), + Item(channel=channel, action='genres_menu', title=config.getLocalizedString(70310), mode='tvshow'), + Item(channel=channel, action='years_menu', title=config.getLocalizedString(70743), mode='tvshow'), + Item(channel=channel, action='discover_list', title=config.getLocalizedString(70311), search_type='list', list_type='tv/popular', mode='tvshow'), + Item(channel=channel, action='discover_list', title=config.getLocalizedString(70312), search_type='list', list_type='tv/on_the_air', mode='tvshow'), + Item(channel=channel, action='discover_list', title=config.getLocalizedString(70313), search_type='list', list_type='tv/top_rated', mode='tvshow')] itemlist = set_context(itemlist) thumb(itemlist) @@ -56,13 +56,13 @@ def set_context(itemlist): logger.debug() channel = 'classicsearch' for elem in itemlist: - elem.context = [{"title": config.get_localized_string(60412), + elem.context = [{"title": config.getLocalizedString(60412), "action": "channel_selections", "channel": channel}, - {"title": config.get_localized_string(60415), + {"title": config.getLocalizedString(60415), "action": "settings", "channel": channel}, - {"title": config.get_localized_string(60416), + {"title": config.getLocalizedString(60416), "action": "clear_saved_searches", "channel": channel}] return itemlist @@ -87,8 +87,8 @@ def channel_selections(item): # Do not include if "include_in_global_search" does not exist in the channel configuration if not channel_parameters['include_in_global_search']: continue - label_cat = ', '.join(config.get_localized_category(c) for c in channel_parameters['categories']) - label_lang = ', '.join(config.get_localized_language(l) for l in channel_parameters['language']) + label_cat = ', '.join(config.getLocalizedCategory(c) for c in channel_parameters['categories']) + label_lang = ', '.join(config.getLocalizedLanguage(l) for l in channel_parameters['language']) label = '{} [{}]'.format(label_cat, label_lang) it = xbmcgui.ListItem(channel.title, label) @@ -100,23 +100,23 @@ def channel_selections(item): # Pre-select dialog preselections = [ - config.get_localized_string(70570), - config.get_localized_string(70571), - config.get_localized_string(70572), - config.get_localized_string(70573), + config.getLocalizedString(70570), + config.getLocalizedString(70571), + config.getLocalizedString(70572), + config.getLocalizedString(70573), ] preselections_values = ['skip', 'actual', 'all', 'none'] categories = ['movie', 'tvshow', 'documentary', 'anime', 'sub', 'live', 'torrent'] for c in categories: - preselections.append(config.get_localized_string(70577) + config.get_localized_category(c)) + preselections.append(config.getLocalizedString(70577) + config.getLocalizedCategory(c)) preselections_values.append(c) if item.action == 'setting_channel': # Configure channels included in search del preselections[0] del preselections_values[0] - ret = platformtools.dialog_select(config.get_localized_string(59994), preselections) + ret = platformtools.dialogSelect(config.getLocalizedString(59994), preselections) if ret == -1: return False # order cancel if preselections_values[ret] == 'skip': @@ -128,7 +128,7 @@ def channel_selections(item): elif preselections_values[ret] == 'actual': preselect = [] for i, channel in enumerate(ids): - channel_status = config.get_setting('include_in_global_search', channel) + channel_status = config.getSetting('include_in_global_search', channel) if channel_status: preselect.append(i) else: @@ -138,27 +138,27 @@ def channel_selections(item): preselect.append(i) # Selection Dialog - ret = platformtools.dialog_multiselect(config.get_localized_string(59994), channel_list, preselect=preselect, useDetails=True) + ret = platformtools.dialogMultiselect(config.getLocalizedString(59994), channel_list, preselect=preselect, useDetails=True) if ret == None: return False # order cancel selected = [ids[i] for i in ret] # Save changes to search channels for channel in ids: - channel_status = config.get_setting('include_in_global_search', channel) + channel_status = config.getSetting('include_in_global_search', channel) if channel_status and channel not in selected: - config.set_setting('include_in_global_search', False, channel) + config.setSetting('include_in_global_search', False, channel) elif not channel_status and channel in selected: - config.set_setting('include_in_global_search', True, channel) + config.setSetting('include_in_global_search', True, channel) return True def save_search(text): if text: - saved_searches_limit = config.get_setting("saved_searches_limit") + saved_searches_limit = config.getSetting("saved_searches_limit") - current_saved_searches_list = config.get_setting("saved_searches_list", "search") + current_saved_searches_list = config.getSetting("saved_searches_list", "search") if current_saved_searches_list is None: saved_searches_list = [] else: @@ -169,44 +169,75 @@ def save_search(text): saved_searches_list.insert(0, text) - config.set_setting("saved_searches_list", saved_searches_list[:saved_searches_limit], "search") + config.setSetting("saved_searches_list", saved_searches_list[:saved_searches_limit], "search") def clear_saved_searches(item): - config.set_setting("saved_searches_list", list(), "search") - platformtools.dialog_ok(config.get_localized_string(60423), config.get_localized_string(60424)) + config.setSetting("saved_searches_list", list(), "search") + platformtools.dialogOk(config.getLocalizedString(60423), config.getLocalizedString(60424)) def saved_search(item): logger.debug() - itemlist = list() - saved_searches_list = get_saved_searches() + itemlist = get_saved_searches() - - for saved_search_text in saved_searches_list: - itemlist.append( - Item(channel=item.channel if not config.get_setting('new_search') else 'globalsearch', - action="new_search" if not config.get_setting('new_search') else 'Search', - title=typo(saved_search_text.split('{}')[0], 'bold'), - search_text=saved_search_text.split('{}')[0], - text=saved_search_text.split('{}')[0], - mode='all', - thumbnail=thumb('search'))) - - if len(saved_searches_list) > 0: + if len(itemlist) > 0: itemlist.append( Item(channel=item.channel, action="clear_saved_searches", - title=typo(config.get_localized_string(60417), 'color kod bold'), + title=typo(config.getLocalizedString(60417), 'color kod bold'), thumbnail=thumb('search'))) itemlist = set_context(itemlist) return itemlist def get_saved_searches(): - current_saved_searches_list = config.get_setting("saved_searches_list", "search") - if current_saved_searches_list is None: - saved_searches_list = [] - else: - saved_searches_list = list(current_saved_searches_list) + current_saved_searches_list = config.getSetting("saved_searches_list", "search") + if not current_saved_searches_list: + current_saved_searches_list = [] + saved_searches_list = [] + for saved_search_item in current_saved_searches_list: + if type(saved_search_item) == str: + text = saved_search_item.split('{}')[0] + saved_searches_list.append( + Item(channel='globalsearch' if config.getSetting('new_search') else 'classicsearch', + folder=False if config.getSetting('new_search') else True, + action="new_search", + title=text, + search_text=text, + text=text, + mode= 'all', + thumbnail=thumb('search'))) + else: + item = Item().fromjson(json.dumps(saved_search_item)) + if item.action == 'Search': + item.action = 'new_search' + if item.type: item.mode = 'search/'+item.type + saved_searches_list.append(item) - return saved_searches_list \ No newline at end of file + return saved_searches_list + +def from_context(item): + logger.debug() + from specials import globalsearch, classicsearch + + select = channel_selections(item) + + if not select: + return + + if 'infoLabels' in item and 'mediatype' in item.infoLabels: + item.mode = item.infoLabels['mediatype'] + else: + return + + if config.getSetting('new_search') and not item.page: + if item.infoLabels['tmdb_id']: + item.mode = 'search/' + item.mode + return globalsearch.new_search(item) + + if 'list_type' not in item: + if 'wanted' in item: + item.title = item.wanted + return classicsearch.channel_search(item) + + return classicsearch.discover_list(item) \ No newline at end of file diff --git a/specials/setting.py b/specials/setting.py index 763e884a..d6069401 100644 --- a/specials/setting.py +++ b/specials/setting.py @@ -16,20 +16,20 @@ CHANNELNAME = "setting" def channel_config(item): - return platformtools.show_channel_settings(channelpath=filetools.join(config.get_runtime_path(), "channels", item.config)) + return platformtools.showChannelSettings(channelpath=filetools.join(config.getRuntimePath(), "channels", item.config)) def server_config(item): - return platformtools.show_channel_settings(channelpath=filetools.join(config.get_runtime_path(), "servers", item.config)) + return platformtools.showChannelSettings(channelpath=filetools.join(config.getRuntimePath(), "servers", item.config)) def server_debrid_config(item): - return platformtools.show_channel_settings(channelpath=filetools.join(config.get_runtime_path(), "servers", "debriders", item.config)) + return platformtools.showChannelSettings(channelpath=filetools.join(config.getRuntimePath(), "servers", "debriders", item.config)) def servers_blacklist(item): server_list = servertools.get_servers_list() - black_list = config.get_setting("black_list", server='servers', default=[]) + black_list = config.getSetting("black_list", server='servers', default=[]) blacklisted = [] list_controls = [] @@ -40,12 +40,12 @@ def servers_blacklist(item): defaults = servertools.get_server_parameters(server) control = server_parameters["name"] - if not config.get_setting("black_list", server=server): + if not config.getSetting("black_list", server=server): list_controls.append(control) if defaults.get("black_list", False) or server in black_list: blacklisted.append(i) list_servers.append(server) - ris = platformtools.dialog_multiselect(config.get_localized_string(60550), list_controls, preselect=blacklisted) + ris = platformtools.dialogMultiselect(config.getLocalizedString(60550), list_controls, preselect=blacklisted) if ris is not None: cb_servers_blacklist({list_servers[n]: True if n in ris else False for n, it in enumerate(list_controls)}) @@ -60,27 +60,27 @@ def servers_favorites(item): list_controls = [{'id': 'favorites_servers', 'type': 'bool', - 'label': config.get_localized_string(60577), + 'label': config.getLocalizedString(60577), 'default': False, 'enabled': True, 'visible': True}, {'id': 'quality_priority', 'type': 'bool', - 'label': config.get_localized_string(30069), + 'label': config.getLocalizedString(30069), 'default': False, 'enabled': 'eq(-1,True)', 'visible': True}] - dict_values['favorites_servers'] = config.get_setting('favorites_servers') - dict_values['quality_priority'] = config.get_setting('quality_priority') + dict_values['favorites_servers'] = config.getSetting('favorites_servers') + dict_values['quality_priority'] = config.getSetting('quality_priority') if dict_values['favorites_servers'] == None: dict_values['favorites_servers'] = False - server_names = [config.get_localized_string(59992)] - favorites = config.get_setting("favorites_servers_list", server='servers', default=[]) - blacklisted = config.get_setting("black_list", server='servers', default=[]) + server_names = [config.getLocalizedString(59992)] + favorites = config.getSetting("favorites_servers_list", server='servers', default=[]) + blacklisted = config.getSetting("black_list", server='servers', default=[]) for server in sorted(server_list.keys()): - if server in blacklisted or config.get_setting("black_list", server=server): + if server in blacklisted or config.getSetting("black_list", server=server): continue server_names.append(server_list[server]['name']) @@ -91,53 +91,28 @@ def servers_favorites(item): for x in range(1, 21): control = {'id': x, 'type': 'list', - 'label': config.get_localized_string(60597) % x, + 'label': config.getLocalizedString(60597) % x, 'lvalues': server_names, 'default': 0, 'enabled': 'eq(-%s,True)' % str(x + 1), 'visible': True} list_controls.append(control) - return platformtools.show_channel_settings(list_controls=list_controls, dict_values=dict_values, item=server_names, - caption=config.get_localized_string(60551), callback="cb_servers_favorites") - - -def cb_servers_favorites(server_names, dict_values): - dict_name = {} - dict_favorites = {} - - for i, v in list(dict_values.items()): - if i == "favorites_servers": - config.set_setting("favorites_servers", v) - elif i == "quality_priority": - config.set_setting("quality_priority", v) - elif int(v) > 0: - dict_name[server_names[v]] = int(i) - - servers_list = list(servertools.get_servers_list().items()) - for server, server_parameters in servers_list: - if server_parameters['name'] in list(dict_name.keys()): - dict_favorites[dict_name[server_parameters['name']]] = server - - favorites_servers_list = [dict_favorites[k] for k in sorted(dict_favorites.keys())] - - config.set_setting("favorites_servers_list", favorites_servers_list, server='servers') - - if not favorites_servers_list: # If there is no server in the list, deactivate it - config.set_setting("favorites_servers", False) + return platformtools.showChannelSettings(list_controls=list_controls, dict_values=dict_values, item=server_names, + caption=config.getLocalizedString(60551)) def settings(item): - config.open_settings() + config.openSettings() def check_quickfixes(item): logger.debug() - if not config.dev_mode(): + if not config.devMode(): from platformcode import updater if not updater.check()[0]: - platformtools.dialog_ok('Kodi on Demand', config.get_localized_string(70667)) + platformtools.dialogOk('Kodi on Demand', config.getLocalizedString(70667)) else: return False @@ -147,7 +122,7 @@ def conf_tools(item): # Enable or disable channels if item.extra == "channels_onoff": - if config.get_platform(True)['num_version'] >= 17.0: # From Kodi 16 you can use multiselect, and from 17 with preselect + if config.getXBMCPlatform(True)['num_version'] >= 17.0: # From Kodi 16 you can use multiselect, and from 17 with preselect return channels_onoff(item) import channelselector @@ -167,14 +142,14 @@ def conf_tools(item): try: list_controls.append({'id': "all_channels", 'type': "list", - 'label': config.get_localized_string(60594), + 'label': config.getLocalizedString(60594), 'default': 0, 'enabled': True, 'visible': True, 'lvalues': ['', - config.get_localized_string(60591), - config.get_localized_string(60592), - config.get_localized_string(60593)]}) + config.getLocalizedString(60591), + config.getLocalizedString(60592), + config.getLocalizedString(60593)]}) for channel in channel_list: # If the channel is on the exclusion list, we skip it @@ -183,13 +158,13 @@ def conf_tools(item): channel_parameters = channeltools.get_channel_parameters(channel.channel) status_control = "" - status = config.get_setting("enabled", channel.channel) + status = config.getSetting("enabled", channel.channel) # if status does not exist, there is NO value in _data.json if status is None: status = channel_parameters["active"] logger.debug("%s | Status (XML): %s" % (channel.channel, status)) if not status: - status_control = config.get_localized_string(60595) + status_control = config.getLocalizedString(60595) else: logger.debug("%s | Status: %s" % (channel.channel, status)) @@ -208,11 +183,10 @@ def conf_tools(item): import traceback logger.error("Error: %s" % traceback.format_exc()) else: - return platformtools.show_channel_settings(list_controls=list_controls, + return platformtools.showChannelSettings(list_controls=list_controls, item=item.clone(channel_list=channel_list), - caption=config.get_localized_string(60596), - callback="channel_status", - custom_button={"visible": False}) + caption=config.getLocalizedString(60596), + callback="channel_status") # Checking channel_data.json files elif item.extra == "lib_check_datajson": @@ -241,14 +215,14 @@ def conf_tools(item): if not list_controls: itemlist.append(Item(channel=CHANNELNAME, - title=channel.title + config.get_localized_string(60569), + title=channel.title + config.getLocalizedString(60569), action="", folder=False, thumbnail=channel.thumbnail)) continue # logger.debug(channel.channel + " SALTADO!") # The json file settings of the channel are loaded - file_settings = os.path.join(config.get_data_path(), "settings_channels", channel.channel + "_data.json") + file_settings = os.path.join(config.getDataPath(), "settings_channels", channel.channel + "_data.json") dict_settings = {} dict_file = {} if filetools.exists(file_settings): @@ -270,7 +244,7 @@ def conf_tools(item): datajson_size = filetools.getsize(file_settings) except: import traceback - logger.error(channel.title + config.get_localized_string(60570) % traceback.format_exc()) + logger.error(channel.title + config.getLocalizedString(60570) % traceback.format_exc()) else: datajson_size = None @@ -285,7 +259,7 @@ def conf_tools(item): # logger.debug(channel.title + " | Default: %s" % default_settings) except: import traceback - logger.error(channel.title + config.get_localized_string(60570) % traceback.format_exc()) + logger.error(channel.title + config.getLocalizedString(60570) % traceback.format_exc()) # default_settings = {} # If _data.json needs to be repaired or doesn't exist ... @@ -298,10 +272,10 @@ def conf_tools(item): # We create the file ../settings/channel_data.json if not filetools.write(file_settings, jsontools.dump(dict_file), silent=True): logger.error("ERROR saving file: %s" % file_settings) - list_status = config.get_localized_string(60560) + list_status = config.getLocalizedString(60560) else: if default_settings is None: - list_status = config.get_localized_string(60571) + list_status = config.getLocalizedString(60571) else: # logger.debug(channel.channel + " - NO correction needed!") @@ -311,18 +285,18 @@ def conf_tools(item): if needsfix is not None: if needsfix: if not channeljson_exists: - list_status = config.get_localized_string(60588) + list_status = config.getLocalizedString(60588) list_colour = "red" else: - list_status = config.get_localized_string(60589) + list_status = config.getLocalizedString(60589) list_colour = "green" else: # If "needsfix" is "false" and "datjson_size" is None, an error will have occurred if datajson_size is None: - list_status = config.get_localized_string(60590) + list_status = config.getLocalizedString(60590) list_colour = "red" else: - list_status = config.get_localized_string(60589) + list_status = config.getLocalizedString(60589) list_colour = "green" if list_status is not None: @@ -355,8 +329,8 @@ def channels_onoff(item): for channel in channels_list: channel_parameters = channeltools.get_channel_parameters(channel.channel) lbl = '%s' % channel_parameters['language'] - # ~ lbl += ' %s' % [config.get_localized_category(categ) for categ in channel_parameters['categories']] - lbl += ' %s' % ', '.join(config.get_localized_category(categ) for categ in channel_parameters['categories']) + # ~ lbl += ' %s' % [config.getLocalizedCategory(categ) for categ in channel_parameters['categories']] + lbl += ' %s' % ', '.join(config.getLocalizedCategory(categ) for categ in channel_parameters['categories']) it = xbmcgui.ListItem(channel.title, lbl) it.setArt({ 'thumb': channel.thumbnail, 'fanart': channel.fanart }) @@ -365,35 +339,35 @@ def channels_onoff(item): # Dialog to pre-select # ---------------------------- - preselecciones = [config.get_localized_string(70517), config.get_localized_string(70518), config.get_localized_string(70519)] - ret = platformtools.dialog_select(config.get_localized_string(60545), preselecciones) + preselecciones = [config.getLocalizedString(70517), config.getLocalizedString(70518), config.getLocalizedString(70519)] + ret = platformtools.dialogSelect(config.getLocalizedString(60545), preselecciones) if ret == -1: return False # order cancel if ret == 2: preselect = [] elif ret == 1: preselect = list(range(len(ids))) else: preselect = [] for i, canal in enumerate(ids): - channel_status = config.get_setting('enabled', canal) + channel_status = config.getSetting('enabled', canal) if channel_status is None: channel_status = True if channel_status: preselect.append(i) # Dialog to select # ------------------------ - ret = platformtools.dialog_multiselect(config.get_localized_string(60545), lista, preselect=preselect, useDetails=True) + ret = platformtools.dialogMultiselect(config.getLocalizedString(60545), lista, preselect=preselect, useDetails=True) if ret == None: return False # order cancel seleccionados = [ids[i] for i in ret] # Save changes to activated channels # ------------------------------------ for canal in ids: - channel_status = config.get_setting('enabled', canal) + channel_status = config.getSetting('enabled', canal) if channel_status is None: channel_status = True if channel_status and canal not in seleccionados: - config.set_setting('enabled', False, canal) + config.setSetting('enabled', False, canal) elif not channel_status and canal in seleccionados: - config.set_setting('enabled', True, canal) + config.setSetting('enabled', True, canal) return False @@ -429,7 +403,7 @@ def channel_status(item, dict_values): # Retrieve default status option if dict_values[k] == 3: # If you have "enabled" in the _data.json, it is because the state is not that of the channel.json - if config.get_setting("enabled", channel.channel): + if config.getSetting("enabled", channel.channel): new_status_all = new_status_all_default # If the channel does not have "enabled" in the _data.json it is not saved, it goes to the next @@ -438,22 +412,22 @@ def channel_status(item, dict_values): # Channel status is saved if new_status_all is not None: - config.set_setting("enabled", new_status_all, channel.channel) + config.setSetting("enabled", new_status_all, channel.channel) break else: continue else: logger.info("Channel: %s | State: %s" % (k, dict_values[k])) - config.set_setting("enabled", dict_values[k], k) - logger.info("the value is like %s " % config.get_setting("enabled", k)) + config.setSetting("enabled", dict_values[k], k) + logger.info("the value is like %s " % config.getSetting("enabled", k)) - platformtools.itemlist_update(Item(channel=CHANNELNAME, action="mainlist")) + platformtools.itemlistUpdate(Item(channel=CHANNELNAME, action="mainlist")) except: import traceback logger.error("Error detail: %s" % traceback.format_exc()) - platformtools.dialog_notification(config.get_localized_string(60579), config.get_localized_string(60580)) + platformtools.dialogNotification(config.getLocalizedString(60579), config.getLocalizedString(60580)) def restore_tools(item): @@ -461,13 +435,13 @@ def restore_tools(item): from core import videolibrarytools import os - seleccion = platformtools.dialog_yesno(config.get_localized_string(60581), - config.get_localized_string(60582) + '\n' + - config.get_localized_string(60583)) + seleccion = platformtools.dialogYesNo(config.getLocalizedString(60581), + config.getLocalizedString(60582) + '\n' + + config.getLocalizedString(60583)) if seleccion == 1: # tvshows - heading = config.get_localized_string(60584) - p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(60585), heading) + heading = config.getLocalizedString(60584) + p_dialog = platformtools.dialogProgressBg(config.getLocalizedString(60585), heading) p_dialog.update(0, '') show_list = [] @@ -495,8 +469,8 @@ def restore_tools(item): p_dialog.close() # movies - heading = config.get_localized_string(60586) - p_dialog2 = platformtools.dialog_progress_bg(config.get_localized_string(60585), heading) + heading = config.getLocalizedString(60586) + p_dialog2 = platformtools.dialogProgressBg(config.getLocalizedString(60585), heading) p_dialog2.update(0, '') movies_list = [] @@ -518,9 +492,9 @@ def restore_tools(item): filetools.rmdirtree(path) import math - heading = config.get_localized_string(20000) + heading = config.getLocalizedString(20000) - p_dialog2.update(int(math.ceil((i + 1) * t)), heading, config.get_localized_string(60389) % (movie.contentTitle, + p_dialog2.update(int(math.ceil((i + 1) * t)), heading, config.getLocalizedString(60389) % (movie.contentTitle, movie.channel.capitalize())) # ... and we add it again videolibrarytools.save_movie(movie) @@ -549,24 +523,24 @@ def report_menu(item): # Free pastbin servers have capacity limitations, so the size of the log is important # At the end of the upload operation, the user is passed the log address on the server to report them - itemlist.append(Item(channel=item.channel, action="", title=config.get_localized_string(707418), + itemlist.append(Item(channel=item.channel, action="", title=config.getLocalizedString(707418), thumbnail=thumb_next, folder=False)) - # if not config.get_setting('debug'): + # if not config.getSetting('debug'): itemlist.append(Item(channel=item.channel, action="activate_debug", extra=True, - title=config.get_localized_string(707419) % + title=config.getLocalizedString(707419) % str(paso), thumbnail=thumb_debug, folder=False)) paso += 1 itemlist.append(Item(channel="channelselector", action="getmainlist", - title=config.get_localized_string(707420) % + title=config.getLocalizedString(707420) % str(paso), thumbnail=thumb_debug)) paso += 1 itemlist.append(Item(channel=item.channel, action="report_send", - title=config.get_localized_string(707421) % + title=config.getLocalizedString(707421) % str(paso), thumbnail=thumb_error, folder=False)) paso += 1 - # if config.get_setting('debug'): + # if config.getSetting('debug'): itemlist.append(Item(channel=item.channel, action="activate_debug", extra=False, - title=config.get_localized_string(707422) % str(paso), + title=config.getLocalizedString(707422) % str(paso), thumbnail=thumb_debug, folder=False)) paso += 1 @@ -574,7 +548,7 @@ def report_menu(item): itemlist.append(Item(channel=item.channel, action="", title="", folder=False)) itemlist.append(Item(channel=item.channel, action="", - title=config.get_localized_string(707423), + title=config.getLocalizedString(707423), thumbnail=thumb_next, folder=False)) if item.one_use: @@ -588,10 +562,10 @@ def report_menu(item): thumbnail=thumb_next, unify=False, folder=False)) if item.one_use: itemlist.append(Item(channel=item.channel, action="", - title=config.get_localized_string(60305), + title=config.getLocalizedString(60305), thumbnail=thumb_next, folder=False)) itemlist.append(Item(channel=item.channel, action="", - title=config.get_localized_string(60308), + title=config.getLocalizedString(60308), thumbnail=thumb_next, folder=False)) itemlist.append(Item(channel=item.channel, action="call_browser", title="su Github (raccomandato)", url='https://github.com/kodiondemand/addon/issues', @@ -613,11 +587,11 @@ def activate_debug(item): if isinstance(item.extra, str): return report_menu(item) if item.extra: - config.set_setting('debug', True) - platformtools.dialog_notification(config.get_localized_string(707430), config.get_localized_string(707431)) + config.setSetting('debug', True) + platformtools.dialogNotification(config.getLocalizedString(707430), config.getLocalizedString(707431)) else: - config.set_setting('debug', False) - platformtools.dialog_notification(config.get_localized_string(707430), config.get_localized_string(707432)) + config.setSetting('debug', False) + platformtools.dialogNotification(config.getLocalizedString(707430), config.getLocalizedString(707432)) def report_send(item, description='', fatal=False): @@ -698,16 +672,16 @@ def report_send(item, description='', fatal=False): paste_params = () paste_post = '' status = False - msg = config.get_localized_string(707424) + msg = config.getLocalizedString(707424) # DEBUG = ON is verified, if it is not it is rejected and the user is asked to activate it and reproduce the fault - if not config.get_setting('debug'): - platformtools.dialog_notification(config.get_localized_string(707425), config.get_localized_string(707426)) + if not config.getSetting('debug'): + platformtools.dialogNotification(config.getLocalizedString(707425), config.getLocalizedString(707426)) return report_menu(item) # From each to the future the user will be allowed to enter a brief description of the fault that will be added to the LOG if description == 'OK': - description = platformtools.dialog_input('', 'Introduzca una breve descripción del fallo') + description = platformtools.dialogInput('', 'Introduzca una breve descripción del fallo') # We write in the log some Kodi and Alpha variables that will help us diagnose the failure environment = envtal.list_env() @@ -723,10 +697,10 @@ def report_send(item, description='', fatal=False): log_size = float(environment['log_size']) # File size in MB log_data = filetools.read(log_path) # File data if not log_data: # Some mistake? - platformtools.dialog_notification(config.get_localized_string(707427), '', 2) + platformtools.dialogNotification(config.getLocalizedString(707427), '', 2) return report_menu(item) else: # Log no existe or erroneous path? - platformtools.dialog_notification(config.get_localized_string(707427), '', 2) + platformtools.dialogNotification(config.getLocalizedString(707427), '', 2) return report_menu(item) # If the fault description has been entered, the beginning of the LOG data is inserted @@ -765,7 +739,7 @@ def report_send(item, description='', fatal=False): paste_file_size = float(pastebin_list[paste_name][10]) # Server capacity in MB if paste_file_size > 0: # If it is 0, the capacity is unlimited if log_size > paste_file_size: # Capacity and size verification - msg = config.get_localized_string(60334) + msg = config.getLocalizedString(60334) continue paste_timeout = int(pastebin_list[paste_name][11]) # Timeout for the server paste_random_headers = pastebin_list[paste_name][12] # Do you use RAMDOM headers to mislead the serv? @@ -855,7 +829,7 @@ def report_send(item, description='', fatal=False): data = {} paste_sufix = '/finalise' - data_post = {'fuid': fuid, 'total_chunks': i, 'file_name': paste_title+'.log', 'file_type': 'doc'} + data_post = {'fuid': fuid, 'total_chunks': i, 'file_name': paste_title+'.log', 'fileType': 'doc'} resp = httptools.downloadpage(paste_host+paste_sufix, params=paste_params, ignore_response_code=True, post=data_post, timeout=paste_timeout, random_headers=paste_random_headers, headers=paste_headers) @@ -931,19 +905,19 @@ def report_send(item, description='', fatal=False): status = True # Upload operation completed successfully logger.info('Report created: ' + str(item.url)) # The URL of the user report is saved # if fatal: # For future use, for logger.crash - # platformtools.dialog_ok('KoD CREATED ERROR report', 'Report it in the forum by adding FATAL ERROR and this URL: ', '[COLOR gold]%s[/COLOR]' % item.url, pastebin_one_use_msg) + # platformtools.dialogOk('KoD CREATED ERROR report', 'Report it in the forum by adding FATAL ERROR and this URL: ', '[COLOR gold]%s[/COLOR]' % item.url, pastebin_one_use_msg) # else: # Report URL passed to user - # platformtools.dialog_ok('KoD Crash Report CREATED', 'Report it on the forum by adding a bug description and this URL: ', '[COLOR gold]%s[/COLOR]' % item.url, pastebin_one_use_msg) + # platformtools.dialogOk('KoD Crash Report CREATED', 'Report it on the forum by adding a bug description and this URL: ', '[COLOR gold]%s[/COLOR]' % item.url, pastebin_one_use_msg) break # Operation finished, we don't keep looking if not status and not fatal: # Operation failed ... - platformtools.dialog_notification(config.get_localized_string(707428), msg) #... cause is reported - logger.error(config.get_localized_string(707428) + msg) + platformtools.dialogNotification(config.getLocalizedString(707428), msg) #... cause is reported + logger.error(config.getLocalizedString(707428) + msg) # Control is returned with updated item.url, so the report URL will appear in the menu item.action = 'report_menu' - platformtools.itemlist_update(item, True) + platformtools.itemlistUpdate(item, True) # return report_menu(item) @@ -961,5 +935,5 @@ def call_browser(item): import urllib short = urllib.urlopen( 'https://u.nu/api.php?action=shorturl&format=simple&url=' + item.url).read() - platformtools.dialog_ok(config.get_localized_string(20000), - config.get_localized_string(70740) % short) + platformtools.dialogOk(config.getLocalizedString(20000), + config.getLocalizedString(70740) % short) diff --git a/specials/trailertools.py b/specials/trailertools.py index f4f93f7b..47a37cdf 100644 --- a/specials/trailertools.py +++ b/specials/trailertools.py @@ -36,12 +36,12 @@ from platformcode import config, logger, launcher from platformcode import platformtools info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json -def_lang = info_language[config.get_setting("info_language", "videolibrary")] +def_lang = info_language[config.getSetting("info_language", "videolibrary")] result = None window_select = [] # To enable or disable the manual search option -if config.get_platform() != "plex": +if config.getXBMCPlatform() != "plex": keyboard = True else: keyboard = False @@ -76,8 +76,8 @@ def buscartrailer(item, trailers=[]): item.contentTitle = item.contentTitle.strip() elif keyboard: contentTitle = re.sub(r'\[\/*(B|I|COLOR)\s*[^\]]*\]', '', item.contentTitle.strip()) - item.contentTitle = platformtools.dialog_input(default=contentTitle, - heading=config.get_localized_string(70505)) + item.contentTitle = platformtools.dialogInput(default=contentTitle, + heading=config.getLocalizedString(70505)) if item.contentTitle is None: item.contentTitle = contentTitle else: @@ -110,7 +110,7 @@ def buscartrailer(item, trailers=[]): if multi_search(item, itemlist, tipo): return if not itemlist: - itemlist.append(item.clone(title=config.get_localized_string(70501), title2=item.contentTitle, + itemlist.append(item.clone(title=config.getLocalizedString(70501), title2=item.contentTitle, action="", thumbnail=thumb('nofolder'), text_color="")) from lib.fuzzy_match import algorithims @@ -118,8 +118,8 @@ def buscartrailer(item, trailers=[]): if item.contextual: global window_select, result - select = Select("DialogSelect.xml", config.get_runtime_path(), item=item, itemlist=itemlist, - caption=config.get_localized_string(70506) + item.contentTitle) + select = Select("DialogSelect.xml", config.getRuntimePath(), item=item, itemlist=itemlist, + caption=config.getLocalizedString(70506) + item.contentTitle) window_select.append(select) select.doModal() @@ -130,7 +130,7 @@ def buscartrailer(item, trailers=[]): def multi_search(item, itemlist, tipo): ris = [] - dialog = platformtools.dialog_progress('Trailer', config.get_localized_string(70115)) + dialog = platformtools.dialogProgress('Trailer', config.getLocalizedString(70115)) perc = 0 canceled = False with futures.ThreadPoolExecutor() as executor: @@ -152,7 +152,7 @@ def multi_search(item, itemlist, tipo): def manual_search(item, tipo): logger.debug() itemlist = [] - texto = platformtools.dialog_input(default=item.contentTitle, heading=config.get_localized_string(30112)) + texto = platformtools.dialogInput(default=item.contentTitle, heading=config.getLocalizedString(30112)) if texto is not None: if multi_search(item.clone(contentTitle=texto), itemlist, tipo): return @@ -182,7 +182,7 @@ def tmdb_trailers(item, dialog, tipo="movie"): found = True launcher.run(it) dialog.close() - while platformtools.is_playing(): + while platformtools.isPlaying(): xbmc.sleep(100) return itemlist @@ -207,7 +207,7 @@ def youtube_search(item): patron += r'text":"([^"]+).*?' patron += r'simpleText":"[^"]+.*?simpleText":"([^"]+).*?' patron += r'url":"([^"]+)' - matches = scrapertools.find_multiple_matches(data, patron) + matches = scrapertools.findMultipleMatches(data, patron) for scrapedthumbnail, scrapedtitle, scrapedduration, scrapedurl in matches: scrapedtitle = scrapedtitle if PY3 else scrapedtitle.decode('utf8').encode('utf8') if item.contextual: @@ -218,7 +218,7 @@ def youtube_search(item): # next_page = scrapertools.find_single_match(data, '<a href="([^"]+)"[^>]+><span class="yt-uix-button-content">') # if next_page != "": # next_page = urlparse.urljoin("https://www.youtube.com", next_page) - # itemlist.append(item.clone(title=config.get_localized_string(30992), action="youtube_search", extra="youtube", + # itemlist.append(item.clone(title=config.getLocalizedString(30992), action="youtube_search", extra="youtube", # page=next_page, thumbnail=thumb('search'), text_color="")) return itemlist @@ -287,7 +287,7 @@ try: pass self.getControl(1).setLabel("" + self.caption + "") if keyboard: - self.getControl(5).setLabel(config.get_localized_string(70510)) + self.getControl(5).setLabel(config.getLocalizedString(70510)) self.items = [] for item in self.itemlist: item_l = xbmcgui.ListItem(item.title, item.title2) @@ -323,17 +323,17 @@ try: selectitem = self.control_list.getSelectedItem() item = Item().fromurl(selectitem.getProperty("item_copy")) if item.action == "play" and self.item.windowed: - video_urls, puede, motivo = servertools.resolve_video_urls_for_playing(item.server, item.url) + videoUrls, puede, motivo = servertools.resolve_videoUrls_for_playing(item.server, item.url) self.close() xbmc.sleep(200) if puede: - result = video_urls[-1][1] + result = videoUrls[-1][1] else: result = None elif item.action == "play" and not self.item.windowed: for window in window_select: window.close() - retorna = platformtools.play_video(item, force_direct=True) + retorna = platformtools.playVideo(item, force_direct=True) if not retorna: while True: xbmc.sleep(1000) diff --git a/specials/tvmoviedb.py b/specials/tvmoviedb.py index 796738c2..6fb4754e 100644 --- a/specials/tvmoviedb.py +++ b/specials/tvmoviedb.py @@ -9,28 +9,28 @@ from datetime import datetime langs = Item(tmdb=[tmdb.def_lang, 'de', 'fr', 'pt', 'it', 'es-MX', 'ca', 'en', 'es'], imdb=[tmdb.def_lang, 'de-de', 'fr-fr', 'pt-pt', 'it-it', 'es-MX', 'ca-es', 'en', 'es']) -lang = Item(tmdb=langs.tmdb[config.get_setting('tmdb', 'tvmoviedb')], - tmdbfallback= langs.tmdb[config.get_setting('tmdbfallback', 'tvmoviedb')], - imdb=langs.imdb[config.get_setting('imdb', 'tvmoviedb')]) +lang = Item(tmdb=langs.tmdb[config.getSetting('tmdb', 'tvmoviedb')], + tmdbfallback= langs.tmdb[config.getSetting('tmdbfallback', 'tvmoviedb')], + imdb=langs.imdb[config.getSetting('imdb', 'tvmoviedb')]) imdb_host = 'http://www.imdb.com' -mal_adult = config.get_setting('adult_mal', 'tvmoviedb') +mal_adult = config.getSetting('adult_mal', 'tvmoviedb') mal_key = 'MzE1MDQ2cGQ5N2llYTY4Z2xwbGVzZjFzbTY=' -# fanart = filetools.join(config.get_runtime_path(), re 'fanart.jpg') +# fanart = filetools.join(config.getRuntimePath(), re 'fanart.jpg') def mainlist(item): logger.debug() itemlist = [item.clone(title='TMDB', action='tmdbMenu', thumbnail=support.thumb('tmdb')), item.clone(title='IMDB', action='imdbMenu', thumbnail=support.thumb('imdb'))] - itemlist += [item.clone(title=config.get_localized_string(70415), action='traktMenu', thumbnail=support.thumb('trakt')), - item.clone(title=config.get_localized_string(70026), action='mal', thumbnail=support.thumb('mal')), - item.clone(title=support.typo(config.get_localized_string(70027), 'bold'), action='configuracion', folder=False, thumbnail=support.thumb('setting'))] + itemlist += [item.clone(title=config.getLocalizedString(70415), action='traktMenu', thumbnail=support.thumb('trakt')), + item.clone(title=config.getLocalizedString(70026), action='mal', thumbnail=support.thumb('mal')), + item.clone(title=support.typo(config.getLocalizedString(70027), 'bold'), action='configuracion', folder=False, thumbnail=support.thumb('setting'))] return itemlist def _search(item): - text = platformtools.dialog_input(heading=item.title) + text = platformtools.dialogInput(heading=item.title) if text: if item.search: item.search['query'] = text @@ -43,23 +43,23 @@ def _search(item): def tmdbMenu(item): if not item.args: - return support.thumb([item.clone(title=config.get_localized_string(30122), args='movie'), - item.clone(title=config.get_localized_string(30123), args='tv'), - item.clone(title=config.get_localized_string(70033), action='tmdbResults', args='person/popular'), - item.clone(title=config.get_localized_string(70036), action='_search', search={'url': 'search/person', 'language': lang.tmdb, 'page': 1}), - item.clone(title=config.get_localized_string(70037), action='_search', search={'url': 'search/person', 'language': lang.tmdb, 'page': 1}, crew=True)]) + return support.thumb([item.clone(title=config.getLocalizedString(30122), args='movie'), + item.clone(title=config.getLocalizedString(30123), args='tv'), + item.clone(title=config.getLocalizedString(70033), action='tmdbResults', args='person/popular'), + item.clone(title=config.getLocalizedString(70036), action='_search', search={'url': 'search/person', 'language': lang.tmdb, 'page': 1}), + item.clone(title=config.getLocalizedString(70037), action='_search', search={'url': 'search/person', 'language': lang.tmdb, 'page': 1}, crew=True)]) item.contentType = item.args.replace('tv', 'tvshow') - itemlist = [item.clone(title=config.get_localized_string(70028), action='tmdbResults', args=item.args + '/popular'), - item.clone(title=config.get_localized_string(70029), action='tmdbResults', args=item.args + '/top_rated'), - item.clone(title=config.get_localized_string(50001), action='tmdbResults', args=item.args + '/now_playing' if item.args == 'movie' else 'tv/on_the_air'), - item.clone(title=config.get_localized_string(70032), action='tmdbIndex', mode='genre'), - item.clone(title=config.get_localized_string(70042), action='tmdbIndex', mode='year')] + itemlist = [item.clone(title=config.getLocalizedString(70028), action='tmdbResults', args=item.args + '/popular'), + item.clone(title=config.getLocalizedString(70029), action='tmdbResults', args=item.args + '/top_rated'), + item.clone(title=config.getLocalizedString(50001), action='tmdbResults', args=item.args + '/now_playing' if item.args == 'movie' else 'tv/on_the_air'), + item.clone(title=config.getLocalizedString(70032), action='tmdbIndex', mode='genre'), + item.clone(title=config.getLocalizedString(70042), action='tmdbIndex', mode='year')] - itemlist.extend([item.clone(title=config.get_localized_string(70035) % config.get_localized_string(60244 if item.args == 'movie' else 60245).lower(), action='_search', search={'url': 'search/%s' % item.args, 'language': lang.tmdb, 'page': 1}), - item.clone(title=support.typo(config.get_localized_string(70038),'bold'), action='filter', db_type='tmdb' )]) + itemlist.extend([item.clone(title=config.getLocalizedString(70035) % config.getLocalizedString(60244 if item.args == 'movie' else 60245).lower(), action='_search', search={'url': 'search/%s' % item.args, 'language': lang.tmdb, 'page': 1}), + item.clone(title=support.typo(config.getLocalizedString(70038),'bold'), action='filter', db_type='tmdb' )]) return support.thumb(itemlist) @@ -120,23 +120,23 @@ def tmdbIndex(item): def imdbMenu(item): itemlist = [] if not item.args: - itemlist.extend([item.clone(title=config.get_localized_string(30122), args='movie'), - item.clone(title=config.get_localized_string(30123), args='tvshow'), - item.clone(title=config.get_localized_string(70033), action='imdbResults', args=['actors']), - item.clone(title=config.get_localized_string(70036), action='_search', url='/search/name?name={}', args=['actors']), - item.clone(title=config.get_localized_string(30980), action='_search', url= '/search/title?title={}')]) + itemlist.extend([item.clone(title=config.getLocalizedString(30122), args='movie'), + item.clone(title=config.getLocalizedString(30123), args='tvshow'), + item.clone(title=config.getLocalizedString(70033), action='imdbResults', args=['actors']), + item.clone(title=config.getLocalizedString(70036), action='_search', url='/search/name?name={}', args=['actors']), + item.clone(title=config.getLocalizedString(30980), action='_search', url= '/search/title?title={}')]) else: item.contentType = item.args - itemlist.append(item.clone(title=config.get_localized_string(70028), action='imdbResults', args=[item.contentType])) - itemlist.append(item.clone(title=config.get_localized_string(70029), action='imdbResults', args=[item.contentType,'top'])) + itemlist.append(item.clone(title=config.getLocalizedString(70028), action='imdbResults', args=[item.contentType])) + itemlist.append(item.clone(title=config.getLocalizedString(70029), action='imdbResults', args=[item.contentType,'top'])) if item.contentType == 'movie': - itemlist.extend([item.clone(title=config.get_localized_string(70030), action='imdbResults', args=['cinema']), - item.clone(title=config.get_localized_string(70034), action='imdbResults', args=['soon'])]) + itemlist.extend([item.clone(title=config.getLocalizedString(70030), action='imdbResults', args=['cinema']), + item.clone(title=config.getLocalizedString(70034), action='imdbResults', args=['soon'])]) - itemlist.extend([item.clone(title=config.get_localized_string(70032), action='imdbIndex', args='genre'), - item.clone(title=config.get_localized_string(70042), action='imdbIndex', args='year'), - item.clone(title=support.typo(config.get_localized_string(70038),'color kod'), action='filter', db_type='imdb')]) + itemlist.extend([item.clone(title=config.getLocalizedString(70032), action='imdbIndex', args='genre'), + item.clone(title=config.getLocalizedString(70042), action='imdbIndex', args='year'), + item.clone(title=support.typo(config.getLocalizedString(70038),'color kod'), action='filter', db_type='imdb')]) return support.thumb(itemlist) @@ -194,29 +194,29 @@ def imdbIndex(item): def traktMenu(item): itemlist = [] - token_auth = config.get_setting("token_trakt", "trakt") + token_auth = config.getSetting("token_trakt", "trakt") if not item.args: - itemlist.extend([item.clone(title=config.get_localized_string(30122), args='movies'), - item.clone(title=config.get_localized_string(30123), args='shows')]) - if token_auth: itemlist.append(item.clone(title=support.typo(config.get_localized_string(70057), 'bold'), action="traktResults", url="/users/me/lists")) - else: itemlist.append(item.clone(title=support.typo(config.get_localized_string(70054), 'bold'), action="traktAuth", folder=False)) + itemlist.extend([item.clone(title=config.getLocalizedString(30122), args='movies'), + item.clone(title=config.getLocalizedString(30123), args='shows')]) + if token_auth: itemlist.append(item.clone(title=support.typo(config.getLocalizedString(70057), 'bold'), action="traktResults", url="/users/me/lists")) + else: itemlist.append(item.clone(title=support.typo(config.getLocalizedString(70054), 'bold'), action="traktAuth", folder=False)) else: item.contentType = item.args.replace('shows', 'tvshow').replace('movies', 'movie') - item.title = config.get_localized_string(30122 if item.contentType == 'movie' else 30123) - itemlist.extend([item.clone(title='{} [{}]'.format(item.title, config.get_localized_string(70049)), action='traktResults', url= item.args + '/popular'), - item.clone(title='{} [{}]'.format(item.title, config.get_localized_string(70050)), action='traktResults', url= item.args + '/trending'), - item.clone(title='{} [{}]'.format(item.title, config.get_localized_string(70053)), action='traktResults', url= item.args + '/watched/all'), - item.clone(title='{} [{}]'.format(item.title, config.get_localized_string(70051)), action='traktResults', url= item.args + '/anticipated')]) + item.title = config.getLocalizedString(30122 if item.contentType == 'movie' else 30123) + itemlist.extend([item.clone(title='{} [{}]'.format(item.title, config.getLocalizedString(70049)), action='traktResults', url= item.args + '/popular'), + item.clone(title='{} [{}]'.format(item.title, config.getLocalizedString(70050)), action='traktResults', url= item.args + '/trending'), + item.clone(title='{} [{}]'.format(item.title, config.getLocalizedString(70053)), action='traktResults', url= item.args + '/watched/all'), + item.clone(title='{} [{}]'.format(item.title, config.getLocalizedString(70051)), action='traktResults', url= item.args + '/anticipated')]) if token_auth: - itemlist.extend([item.clone(title='{} [{}]'.format(item.title, config.get_localized_string(70052)), action='traktResults', url='/recommendations/' + item.args), - item.clone(title='{} [{}]'.format(item.title, config.get_localized_string(70055)), action='traktResults', url='/users/me/watchlist/' + item.args), - item.clone(title='{} [{}]'.format(item.title, config.get_localized_string(70056)), action='traktResults', url='/users/me/watched/' + item.args), - item.clone(title='{} [{}]'.format(item.title, config.get_localized_string(70068)), action='traktResults', url='/users/me/collection/' + item.args)]) + itemlist.extend([item.clone(title='{} [{}]'.format(item.title, config.getLocalizedString(70052)), action='traktResults', url='/recommendations/' + item.args), + item.clone(title='{} [{}]'.format(item.title, config.getLocalizedString(70055)), action='traktResults', url='/users/me/watchlist/' + item.args), + item.clone(title='{} [{}]'.format(item.title, config.getLocalizedString(70056)), action='traktResults', url='/users/me/watched/' + item.args), + item.clone(title='{} [{}]'.format(item.title, config.getLocalizedString(70068)), action='traktResults', url='/users/me/collection/' + item.args)]) return itemlist def traktResults(item): - prepage = config.get_setting('pagination', default=20) + prepage = config.getSetting('pagination', default=20) if not item.page: item.page = 1 if item.itemlist: itemlist = support.pagination(support.itemlistdb(), item, 'traktResults') @@ -224,7 +224,7 @@ def traktResults(item): return itemlist if item.prevthumb: item.thumbnail = item.prevthumb - token_auth = config.get_setting('token_trakt', 'trakt') + token_auth = config.getSetting('token_trakt', 'trakt') itemlist = [] client_id = trakt_tools.client_id headers = [['Content-Type', 'application/json'], ['trakt-api-key', client_id], ['trakt-api-version', '2']] @@ -238,7 +238,7 @@ def traktResults(item): data = httptools.downloadpage(url, post=post, headers=headers) if data.code == '401': trakt_tools.token_trakt(item.clone(args='renew')) - token_auth = config.get_setting('token_trakt', 'trakt') + token_auth = config.getSetting('token_trakt', 'trakt') headers[3][1] = 'Bearer {}'.format(token_auth) data = httptools.downloadpage(url, post=post, headers=headers) @@ -322,15 +322,15 @@ def traktAuth(item): def filter(item): import xbmcgui - orderTitle = [config.get_localized_string(70456), config.get_localized_string(70457), config.get_localized_string(70458), config.get_localized_string(70459), config.get_localized_string(70460), config.get_localized_string(70461), config.get_localized_string(70462), config.get_localized_string(70462)] + orderTitle = [config.getLocalizedString(70456), config.getLocalizedString(70457), config.getLocalizedString(70458), config.getLocalizedString(70459), config.getLocalizedString(70460), config.getLocalizedString(70461), config.getLocalizedString(70462), config.getLocalizedString(70462)] tmdbOrder = ['popularity.desc', 'popularity.asc', 'release_date.desc', 'release_date.asc', 'vote_average.desc', 'vote_average.asc', 'title.asc', 'title.desc'] imdbOrder = ['moviemeter,asc', 'moviemeter,desc', 'release_date,asc', 'release_date,desc', 'user_rating,asc', 'user_rating,desc', 'alpha,asc', 'alpha,desc'] - defControls = {'year':{'title': config.get_localized_string(60232), 'values': '', 'order':0}, - 'genre':{'title': config.get_localized_string(70032), 'values': '', 'order':1}, - 'rating':{'title': config.get_localized_string(70473), 'values': '', 'order':2}, - 'order': {'title': config.get_localized_string(70455), 'values': orderTitle[0], 'order':3}} + defControls = {'year':{'title': config.getLocalizedString(60232), 'values': '', 'order':0}, + 'genre':{'title': config.getLocalizedString(70032), 'values': '', 'order':1}, + 'rating':{'title': config.getLocalizedString(70473), 'values': '', 'order':2}, + 'order': {'title': config.getLocalizedString(70455), 'values': orderTitle[0], 'order':3}} - controls = dict(sorted(config.get_setting('controls', item.channel, default=defControls).items(), key=lambda k: k[1]['order'])) + controls = dict(sorted(config.getSetting('controls', item.channel, default=defControls).items(), key=lambda k: k[1]['order'])) class Filter(xbmcgui.WindowXMLDialog): def start(self, item): self.item = item @@ -350,7 +350,7 @@ def filter(item): logger.debug('CONTROL', control) if control in [100]: # Year years = [str(i) for i in range(datetime.now().year + 3, 1899, -1)] - selection = platformtools.dialog_select('', years) + selection = platformtools.dialogSelect('', years) self.controls['year']['values'] = years[selection] if selection > -1 else '' self.getControl(100).setLabel('{}: {}'.format(self.controls['year']['title'], self.controls['year']['values'])) elif control in [101]: # Genre @@ -369,17 +369,17 @@ def filter(item): genresNames.append(genre) genresIds.append(value) selected = [genresIds.index(i.strip()) for i in self.controls['genre']['values'].split(',') if i] - selections = platformtools.dialog_multiselect('', genresNames, preselect=selected) + selections = platformtools.dialogMultiselect('', genresNames, preselect=selected) self.controls['genre']['values'] = ','.join(genresIds[g] for g in selections) names= ', '.join(genresNames[g] for g in selections) self.getControl(101).setLabel('{}: {}'.format(self.controls['genre']['title'], names)) elif control in [102]: rating = [str(i) for i in range(1, 11)] - selection = platformtools.dialog_select('', rating, preselect=rating.index(self.controls['rating']['values']) if self.controls['rating']['values'] else 0) + selection = platformtools.dialogSelect('', rating, preselect=rating.index(self.controls['rating']['values']) if self.controls['rating']['values'] else 0) self.controls['rating']['values'] = rating[selection] self.getControl(102).setLabel('{}: {}'.format(self.controls['rating']['title'], self.controls['rating']['values'])) elif control in [103]: - selection = platformtools.dialog_select('', orderTitle) + selection = platformtools.dialogSelect('', orderTitle) if selection > -1: self.controls['order']['values'] = self.order[selection] self.getControl(103).setLabel('{}: {}'.format(self.controls['order']['title'], orderTitle[selection])) @@ -388,12 +388,12 @@ def filter(item): self.close() elif control in [201]: - config.set_setting('controls', self.controls, self.item.channel) - platformtools.dialog_notification('TMDB', 'Filtro salvato', time=1000, sound=False) + config.setSetting('controls', self.controls, self.item.channel) + platformtools.dialogNotification('TMDB', 'Filtro salvato', time=1000, sound=False) elif control in [202]: - config.set_setting('controls', defControls, self.item.channel) - platformtools.dialog_notification('TMDB', 'Filtro eliminato', time=1000, sound=False) + config.setSetting('controls', defControls, self.item.channel) + platformtools.dialogNotification('TMDB', 'Filtro eliminato', time=1000, sound=False) self.controls = None self.close() return filter(self.item) @@ -409,7 +409,7 @@ def filter(item): self.close() - controls = Filter('Filter.xml', config.get_runtime_path()).start(item) + controls = Filter('Filter.xml', config.getRuntimePath()).start(item) if controls: item.search = {'url': 'discover/' + item.args, 'vote_count.gte': 10} if item.db_type == 'tmdb' else {} diff --git a/specials/url.py b/specials/url.py index 9f7d58d6..93dafe64 100644 --- a/specials/url.py +++ b/specials/url.py @@ -10,9 +10,9 @@ def mainlist(item): logger.debug() itemlist = [] - itemlist.append(Item(channel=item.channel, action="search", title=config.get_localized_string(60089), thumbnail=item.thumbnail, args='server')) - itemlist.append(Item(channel=item.channel, action="search", title=config.get_localized_string(60090), thumbnail=item.thumbnail, args='direct')) - itemlist.append(Item(channel=item.channel, action="search", title=config.get_localized_string(60091), thumbnail=item.thumbnail)) + itemlist.append(Item(channel=item.channel, action="search", title=config.getLocalizedString(60089), thumbnail=item.thumbnail, args='server')) + itemlist.append(Item(channel=item.channel, action="search", title=config.getLocalizedString(60090), thumbnail=item.thumbnail, args='direct')) + itemlist.append(Item(channel=item.channel, action="search", title=config.getLocalizedString(60091), thumbnail=item.thumbnail)) return itemlist @@ -29,7 +29,7 @@ def search(item, text): if "server" in item.args: itemlist = server(item, text) elif "direct" in item.args: - itemlist.append(Item(channel=item.channel, action="play", url=text, server="directo", title=config.get_localized_string(60092))) + itemlist.append(Item(channel=item.channel, action="play", url=text, server="directo", title=config.getLocalizedString(60092))) itemlist = server(item, itemlist=itemlist) else: data = match(text).data @@ -39,6 +39,6 @@ def search(item, text): item.action = "play" if len(itemlist) == 0: - itemlist.append(Item(channel=item.channel, action="search", title=config.get_localized_string(60093))) + itemlist.append(Item(channel=item.channel, action="search", title=config.getLocalizedString(60093))) return itemlist diff --git a/specials/videolibrary.json b/specials/videolibrary.json index 668202c9..ee0027ef 100644 --- a/specials/videolibrary.json +++ b/specials/videolibrary.json @@ -22,7 +22,8 @@ "type": "list", "label": "@60606", "default": 0, - "enabled": "eq(-1,@60603)|eq(-1,@60605)", + "submenu": true, + "visible": "eq(-1,@60603)|eq(-1,@60605)", "lvalues": [ "No", "@60609", @@ -36,7 +37,8 @@ "type": "list", "label": "@60613", "default": 1, - "enabled": "eq(-2,@60604)|eq(-2,@60605)", + "submenu": true, + "visible": "eq(-2,@60604)|eq(-2,@60605)", "lvalues": [ "00:00", "04:00", @@ -46,28 +48,6 @@ "20:00" ] }, - { - "id": "updatetvshows_interval", - "type": "list", - "label": "@60614", - "default": 0, - "enabled": "!eq(-3,@60615)", - "lvalues": [ - "@60616", - "@60617" - ] - }, - { - "id": "search_new_content", - "type": "list", - "label": "@60618", - "default": 0, - "enabled": "!eq(-4,@60615)", - "lvalues": [ - "@60619", - "@60620" - ] - }, { "id": "lab_1", "type": "label", @@ -75,42 +55,20 @@ "enabled": true, "visible": true }, - { - "id": "scraper_movies", - "type": "list", - "label": "@60651", - "enabled": false, - "default": 0, - "visible": false, - "lvalues": [ - "TMDB", - "None" - ] - }, - { - "id": "scraper_tvshows", - "type": "list", - "label": "@60652", - "default": 0, - "visible": false, - "lvalues": [ - "TMDB", - "TVDB" - ] - }, { "id": "tvdb_retry_eng", "type": "bool", "label": "@60653", "default": true, - "enabled": "eq(-1,TVDB)", - "visible": true + "submenu": true, + "visible": false }, { "id": "info_language", "type": "list", "label": "@60662", "enabled": true, + "submenu": true, "default": 4, "lvalues": [ "de", @@ -123,50 +81,15 @@ }, { "id": "max_links", - "type": "list", + "type": "text", + "mode": "number", "label": "@60624", - "default": 0, - "enabled": true, - "visible": true, - "lvalues": [ - "@60625", - "30", - "60", - "90", - "120", - "150", - "180", - "210" - ] - }, - { - "id": "white_list_order", - "type": "bool", - "label": "@60626", - "enabled": true, - "visible": true, - "default": false - }, - { - "id": "quit_channel_name", - "type": "bool", - "label": "@60627", - "enabled": true, - "visible": true, - "default": false - }, - { - "id": "replace_VD", - "type": "bool", - "label": "@60628", - "enabled": "eq(-4,@60623)", - "visible": true, - "default": false + "default": 0 }, { "id": "db_mode", "type": "bool", - "label": "@60629", + "label": "@60629","submenu": true, "default": false, "enabled": true, "visible": true @@ -175,20 +98,21 @@ "id": "xbmc_host", "type": "text", "label": "@60632", - "visible": true, - "enabled": "eq(-1,true)" + "submenu": true, + "visible": "eq(-1,true)" }, { "id": "xbmc_puerto", "type": "text", "label": "@60633", - "enabled": "eq(-2,true)", - "visible": true + "submenu": true, + "visible": "eq(-2,true)" }, { "id": "mark_as_watched", "type": "bool", "label": "@60634", + "submenu": true, "default": true, "enabled": true, "visible": true @@ -200,26 +124,11 @@ "enabled": true, "visible": true }, - { - "id": "sync_trakt_watched", - "type": "bool", - "label": "@60638", - "default": false, - "visible": true, - "enabled": "eq(-3,true)" - }, - { - "id": "sync_trakt_notification", - "type": "bool", - "label": "@60639", - "default": true, - "visible": true, - "enabled": "eq(-1,true)" - }, { "id": "sync_trakt_new_tvshow", "type": "bool", "label": "@60640", + "submenu": true, "default": false, "enabled": true, "visible": true @@ -229,8 +138,8 @@ "type": "bool", "label": "@60641", "default": true, - "visible": true, - "enabled": "eq(-1,true)" + "submenu": true, + "visible": "eq(-1,true)" }, { "id": "show_all_seasons", @@ -249,12 +158,6 @@ "@60616" ] }, - { - "id": "ask_channel", - "type": "bool", - "label": "@60645", - "default": false - }, { "id": "original_title_folder", "type": "bool", @@ -266,12 +169,6 @@ "type": "bool", "label": "@70703", "default": false - }, - { - "id": "verify_playcount", - "type": "bool", - "label": "@70526", - "default": false } ] } diff --git a/specials/videolibrary.py b/specials/videolibrary.py index 93ae3e9e..41d1cfe0 100644 --- a/specials/videolibrary.py +++ b/specials/videolibrary.py @@ -21,24 +21,24 @@ else: def mainlist(item): logger.debug() - itemlist = [item.clone(title=config.get_localized_string(60509), contentType='movie', action='list_movies', thumbnail=support.thumb('videolibrary_movie')), - item.clone(title=support.typo(config.get_localized_string(70741) % config.get_localized_string(30122) + '...', 'submenu'), contentType='movie',action='search_list', thumbnail=support.thumb('search_movie')), - item.clone(title=config.get_localized_string(60600), contentType='tvshow', action='list_tvshows', thumbnail=support.thumb('videolibrary_tvshow'), - context=[{'channel':'videolibrary', 'action':'update_videolibrary', 'title':config.get_localized_string(70269)}]), - item.clone(title=support.typo(config.get_localized_string(70741) % config.get_localized_string(30123) + '...', 'submenu'),contentType='tvshow', action='search_list', thumbnail=support.thumb('search_tvshow')), - item.clone(channel='shortcuts', title=support.typo(config.get_localized_string(70287),'bold color kod'), action='SettingOnPosition', + itemlist = [item.clone(title=config.getLocalizedString(60509), contentType='movie', action='list_movies', thumbnail=support.thumb('videolibrary_movie')), + item.clone(title=support.typo(config.getLocalizedString(70741) % config.getLocalizedString(30122) + '...', 'submenu'), contentType='movie',action='search_list', thumbnail=support.thumb('search_movie')), + item.clone(title=config.getLocalizedString(60600), contentType='tvshow', action='list_tvshows', thumbnail=support.thumb('videolibrary_tvshow'), + context=[{'channel':'videolibrary', 'action':'update_videolibrary', 'title':config.getLocalizedString(70269)}]), + item.clone(title=support.typo(config.getLocalizedString(70741) % config.getLocalizedString(30123) + '...', 'submenu'),contentType='tvshow', action='search_list', thumbnail=support.thumb('search_tvshow')), + item.clone(channel='shortcuts', title=support.typo(config.getLocalizedString(70287),'bold color kod'), action='SettingOnPosition', category=2, setting=1, thumbnail = support.thumb('setting'),folder=False)] support.thumb(itemlist) return itemlist def search_list(item): - itemlist = [item.clone(title=config.get_localized_string(70032) + '{search}', action='list_genres'), - item.clone(title=config.get_localized_string(70042) + '{search}', action='list_years'), - item.clone(title=config.get_localized_string(70314) + '{search}', action='list_az', next_action='list_actors'), - item.clone(title=config.get_localized_string(70473) + '{search}', action='list_ratings'), + itemlist = [item.clone(title=config.getLocalizedString(70032) + '{search}', action='list_genres'), + item.clone(title=config.getLocalizedString(70042) + '{search}', action='list_years'), + item.clone(title=config.getLocalizedString(70314) + '{search}', action='list_az', next_action='list_actors'), + item.clone(title=config.getLocalizedString(70473) + '{search}', action='list_ratings'), item.clone(title='Registi' + '{search}', action='list_az', next_action='list_directors'), - item.clone(title=config.get_localized_string(30980) + '{search}', action='search')] + item.clone(title=config.getLocalizedString(30980) + '{search}', action='search')] if item.contentType == 'movie': itemlist.insert(0, item.clone(title='Collezioni', action='list_sets')) support.thumb(itemlist) @@ -116,7 +116,7 @@ def list_directors(item): for i, d in enumerate(directors): d = d.strip() if d and d[0][0] == item.title and d not in [it.list_director for it in itemlist]: - it = item.clone(title = d, action='list_{}s'.format(item.contentType), list_director=d, thumbnail=director_images[i] if len(director_images) > i else filetools.join(config.get_runtime_path(), 'resources','skins','Default','media','Infoplus','no_photo.png')) + it = item.clone(title = d, action='list_{}s'.format(item.contentType), list_director=d, thumbnail=director_images[i] if len(director_images) > i else filetools.join(config.getRuntimePath(), 'resources','skins','Default','media','Infoplus','no_photo.png')) itemlist.append(it) itemlist.sort(key=lambda it: it.list_director) @@ -166,7 +166,7 @@ def list_actors(item): itemlist = [] for a in actors: if a and a[0][0] == item.title and a[0] not in [it.list_actor for it in itemlist]: - it = item.clone(title = a[0], action='list_{}s'.format(item.contentType), list_actor=a[0], thumbnail=a[1] if a[1] else filetools.join(config.get_runtime_path(), 'resources','skins','Default','media','Infoplus','no_photo.png')) + it = item.clone(title = a[0], action='list_{}s'.format(item.contentType), list_actor=a[0], thumbnail=a[1] if a[1] else filetools.join(config.getRuntimePath(), 'resources','skins','Default','media','Infoplus','no_photo.png')) itemlist.append(it) itemlist.sort(key=lambda it: it.list_actor) @@ -191,7 +191,7 @@ def list_movies(item, silent=False): elif item.list_actor: itemlist = [platformtools.window_type(v['item']) for v in videos if item.list_actor in str(v['item'].infoLabels['castandrole'])] elif item.list_director: itemlist = [platformtools.window_type(v['item']) for v in videos if item.list_director in v['item'].infoLabels['director']] elif item.set: itemlist = [platformtools.window_type(v['item']) for v in videos if item.set == v['item'].infoLabels.get('setid', '')] - elif config.get_setting('collection') and not item.text: itemlist = [v['item'] for v in videos if (item.text.lower() in v['item'].title.lower() and not 'setid' in v['item'].infoLabels)] + [v.clone(contentType='list') for v in dict(videolibrarydb['collection']).values()] + elif config.getSetting('collection') and not item.text: itemlist = [v['item'] for v in videos if (item.text.lower() in v['item'].title.lower() and not 'setid' in v['item'].infoLabels)] + [v.clone(contentType='list') for v in dict(videolibrarydb['collection']).values()] else: itemlist = [platformtools.window_type(v['item']) for v in videos if item.text.lower() in v['item'].title.lower()] videolibrarydb.close() add_context(itemlist) @@ -220,7 +220,7 @@ def list_tvshows(item): def sub_thread(it): it.contentType = 'tvshow' seasons = videolibrarydb['season'][it.videolibrary_id] - if config.get_setting('no_pile_on_seasons', 'videolibrary') == 2 or config.get_setting('no_pile_on_seasons', 'videolibrary') == 1 and len(seasons) == 1: + if config.getSetting('no_pile_on_seasons', 'videolibrary') == 2 or config.getSetting('no_pile_on_seasons', 'videolibrary') == 1 and len(seasons) == 1: it.action = 'get_episodes' it.all = True if not it.active: @@ -240,7 +240,7 @@ def list_tvshows(item): thumbnail = support.thumb('videolibrary_tvshow') itemlist += [Item(channel=item.channel, action='update_videolibrary', thumbnail=thumbnail, fanart=thumbnail, landscape=thumbnail, - title=support.typo(config.get_localized_string(70269), 'bold color kod'), folder=False)] + title=support.typo(config.getLocalizedString(70269), 'bold color kod'), folder=False)] videolibrarydb.close() return itemlist @@ -261,7 +261,7 @@ def configure_update_videolibrary(item): preselect.append(i) # Select Dialog - ret = platformtools.dialog_multiselect(config.get_localized_string(60601), lista, preselect=preselect, useDetails=True) + ret = platformtools.dialogMultiselect(config.getLocalizedString(60601), lista, preselect=preselect, useDetails=True) if ret is None: return False # order cancel selection = [ids[i] for i in ret] @@ -273,7 +273,7 @@ def configure_update_videolibrary(item): tvshow.active = 1 mark_tvshow_as_updatable(tvshow, silent=True) - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() return True @@ -304,12 +304,12 @@ def get_episodes(item): it = ep['item'] if it.contentSeason == item.contentSeason or item.all: - if config.get_setting('no_pile_on_seasons', 'videolibrary') == 2 or item.all: + if config.getSetting('no_pile_on_seasons', 'videolibrary') == 2 or item.all: it.onlyep = False else: it.onlyep = True it = get_host(it) - it.window = True if item.window_type == 0 or (config.get_setting("window_type") == 0) else False + it.window = True if item.window_type == 0 or (config.getSetting("window_type") == 0) else False if it.window: it.folder = False it.from_library = item.from_library @@ -397,13 +397,13 @@ def findvideos(item): for it in itemlist: it.title = '[{}] {}'.format(it.ch_name, it.title) - if config.get_setting('autoplay'): + if config.getSetting('autoplay'): itemlist = autoplay.start(itemlist, item) else: itemlist = servertools.sort_servers(itemlist) - if config.get_setting('checklinks') and not config.get_setting('autoplay'): - itemlist = servertools.check_list_links(itemlist, config.get_setting('checklinks_number')) + if config.getSetting('checklinks') and not config.getSetting('autoplay'): + itemlist = servertools.check_list_links(itemlist, config.getSetting('checklinks_number')) if not item.window: add_download_items(item, itemlist) @@ -433,7 +433,7 @@ def servers(item, ch, items): return serverlist if ch_params.get('active', False): - channel = platformtools.channel_import(ch) + channel = platformtools.channelImport(ch) with futures.ThreadPoolExecutor() as executor: itlist = [executor.submit(channel_servers, item, it, channel, ch_name) for it in items] @@ -447,10 +447,10 @@ def play(item): logger.log() # logger.dbg() # logger.debug("item:\n" + item.tostring('\n')) - # platformtools.play_video(item) + # platformtools.playVideo(item) if not item.channel == "local": - channel = platformtools.channel_import(item.channel) + channel = platformtools.channelImport(item.channel) if hasattr(channel, "play"): itemlist = getattr(channel, "play")(item) @@ -458,12 +458,12 @@ def play(item): else: itemlist = [item.clone()] else: - return platformtools.play_video(item.clone(url=item.url, server="local")) + return platformtools.playVideo(item.clone(url=item.url, server="local")) # itemlist = [item.clone(url=item.url, server="local")] # For direct links in list format if isinstance(itemlist[0], list): - item.video_urls = itemlist + item.videoUrls = itemlist itemlist = [item] # This is necessary in case the channel play deletes the data @@ -476,7 +476,7 @@ def play(item): v.title = item.contentTitle else: if item.contentType == "episode": - v.title = config.get_localized_string(60036) % item.contentEpisodeNumber + v.title = config.getLocalizedString(60036) % item.contentEpisodeNumber v.thumbnail = item.thumbnail v.contentThumbnail = item.thumbnail v.contentChannel = item.contentChannel @@ -494,10 +494,10 @@ def update_videolibrary(item=None): now = datetime.date.today() try: - config.set_setting('updatelibrary_last_check', now.strftime('%Y-%m-%d'), 'videolibrary') + config.setSetting('updatelibrary_last_check', now.strftime('%Y-%m-%d'), 'videolibrary') - message = config.get_localized_string(60389) - p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(60037)) + message = config.getLocalizedString(60389) + p_dialog = platformtools.dialogProgressBg(config.getLocalizedString(20000), config.getLocalizedString(60037)) p_dialog.update(0, '') show_list = [] @@ -523,11 +523,11 @@ def update_videolibrary(item=None): chname = channeltools.get_channel_parameters(it.channel)['title'] p_dialog.update(int(i * t), message=message % (it.fulltitle, chname)) it = get_host(it) - channel = platformtools.channel_import(it.channel) + channel = platformtools.channelImport(it.channel) itemlist = getattr(channel, it.action)(it) videolibrarytools.save_tvshow(it, itemlist, True) p_dialog.close() - if config.get_setting("videolibrary_kodi"): + if config.getSetting("videolibrary_kodi"): dbconverter.save_all('tvshow') except: @@ -542,9 +542,9 @@ def update_videolibrary(item=None): update_when_finished = set_active_tvshow(list(shows)) if update_when_finished: - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() - # if config.get_setting('trakt_sync'): + # if config.getSetting('trakt_sync'): # from core import trakt_tools # trakt_tools.update_all() @@ -638,7 +638,7 @@ def mark_content_as_watched(item): # elif self.item.contentType == 'season': it = self.seasons[self.s] if it: xbmc_videolibrary.mark_content_as_watched_on_kodi(it, self.playcount) - platformtools.itemlist_refresh(1, True if item.contentType in ['season', 'episode'] else False) + platformtools.itemlistRefresh(1, True if item.contentType in ['season', 'episode'] else False) def mark_previous(self): if self.item.contentType == 'episode': @@ -793,7 +793,7 @@ def mark_tvshow_as_updatable(item, silent=False): filetools.write(item.nfo, head_nfo + it.tojson()) if not silent: - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() def prefered_lang(item): @@ -802,7 +802,7 @@ def prefered_lang(item): item = tempdb['item'] lang_list = tempdb['item'].lang_list prefered = item.lang_list.index(item.prefered_lang) - item.prefered_lang = lang_list[platformtools.dialog_select(config.get_localized_string(70246), lang_list, prefered)] + item.prefered_lang = lang_list[platformtools.dialogSelect(config.getLocalizedString(70246), lang_list, prefered)] tempdb['item'] = item videolibrarydb[item.contentType][item.videolibrary_id] = tempdb videolibrarydb.close() @@ -816,7 +816,7 @@ def disable_channels(item): channels_list = list(tempdb['channels'].keys()) channels_name = [channeltools.get_channel_parameters(c).get('title', '') for c in channels_list] disabled = [channels_list.index(c) for c in channels_list if c in item.disabled] - channels_disabled = platformtools.dialog_multiselect(config.get_localized_string(70837), channels_name, preselect=disabled) + channels_disabled = platformtools.dialogMultiselect(config.getLocalizedString(70837), channels_name, preselect=disabled) if type(channels_disabled) == list: item.disabled = [channels_list[c] for c in channels_disabled] videolibrarydb[item.contentType][item.videolibrary_id] = tempdb @@ -829,7 +829,7 @@ def get_host(item , channel=None): item.url = urlparse.urlparse(item.url).path if item.url.startswith('/'): if not channel: - channel = platformtools.channel_import(item.channel) + channel = platformtools.channelImport(item.channel) host = channel.host if host.endswith('/'): host = host[:-1] item.url = host + item.url @@ -843,12 +843,12 @@ def set_active(item): show['item'].active = False if item.active else True videolibrarydb['tvshow'][item.videolibrary_id] = show videolibrarydb.close() - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() #-------------- CONTEXT -------------- -def add_context(itemlist, title=config.get_localized_string(30052)): +def add_context(itemlist, title=config.getLocalizedString(30052)): title += '...' for item in itemlist: item.infoLabels['title'] = item.infoLabels.get('title', item.title) @@ -868,7 +868,7 @@ class subcontext(object): self.run() def title(self, _type): - return config.get_localized_string(self.titledict[self.item.contentType][_type]) + return config.getLocalizedString(self.titledict[self.item.contentType][_type]) def makecontext(self): # logger.dbg() @@ -900,7 +900,7 @@ class subcontext(object): if self.item.contentType in ['movie', 'tvshow']: if len(videolibrarydb[self.item.contentType].get(self.item.videolibrary_id, {}).get('channels', {}).keys()) > 1: - self.context.append(config.get_localized_string(70837)) + self.context.append(config.getLocalizedString(70837)) self.commands.append(self.item.clone(action='disable_channels')) videolibrarydb.close() @@ -942,7 +942,7 @@ class set_images(object): types.append(it) self.types.append(k) self.list.append(self.item.infoLabels[k]) - selection = platformtools.dialog_select(self.item.contentTitle, types, 0, True) + selection = platformtools.dialogSelect(self.item.contentTitle, types, 0, True) if selection >= 0: self.set_art(self.types[selection]) @@ -958,7 +958,7 @@ class set_images(object): items.append(it) images.append(a) - selection = platformtools.dialog_select(self.item.contentTitle, items, 0, True) + selection = platformtools.dialogSelect(self.item.contentTitle, items, 0, True) if selection > 0: selected = images[selection] @@ -987,12 +987,12 @@ class set_images(object): videolibrarydb[self.item_type][self.item.videolibrary_id] = self.video videolibrarydb.close() - platformtools.itemlist_refresh() + platformtools.itemlistRefresh() #-------------- DOWNLOAD -------------- def add_download_items(item, itemlist): - if config.get_setting('downloadenabled'): + if config.getSetting('downloadenabled'): localOnly = True for i in itemlist: if i.contentChannel != 'local': @@ -1001,7 +1001,7 @@ def add_download_items(item, itemlist): if not item.fromLibrary and not localOnly: downloadItem = Item(channel='downloads', from_channel=item.channel, - title=support.typo(config.get_localized_string(60355), 'color kod bold'), + title=support.typo(config.getLocalizedString(60355), 'color kod bold'), fulltitle=item.fulltitle, show=item.fulltitle, contentType=item.contentType, @@ -1009,25 +1009,25 @@ def add_download_items(item, itemlist): url=item.url, action='save_download', from_action='findvideos', - contentTitle=config.get_localized_string(60355), + contentTitle=config.getLocalizedString(60355), path=item.path, thumbnail=support.thumb('download'), parent=item.tourl()) if item.action == 'findvideos': if item.contentType != 'movie': - downloadItem.title = '{} {}'.format(support.typo(config.get_localized_string(60356), 'color kod bold'), item.title) + downloadItem.title = '{} {}'.format(support.typo(config.getLocalizedString(60356), 'color kod bold'), item.title) else: # film - downloadItem.title = support.typo(config.get_localized_string(60354), 'color kod bold') + downloadItem.title = support.typo(config.getLocalizedString(60354), 'color kod bold') downloadItem.downloadItemlist = [i.tourl() for i in itemlist] itemlist.append(downloadItem) else: if item.contentSeason: # season - downloadItem.title = support.typo(config.get_localized_string(60357), 'color kod bold') + downloadItem.title = support.typo(config.getLocalizedString(60357), 'color kod bold') itemlist.append(downloadItem) else: # tvshow + not seen itemlist.append(downloadItem) - itemlist.append(downloadItem.clone(title=support.typo(config.get_localized_string(60003), 'color kod bold'), contentTitle=config.get_localized_string(60003), unseen=True)) + itemlist.append(downloadItem.clone(title=support.typo(config.getLocalizedString(60003), 'color kod bold'), contentTitle=config.getLocalizedString(60003), unseen=True)) #-------------- DELETE -------------- @@ -1049,15 +1049,15 @@ def delete(item): from core import channeltools channels = [c for c in videolibrarydb[item.contentType].get(item.videolibrary_id,{}).get('channels',{}).keys()] channels.sort() - option_list = [config.get_localized_string(head)] + option_list = [config.getLocalizedString(head)] for channel in channels: option_list.append(channeltools.get_channel_parameters(channel)['title']) # If there are more channels shows the dialogue of choice if len(option_list) > 2: - select = platformtools.dialog_select(config.get_localized_string(70088) % item.infoLabels['title'], option_list) + select = platformtools.dialogSelect(config.getLocalizedString(70088) % item.infoLabels['title'], option_list) else: - delete = platformtools.dialog_yesno(config.get_localized_string(head), config.get_localized_string(70088) % item.infoLabels['title']) + delete = platformtools.dialogYesNo(config.getLocalizedString(head), config.getLocalizedString(70088) % item.infoLabels['title']) # If you have chosen to delete the movie, the collection or the series if select == 0 or delete: @@ -1067,7 +1067,7 @@ def delete(item): for k, v in dict(videolibrarydb['movie']).items(): if v['item'].infoLabels.get('setid') == item.set: del videolibrarydb['movie'][k] - platformtools.itemlist_refresh(-1) + platformtools.itemlistRefresh(-1) else: # delete movie or series del videolibrarydb[item.contentType][item.videolibrary_id] @@ -1091,11 +1091,11 @@ def delete(item): path = filetools.join(library_path, item.base_name) filetools.rmdirtree(path) - if config.is_xbmc() and config.get_setting('videolibrary_kodi'): + if config.is_xbmc() and config.getSetting('videolibrary_kodi'): from platformcode import xbmc_videolibrary xbmc_videolibrary.clean_by_id(item) else: - platformtools.itemlist_refresh(-1) + platformtools.itemlistRefresh(-1) # delete channel from video item if select and select > 0: @@ -1142,13 +1142,13 @@ def delete(item): def delete_videolibrary(item): logger.debug() - if not platformtools.dialog_yesno(config.get_localized_string(20000), config.get_localized_string(80037)): + if not platformtools.dialogYesNo(config.getLocalizedString(20000), config.getLocalizedString(80037)): return - p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(80038)) + p_dialog = platformtools.dialogProgressBg(config.getLocalizedString(20000), config.getLocalizedString(80038)) p_dialog.update(0) - if config.is_xbmc() and config.get_setting('videolibrary_kodi'): + if config.is_xbmc() and config.getSetting('videolibrary_kodi'): from platformcode import xbmc_videolibrary xbmc_videolibrary.clean() p_dialog.update(10) @@ -1157,7 +1157,7 @@ def delete_videolibrary(item): filetools.rmdirtree(videolibrarytools.TVSHOWS_PATH) p_dialog.update(90) - config.verify_directories_created() + config.verifyDirectoriesCreated() p_dialog.update(100) xbmc.sleep(1000) p_dialog.close() @@ -1169,7 +1169,7 @@ def delete_videolibrary(item): videolibrarydb['episode'].clear() videolibrarydb.close() - platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(80039), time=5000, sound=False) + platformtools.dialogNotification(config.getLocalizedString(20000), config.getLocalizedString(80039), time=5000, sound=False) #-------------- MOVE -------------- @@ -1189,7 +1189,7 @@ def move_videolibrary(current_path, new_path, current_movies_folder, new_movies_ logger.info('new_tvshows_folder: ' + new_tvshows_folder) notify = False - progress = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(80011)) + progress = platformtools.dialogProgressBg(config.getLocalizedString(20000), config.getLocalizedString(80011)) xbmc.sleep(1000) current_path = u'' + xbmc.translatePath(current_path) new_path = u'' + xbmc.translatePath(new_path) @@ -1211,18 +1211,18 @@ def move_videolibrary(current_path, new_path, current_movies_folder, new_movies_ filetools.rmdir(new_movies_path) if not tvshows_path: filetools.rmdir(new_tvshows_path) - config.set_setting('videolibrarypath', backup_current_path) - config.set_setting('folder_movies', current_movies_folder) - config.set_setting('folder_tvshows', current_tvshows_folder) + config.setSetting('videolibrarypath', backup_current_path) + config.setSetting('folder_movies', current_movies_folder) + config.setSetting('folder_tvshows', current_tvshows_folder) xbmc_videolibrary.update_sources(backup_current_path, backup_new_path) progress.update(100) xbmc.sleep(1000) progress.close() - platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(80028)) + platformtools.dialogOk(config.getLocalizedString(20000), config.getLocalizedString(80028)) return - config.verify_directories_created() - progress.update(10, config.get_localized_string(20000), config.get_localized_string(80012)) + config.verifyDirectoriesCreated() + progress.update(10, config.getLocalizedString(20000), config.getLocalizedString(80012)) if current_movies_path != new_movies_path: if filetools.listdir(current_movies_path): dir_util.copy_tree(current_movies_path, new_movies_path) @@ -1239,21 +1239,21 @@ def move_videolibrary(current_path, new_path, current_movies_folder, new_movies_ filetools.rmdirtree(current_path) xbmc_videolibrary.update_sources(backup_new_path, backup_current_path) - if config.is_xbmc() and config.get_setting('videolibrary_kodi'): + if config.is_xbmc() and config.getSetting('videolibrary_kodi'): xbmc_videolibrary.update_db(backup_current_path, backup_new_path, current_movies_folder, new_movies_folder, current_tvshows_folder, new_tvshows_folder, progress) else: progress.update(100) xbmc.sleep(1000) progress.close() if notify: - platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(80014), time=5000, sound=False) + platformtools.dialogNotification(config.getLocalizedString(20000), config.getLocalizedString(80014), time=5000, sound=False) #------------------------------------------------ # OLD FUNCTIONS #------------------------------------------------ def channel_config(item): - return platformtools.show_channel_settings(channelpath=os.path.join(config.get_runtime_path(), 'channels', item.channel), caption=config.get_localized_string(60598)) + return platformtools.showChannelSettings(channelpath=os.path.join(config.getRuntimePath(), 'channels', item.channel), caption=config.getLocalizedString(60598)) def get_results(nfo_path, root, Type, local=False): value = 0 @@ -1275,7 +1275,7 @@ def get_results(nfo_path, root, Type, local=False): item.path = filetools.split(nfo_path)[0] item.nfo = nfo_path sep = '/' if '/' in nfo_path else '\\' - item.extra = filetools.join(config.get_setting('videolibrarypath'), config.get_setting(folder), item.path.split(sep)[-1]) + item.extra = filetools.join(config.getSetting('videolibrarypath'), config.getSetting(folder), item.path.split(sep)[-1]) strm_path = item.strm_path.replace('\\', '/').rstrip('/') if not item.thumbnail: item.thumbnail = item.infoLabels['thumbnail'] if '/' in item.path: item.strm_path = strm_path @@ -1286,17 +1286,17 @@ def get_results(nfo_path, root, Type, local=False): visto = item.library_playcounts.get(strm_path.strip('/').split('/')[0], 0) item.infoLabels['playcount'] = visto if visto > 0: - seen_text = config.get_localized_string(60016) + seen_text = config.getLocalizedString(60016) counter = 0 else: - seen_text = config.get_localized_string(60017) + seen_text = config.getLocalizedString(60017) counter = 1 # Context menu: Delete series / channel channels_num = len(item.library_urls) if 'downloads' in item.library_urls: channels_num -= 1 - if channels_num > 1: delete_text = config.get_localized_string(60018) - else: delete_text = config.get_localized_string(60019) + if channels_num > 1: delete_text = config.getLocalizedString(60018) + else: delete_text = config.getLocalizedString(60019) item.context = [{'title': seen_text, 'action': 'mark_content_as_watched', 'channel': 'videolibrary', 'playcount': counter}, {'title': delete_text, 'action': 'delete', 'channel': 'videolibrary', 'multichannel': multichannel}] @@ -1307,16 +1307,16 @@ def get_results(nfo_path, root, Type, local=False): item.path = filetools.split(nfo_path)[0] item.nfo = nfo_path sep = '/' if '/' in nfo_path else '\\' - item.extra = filetools.join(config.get_setting('videolibrarypath'), config.get_setting(folder), item.path.split(sep)[-1]) + item.extra = filetools.join(config.getSetting('videolibrarypath'), config.getSetting(folder), item.path.split(sep)[-1]) # Contextual menu: Mark as seen / not seen visto = item.library_playcounts.get(item.contentTitle, 0) item.infoLabels['playcount'] = visto logger.debug('item\n' + str(item)) if visto > 0: - seen_text = config.get_localized_string(60020) + seen_text = config.getLocalizedString(60020) counter = 0 else: - seen_text = config.get_localized_string(60021) + seen_text = config.getLocalizedString(60021) counter = 1 except: @@ -1326,25 +1326,25 @@ def get_results(nfo_path, root, Type, local=False): # Context menu: Automatically search for new episodes or not if item.active and int(item.active) > 0: - update_text = config.get_localized_string(60022) + update_text = config.getLocalizedString(60022) value = 0 else: - update_text = config.get_localized_string(60023) + update_text = config.getLocalizedString(60023) value = 1 item.title += ' [B]' + u'\u2022' + '[/B]' # Context menu: Delete series / channel channels_num = len(item.library_urls) if 'downloads' in item.library_urls: channels_num -= 1 - if channels_num > 1: delete_text = config.get_localized_string(60024) - else: delete_text = config.get_localized_string(60025) + if channels_num > 1: delete_text = config.getLocalizedString(60024) + else: delete_text = config.getLocalizedString(60025) item.context = [{'title': seen_text, 'action': 'mark_content_as_watched', 'channel': 'videolibrary', 'playcount': counter}, {'title': update_text, 'action': 'mark_tvshow_as_updatable', 'channel': 'videolibrary', 'active': value}, {'title': delete_text, 'action': 'delete', 'channel': 'videolibrary', 'multichannel': multichannel}, - {'title': config.get_localized_string(70269), 'action': 'update_tvshow', 'channel': 'videolibrary'}] - if item.local_episodes_path == '': item.context.append({'title': config.get_localized_string(80048), 'action': 'add_local_episodes', 'channel': 'videolibrary'}) - else: item.context.append({'title': config.get_localized_string(80049), 'action': 'remove_local_episodes', 'channel': 'videolibrary'}) + {'title': config.getLocalizedString(70269), 'action': 'update_tvshow', 'channel': 'videolibrary'}] + if item.local_episodes_path == '': item.context.append({'title': config.getLocalizedString(80048), 'action': 'add_local_episodes', 'channel': 'videolibrary'}) + else: item.context.append({'title': config.getLocalizedString(80049), 'action': 'remove_local_episodes', 'channel': 'videolibrary'}) else: item = Item() return item, value diff --git a/tests/test_generic.py b/tests/test_generic.py index 3b2ebd1f..a3b726e8 100644 --- a/tests/test_generic.py +++ b/tests/test_generic.py @@ -41,9 +41,9 @@ import parameterized from platformcode import config, logger -config.set_setting('tmdb_active', False) +config.setSetting('tmdb_active', False) -librerias = os.path.join(config.get_runtime_path(), 'lib') +librerias = os.path.join(config.getRuntimePath(), 'lib') sys.path.insert(0, librerias) from core.support import typo from core.item import Item @@ -281,7 +281,7 @@ class GenericChannelMenuItemTest(unittest.TestCase): if self.ch in chNumRis: # i know how much results should be for content in chNumRis[self.ch]: if content in self.title: - risNum = len([i for i in self.itemlist if i.title != typo(config.get_localized_string(30992), 'color kod bold')]) # not count nextpage + risNum = len([i for i in self.itemlist if i.title != typo(config.getLocalizedString(30992), 'color kod bold')]) # not count nextpage self.assertEqual(chNumRis[self.ch][content], risNum, 'channel ' + self.ch + ' -> ' + self.title + ' returned wrong number of results<br>' + str(risNum) + ' but should be ' + str(chNumRis[self.ch][content]) + '<br>' + @@ -302,7 +302,7 @@ class GenericChannelMenuItemTest(unittest.TestCase): self.assert_(type(resIt.infoLabels['year']) is int or resIt.infoLabels['year'].isdigit(), msgYear) self.assert_(1900 < int(resIt.infoLabels['year']) < 2100, msgYear) - if resIt.title == typo(config.get_localized_string(30992), 'color kod bold'): # next page + if resIt.title == typo(config.getLocalizedString(30992), 'color kod bold'): # next page nextPageItemlist = getattr(self.module, resIt.action)(resIt) self.assertTrue(nextPageItemlist, 'channel ' + self.ch + ' -> ' + self.title + ' has nextpage not working') @@ -312,7 +312,7 @@ class GenericChannelMenuItemTest(unittest.TestCase): @parameterized.parameterized_class(serversFinal, class_name_func=testnameSrv) class GenericServerTest(unittest.TestCase): - def test_get_video_url(self): + def test_get_videoUrl(self): module = __import__('servers.%s' % self.name, fromlist=["servers.%s" % self.name]) page_url = self.server.url # httptools.default_headers['Referer'] = self.server.referer @@ -323,7 +323,7 @@ class GenericServerTest(unittest.TestCase): self.assert_(hasattr(module, 'test_video_exists'), self.name + ' has no test_video_exists') if module.test_video_exists(page_url)[0]: - urls = module.get_video_url(page_url) + urls = module.get_videoUrl(page_url) server_parameters = servertools.get_server_parameters(self.name) self.assertTrue(urls or server_parameters.get("premium"), self.name + ' scraper did not return direct urls for ' + page_url) @@ -358,6 +358,6 @@ class GenericServerTest(unittest.TestCase): if __name__ == '__main__': unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(report_name='report', add_timestamp=False, combine_reports=True, - report_title='KoD Test Suite', template=os.path.join(config.get_runtime_path(), 'tests', 'template.html')), exit=False) + report_title='KoD Test Suite', template=os.path.join(config.getRuntimePath(), 'tests', 'template.html')), exit=False) import webbrowser webbrowser.open(os.path.join(outDir, 'report.html'))