def get_resume_choice(trakt_id, season, episode): if kodi.get_setting('trakt_bookmark') == 'true': resume_point = '%s%%' % (trakt_api.get_bookmark(trakt_id, season, episode)) header = utils2.i18n('trakt_bookmark_exists') else: resume_point = utils2.format_time(_get_db_connection().get_bookmark(trakt_id, season, episode)) header = utils2.i18n('local_bookmark_exists') question = utils2.i18n('resume_from') % (resume_point) return xbmcgui.Dialog().yesno(header, question, '', '', utils2.i18n('start_from_beginning'), utils2.i18n('resume')) == 1
def onInit(self): # log_utils.log('onInit:', log_utils.LOGDEBUG) self.cancel = False self.getControl(INSTR_LABEL).setLabel( i18n('ip_auth_line1') + visit_url + i18n('ip_auth_line2')) self.progress = self.getControl(PROGRESS_CTRL) self.progress.setPercent(100) if qr_code: img = self.getControl(QR_CODE_CTRL) img.setImage(qr_code)
def choose_list(username=None): lists = trakt_api.get_lists(username) if username is None: lists.insert(0, {'name': 'watchlist', 'ids': {'slug': WATCHLIST_SLUG}}) if lists: dialog = xbmcgui.Dialog() index = dialog.select(utils2.i18n('pick_a_list'), [list_data['name'] for list_data in lists]) if index > -1: return lists[index]['ids']['slug'] else: kodi.notify(msg=utils2.i18n('no_lists_for_user') % (username), duration=5000)
def get_resume_choice(trakt_id, season, episode): if kodi.get_setting('trakt_bookmark') == 'true': resume_point = '%s%%' % (trakt_api.get_bookmark(trakt_id, season, episode)) header = utils2.i18n('trakt_bookmark_exists') else: resume_point = utils.format_time(db_connection.get_bookmark(trakt_id, season, episode)) header = utils2.i18n('local_bookmark_exists') question = utils2.i18n('resume_from') % (resume_point) dialog = xbmcgui.Dialog() try: return dialog.contextmenu([question, utils2.i18n('start_from_beginning')]) == 0 except: return dialog.yesno(header, question, '', '', utils2.i18n('start_from_beginning'), utils2.i18n('resume')) == 1
def attempt_db_recovery(self): header = i18n('recovery_header') if xbmcgui.Dialog().yesno(header, i18n('rec_mig_1'), i18n('rec_mig_2')): try: self.init_database('Unknown') except Exception as e: logger.log('DB Migration Failed: %s' % (e), log_utils.LOGWARNING) if self.db_type == DB_TYPES.SQLITE: if xbmcgui.Dialog().yesno(header, i18n('rec_reset_1'), i18n('rec_reset_2'), i18n('rec_reset_3')): try: self.reset_db() except Exception as e: logger.log('Reset Failed: %s' % (e), log_utils.LOGWARNING) try: msg = i18n('reset_failed') % (e) except: msg = 'Reset Failed: %s' % (e) else: msg = i18n('db_reset_success') kodi.notify(msg=msg, duration=5000)
def perform_auto_conf(responses): with kodi.WorkingDialog(): length = len(responses) TOTAL = 13 if length < TOTAL: responses += [True] * (TOTAL - length) if responses[0]: kodi.set_setting('trakt_timeout', '60') if responses[1]: kodi.set_setting('calendar-day', '-1') if responses[2]: kodi.set_setting('calendar_time', '2') if responses[3]: kodi.set_setting('source_timeout', '20') if responses[4]: kodi.set_setting('include_watchlist_next', 'true') if responses[5]: kodi.set_setting('filter_direct', 'true') if responses[6]: kodi.set_setting('filter_unusable', 'true') if responses[7]: kodi.set_setting('show_debrid', 'true') if responses[8]: kodi.set_setting('source_results', '0') if responses[9]: kodi.set_setting('enable_sort', 'true') kodi.set_setting('sort1_field', '2') kodi.set_setting('sort2_field', '5') kodi.set_setting('sort3_field', '6') kodi.set_setting('sort4_field', '1') kodi.set_setting('sort5_field', '3') kodi.set_setting('sort6_field', '4') if responses[10]: tiers = ['Local', 'Premiumize.V2', 'Premiumize.me', 'Furk.net', 'EasyNews', 'DD.tv', 'NoobRoom', ['yify.tv', 'torba.se', 'MoviesPlanet', '123Movies', '9Movies', 'DayT.se', 'niter.tv', 'YesMovies', 'HDFlix', 'HDMovie14', 'ororo.tv'], ['StreamLord', 'MovieFlix', 'CyberReel', 'm4ufree', 'tunemovie', 'fmovie.co', 'afdah.org', 'xmovies8', 'xmovies8.v2', 'KiwiHD', 'HDMovieFree'], ['MovieGo', 'MovieXK', 'PelisPedia', 'FardaDownload', 'PutMV', 'PirateJunkies', 'SeriesWatch', 'VidNow4K', 'VeoCube', 'Quikr'], ['HeyDL', 'HEVCBluRay', 'MovieZone', 'SezonLukDizi', 'YabanciDizi', 'Dizimag', 'Dizilab', 'Dizigold', 'Dizibox', 'Diziay', 'Dizipas', 'OnlineDizi'], ['Dizist', 'MaksiDizi', 'DownloadTube', 'scene-rls', 'DDLValley', '2DDL', 'DDLSeries', 'Crazy4TV', 'SceneDown', 'CinemaMKV', 'TVShow.me'], ['rls-movies', 'ReleaseBB', 'MyVideoLinks.eu', 'OCW', 'RLSSource.net', 'WatchInHD'], ['vivo.to', 'IceFilms', 'Flixanity', 'Watch5s', 'WatchEpisodes', 'WatchItVideos', 'PrimeWire', 'alluc.com', 'tvonline', 'SolarMovie', 'SantaSeries'], ['TVWTVS', 'MWM', 'MoviePool', 'WatchSeries', 'RLSeries', 'Putlocker', 'MovieWatcher', 'VKFlix', 'WatchFree.to', 'pftv', 'streamallthis.is', 'Movie4K'], ['MovieZone', 'MovieHubs', 'tvrush', 'afdah', 'MiraDeTodo', 'Filmovizija', 'wso.ch', 'MovieSub', 'MovieHut', 'CouchTunerV1', 'Watch8Now', 'SnagFilms'], ['MoviePool', 'Ventures', 'yshows', 'iWatchOnline', 'vidics.ch', 'pubfilm', 'eMovies.Pro', 'OnlineMoviesPro', 'movie25', 'viooz.ac'], ['SpaceMov', 'LosMovies', 'wmo.ch', 'stream-tv.co', 'MintMovies', 'MovieNight', 'cmz', 'SeriesCoco', 'filmikz.ch', 'clickplay.to'], ['MovieTube', 'FilmStreaming.in', 'IFlix']] sso = [] random_sso = kodi.get_setting('random_sso') == 'true' for tier in tiers: if isinstance(tier, basestring): sso.append(tier) else: if random_sso: random.shuffle(tier) sso += tier kodi.set_setting('source_sort_order', '|'.join(sso)) if responses[11]: reset_base_url() if responses[12]: kodi.set_setting('mne_time', '2') trigger = [False, True, False, True, False, True, True, False, True, False, False, False] if all([t == r for t, r in zip(trigger, responses)]): kodi.set_setting('scraper_download', 'true') kodi.notify(msg=i18n('auto_conf_complete'))
def perform_auto_conf(responses): with kodi.WorkingDialog(): length = len(responses) TOTAL = 13 if length < TOTAL: responses += [True] * (TOTAL - length) if responses[0]: kodi.set_setting('trakt_timeout', '60') if responses[1]: kodi.set_setting('calendar-day', '-1') if responses[2]: kodi.set_setting('calendar_time', '2') if responses[3]: kodi.set_setting('source_timeout', '20') if responses[4]: kodi.set_setting('include_watchlist_next', 'true') if responses[5]: kodi.set_setting('filter_direct', 'true') if responses[6]: kodi.set_setting('filter_unusable', 'true') if responses[7]: kodi.set_setting('show_debrid', 'true') if responses[8]: kodi.set_setting('source_results', '0') if responses[9]: kodi.set_setting('enable_sort', 'true') kodi.set_setting('sort1_field', '2') kodi.set_setting('sort2_field', '5') kodi.set_setting('sort3_field', '6') kodi.set_setting('sort4_field', '1') kodi.set_setting('sort5_field', '3') kodi.set_setting('sort6_field', '4') if responses[10]: tiers = ['Local', 'Premiumize.V2', 'Premiumize.me', 'Furk.net', 'EasyNews', 'DD.tv', 'NoobRoom', 'Sit2Play', ['yify.tv', 'MoviesPlanet', 'goojara', '123Movies', '9Movies', 'DayT.se', 'mvgee', 'niter.tv', 'YesMovies', 'ororo.tv', 'MovieOcean'], ['StreamLord', 'MovieFlix', 'CyberReel', 'm4ufree', 'tunemovie', 'fmovie.co', 'xmovies8', 'xmovies8.v2', 'KiwiHD', 'HDMovieFree', 'Mehliz'], ['OLMovies', 'MovieGo', 'MovieXK', 'PelisPedia', 'PutMV', 'PirateJunkies', 'SeriesWatch', 'VidNow4K', 'VeoCube', 'Quikr', 'MovieBlast', 'Pubfilm.to'], ['IOMovies', 'RealMovies', 'HeyDL', 'HEVCBluRay', 'SezonLukDizi', 'Dizimag', 'Dizilab', 'Dizigold', 'Dizibox', 'Diziay', 'Dizipas', 'OnlineDizi'], ['SeriesOnline', 'MovyTvy', 'Dizist', 'DownloadTube', 'scene-rls', 'DDLValley', '2DDL', 'MyDDL', 'DDLSeries', 'SceneDown', 'CinemaMKV'], ['RMZ', 'BestMoviez', 'SceneHDTV', 'Vumoo', 'TVHD', 'RLSHD', 'rls-movies', 'ReleaseBB', 'MyVideoLinks.eu', 'RLSSource.net', 'SeeHD'], ['TVShow.me', 'vivo.to', 'IceFilms', 'Flixanity', 'Watch5s', 'WatchEpisodes', 'WatchItVideos', 'PrimeWire', 'alluc.com', 'tvonline', 'SantaSeries'], ['WatchOnline', 'StreamDor', 'Vebup', 'WatchSeries', 'Putlocker', 'MovieWatcher', 'VKFlix', 'WatchFree.to', 'pftv', 'Movie4K', 'MovieZone'], ['MovieHubs', 'tvrush', 'afdah', 'MiraDeTodo', 'Filmovizija', 'wso.ch', 'MovieSub', 'MovieHut', 'CouchTunerV1', 'Watch8Now', 'SnagFilms'], ['treasureen', 'MoviePool', 'iWatchOnline', 'vidics.ch', 'pubfilm', 'eMovies.Pro', 'OnlineMoviesPro', 'movie25', 'viooz.ac'], ['SpaceMov', 'LosMovies', 'wmo.ch', 'stream-tv.co', 'MintMovies', 'MovieNight', 'cmz', 'SeriesCoco', 'filmikz.ch', 'clickplay.to'], ['MovieTube']] sso = [] random_sso = kodi.get_setting('random_sso') == 'true' for tier in tiers: if isinstance(tier, basestring): sso.append(tier) else: if random_sso: random.shuffle(tier) sso += tier kodi.set_setting('source_sort_order', '|'.join(sso)) if responses[11]: reset_base_url() if responses[12]: kodi.set_setting('mne_time', '2') trigger = [False, True, False, True, False, True, True, False, True, False, False, False] if all([t == r for t, r in zip(trigger, responses)]): kodi.set_setting('scraper_download', 'true') kodi.notify(msg=i18n('auto_conf_complete'))
def record_sru_failures(fails, total_scrapers, related_list): utils2.record_failures(fails) timeouts = len(fails) timeout_msg = utils2.i18n('scraper_timeout') % (timeouts, total_scrapers) if timeouts else '' if timeout_msg: kodi.notify(msg=timeout_msg, duration=5000) for related in related_list: if related['name'] in fails: related['label'] = '[COLOR darkred]%s[/COLOR]' % (related['label'])
def onClick(self, control): # print 'onClick: %s' % (control) if control == AUTH_BUTTON: if not self.__get_token(): kodi.notify(msg=i18n('pin_auth_failed'), duration=5000) return self.auth = True if control == LATER_BUTTON: kodi.notify(msg=i18n('remind_in_24hrs'), duration=5000) kodi.set_setting('last_reminder', str(int(time.time()))) if control == NEVER_BUTTON: kodi.notify(msg=i18n('use_addon_settings'), duration=5000) kodi.set_setting('last_reminder', '-1') if control in [AUTH_BUTTON, LATER_BUTTON, NEVER_BUTTON]: self.close()
def onInit(self): # log_utils.log('onInit:', log_utils.LOGDEBUG) self.cancel = False self.getControl(INSTR_LABEL).setLabel(i18n('ip_auth_line1') + visit_url + i18n('ip_auth_line2')) self.progress = self.getControl(PROGRESS_CTRL) self.progress.setPercent(100) if qr_code: img = self.getControl(QR_CODE_CTRL) img.setImage(qr_code)
def perform_auto_conf(responses): length = len(responses) TOTAL = 12 if length < TOTAL: responses += [True] * (TOTAL - length) if responses[0]: kodi.set_setting('trakt_timeout', '60') if responses[1]: kodi.set_setting('calendar-day', '-1') if responses[2]: kodi.set_setting('calendar_time', '2') if responses[3]: kodi.set_setting('source_timeout', '20') if responses[4]: kodi.set_setting('include_watchlist_next', 'true') if responses[5]: kodi.set_setting('filter_direct', 'true') if responses[6]: kodi.set_setting('filter_unusable', 'true') if responses[7]: kodi.set_setting('show_debrid', 'true') if responses[8]: kodi.set_setting('source_results', '0') if responses[9]: kodi.set_setting('enable_sort', 'true') kodi.set_setting('sort1_field', '2') kodi.set_setting('sort2_field', '5') kodi.set_setting('sort3_field', '6') kodi.set_setting('sort4_field', '1') kodi.set_setting('sort5_field', '3') kodi.set_setting('sort6_field', '4') if responses[10]: tiers = ['Local', 'Premiumize.V2', 'Premiumize.me', 'Furk.net', 'EasyNews', 'DD.tv', 'NoobRoom', ['WatchHD', 'IFlix', 'MoviesPlanet', 'TVWTVS', '9Movies', '123Movies', 'niter.tv', 'HDMovie14', 'ororo.tv'], ['StreamLord', 'CyberReel', 'MovCav', 'tunemovie', 'MovieMax', 'afdah.org', 'xmovies8', 'xmovies8.v2', 'MovieXK'], ['Rainierland', 'DayT.se', 'FardaDownload', 'zumvo.com', 'PutMV', 'vivo.to', 'MiraDeTodo', 'beinmovie', 'FireMoviesHD'], ['IzlemeyeDeger', 'SezonLukDizi', 'Dizimag', 'Dizilab', 'Dizigold', 'Dizibox', 'Diziay', 'Dizipas', 'OneClickTVShows', 'OnlineDizi'], ['DDLValley', '2DDL', 'ReleaseBB', 'MyVideoLinks.eu', 'OCW', 'TheExtopia', 'RLSSource.net', 'TVRelease.Net'], ['IceFilms', 'WatchEpisodes', 'PrimeWire', 'tvonline', 'SantaSeries', 'Flixanity', 'wso.ch', 'WatchSeries', 'UFlix.org', 'Putlocker'], ['MovieWatcher', 'alluc.com', 'VKFlix', 'WatchFree.to', 'pftv', 'streamallthis.is', 'Movie4K', 'afdah', 'SolarMovie'], ['MovieSub', 'MovieHut', 'CouchTunerV2', 'CouchTunerV1', 'Watch8Now', 'yshows', 'iWatchOnline'], ['vidics.ch', 'pubfilm', 'OnlineMoviesIs', 'OnlineMoviesPro', 'ViewMovies', 'movie25', 'viooz.ac', 'view47', 'MoviesHD'], ['wmo.ch', 'stream-tv.co', 'clickplay.to', 'MintMovies', 'MovieNight', 'cmz', 'ch131', 'filmikz.ch'], ['MovieTube', 'LosMovies', 'FilmStreaming.in', 'moviestorm.eu', 'MerDB'], 'MWM', 'ayyex'] sso = [] random_sso = kodi.get_setting('random_sso') == 'true' for tier in tiers: if isinstance(tier, basestring): sso.append(tier) else: if random_sso: random.shuffle(tier) sso += tier kodi.set_setting('source_sort_order', '|'.join(sso)) if responses[11]: reset_base_url() trigger = [False, True, False, True, False, True, True, False, True, False, False, False] if all([t == r for t, r in zip(trigger, responses)]): kodi.set_setting('scraper_download', 'true') kodi.notify(msg=i18n('auto_conf_complete'))
def parallel_get_url(scraper, video): url = scraper.get_url(video) logger.log('%s returned url %s' % (scraper.get_name(), url), log_utils.LOGDEBUG) if not url: url = '' if url == FORCE_NO_MATCH: label = '[%s] [COLOR green]%s[/COLOR]' % (scraper.get_name(), utils2.i18n('force_no_match')) else: label = '[%s] %s' % (scraper.get_name(), url) related = {'class': scraper, 'url': url, 'name': scraper.get_name(), 'label': label} return related
def do_disable_check(): auto_disable = kodi.get_setting('auto-disable') disable_limit = int(kodi.get_setting('disable-limit')) cur_failures = utils2.get_failures() for cls in relevant_scrapers(): fails = cur_failures.get(cls.get_name(), 0) if fails >= disable_limit: if auto_disable == DISABLE_SETTINGS.ON: kodi.set_setting('%s-enable' % (cls.get_name()), 'false') kodi.notify(msg='[COLOR blue]%s[/COLOR] %s' % (cls.get_name(), utils2.i18n('scraper_disabled')), duration=5000) cur_failures[cls.get_name()] = 0 elif auto_disable == DISABLE_SETTINGS.PROMPT: dialog = xbmcgui.Dialog() line1 = utils2.i18n('disable_line1') % (cls.get_name(), fails) line2 = utils2.i18n('disable_line2') line3 = utils2.i18n('disable_line3') ret = dialog.yesno('SALTS', line1, line2, line3, utils2.i18n('keep_enabled'), utils2.i18n('disable_it')) if ret: kodi.set_setting('%s-enable' % (cls.get_name()), 'false') cur_failures[cls.get_name()] = 0 else: cur_failures[cls.get_name()] = -1 utils2.store_failures(cur_failures)
def do_disable_check(): auto_disable = kodi.get_setting('auto-disable') disable_limit = int(kodi.get_setting('disable-limit')) for cls in relevant_scrapers(): setting = '%s_last_results' % (cls.get_name()) fails = kodi.get_setting(setting) fails = int(fails) if fails else 0 if fails >= disable_limit: if auto_disable == DISABLE_SETTINGS.ON: kodi.set_setting('%s-enable' % (cls.get_name()), 'false') kodi.notify(msg='[COLOR blue]%s[/COLOR] %s' % (cls.get_name(), utils2.i18n('scraper_disabled')), duration=5000) kodi.set_setting(setting, '0') elif auto_disable == DISABLE_SETTINGS.PROMPT: dialog = xbmcgui.Dialog() line1 = utils2.i18n('disable_line1') % (cls.get_name(), fails) line2 = utils2.i18n('disable_line2') line3 = utils2.i18n('disable_line3') ret = dialog.yesno('SALTS', line1, line2, line3, utils2.i18n('keep_enabled'), utils2.i18n('disable_it')) if ret: kodi.set_setting('%s-enable' % (cls.get_name()), 'false') kodi.set_setting(setting, '0') else: kodi.set_setting(setting, '-1')
def auth_trakt(): start = time.time() use_https = kodi.get_setting('use_https') == 'true' trakt_timeout = int(kodi.get_setting('trakt_timeout')) trakt_api = Trakt_API(use_https=use_https, timeout=trakt_timeout) result = trakt_api.get_code() code, expires, interval = result['device_code'], result[ 'expires_in'], result['interval'] time_left = expires - int(time.time() - start) line1 = i18n('verification_url') % (result['verification_url']) line2 = i18n('prompt_code') % (result['user_code']) line3 = i18n('code_expires') % (time_left) with ProgressDialog(i18n('trakt_acct_auth'), line1=line1, line2=line2, line3=line3) as pd: pd.update(100) while time_left: for _ in range(INTERVALS): kodi.sleep(interval * 1000 / INTERVALS) if pd.is_canceled(): return try: result = trakt_api.get_device_token(code) break except urllib2.URLError as e: # authorization is pending; too fast if e.code in [400, 429]: pass elif e.code == 418: kodi.notify(msg=i18n('user_reject_auth'), duration=3000) return elif e.code == 410: break else: raise time_left = expires - int(time.time() - start) progress = time_left * 100 / expires pd.update(progress, line3=i18n('code_expires') % (time_left)) try: kodi.set_setting('trakt_oauth_token', result['access_token']) kodi.set_setting('trakt_refresh_token', result['refresh_token']) trakt_api = Trakt_API(result['access_token'], use_https=use_https, timeout=trakt_timeout) profile = trakt_api.get_user_profile(cached=False) kodi.set_setting('trakt_user', '%s (%s)' % (profile['username'], profile['name'])) kodi.notify(msg=i18n('trakt_auth_complete'), duration=3000) except Exception as e: log_utils.log('Trakt Authorization Failed: %s' % (e), log_utils.LOGDEBUG)
def attempt_db_recovery(self): header = i18n('recovery_header') if xbmcgui.Dialog().yesno(header, i18n('rec_mig_1'), i18n('rec_mig_2')): try: self.init_database('Unknown') except Exception as e: log_utils.log('DB Migration Failed: %s' % (e), log_utils.LOGWARNING) if self.db_type == DB_TYPES.SQLITE: if xbmcgui.Dialog().yesno(header, i18n('rec_reset_1'), i18n('rec_reset_2'), i18n('rec_reset_3')): try: self.reset_db() except Exception as e: log_utils.log('Reset Failed: %s' % (e), log_utils.LOGWARNING) try: msg = i18n('reset_failed') % (e) except: msg = 'Reset Failed: %s' % (e) else: msg = i18n('db_reset_success') kodi.notify(msg=msg, duration=5000)
def auth_trakt(): start = time.time() use_https = kodi.get_setting('use_https') == 'true' trakt_timeout = int(kodi.get_setting('trakt_timeout')) trakt_api = Trakt_API(use_https=use_https, timeout=trakt_timeout) result = trakt_api.get_code() code, expires, interval = result['device_code'], result['expires_in'], result['interval'] time_left = expires - int(time.time() - start) line1 = i18n('verification_url') % (result['verification_url']) line2 = i18n('prompt_code') % (result['user_code']) line3 = i18n('code_expires') % (time_left) with ProgressDialog(i18n('trakt_acct_auth'), line1=line1, line2=line2, line3=line3) as pd: pd.update(100) while time_left: for _ in range(INTERVALS): kodi.sleep(interval * 1000 / INTERVALS) if pd.is_canceled(): return try: result = trakt_api.get_device_token(code) break except urllib2.URLError as e: # authorization is pending; too fast if e.code in [400, 429]: pass elif e.code == 418: kodi.notify(msg=i18n('user_reject_auth'), duration=3000) return elif e.code == 410: break else: raise time_left = expires - int(time.time() - start) progress = time_left * 100 / expires pd.update(progress, line3=i18n('code_expires') % (time_left)) try: kodi.set_setting('trakt_oauth_token', result['access_token']) kodi.set_setting('trakt_refresh_token', result['refresh_token']) trakt_api = Trakt_API(result['access_token'], use_https=use_https, timeout=trakt_timeout) profile = trakt_api.get_user_profile(cached=False) kodi.set_setting('trakt_user', '%s (%s)' % (profile['username'], profile['name'])) kodi.notify(msg=i18n('trakt_auth_complete'), duration=3000) except Exception as e: log_utils.log('Trakt Authorization Failed: %s' % (e), log_utils.LOGDEBUG)
def do_auto_config(): ACTION_PREVIOUS_MENU = 10 ACTION_BACK = 92 CONTINUE_BUTTON = 200 CANCEL_BUTTON = 201 starty = 60 posx = 30 gap = 35 RADIO_BUTTONS = [ i18n('set_trakt_timeout'), i18n('set_cal_start'), i18n('set_cal_airtime'), i18n('set_scraper_timeout'), i18n('set_wl_mne'), i18n('set_test_direct'), i18n('set_filter_unusable'), i18n('set_show_debrid'), i18n('set_no_limit'), i18n('set_source_sort'), i18n('set_sso'), i18n('set_reset_url'), i18n('select_all_none')] class AutoConfDialog(xbmcgui.WindowXMLDialog): def onInit(self): log_utils.log('onInit:', log_utils.LOGDEBUG) self.OK = False self.radio_buttons = [] posy = starty for label in RADIO_BUTTONS: self.radio_buttons.append(self.__get_radio_button(posx, posy, label)) posy += gap try: responses = json.loads(kodi.get_setting('prev_responses')) except: responses = [True] * len(self.radio_buttons) if len(responses) < len(self.radio_buttons): responses += [True] * (len(self.radio_buttons) - len(responses)) self.addControls(self.radio_buttons) last_button = None for response, radio_button in zip(responses, self.radio_buttons): radio_button.setSelected(response) if last_button is not None: radio_button.controlUp(last_button) radio_button.controlLeft(last_button) last_button.controlDown(radio_button) last_button.controlRight(radio_button) last_button = radio_button continue_ctrl = self.getControl(CONTINUE_BUTTON) cancel_ctrl = self.getControl(CANCEL_BUTTON) self.radio_buttons[0].controlUp(cancel_ctrl) self.radio_buttons[0].controlLeft(cancel_ctrl) self.radio_buttons[-1].controlDown(continue_ctrl) self.radio_buttons[-1].controlRight(continue_ctrl) continue_ctrl.controlUp(self.radio_buttons[-1]) continue_ctrl.controlLeft(self.radio_buttons[-1]) cancel_ctrl.controlDown(self.radio_buttons[0]) cancel_ctrl.controlRight(self.radio_buttons[0]) def __get_radio_button(self, x, y, label): kwargs = {'font': 'font12', 'focusTexture': 'button-focus2.png', 'noFocusTexture': 'button-nofocus.png', 'focusOnTexture': 'radiobutton-focus.png', 'noFocusOnTexture': 'radiobutton-focus.png', 'focusOffTexture': 'radiobutton-nofocus.png', 'noFocusOffTexture': 'radiobutton-nofocus.png'} temp = xbmcgui.ControlRadioButton(x, y, 450, 30, label, **kwargs) return temp def onAction(self, action): # log_utils.log('Action: %s' % (action.getId()), log_utils.LOGDEBUG) if action == ACTION_PREVIOUS_MENU or action == ACTION_BACK: self.close() def onControl(self, control): # log_utils.log('onControl: %s' % (control), log_utils.LOGDEBUG) pass def onFocus(self, control): # log_utils.log('onFocus: %s' % (control), log_utils.LOGDEBUG) pass def onClick(self, control): # log_utils.log('onClick: %s' % (control), log_utils.LOGDEBUG) focus_button = self.getControl(control) if focus_button == self.radio_buttons[-1]: all_status = focus_button.isSelected() for button in self.radio_buttons: button.setSelected(all_status) if control == CONTINUE_BUTTON: self.OK = True if control == CANCEL_BUTTON: self.OK = False if control == CONTINUE_BUTTON or control == CANCEL_BUTTON: self.close() def get_responses(self): return [bool(button.isSelected()) for button in self.radio_buttons] dialog = AutoConfDialog('AutoConfDialog.xml', kodi.get_path()) dialog.doModal() if dialog.OK: responses = dialog.get_responses() kodi.set_setting('prev_responses', json.dumps(responses)) perform_auto_conf(responses) del dialog
def get_pin(): AUTH_BUTTON = 200 LATER_BUTTON = 201 NEVER_BUTTON = 202 ACTION_PREVIOUS_MENU = 10 ACTION_BACK = 92 CENTER_Y = 6 CENTER_X = 2 class PinAuthDialog(xbmcgui.WindowXMLDialog): auth = False def onInit(self): self.pin_edit_control = self.__add_editcontrol(30, 240, 40, 450) self.setFocus(self.pin_edit_control) auth = self.getControl(AUTH_BUTTON) never = self.getControl(NEVER_BUTTON) self.pin_edit_control.controlUp(never) self.pin_edit_control.controlLeft(never) self.pin_edit_control.controlDown(auth) self.pin_edit_control.controlRight(auth) auth.controlUp(self.pin_edit_control) auth.controlLeft(self.pin_edit_control) never.controlDown(self.pin_edit_control) never.controlRight(self.pin_edit_control) def onAction(self, action): # print 'Action: %s' % (action.getId()) if action == ACTION_PREVIOUS_MENU or action == ACTION_BACK: self.close() def onControl(self, control): # print 'onControl: %s' % (control) pass def onFocus(self, control): # print 'onFocus: %s' % (control) pass def onClick(self, control): # print 'onClick: %s' % (control) if control == AUTH_BUTTON: if not self.__get_token(): kodi.notify(msg=i18n('pin_auth_failed'), duration=5000) return self.auth = True if control == LATER_BUTTON: kodi.notify(msg=i18n('remind_in_24hrs'), duration=5000) kodi.set_setting('last_reminder', str(int(time.time()))) if control == NEVER_BUTTON: kodi.notify(msg=i18n('use_addon_settings'), duration=5000) kodi.set_setting('last_reminder', '-1') if control in [AUTH_BUTTON, LATER_BUTTON, NEVER_BUTTON]: self.close() def __get_token(self): pin = self.pin_edit_control.getText().strip() if pin: try: trakt_api = Trakt_API(use_https=use_https, timeout=trakt_timeout) result = trakt_api.get_token(pin=pin) kodi.set_setting('trakt_oauth_token', result['access_token']) kodi.set_setting('trakt_refresh_token', result['refresh_token']) profile = trakt_api.get_user_profile(cached=False) kodi.set_setting('trakt_user', '%s (%s)' % (profile['username'], profile['name'])) return True except Exception as e: log_utils.log('Trakt Authorization Failed: %s' % (e), log_utils.LOGDEBUG) return False return False # have to add edit controls programatically because getControl() (hard) crashes XBMC on them def __add_editcontrol(self, x, y, height, width): media_path = os.path.join(kodi.get_path(), 'resources', 'skins', 'Default', 'media') temp = xbmcgui.ControlEdit(0, 0, 0, 0, '', font='font12', textColor='0xFFFFFFFF', focusTexture=os.path.join(media_path, 'button-focus2.png'), noFocusTexture=os.path.join(media_path, 'button-nofocus.png'), _alignment=CENTER_Y | CENTER_X) temp.setPosition(x, y) temp.setHeight(height) temp.setWidth(width) self.addControl(temp) return temp dialog = PinAuthDialog('TraktPinAuthDialog.xml', kodi.get_path()) dialog.doModal() if dialog.auth: kodi.notify(msg=i18n('trakt_auth_complete'), duration=3000) del dialog
def get_pin(): AUTH_BUTTON = 200 LATER_BUTTON = 201 NEVER_BUTTON = 202 ACTION_PREVIOUS_MENU = 10 ACTION_BACK = 92 CENTER_Y = 6 CENTER_X = 2 class PinAuthDialog(xbmcgui.WindowXMLDialog): auth = False def onInit(self): self.pin_edit_control = self.__add_editcontrol(30, 240, 40, 450) self.setFocus(self.pin_edit_control) auth = self.getControl(AUTH_BUTTON) never = self.getControl(NEVER_BUTTON) self.pin_edit_control.controlUp(never) self.pin_edit_control.controlLeft(never) self.pin_edit_control.controlDown(auth) self.pin_edit_control.controlRight(auth) auth.controlUp(self.pin_edit_control) auth.controlLeft(self.pin_edit_control) never.controlDown(self.pin_edit_control) never.controlRight(self.pin_edit_control) def onAction(self, action): # print 'Action: %s' % (action.getId()) if action == ACTION_PREVIOUS_MENU or action == ACTION_BACK: self.close() def onControl(self, control): # print 'onControl: %s' % (control) pass def onFocus(self, control): # print 'onFocus: %s' % (control) pass def onClick(self, control): # print 'onClick: %s' % (control) if control == AUTH_BUTTON: if not self.__get_token(): kodi.notify(msg=i18n('pin_auth_failed'), duration=5000) return self.auth = True if control == LATER_BUTTON: kodi.notify(msg=i18n('remind_in_24hrs'), duration=5000) kodi.set_setting('last_reminder', str(int(time.time()))) if control == NEVER_BUTTON: kodi.notify(msg=i18n('use_addon_settings'), duration=5000) kodi.set_setting('last_reminder', '-1') if control in [AUTH_BUTTON, LATER_BUTTON, NEVER_BUTTON]: self.close() def __get_token(self): pin = self.pin_edit_control.getText().strip() if pin: try: trakt_api = Trakt_API(use_https=use_https, timeout=trakt_timeout) result = trakt_api.get_token(pin=pin) kodi.set_setting('trakt_oauth_token', result['access_token']) kodi.set_setting('trakt_refresh_token', result['refresh_token']) profile = trakt_api.get_user_profile(cached=False) kodi.set_setting( 'trakt_user', '%s (%s)' % (profile['username'], profile['name'])) return True except Exception as e: log_utils.log('Trakt Authorization Failed: %s' % (e), log_utils.LOGDEBUG) return False return False # have to add edit controls programatically because getControl() (hard) crashes XBMC on them def __add_editcontrol(self, x, y, height, width): media_path = os.path.join(kodi.get_path(), 'resources', 'skins', 'Default', 'media') temp = xbmcgui.ControlEdit( 0, 0, 0, 0, '', font='font12', textColor='0xFFFFFFFF', focusTexture=os.path.join(media_path, 'button-focus2.png'), noFocusTexture=os.path.join(media_path, 'button-nofocus.png'), _alignment=CENTER_Y | CENTER_X) temp.setPosition(x, y) temp.setHeight(height) temp.setWidth(width) self.addControl(temp) return temp dialog = PinAuthDialog('TraktPinAuthDialog.xml', kodi.get_path()) dialog.doModal() if dialog.auth: kodi.notify(msg=i18n('trakt_auth_complete'), duration=3000) del dialog
def do_auto_config(): ACTION_PREVIOUS_MENU = 10 ACTION_BACK = 92 CONTINUE_BUTTON = 200 CANCEL_BUTTON = 201 starty = 60 posx = 30 gap = 35 RADIO_BUTTONS = [ i18n('set_trakt_timeout'), i18n('set_cal_start'), i18n('set_cal_airtime'), i18n('set_scraper_timeout'), i18n('set_wl_mne'), i18n('set_test_direct'), i18n('set_filter_unusable'), i18n('set_show_debrid'), i18n('set_no_limit'), i18n('set_source_sort'), i18n('set_sso'), i18n('set_reset_url'), i18n('select_all_none') ] class AutoConfDialog(xbmcgui.WindowXMLDialog): def onInit(self): log_utils.log('onInit:', log_utils.LOGDEBUG) self.OK = False self.radio_buttons = [] posy = starty for label in RADIO_BUTTONS: self.radio_buttons.append( self.__get_radio_button(posx, posy, label)) posy += gap try: responses = json.loads(kodi.get_setting('prev_responses')) except: responses = [True] * len(self.radio_buttons) if len(responses) < len(self.radio_buttons): responses += [True ] * (len(self.radio_buttons) - len(responses)) self.addControls(self.radio_buttons) last_button = None for response, radio_button in zip(responses, self.radio_buttons): radio_button.setSelected(response) if last_button is not None: radio_button.controlUp(last_button) radio_button.controlLeft(last_button) last_button.controlDown(radio_button) last_button.controlRight(radio_button) last_button = radio_button continue_ctrl = self.getControl(CONTINUE_BUTTON) cancel_ctrl = self.getControl(CANCEL_BUTTON) self.radio_buttons[0].controlUp(cancel_ctrl) self.radio_buttons[0].controlLeft(cancel_ctrl) self.radio_buttons[-1].controlDown(continue_ctrl) self.radio_buttons[-1].controlRight(continue_ctrl) continue_ctrl.controlUp(self.radio_buttons[-1]) continue_ctrl.controlLeft(self.radio_buttons[-1]) cancel_ctrl.controlDown(self.radio_buttons[0]) cancel_ctrl.controlRight(self.radio_buttons[0]) def __get_radio_button(self, x, y, label): kwargs = { 'font': 'font12', 'focusTexture': 'button-focus2.png', 'noFocusTexture': 'button-nofocus.png', 'focusOnTexture': 'radiobutton-focus.png', 'noFocusOnTexture': 'radiobutton-focus.png', 'focusOffTexture': 'radiobutton-nofocus.png', 'noFocusOffTexture': 'radiobutton-nofocus.png' } temp = xbmcgui.ControlRadioButton(x, y, 450, 30, label, **kwargs) return temp def onAction(self, action): # log_utils.log('Action: %s' % (action.getId()), log_utils.LOGDEBUG) if action == ACTION_PREVIOUS_MENU or action == ACTION_BACK: self.close() def onControl(self, control): # log_utils.log('onControl: %s' % (control), log_utils.LOGDEBUG) pass def onFocus(self, control): # log_utils.log('onFocus: %s' % (control), log_utils.LOGDEBUG) pass def onClick(self, control): # log_utils.log('onClick: %s' % (control), log_utils.LOGDEBUG) focus_button = self.getControl(control) if focus_button == self.radio_buttons[-1]: all_status = focus_button.isSelected() for button in self.radio_buttons: button.setSelected(all_status) if control == CONTINUE_BUTTON: self.OK = True if control == CANCEL_BUTTON: self.OK = False if control == CONTINUE_BUTTON or control == CANCEL_BUTTON: self.close() def get_responses(self): return [bool(button.isSelected()) for button in self.radio_buttons] dialog = AutoConfDialog('AutoConfDialog.xml', kodi.get_path()) dialog.doModal() if dialog.OK: responses = dialog.get_responses() kodi.set_setting('prev_responses', json.dumps(responses)) perform_auto_conf(responses) del dialog
def perform_auto_conf(responses): length = len(responses) TOTAL = 12 if length < TOTAL: responses += [True] * (TOTAL - length) if responses[0]: kodi.set_setting('trakt_timeout', '60') if responses[1]: kodi.set_setting('calendar-day', '-1') if responses[2]: kodi.set_setting('calendar_time', '2') if responses[3]: kodi.set_setting('source_timeout', '20') if responses[4]: kodi.set_setting('include_watchlist_next', 'true') if responses[5]: kodi.set_setting('filter_direct', 'true') if responses[6]: kodi.set_setting('filter_unusable', 'true') if responses[7]: kodi.set_setting('show_debrid', 'true') if responses[8]: kodi.set_setting('source_results', '0') if responses[9]: kodi.set_setting('enable_sort', 'true') kodi.set_setting('sort1_field', '2') kodi.set_setting('sort2_field', '5') kodi.set_setting('sort3_field', '6') kodi.set_setting('sort4_field', '1') kodi.set_setting('sort5_field', '3') kodi.set_setting('sort6_field', '4') if responses[10]: tiers = [ 'Local', 'Premiumize.V2', 'Premiumize.me', 'Furk.net', 'EasyNews', 'DD.tv', 'NoobRoom', [ 'WatchHD', 'IFlix', 'MoviesPlanet', 'TVWTVS', 'MWM', '9Movies', '123Movies', 'niter.tv', 'HDMovie14', 'ororo.tv', 'm4ufree' ], [ 'StreamLord', 'CyberReel', 'MovCav', 'tunemovie', 'MovieMax', 'afdah.org', 'xmovies8', 'xmovies8.v2', 'MovieXK' ], [ 'Rainierland', 'DayT.se', 'FardaDownload', 'zumvo.com', 'PutMV', 'vivo.to', 'MiraDeTodo', 'beinmovie', 'FireMoviesHD' ], [ 'IzlemeyeDeger', 'SezonLukDizi', 'Dizimag', 'Dizilab', 'Dizigold', 'Dizibox', 'Diziay', 'Dizipas', 'OneClickTVShows', 'OnlineDizi' ], [ 'DDLValley', '2DDL', 'ReleaseBB', 'MyVideoLinks.eu', 'OCW', 'TheExtopia', 'RLSSource.net', 'TVRelease.Net' ], [ 'IceFilms', 'WatchEpisodes', 'PrimeWire', 'tvonline', 'SantaSeries', 'Flixanity', 'wso.ch', 'WatchSeries', 'UFlix.org', 'Putlocker' ], [ 'MovieWatcher', 'alluc.com', 'VKFlix', 'WatchFree.to', 'pftv', 'streamallthis.is', 'Movie4K', 'afdah', 'SolarMovie' ], [ 'MysticLand', 'MovieSub', 'MovieHut', 'CouchTunerV2', 'CouchTunerV1', 'Watch8Now', 'yshows', 'iWatchOnline' ], [ 'Ganool', 'vidics.ch', 'pubfilm', 'eMovies.Pro', 'OnlineMoviesPro', 'movie25', 'viooz.ac', 'view47', 'MoviesHD' ], [ 'wmo.ch', 'stream-tv.co', 'clickplay.to', 'MintMovies', 'MovieNight', 'cmz', 'ch131', 'filmikz.ch' ], [ 'MovieTube', 'LosMovies', 'FilmStreaming.in', 'moviestorm.eu', 'MerDB' ] ] sso = [] random_sso = kodi.get_setting('random_sso') == 'true' for tier in tiers: if isinstance(tier, basestring): sso.append(tier) else: if random_sso: random.shuffle(tier) sso += tier kodi.set_setting('source_sort_order', '|'.join(sso)) if responses[11]: reset_base_url() trigger = [ False, True, False, True, False, True, True, False, True, False, False, False ] if all([t == r for t, r in zip(trigger, responses)]): kodi.set_setting('scraper_download', 'true') kodi.notify(msg=i18n('auto_conf_complete'))