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 play_this(item, title='', thumbnail='', player=True, history=None): if history is None: history = kodi.get_setting('history-add-on-play') == "true" override_history = kodi.get_setting('history-add-on-play') == "true" stream_url = None headers = None content_type = 'video' override_content_type = None is_dash = False direct = [ 'rtmp:', 'rtmpe:', 'ftp:', 'ftps:', 'special:', 'plugin:', 'udp:', 'upnp:' ] unresolved_source = None label = title source_label = label source_thumbnail = thumbnail history_item = None if item.startswith('http'): with kodi.ProgressDialog( '%s...' % kodi.i18n('resolving'), '%s:' % kodi.i18n('attempting_determine_type'), item) as progress_dialog: while not progress_dialog.is_canceled(): url_override = __check_for_new_url(item) if item != url_override: log_utils.log( 'Source |{0}| has been replaced by |{1}|'.format( item, url_override), log_utils.LOGDEBUG) progress_dialog.update( 5, '%s: %s' % (kodi.i18n('source'), item), '%s: %s' % (kodi.i18n('replaced_with'), url_override), ' ') item = url_override result = __get_content_type_and_headers(item) content_type = result['content_type'] headers = result['headers'] url_override = result['url_override'] if url_override: log_utils.log( 'Source |{0}| has been replaced by |{1}|'.format( item, url_override), log_utils.LOGDEBUG) progress_dialog.update( 10, '%s: %s' % (kodi.i18n('source'), item), '%s: %s' % (kodi.i18n('replaced_with'), url_override), ' ') item = url_override log_utils.log( 'Source |{0}| has media type |{1}|'.format( item, content_type), log_utils.LOGDEBUG) progress_dialog.update( 20, '%s: %s' % (kodi.i18n('source'), item), '%s: %s' % (kodi.i18n('using_media_type'), content_type), ' ') if content_type == 'video' or content_type == 'audio' or content_type == 'image' \ or content_type == 'mpd' or content_type == 'smil': source = item if content_type == 'smil': content_type = 'video' smil_result = __get_html_and_headers(item, headers) source = pick_source( parse_smil_source_list(smil_result['contents'])) elif content_type == 'mpd': content_type = 'video' if not dash_supported: source = None else: is_dash = True if source: stream_url = source elif content_type == 'text': if progress_dialog.is_canceled(): sys.exit(0) progress_dialog.update( 40, '%s: %s' % (kodi.i18n('source'), item), '%s: URLResolver' % kodi.i18n('attempt_resolve_with'), ' ') content_type = 'video' headers.update({'Referer': item}) source = resolve(item, title=title) if source: log_utils.log( 'Source |{0}| was |URLResolver supported|'.format( source), log_utils.LOGDEBUG) sd_result = __check_smil_dash(source, headers) source = sd_result['url'] is_dash = sd_result['is_dash'] if source: progress_dialog.update( 98, '%s: %s' % (kodi.i18n('source'), item), '%s: URLResolver' % kodi.i18n('attempt_resolve_with'), '%s: %s' % (kodi.i18n('resolution_successful'), source)) stream_url = source if not stream_url: if progress_dialog.is_canceled(): sys.exit(0) progress_dialog.update( 60, '%s: %s' % (kodi.i18n('source'), item), '%s: youtube-dl' % kodi.i18n('attempt_resolve_with'), ' ') if ytdl_supported(item): ytdl_result = resolve_youtube_dl(item) if ytdl_result['resolved_url']: headers = ytdl_result['headers'] label = ytdl_result['label'] if ytdl_result[ 'label'] is not None else label source_thumbnail = ytdl_result[ 'thumbnail'] if ytdl_result[ 'thumbnail'] is not None else source_thumbnail log_utils.log( 'Source |{0}| found by |youtube-dl|'. format(ytdl_result['resolved_url']), log_utils.LOGDEBUG) sd_result = __check_smil_dash( ytdl_result['resolved_url'], headers) source = sd_result['url'] is_dash = sd_result['is_dash'] if source: progress_dialog.update( 98, '%s: %s' % (kodi.i18n('source'), item), '%s: youtube-dl' % kodi.i18n('attempt_resolve_with'), '%s: %s' % (kodi.i18n('resolution_successful'), source)) stream_url = source if not progress_dialog.is_canceled(): progress_dialog.update(100, ' ', kodi.i18n('resolution_completed'), ' ') break else: sys.exit(0) if not stream_url: content_type = 'executable' scrape_result = scrape(item) source = scrape_result['resolved_url'] override_content_type = scrape_result['content_type'] unresolved_source = scrape_result['unresolved_url'] source_label = scrape_result['label'] headers = scrape_result['headers'] if scrape_result['thumbnail']: source_thumbnail = scrape_result['thumbnail'] if scrape_result['title']: label = scrape_result['title'] if source: log_utils.log( 'Source |{0}| found by |Scraping for supported|'.format( source), log_utils.LOGDEBUG) if override_content_type == 'video': sd_result = __check_smil_dash(source, headers) source = sd_result['url'] is_dash = sd_result['is_dash'] if source: stream_url = source if stream_url: stream_url = stream_url.replace(r'\\', '') elif any(item.startswith(p) for p in direct): log_utils.log('Source |{0}| may be supported'.format(item), log_utils.LOGDEBUG) stream_url = item if is_dash and (not dash_supported or not kodi.addon_enabled('inputstream.adaptive')): stream_url = None if stream_url and (content_type == 'video' or content_type == 'audio' or content_type == 'image' or content_type == 'executable'): working_dialog = kodi.WorkingDialog() with working_dialog: play_history = utils.PlayHistory() working_dialog.update(20) if history or player == 'history': history_item = item.split('|')[0] if '%' not in history_item: history_item = urllib2.quote(history_item) log_utils.log( 'Adding source |{0}| to history with content_type |{1}|'. format(item, content_type), log_utils.LOGDEBUG) play_history.add(history_item, content_type, label if label else item, urllib2.quote(thumbnail)) working_dialog.update(40) if override_content_type and override_history: history_item = stream_url if history_item.startswith('plugin://') or unresolved_source: history_item = unresolved_source history_item = history_item.split('|')[0] if '%' not in history_item: history_item = urllib2.quote(history_item) log_utils.log( 'Adding source |{0}| to history with content_type |{1}|'. format(unresolved_source, override_content_type), log_utils.LOGDEBUG) play_history.add(history_item, override_content_type, source_label, urllib2.quote(source_thumbnail)) if player == 'history': return if history_item: kodi.refresh_container() working_dialog.update(60) if (not stream_url.startswith('plugin://')) and (headers is not None): stream_url = get_url_with_headers(stream_url, headers) working_dialog.update(80) if any(plugin_id in stream_url for plugin_id in RUNPLUGIN_EXCEPTIONS): log_utils.log('Running plugin: |{0!s}|'.format(stream_url), log_utils.LOGDEBUG) kodi.execute_builtin('RunPlugin(%s)' % stream_url) else: if override_content_type: content_type = override_content_type source = { 'content_type': content_type, 'url': stream_url, 'is_dash': is_dash, 'info': { 'title': source_label }, 'art': { 'icon': source_thumbnail, 'thumb': source_thumbnail } } play(source, player) else: log_utils.log('Found no potential sources: |{0!s}|'.format(item), log_utils.LOGDEBUG)