def add_trakt(title, year=''): trakt_api = Trakt_API(kodi.get_setting('trakt_oauth_token'), kodi.get_setting('use_https') == 'true', timeout=int(kodi.get_setting('trakt_timeout'))) results = trakt_api.search(SECTIONS.MOVIES, title) try: results = [result for result in results if result['year'] is not None and int(result['year']) - 1 <= int(year) <= int(result['year'] + 1)] except: pass if not results: kodi.notify(msg=i18n('no_movie_found')) return if len(results) == 1: index = 0 else: pick_list = [movie['title'] if movie['year'] is None else '%s (%s)' % (movie['title'], movie['year']) for movie in results] index = xbmcgui.Dialog().select(i18n('pick_a_movie'), pick_list) if index > -1: slug = kodi.get_setting('default_slug') name = kodi.get_setting('default_list') if not slug: result = utils.choose_list(Trakt_API, translations) if result is None: return else: slug, name = result item = {'trakt': results[index]['ids']['trakt']} if slug == WATCHLIST_SLUG: trakt_api.add_to_watchlist(SECTIONS.MOVIES, item) elif slug: trakt_api.add_to_list(SECTIONS.MOVIES, slug, item) movie = results[index] label = movie['title'] if movie['year'] is None else '%s (%s)' % (movie['title'], movie['year']) kodi.notify(msg=i18n('added_to_list') % (label, name)) kodi.refresh_container()
def update_scraper(filename, scraper_url): try: if not filename: return py_path = os.path.join(kodi.get_path(), 'scrapers', filename) exists = os.path.exists(py_path) scraper_password = kodi.get_setting('scraper_password') if scraper_url and scraper_password: old_lm = None old_py = '' if exists: with open(py_path, 'r') as f: old_py = f.read() match = re.search('^#\s+Last-Modified:\s*(.*)', old_py) if match: old_lm = match.group(1).strip() new_lm, new_py = utils2.get_and_decrypt(scraper_url, scraper_password, old_lm) if new_py: logger.log('%s path: %s, new_py: %s, match: %s' % (filename, py_path, bool(new_py), new_py == old_py), log_utils.LOGDEBUG) if old_py != new_py: with open(py_path, 'w') as f: f.write('# Last-Modified: %s\n' % (new_lm)) f.write(new_py) kodi.notify(msg=utils2.i18n('scraper_updated') + filename) except Exception as e: logger.log('Failure during %s scraper update: %s' % (filename, e), log_utils.LOGWARNING)
def __get_cached_url(self, url, cache=8): log_utils.log("Fetching Cached URL: %s" % url, log_utils.LOGDEBUG) before = time.time() _, html = db_connection.get_cached_url(url, cache) if html: log_utils.log("Returning cached result for: %s" % (url), log_utils.LOGDEBUG) return html log_utils.log("No cached url found for: %s" % url, log_utils.LOGDEBUG) req = urllib2.Request(url) host = BASE_URL.replace("http://", "") req.add_header("User-Agent", USER_AGENT) req.add_header("Host", host) req.add_header("Referer", BASE_URL) try: body = self.__http_get_with_retry(url, req) body = body.decode("utf-8") parser = HTMLParser.HTMLParser() body = parser.unescape(body) except Exception as e: kodi.notify(msg="Failed to connect to URL: %s" % (url), duration=5000) log_utils.log("Failed to connect to URL %s: (%s)" % (url, e), log_utils.LOGERROR) return "" db_connection.cache_url(url, body) after = time.time() log_utils.log("Cached Url Fetch took: %.2f secs" % (after - before), log_utils.LOGDEBUG) return body
def __get_cached_url(self, url, cache=8): log_utils.log('Fetching Cached URL: %s' % url, log_utils.LOGDEBUG) before = time.time() _created, _res_header, html = self.db_connection.get_cached_url(url, cache_limit=cache) if html: log_utils.log('Returning cached result for: %s' % (url), log_utils.LOGDEBUG) return html log_utils.log('No cached url found for: %s' % url, log_utils.LOGDEBUG) req = urllib2.Request(url) host = BASE_URL.replace('http://', '') req.add_header('User-Agent', USER_AGENT) req.add_header('Host', host) req.add_header('Referer', BASE_URL) try: body = self.__http_get_with_retry(url, req) body = body.decode('utf-8') parser = HTMLParser.HTMLParser() body = parser.unescape(body) except Exception as e: kodi.notify(msg='Failed to connect to URL: %s' % (url), duration=5000) log_utils.log('Failed to connect to URL %s: (%s)' % (url, e), log_utils.LOGERROR) return '' self.db_connection.cache_url(url, body) after = time.time() log_utils.log('Cached Url Fetch took: %.2f secs' % (after - before), log_utils.LOGDEBUG) return body
def show_next_up(last_label, sf_begin): token = kodi.get_setting('trakt_oauth_token') if token and xbmc.getInfoLabel('Container.PluginName') == kodi.get_id() and xbmc.getInfoLabel('Container.Content') == 'tvshows': if xbmc.getInfoLabel('ListItem.label') != last_label: sf_begin = time.time() last_label = xbmc.getInfoLabel('ListItem.label') if sf_begin and (time.time() - sf_begin) >= int(kodi.get_setting('next_up_delay')): liz_url = xbmc.getInfoLabel('ListItem.FileNameAndPath') queries = kodi.parse_query(liz_url[liz_url.find('?'):]) if 'trakt_id' in queries: try: list_size = int(kodi.get_setting('list_size')) except: list_size = 30 try: trakt_timeout = int(kodi.get_setting('trakt_timeout')) except: trakt_timeout = 20 trakt_api = Trakt_API(token, kodi.get_setting('use_https') == 'true', list_size, trakt_timeout, kodi.get_setting('trakt_offline') == 'true') progress = trakt_api.get_show_progress(queries['trakt_id'], full=True) if 'next_episode' in progress and progress['next_episode']: if progress['completed'] or kodi.get_setting('next_unwatched') == 'true': next_episode = progress['next_episode'] date = utils2.make_day(utils2.make_air_date(next_episode['first_aired'])) if kodi.get_setting('next_time') != '0': date_time = '%s@%s' % (date, utils2.make_time(utils.iso_2_utc(next_episode['first_aired']), 'next_time')) else: date_time = date msg = '[[COLOR deeppink]%s[/COLOR]] - %sx%s' % (date_time, next_episode['season'], next_episode['number']) if next_episode['title']: msg += ' - %s' % (next_episode['title']) duration = int(kodi.get_setting('next_up_duration')) * 1000 kodi.notify(header=i18n('next_episode'), msg=msg, duration=duration) sf_begin = 0 else: last_label = '' return last_label, sf_begin
def play_link(link): log_utils.log('Playing Link: |%s|' % (link), log_utils.LOGDEBUG) hmf = urlresolver.HostedMediaFile(url=link) if not hmf: log_utils.log('Indirect hoster_url not supported by urlresolver: %s' % (link)) kodi.notify('Link Not Supported: %s' % (link), duration=7500) return False log_utils.log('Link Supported: |%s|' % (link), log_utils.LOGDEBUG) try: stream_url = hmf.resolve() if not stream_url or not isinstance(stream_url, basestring): try: msg = stream_url.msg except: msg = link raise Exception(msg) except Exception as e: try: msg = str(e) except: msg = link kodi.notify('Resolve Failed: %s' % (msg), duration=7500) return False log_utils.log('Link Resolved: |%s|%s|' % (link, stream_url), log_utils.LOGDEBUG) listitem = xbmcgui.ListItem(path=stream_url) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
def __get_cached_url(self, url, cache=8): logger.log('Fetching Cached URL: %s' % url, log_utils.LOGDEBUG) before = time.time() _created, _res_header, html = self.db_connection.get_cached_url(url, cache_limit=cache) if html: logger.log('Returning cached result for: %s' % (url), log_utils.LOGDEBUG) return html.decode('utf-8') logger.log('No cached url found for: %s' % url, log_utils.LOGDEBUG) req = urllib2.Request(url) host = BASE_URL.replace('http://', '') req.add_header('User-Agent', USER_AGENT) req.add_header('Host', host) req.add_header('Referer', BASE_URL) try: response = urllib2.urlopen(req, timeout=10) html = response.read() html = utils2.cleanse_title(html) except Exception as e: kodi.notify(msg='Failed to connect to URL: %s' % (url), duration=5000) logger.log('Failed to connect to URL %s: (%s)' % (url, e), log_utils.LOGERROR) return '' self.db_connection.cache_url(url, html) after = time.time() logger.log('Cached Url Fetch took: %.2f secs' % (after - before), log_utils.LOGDEBUG) return html
def do_disable_check(): scrapers = relevant_scrapers() auto_disable = kodi.get_setting('auto-disable') check_freq = int(kodi.get_setting('disable-freq')) disable_thresh = int(kodi.get_setting('disable-thresh')) for cls in scrapers: last_check = db_connection.get_setting('%s_check' % (cls.get_name())) last_check = int(last_check) if last_check else 0 tries = kodi.get_setting('%s_try' % (cls.get_name())) tries = int(tries) if tries else 0 if tries > 0 and tries / check_freq > last_check / check_freq: kodi.set_setting('%s_check' % (cls.get_name()), str(tries)) success_rate = calculate_success(cls.get_name()) if success_rate < disable_thresh: if auto_disable == DISABLE_SETTINGS.ON: kodi.set_setting('%s-enable' % (cls.get_name()), 'false') kodi.notify(msg='[COLOR blue]%s[/COLOR] %s' % (i18n('scraper_disabled')), duration=5000) elif auto_disable == DISABLE_SETTINGS.PROMPT: dialog = xbmcgui.Dialog() line1 = i18n('disable_line1') % (cls.get_name(), 100 - success_rate, tries) line2 = i18n('disable_line2') line3 = i18n('disable_line3') ret = dialog.yesno('SALTS', line1, line2, line3, i18n('keep_enabled'), i18n('disable_it')) if ret: kodi.set_setting('%s-enable' % (cls.get_name()), 'false')
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 download_media(url, path, file_name): try: progress = int(kodi.get_setting('down_progress')) active = not progress == PROGRESS.OFF background = progress == PROGRESS.BACKGROUND with kodi.ProgressDialog('Premiumize Cloud', i18n('downloading') % (file_name), background=background, active=active) as pd: request = urllib2.Request(url) request.add_header('User-Agent', USER_AGENT) request.add_unredirected_header('Host', request.get_host()) response = urllib2.urlopen(request) content_length = 0 if 'Content-Length' in response.info(): content_length = int(response.info()['Content-Length']) file_name = file_name.replace('.strm', get_extension(url, response)) full_path = os.path.join(path, file_name) log_utils.log('Downloading: %s -> %s' % (url, full_path), log_utils.LOGDEBUG) path = xbmc.makeLegalFilename(path) try: try: xbmcvfs.mkdirs(path) except: os.makedirs(path) except Exception as e: log_utils.log('Dir Create Failed: %s' % (e), log_utils.LOGDEBUG) if not xbmcvfs.exists(path): raise Exception(i18n('failed_create_dir')) file_desc = xbmcvfs.File(full_path, 'w') total_len = 0 cancel = False while True: data = response.read(CHUNK_SIZE) if not data: break if pd.is_canceled(): cancel = True break total_len += len(data) if not file_desc.write(data): raise Exception(i18n('failed_write_file')) percent_progress = (total_len) * 100 / content_length if content_length > 0 else 0 log_utils.log('Position : %s / %s = %s%%' % (total_len, content_length, percent_progress), log_utils.LOGDEBUG) pd.update(percent_progress) file_desc.close() if not cancel: kodi.notify(msg=i18n('download_complete') % (file_name), duration=5000) log_utils.log('Download Complete: %s -> %s' % (url, full_path), log_utils.LOGDEBUG) except Exception as e: log_utils.log('Error (%s) during download: %s -> %s' % (str(e), url, file_name), log_utils.LOGERROR) kodi.notify(msg=i18n('download_error') % (str(e), file_name), duration=5000)
def authorize(self, pin): response = self._authorize(pin) if response: kodi.notify(header='Trakt', msg='You are now authorized' , duration=5000, sound=None) the_username=self.my_username() kodi.set_setting('trakt_username',the_username['username']) else: kodi.notify(header='Trakt', msg='Authorization Failed try again' , duration=5000, sound=None) return response
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 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 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(i18n('pick_a_list'), [list_data['name'] for list_data in lists]) if index > -1: return lists[index]['ids']['slug'] else: kodi.notify(msg=i18n('no_lists_for_user') % (username), duration=5000)
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(i18n("pick_a_list"), [list_data["name"] for list_data in lists]) if index > -1: return lists[index]["ids"]["slug"] else: kodi.notify(msg=i18n("no_lists_for_user") % (username), duration=5000)
def choose_list(Trakt_API, translations, username=None): i18n = translations.i18n trakt_api = Trakt_API(kodi.get_setting('trakt_oauth_token'), kodi.get_setting('use_https') == 'true', timeout=int(kodi.get_setting('trakt_timeout'))) 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(i18n('pick_a_list'), [list_data['name'] for list_data in lists]) if index > -1: return (lists[index]['ids']['slug'], lists[index]['name']) else: kodi.notify(msg=i18n('no_lists_for_user') % (username), duration=5000)
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', 'Furk.net', 'EasyNews', 'DD.tv', 'NoobRoom', ['alluc.com', 'OneClickTVShows', 'CyberReel', '123Movies', 'niter.tv', 'ororo.tv', 'movietv.to', 'StreamLord'], ['tunemovie', 'afdah.org', 'xmovies8', 'xmovies8.v2', 'beinmovie', 'torba.se', 'IzlemeyeDeger', 'Rainierland', 'zumvo.com', 'MiraDeTodo'], ['SezonLukDizi', 'Dizimag', 'Dizilab', 'Dizigold', 'Diziay', 'Dizipas', 'Shush.se', 'MovieFarsi'], ['DDLValley', 'ReleaseBB', 'MyVideoLinks.eu', 'OneClickWatch', 'RLSSource.net'], ['IceFilms', 'PrimeWire', 'Flixanity', 'wso.ch', 'WatchSeries', 'UFlix.org', 'Putlocker', 'MovieHut'], ['funtastic-vids', 'WatchFree.to', 'pftv', 'streamallthis.is', 'Movie4K', 'afdah', 'SolarMovie', 'yify-streaming'], ['CouchTunerV2', 'CouchTunerV1', 'Watch8Now', 'yshows', '2movies', 'iWatchOnline', 'vidics.ch', 'pubfilm'], ['OnlineMoviesIs', 'OnlineMoviesPro', 'ViewMovies', 'movie25', 'viooz.ac', 'view47', 'MoviesHD', 'wmo.ch'], ['ayyex', 'stream-tv.co', 'clickplay.to', 'MintMovies', 'MovieNight', 'cmz', 'ch131', 'filmikz.ch'], ['MovieTube', 'LosMovies', 'FilmStreaming.in', 'moviestorm.eu', 'MerDB'], 'MoviesOnline7'] 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() kodi.set_setting('filter-unknown', 'false') kodi.notify(msg=i18n('auto_conf_complete'))
def __auth_trakt(trakt_api, code, i18n): try: result = trakt_api.get_device_token(code) return result except urllib2.URLError as e: # authorization is pending; too fast if e.code in [400, 429]: return elif e.code == 418: kodi.notify(msg=i18n('user_reject_auth'), duration=3000) return True elif e.code == 410: return else: raise
def __attempt_db_recovery(self): self.__recovery = True header = i18n('recovery_header') if xbmcgui.Dialog().yesno(header, i18n('rec_mig_1'), i18n('rec_mig_2')): try: self.init_database('0.0.0') except Exception as e: log_utils.log('DB Migration Failed: %s' % (e), log_utils.LOGWARNING) if xbmcgui.Dialog().yesno(header, i18n('rec_reset_1'), i18n('rec_reset_2'), i18n('rec_reset_3')): try: result = self.reset_db() except Exception as e: log_utils.log('Reset Failed: %s' % (e), log_utils.LOGWARNING) kodi.notify(msg=i18n('reset_failed') % e, duration=5000) else: if result: kodi.notify(msg=i18n('db_reset_success'))
def play_most_recent(location, movie_id='', thumb=''): path = kodi.get_setting('download_path') trailers = scraper.get_trailers(location, movie_id) try: trailer = trailers.next() stream_url = local_utils.get_best_stream(trailer['streams'], 'stream') if path: file_name = utils.create_legal_filename(trailer['title'], trailer.get('year', '')) else: file_name = '' if not thumb: thumb = trailer.get('thumb', '') play_trailer(stream_url, thumb, file_name, playable=False, meta=trailer) except StopIteration: kodi.notify(i18n('none_available'))
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 main(argv=None): if sys.argv: argv = sys.argv queries = kodi.parse_query(sys.argv[2]) log_utils.log('Version: |%s| Queries: |%s|' % (kodi.get_version(), queries), log_utils.LOGNOTICE) log_utils.log('Args: |%s|' % (argv), log_utils.LOGNOTICE) # don't process params that don't match our url exactly. (e.g. plugin://plugin.video.1channel/extrafanart) plugin_url = 'plugin://%s/' % (kodi.get_id()) if argv[0] != plugin_url: return try: mode = queries.get('mode', None) url_dispatcher.dispatch(mode, queries) except (TransientTraktError, TraktError, TraktAuthError) as e: log_utils.log(str(e), log_utils.LOGERROR) kodi.notify(msg=str(e), 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 __get_url(self, url): try: req = urllib2.Request(url) host = BASE_URL.replace('http://', '') req.add_header('User-Agent', USER_AGENT) req.add_header('Host', host) req.add_header('Referer', BASE_URL) response = urllib2.urlopen(req, timeout=10) body = response.read() parser = HTMLParser.HTMLParser() body = parser.unescape(body) except Exception as e: kodi.notify(msg='Failed to connect to URL: %s' % (url), duration=5000) log_utils.log('Failed to connect to URL %s: (%s)' % (url, e), log_utils.LOGERROR) return ('', '') return (response, body)
def onClick(self, control): # print 'onClick: %s' % (control) if control == AUTH_BUTTON: print "PIN INPUT" if not self.__get_token(): kodi.notify(header='Not Authorized',msg='Using Standard Menus',duration=5000,sound=None) #self.auth = True if control == NEVER_BUTTON: #xbmc.executebuiltin('RunPlugin(%s)' % addon.build_plugin_url({'mode':None})) kodi.notify(header='Not Authorized',msg='Using Standard Menus',duration=5000,sound=None) # 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 _callnetworks(self, uri, data=None, params=None, auth=False, cache=False, timeout=None): url = '%s%s' % (BASE_URL, uri) if timeout is not None: self.timetout = timeout json_data = json.dumps(data) if data else None headers = {'Content-Type': 'application/json', 'trakt-api-key': CLIENT_ID, 'trakt-api-version': 2} if auth: self._authorize() if self.token is None: raise TraktError('Trakt Authorization Required: 400') headers.update({'Authorization': 'Bearer %s' % (self.token)}) #url = '%s%s' % (BASE_URL, uri) #print "URL IS = "+url if params and not uri.endswith('/token'): params['limit'] = 200 else: params = {'limit': 200} url = url + '?' + urllib.urlencode(params) #START CACHE STUFF created, cached_result = cache_stat.get_cached_url(url) now = time.time() #print "API NOW TIME IS :"+str(now) limit = 60 * 60 * int(kodi.get_setting('cache_limit')) #print "API LIMIT IS : "+str(limit) age = now - created #print "API AGE IS :"+str(age) if cached_result and age < limit: result = cached_result #print 'Using cached result for: %s' % (url) response = json.loads(result) return response #END CACHE STUFF else: try: request = urllib2.Request(url, data=json_data, headers=headers) f = urllib2.urlopen(request, timeout=self.timeout) result = f.read() response = json.loads(result) except HTTPError as e: print "ERROR IS = "+str(e) kodi.notify(header='Trakt Error',msg='(error) %s %s' % (str(e), ''),duration=5000,sound=None) if not uri.endswith('/token'): print "ERROR IS = "+str(e) kodi.notify(header='Trakt Error',msg='(error) %s %s' % (str(e), ''),duration=5000,sound=None) #ADDON.show_error_dialog(['Trakt Error', 'HTTP ERROR', str(e)]) #raise TraktError('Trakt-HTTP-Error: %s' % e) return False except URLError as e: print "URLERROR IS = "+str(e) #ADDON.log(url, LOG_LEVEL.VERBOSE) if not uri.endswith('/token'): #ADDON.show_error_dialog(['Trakt Error', 'URLLib ERROR', str(e)]) kodi.notify(header='Trakt Error',msg='(error) %s %s' % (str(e), ''),duration=5000,sound=None) raise TraktError('Trakt-URL-Error: %s' % e) return False else: if cache =='true': cache_stat.set_cache_url(url,result) return response else: return response
def auth_trakt(Trakt_API, translations): i18n = translations.i18n 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']) with kodi.CountdownDialog(i18n('trakt_acct_auth'), line1=line1, line2=line2, countdown=time_left, interval=interval) as cd: result = cd.start(__auth_trakt, [trakt_api, code, i18n]) 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: logger.log('Trakt Authorization Failed: %s' % (e), log_utils.LOGDEBUG)
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(), i18n('scraper_disabled')), duration=5000) kodi.set_setting(setting, '0') elif auto_disable == DISABLE_SETTINGS.PROMPT: dialog = xbmcgui.Dialog() line1 = i18n('disable_line1') % (cls.get_name(), fails) line2 = i18n('disable_line2') line3 = i18n('disable_line3') ret = dialog.yesno('SALTS', line1, line2, line3, i18n('keep_enabled'), 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 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(), i18n("scraper_disabled")), duration=5000) kodi.set_setting(setting, "0") elif auto_disable == DISABLE_SETTINGS.PROMPT: dialog = xbmcgui.Dialog() line1 = i18n("disable_line1") % (cls.get_name(), fails) line2 = i18n("disable_line2") line3 = i18n("disable_line3") ret = dialog.yesno("SALTS", line1, line2, line3, i18n("keep_enabled"), 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 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 content(url, searched=False): try: c = cloudflare.get(url, headers=headers).text soup = BeautifulSoup(c, 'html5lib') content = soup.find('div', class_={'results results_search'}) if (not content) and (not searched): log_utils.log( 'Scraping Error in %s:: Content of request: %s' % (base_name.title(), str(c)), log_utils.LOGERROR) kodi.notify(msg='Scraping Error: Info Added To Log File', duration=6000, sound=True) except Exception as e: if (not searched): log_utils.log( 'Fatal Error in %s:: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR) kodi.notify(msg='Fatal Error', duration=4000, sound=True) quit() else: pass dirlst = [] for a in content.find_all('a', class_={'thumb'}): try: title = a.img['alt'].title() url2 = a['href'] if not base_domain in url2: url2 = base_domain + url2 icon = a.img['data-src'] if not 'http' in icon: icon = 'https:' + icon fanarts = translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/%s/fanart.jpg' % filename)) dirlst.append({ 'name': title, 'url': url2, 'mode': player_mode, 'icon': icon, 'fanart': fanarts, 'description': title, 'folder': False }) except Exception as e: dialog.ok("E", str(e)) log_utils.log('Error: %s' % str(e), log_utils.LOGERROR) if dirlst: buildDirectory(dirlst, stopend=True, isVideo=True, isDownloadable=True) else: if (not searched): kodi.notify(msg='No Content Found') quit() if searched: return str(len(r)) if not searched: try: search_pattern = '''<li\s*class\=['"]next['"]\>\<a\s*href\=['"]([^'"]+)''' parse = base_domain helper.scraper().get_next_page(content_mode, url, search_pattern, filename, parse) except Exception as e: log_utils.log( 'Error getting next page for %s :: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR)
P_MODE = int(kodi.get_setting('parallel_mode')) if P_MODE in [P_MODES.THREADS, P_MODES.NONE]: import threading from Queue import Queue, Empty elif P_MODE == P_MODES.PROCESSES: try: import multiprocessing from multiprocessing import Queue from Queue import Empty except ImportError: import threading from Queue import Queue, Empty P_MODE = P_MODES.THREADS kodi.notify( msg= 'Process Mode not supported on this platform falling back to Thread Mode', duration=7500) TOKEN = kodi.get_setting('trakt_oauth_token') use_https = kodi.get_setting('use_https') == 'true' trakt_timeout = int(kodi.get_setting('trakt_timeout')) list_size = int(kodi.get_setting('list_size')) trakt_api = Trakt_API(TOKEN, use_https, list_size, trakt_timeout) db_connection = DB_Connection() THEME_LIST = [ 'Shine', 'Luna_Blue', 'Iconic', 'Simple', 'SALTy', 'SALTy (Blended)', 'SALTy (Blue)', 'SALTy (Frog)', 'SALTy (Green)', 'SALTy (Macaw)', 'SALTier (Green)', 'SALTier (Orange)', 'SALTier (Red)', 'IGDB', 'Simply Elegant' ]
def download_media(url, path, file_name, translations, progress=None): try: if progress is None: progress = int(kodi.get_setting('down_progress')) i18n = translations.i18n active = not progress == PROGRESS.OFF background = progress == PROGRESS.BACKGROUND with kodi.ProgressDialog(kodi.get_name(), i18n('downloading') % (file_name), background=background, active=active) as pd: try: headers = dict([ item.split('=') for item in (url.split('|')[1]).split('&') ]) for key in headers: headers[key] = urllib.unquote(headers[key]) except: headers = {} if 'User-Agent' not in headers: headers['User-Agent'] = BROWSER_UA request = urllib2.Request(url.split('|')[0], headers=headers) response = urllib2.urlopen(request) if 'Content-Length' in response.info(): content_length = int(response.info()['Content-Length']) else: content_length = 0 file_name += '.' + get_extension(url, response) full_path = os.path.join(path, file_name) logger.log('Downloading: %s -> %s' % (url, full_path), log_utils.LOGDEBUG) path = kodi.translate_path(xbmc.makeLegalFilename(path)) try: try: xbmcvfs.mkdirs(path) except: os.makedirs(path) except Exception as e: logger.log('Path Create Failed: %s (%s)' % (e, path), log_utils.LOGDEBUG) if not path.endswith(os.sep): path += os.sep if not xbmcvfs.exists(path): raise Exception(i18n('failed_create_dir')) file_desc = xbmcvfs.File(full_path, 'w') total_len = 0 cancel = False while True: data = response.read(CHUNK_SIZE) if not data: break if pd.is_canceled(): cancel = True break total_len += len(data) if not file_desc.write(data): raise Exception(i18n('failed_write_file')) percent_progress = ( total_len ) * 100 / content_length if content_length > 0 else 0 logger.log( 'Position : %s / %s = %s%%' % (total_len, content_length, percent_progress), log_utils.LOGDEBUG) pd.update(percent_progress) file_desc.close() if not cancel: kodi.notify(msg=i18n('download_complete') % (file_name), duration=5000) logger.log('Download Complete: %s -> %s' % (url, full_path), log_utils.LOGDEBUG) except Exception as e: logger.log( 'Error (%s) during download: %s -> %s' % (str(e), url, file_name), log_utils.LOGERROR) kodi.notify(msg=i18n('download_error') % (str(e), file_name), duration=5000)
def find_link(url, name, iconimage, downloadableLink=False): xbmc.executebuiltin("ActivateWindow(busydialog)") if '|SPLIT|' in url: url = url.split('|SPLIT|')[0] if 'site=' in url: url = url.split('site=')[0] if '|' in url: url = url.split('|User-Agent')[0] c = client.request(url, output='headers') checks = ['video', 'mpegurl'] exts = ['.mp4', '.flv', '.m3u8'] try: if any(f for f in checks if f in c['Content-Type']): downloadableLink = True except: if any(f for f in exts if f in url): downloadableLink = True else: xbmc.executebuiltin("Dialog.Close(busydialog)") kodi.notify(msg='Error downloading video.') quit() name = kodi.stripColor(name) if '] -' in name: name = name.split('] -')[1] if downloadableLink: dest = getDest() dest = os.path.join(dest, '%s.mp4' % urllib.quote_plus(name)) download(url, name, iconimage, dest) else: u = None log_utils.log('Sending %s to XXX Resolver' % (url), log_utils.LOGNOTICE) if urlresolver.HostedMediaFile(url, include_xxx=True).valid_url(): log_utils.log( '%s is a valid SMU resolvable URL. Attempting to resolve.' % (url), log_utils.LOGNOTICE) try: u = urlresolver.HostedMediaFile(url, include_xxx=True).resolve() except Exception as e: log_utils.log( 'Error getting valid link from SMU :: %s :: %s' % (url, str(e)), log_utils.LOGERROR) kodi.idle() kodi.notify(msg='Something went wrong! | %s' % str(e), duration=8000, sound=True) quit() log_utils.log('Link returned by XXX Resolver :: %s' % (u), log_utils.LOGNOTICE) else: log_utils.log( '%s is not a valid SMU resolvable link. Attempting to resolve by XXXODUS backup resolver.' % (url), log_utils.LOGNOTICE) try: u = adultresolver.resolve(url) except Exception as e: log_utils.log( 'Error getting valid link from SMU :: %s :: %s' % (url, str(e)), log_utils.LOGERROR) kodi.idle() kodi.notify(msg='Something went wrong! | %s' % str(e), duration=8000, sound=True) quit() log_utils.log('%s returned by XXX-O-DUS backup resolver.' % (u), log_utils.LOGNOTICE) if (not isinstance(u, str)): try: u = multilinkselector(u) except: pass if u == 'quit': xbmc.executebuiltin("Dialog.Close(busydialog)") quit() if u: dest = getDest() dest = os.path.join(dest, '%s.tmp_mp4' % urllib.quote_plus(name)) download(u, name, iconimage, dest) else: xbmc.executebuiltin("Dialog.Close(busydialog)") kodi.notify('No Downloadable Link Found.') quit()
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', 'Furk.net', 'Premiumize.me', 'EasyNews', 'DD.tv', 'NoobRoom', [ 'WatchHD', 'IFlix', 'MoviesPlanet', 'TVWTVS', '9Movies', '123Movies', 'niter.tv', 'HDMovie14', 'ororo.tv' ], [ 'StreamLord', 'CyberReel', 'MWM', 'tunemovie', 'MovieMax', 'afdah.org', 'xmovies8', 'xmovies8.v2', 'MovieXK' ], [ 'torba.se', 'Rainierland', 'FardaDownload', 'zumvo.com', 'PutMV', 'MiraDeTodo', 'beinmovie', 'FireMoviesHD' ], [ 'IzlemeyeDeger', 'SezonLukDizi', 'Dizimag', 'Dizilab', 'Dizigold', 'Dizibox', 'Diziay', 'Dizipas', 'OneClickTVShows' ], [ 'DayT.se', 'DDLValley', 'ReleaseBB', 'MyVideoLinks.eu', 'OCW', 'RLSSource.net', 'TVRelease.Net', 'alluc.com' ], [ 'IceFilms', 'WatchEpisodes', 'PrimeWire', 'SantaSeries', 'Flixanity', 'wso.ch', 'WatchSeries', 'UFlix.org', 'Putlocker' ], [ 'VKFlix', 'funtastic-vids', 'WatchFree.to', 'pftv', 'streamallthis.is', 'Movie4K', 'afdah', 'SolarMovie', 'yify-streaming' ], [ 'MovieSub', 'MovieHut', 'CouchTunerV2', 'CouchTunerV1', 'Watch8Now', 'yshows', 'TwoMovies.us', 'iWatchOnline' ], [ 'vidics.ch', 'pubfilm', 'OnlineMoviesIs', 'OnlineMoviesPro', 'ViewMovies', 'movie25', 'viooz.ac', 'view47', 'MoviesHD' ], [ 'wmo.ch', 'ayyex', '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'))
def setViewCM(viewtype): window = xbmcgui.Window(xbmcgui.getCurrentWindowId()) viewid = str(window.getFocusId()) xbmcaddon.Addon().setSetting("%s_view" % (viewtype), viewid) kodi.notify(kodi.get_name(),"%s view has been set to (%s)." % (viewtype.title(), viewid))
def content(url, searched=False): if not base_domain in url: url = base_domain + url try: headers = { 'User-Agent': 'Google Chrome Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36' } c = client.request(url, headers=headers) r = re.findall('<div class="video-item">(.*?)</select>', c, flags=re.DOTALL) if (not r) and (not searched): log_utils.log( 'Scraping Error in %s:: Content of request: %s' % (base_name.title(), str(c)), log_utils.LOGERROR) kodi.notify(msg='Scraping Error: Info Added To Log File', duration=6000, sound=True) except Exception as e: if (not searched): log_utils.log( 'Fatal Error in %s:: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR) kodi.notify(msg='Fatal Error', duration=4000, sound=True) quit() else: pass dirlst = [] for i in r: try: name = re.findall("""<a href='.+?'>(.*?)</a>""", i, flags=re.DOTALL)[0] url2 = re.findall('href="(.*?)"', i, flags=re.DOTALL)[0] if not base_domain in url2: url2 = base_domain + url2 icon = re.findall('src="(.*?)"', i, flags=re.DOTALL)[0] if not 'https' in icon: icon = 'https:' + icon fanarts = xbmc.translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/%s/fanart.jpg' % filename)) dirlst.append({ 'name': name, 'url': url2, 'mode': player_mode, 'icon': icon, 'fanart': fanarts, 'folder': False }) except Exception as e: log_utils.log( 'Error adding menu item %s in %s:: Error: %s' % (i[1].title(), base_name.title(), str(e)), log_utils.LOGERROR) if dirlst: buildDirectory(dirlst, stopend=True, isVideo=True, isDownloadable=True) else: if (not searched): kodi.notify(msg='No Content Found') quit() if searched: return str(len(r)) if not searched: try: search_pattern = '''\s*href\=['"]([^'"]+)['"]\>Next''' parse = base_domain helper.scraper().get_next_page(content_mode, url, search_pattern, filename, parse) except Exception as e: log_utils.log( 'Error getting next page for %s :: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR)
def content(url, searched=False): if not base_domain in url: url = base_domain + url try: headers = { 'User-Agent': 'Google Chrome Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36' } link = requests.get(url, headers=headers).text soup = BeautifulSoup(link, 'html.parser') r = soup.find_all('div', class_={'video-thumb'}) if (not r) and (not searched): log_utils.log( 'Scraping Error in %s:: Content of request: %s' % (base_name.title(), str(c)), log_utils.LOGERROR) kodi.notify(msg='Scraping Error: Info Added To Log File', duration=6000, sound=True) except Exception as e: if (not searched): log_utils.log( 'Fatal Error in %s:: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR) kodi.notify(msg='Fatal Error', duration=4000, sound=True) quit() else: pass dirlst = [] for i in r: try: name = i.find('div', class_={'video-title'}).a.text media_url = i.find('div', class_={'video-title'}).a['href'] icon = i.img['data-original'] if not base_domain in media_url: media_url = base_domain + media_url if not 'https' in icon: icon = 'https:' + icon fanarts = translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/%s/fanart.jpg' % filename)) dirlst.append({ 'name': name, 'url': media_url, 'mode': player_mode, 'icon': icon, 'fanart': fanarts, 'folder': False }) except Exception as e: log_utils.log( 'Error adding menu item %s in %s:: Error: %s' % (i[1].title(), base_name.title(), str(e)), log_utils.LOGERROR) if dirlst: buildDirectory(dirlst, stopend=True, isVideo=True, isDownloadable=True) else: if (not searched): kodi.notify(msg='No Content Found') quit() if searched: return str(len(r)) if not searched: try: search_pattern = '''\s*href\=['"]([^'"]+)['"]\>Next''' parse = base_domain helper.scraper().get_next_page(content_mode, url, search_pattern, filename, parse) except Exception as e: log_utils.log( 'Error getting next page for %s :: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR)
def menu(): lover.checkupdates() try: url = urlparse.urljoin(base_domain, 'video') c = client.request(url) r = dom_parser2.parse_dom(c, 'a', {'class': 'sidebar_section_item'}) r = [i for i in r if 'channels' in i.attrs['href']] r = [(urlparse.urljoin(base_domain, i.attrs['href']), i.content + ' - [ Professional ]') for i in r] url = urlparse.urljoin(base_domain, 'amateur/videos/') c = client.request(url) e = dom_parser2.parse_dom(c, 'a', {'class': 'sidebar_section_item'}) e = [i for i in e if 'channels' in i.attrs['href']] r += [(urlparse.urljoin(base_domain, i.attrs['href']), i.content + ' - [ Amateur ]') for i in e] r = sorted(r, key=lambda x: x[1]) if (not r): log_utils.log( 'Scraping Error in %s:: Content of request: %s' % (base_name.title(), str(c)), log_utils.LOGERROR) kodi.notify(msg='Scraping Error: Info Added To Log File', duration=6000, sound=True) quit() except Exception as e: log_utils.log( 'Fatal Error in %s:: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR) kodi.notify(msg='Fatal Error', duration=4000, sound=True) quit() dirlst = [] urls = [] for i in r: try: name = i[1] icon = xbmc.translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/%s/icon.png' % filename)) fanarts = xbmc.translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/%s/fanart.jpg' % filename)) dirlst.append({ 'name': name, 'url': i[0], 'mode': content_mode, 'icon': icon, 'fanart': fanarts, 'folder': True }) except Exception as e: log_utils.log( 'Error adding menu item %s in %s:: Error: %s' % (i[1].title(), base_name.title(), str(e)), log_utils.LOGERROR) if dirlst: buildDirectory(dirlst) else: kodi.notify(msg='No Menu Items Found') quit()
def content(url, searched=False): try: c = client.request(url) soup = BeautifulSoup(c, 'html5lib') content = soup.find_all('div', class_={'item'}) if (not content) and (not searched): log_utils.log( 'Scraping Error in %s:: Content of request: %s' % (base_name.title(), str(c)), log_utils.LOGERROR) kodi.notify(msg='Scraping Error: Info Added To Log File', duration=6000, sound=True) except Exception as e: if (not searched): log_utils.log( 'Fatal Error in %s:: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR) kodi.notify(msg='Fatal Error', duration=4000, sound=True) quit() else: pass dirlst = [] for i in content: try: title = i.a['title'] url = i.a['href'] icon = i.a.img['data-original'] time = i.find('div', class_={'duration'}).text title = ('%s | %s' % (title, time)) if searched: description = 'Result provided by %s' % base_name.title() else: description = time fanarts = xbmc.translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/%s/fanart.jpg' % filename)) dirlst.append({ 'name': title, 'url': url, 'mode': player_mode, 'icon': icon, 'fanart': fanarts, 'description': description, 'folder': False }) except Exception as e: log_utils.log( 'Error adding menu item %s in %s:: Error: %s' % (i[0].title(), base_name.title(), str(e)), log_utils.LOGERROR) if dirlst: buildDirectory(dirlst, stopend=True, isVideo=True, isDownloadable=True) else: if (not searched): kodi.notify(msg='No Content Found') quit() if searched: return str(len(r)) if not searched: search_pattern = '''"\w{4}"\s*\w{4}\=['"]([^\'\"]+)[\'\"]\s*\/>''' parse = base_domain helper.scraper().get_next_page(content_mode, url, search_pattern, filename, parse)
def content(url, searched=False): try: c = client.request(url) r = dom_parser2.parse_dom(c, 'div', {'id': re.compile('video_\d+')}) r = [(dom_parser2.parse_dom(i, 'a', req=['href','title']), \ dom_parser2.parse_dom(i, 'span', {'class': 'duration'}), \ dom_parser2.parse_dom(i, 'img', req='data-src'), \ dom_parser2.parse_dom(i, 'span', {'class': 'video-hd-mark'})) \ for i in r if i] r = [(urlparse.urljoin(base_domain, i[0][0].attrs['href']), i[0][0].attrs['title'], i[1][0].content, i[2][0].attrs['data-src'], i[3][0].content if i[3] else 'SD') for i in r] if (not r) and (not searched): log_utils.log( 'Scraping Error in %s:: Content of request: %s' % (base_name.title(), str(c)), log_utils.LOGERROR) kodi.notify(msg='Scraping Error: Info Added To Log File', duration=6000, sound=True) except Exception as e: if (not searched): log_utils.log( 'Fatal Error in %s:: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR) kodi.notify(msg='Fatal Error', duration=4000, sound=True) quit() else: pass dirlst = [] for i in r: try: name = '%s - [ %s - %s ]' % (kodi.sortX( i[1].encode('utf-8')).title(), kodi.sortX( i[2].encode('utf-8')), kodi.sortX(i[4].encode('utf-8'))) if searched: description = 'Result provided by %s' % base_name.title() else: description = name icon = re.sub('(\.THUMBNUM\.)', '.1.', i[3]) content_url = i[0] + '|SPLIT|%s' % base_name fanarts = xbmc.translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/%s/fanart.jpg' % filename)) dirlst.append({ 'name': name, 'url': content_url, 'mode': player_mode, 'icon': icon, 'fanart': fanarts, 'description': description, 'folder': False }) except Exception as e: log_utils.log( 'Error adding menu item %s in %s:: Error: %s' % (i[1].title(), base_name.title(), str(e)), log_utils.LOGERROR) if dirlst: buildDirectory(dirlst, stopend=True, isVideo=True, isDownloadable=True) else: if (not searched): kodi.notify(msg='No Content Found') quit() if searched: return str(len(r)) if not searched: try: search_pattern = '''href=['"]([^'"]+)"\s*class="no-page\s*next-page">Next''' parse = base_domain helper.scraper().get_next_page(content_mode, url, search_pattern, filename, parse) except Exception as e: log_utils.log( 'Error getting next page for %s :: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR)
def play(url, name, iconimage=None, ref=None, site=None): try: kodi.busy() if not site: if 'site=' in url: url,site = url.split('site=') else: site = 'Unknown' if not name: name = 'Unknown' if not iconimage: iconimage = kodi.addonicon name = re.sub(r'(\[.+?\])','',name); name = name.lstrip() if '] - ' in name: name = name.split('] - ')[-1] chatur = False if ref: if 'chaturbate.com' in ref: chatur = True else: ref = '' if 'chaturbate.com' in url: chatur = True ref = url url = adultresolver.resolve(url) if ( isinstance(url, list) ): try: url = multilinkselector(url) except: pass history_on_off = kodi.get_setting("history_setting") if history_on_off == "true": web_checks = ['http:','https:','rtmp:'] locak_checks = ['.mp4'] try: if any(f for f in web_checks if f in url): site = site.title() elif any(f for f in locak_checks if f in url): site = 'Local File' else: site = 'Unknown' except: site = site.title() #if chatur: history.delEntry(ref) history.addHistory(name, ref, site.title(), iconimage) #else: # history.delEntry(url) # history.addHistory(name, url, site.title(), iconimage) kodi.idle() if 'chaturbate.com' in ref: if kodi.get_setting("mobile_mode") == 'true': url = url.replace('_fast_aac','_aac') else: bandwidth = kodi.get_setting("chaturbate_band") if bandwidth == '0': url = url.replace('_fast_aac','_aac') elif bandwidth == '2': choice = kodi.dialog.select("[COLOR white][B]" + name + "[/B][/COLOR]", ['[COLOR white]Play High Bandwidth Stream[/COLOR]','[COLOR white]Play Low Bandwidth Stream[/COLOR]']) if choice == 1: url = url.replace('_fast_aac','_aac') elif choice == 0: pass else: quit() liz = xbmcgui.ListItem(name, iconImage=iconimage, thumbnailImage=iconimage) xbmc.executebuiltin("Dialog.Close(busydialog)") xbmc.Player().play(url, liz, False) if kodi.get_setting("chaturbate_subject") == "true": sleeper = kodi.get_setting("chaturbate_subject_refresh") i = 0 while not xbmc.Player().isPlayingVideo(): time.sleep(1) i += 1 if i == 30: quit() while xbmc.Player().isPlayingVideo(): try: r = client.request(ref) subject = re.compile('default_subject:\s\"([^,]+)",').findall(r)[0]; subject = urllib.unquote_plus(subject) kodi.notify(msg=subject, duration=8500, sound=True, icon_path=iconimage) except: pass time.sleep(int(sleeper)) else: liz = xbmcgui.ListItem(name, iconImage=iconimage, thumbnailImage=iconimage) xbmc.Player().play(url, liz, False) except: kodi.idle() kodi.notify(msg='Error playing %s' % name)
def menu(): scraper_updater.check(filename) if sys.version_info <= (2, 7, 9): kodi.notify( msg= 'Your python version does not support this site. Please update Python to > 2.7.9 or Kodi to 17.', duration=8000, sound=True) quit() try: url = base_domain c = client.request(url) r = dom_parser2.parse_dom( c, 'li', {'class': re.compile('cat-item\scat-item-\d+')}) r = dom_parser2.parse_dom(r, 'a') r = [(i.attrs['href'], i.content) for i in r] if (not r): log_utils.log( 'Scraping Error in %s:: Content of request: %s' % (base_name.title(), str(c)), log_utils.LOGERROR) kodi.notify(msg='Scraping Error: Info Added To Log File', duration=6000, sound=True) quit() except Exception as e: log_utils.log( 'Fatal Error in %s:: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR) kodi.notify(msg='Fatal Error', duration=4000, sound=True) quit() dirlst = [] for i in r: try: name = kodi.sortX(i[1].encode('utf-8')) icon = xbmc.translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/%s/icon.png' % filename)) fanarts = xbmc.translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/%s/fanart.jpg' % filename)) dirlst.append({ 'name': name, 'url': i[0], 'mode': content_mode, 'icon': icon, 'fanart': fanarts, 'folder': True }) except Exception as e: log_utils.log( 'Error adding menu item %s in %s:: Error: %s' % (i[1].title(), base_name.title(), str(e)), log_utils.LOGERROR) if dirlst: buildDirectory(dirlst) else: kodi.notify(msg='No Menu Items Found') quit()
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 menu(): lover.checkupdates() try: headers = { 'User-Agent': 'Google Chrome Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36' } url = urlparse.urljoin(base_domain, 'tags') c = client.request(url, headers=headers) r = dom_parser2.parse_dom(c, 'li') r = [ i.content for i in r if 'href' in i.content and 'span' in i.content ] r = [(dom_parser2.parse_dom(i, 'a', req='href'), \ dom_parser2.parse_dom(i, 'span')) \ for i in r] r = [(i[0][0].attrs['href'].replace(' ', '%20'), re.sub('<.+?>', '', i[0][0].content), i[1][0].content.replace('(', '').replace(')', '')) for i in r] r = [(i[0], i[1], i[2]) for i in r if i[2].isdigit()] if (not r): log_utils.log( 'Scraping Error in %s:: Content of request: %s' % (base_name.title(), str(c)), log_utils.LOGERROR) kodi.notify(msg='Scraping Error: Info Added To Log File', duration=6000, sound=True) quit() except Exception as e: log_utils.log( 'Fatal Error in %s:: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR) kodi.notify(msg='Fatal Error', duration=4000, sound=True) quit() dirlst = [] for i in r: try: name = kodi.sortX(i[1].encode('utf-8')) name = name.title() + ' - [ %s ]' % i[2] icon = xbmc.translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/%s/icon.png' % filename)) fanarts = xbmc.translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/%s/fanart.jpg' % filename)) dirlst.append({ 'name': name, 'url': i[0], 'mode': content_mode, 'icon': icon, 'fanart': fanarts, 'folder': True }) except Exception as e: log_utils.log( 'Error adding menu item %s in %s:: Error: %s' % (i[1].title(), base_name.title(), str(e)), log_utils.LOGERROR) if dirlst: buildDirectory(dirlst) else: kodi.notify(msg='No Menu Items Found') quit()
def clearCache(mode='verbose'): if os.path.exists(cachePath) == True: for root, dirs, files in os.walk(cachePath): file_count = 0 file_count += len(files) if file_count > 0: for f in files: try: if (f == "kodi.log" or f == "kodi.old.log"): continue os.unlink(os.path.join(root, f)) except: pass for d in dirs: try: shutil.rmtree(os.path.join(root, d)) except: pass else: pass if os.path.exists(tempPath) == True: for root, dirs, files in os.walk(tempPath): file_count = 0 file_count += len(files) if file_count > 0: for f in files: try: if (f == "kodi.log" or f == "kodi.old.log"): continue os.unlink(os.path.join(root, f)) except: pass for d in dirs: try: shutil.rmtree(os.path.join(root, d)) except: pass else: pass if xbmc.getCondVisibility('system.platform.ATV2'): atv2_cache_a = os.path.join( '/private/var/mobile/Library/Caches/AppleTV/Video/', 'Other') for root, dirs, files in os.walk(atv2_cache_a): file_count = 0 file_count += len(files) if file_count > 0: for f in files: os.unlink(os.path.join(root, f)) for d in dirs: shutil.rmtree(os.path.join(root, d)) else: pass atv2_cache_b = os.path.join( '/private/var/mobile/Library/Caches/AppleTV/Video/', 'LocalAndRental') for root, dirs, files in os.walk(atv2_cache_b): file_count = 0 file_count += len(files) if file_count > 0: for f in files: os.unlink(os.path.join(root, f)) for d in dirs: shutil.rmtree(os.path.join(root, d)) else: pass # cacheEntries = [] # for entry in cacheEntries: # clear_cache_path = xbmc.translatePath(entry.path) # if os.path.exists(clear_cache_path)==True: # for root, dirs, files in os.walk(clear_cache_path): # file_count = 0 # file_count += len(files) # if file_count > 0: # for f in files: # os.unlink(os.path.join(root, f)) # for d in dirs: # shutil.rmtree(os.path.join(root, d)) # else: # pass if mode == 'verbose': kodi.notify('Maintenance', 'Clean Completed')
def content(url, searched=False): try: c = client.request(url) r = dom_parser2.parse_dom(c, 'div', {'class': 'mb'}) r = [(dom_parser2.parse_dom(i, 'a', req=['href', 'title']), dom_parser2.parse_dom(i, 'img', req=['src'])) for i in r if r] r = [(urlparse.urljoin(base_domain, i[0][0].attrs['href']), i[0][0].attrs['title'], i[1][0].attrs['src']) for i in r] if (not r) and (not searched): log_utils.log( 'Scraping Error in %s:: Content of request: %s' % (base_name.title(), str(c)), log_utils.LOGERROR) kodi.notify(msg='Scraping Error: Info Added To Log File', duration=6000, sound=True) except Exception as e: if (not searched): log_utils.log( 'Fatal Error in %s:: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR) kodi.notify(msg='Fatal Error', duration=4000, sound=True) quit() else: pass dirlst = [] for i in r: try: name = kodi.sortX(i[1].encode('utf-8')) if searched: description = 'Result provided by %s' % base_name.title() else: description = name content_url = i[0] + '|SPLIT|%s' % base_name fanarts = xbmc.translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/%s/fanart.jpg' % filename)) dirlst.append({ 'name': name, 'url': content_url, 'mode': player_mode, 'icon': i[2], 'fanart': fanarts, 'description': description, 'folder': False }) except Exception as e: log_utils.log( 'Error adding menu item %s in %s:: Error: %s' % (i[0].title(), base_name.title(), str(e)), log_utils.LOGERROR) if dirlst: buildDirectory(dirlst, stopend=True, isVideo=True, isDownloadable=True) else: if (not searched): kodi.notify(msg='No Content Found') quit() if searched: return str(len(r)) if not searched: search_pattern = '''href=['"]+([^'"]+)['"]\s+title=['"]Next''' parse = base_domain helper.scraper().get_next_page(content_mode, url, search_pattern, filename, parse)
from dsrd_lib import cf_captcha import kodi import log_utils # @UnusedImport from dsrd_lib import scraper_utils from dsrd_lib.constants import FORCE_NO_MATCH from dsrd_lib.constants import Q_ORDER from dsrd_lib.constants import SHORT_MONS from dsrd_lib.constants import VIDEO_TYPES from dsrd_lib.constants import DEFAULT_TIMEOUT from dsrd_lib.db_utils import DB_Connection from dsrd_lib.utils2 import i18n, ungz try: import resolveurl except: kodi.notify(msg=i18n('smu_failed'), duration=5000) logger = log_utils.Logger.get_logger() BASE_URL = '' COOKIEPATH = kodi.translate_path(kodi.get_profile()) MONTHS = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ] MAX_RESPONSE = 1024 * 1024 * 5 CF_CAPCHA_ENABLED = kodi.get_setting('cf_captcha') == 'true' class ScrapeError(Exception): pass
def content(url, searched=None): pattern = r'''%s\=['"]+([^'"]+)''' try: c = client.request(url) r = dom_parser2.parse_dom(c, 'li') r = [i.content for i in r if 'thumb-item-desc' in i.content] if (not r): log_utils.log( 'Scraping Error in %s:: Content of request: %s' % (base_name.title(), str(c)), log_utils.LOGERROR) kodi.notify(msg='Scraping Error: Info Added To Log File', duration=6000, sound=True) except Exception as e: log_utils.log( 'Fatal Error in %s:: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR) kodi.notify(msg='Fatal Error', duration=4000, sound=True) quit() dirlst = [] for i in r: try: name = re.findall(pattern % 'title', i)[0] name = kodi.sortX(name.encode('utf-8')) if searched: description = 'Result provided by %s' % base_name.title() else: description = name url = re.findall(pattern % 'href', i)[0] iconimg = re.findall(pattern % 'src', i)[0] iconimg = 'http:%s' % iconimg if iconimg.startswith( '//') else iconimg fanarts = xbmc.translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/%s/fanart.jpg' % filename)) dirlst.append({ 'name': name, 'url': urlparse.urljoin(base_domain, url + '|SPLIT|%s' % base_name), 'mode': player_mode, 'icon': iconimg, 'fanart': fanarts, 'description': description, 'folder': False }) except Exception as e: log_utils.log( 'Error adding menu item %s in %s:: Error: %s' % (i[1].title(), base_name.title(), str(e)), log_utils.LOGERROR) if searched: if dirlst: buildDirectory(dirlst, stopend=True, isVideo=True, isDownloadable=True) return str(len(r)) else: if dirlst: buildDirectory(dirlst, isVideo=True, isDownloadable=True) else: kodi.notify(msg='No Content Found') quit()
def download_media(url, path, file_name): try: progress = int(kodi.get_setting('down_progress')) active = not progress == PROGRESS.OFF background = progress == PROGRESS.BACKGROUND with kodi.ProgressDialog('Premiumize Cloud', i18n('downloading') % (file_name), background=background, active=active) as pd: request = urllib2.Request(url) request.add_header('User-Agent', USER_AGENT) request.add_unredirected_header('Host', request.get_host()) response = urllib2.urlopen(request) content_length = 0 if 'Content-Length' in response.info(): content_length = int(response.info()['Content-Length']) file_name = file_name.replace('.strm', get_extension(url, response)) full_path = os.path.join(path, file_name) log_utils.log('Downloading: %s -> %s' % (url, full_path), log_utils.LOGDEBUG) path = xbmc.makeLegalFilename(path) if not xbmcvfs.exists(path): try: try: xbmcvfs.mkdirs(path) except: os.mkdir(path) except Exception as e: raise Exception(i18n('failed_create_dir')) file_desc = xbmcvfs.File(full_path, 'w') total_len = 0 cancel = False while True: data = response.read(CHUNK_SIZE) if not data: break if pd.is_canceled(): cancel = True break total_len += len(data) if not file_desc.write(data): raise Exception(i18n('failed_write_file')) percent_progress = ( total_len ) * 100 / content_length if content_length > 0 else 0 log_utils.log( 'Position : %s / %s = %s%%' % (total_len, content_length, percent_progress), log_utils.LOGDEBUG) pd.update(percent_progress) file_desc.close() if not cancel: kodi.notify(msg=i18n('download_complete') % (file_name), duration=5000) log_utils.log('Download Complete: %s -> %s' % (url, full_path), log_utils.LOGDEBUG) except Exception as e: log_utils.log( 'Error (%s) during download: %s -> %s' % (str(e), url, file_name), log_utils.LOGERROR) kodi.notify(msg=i18n('download_error') % (str(e), file_name), duration=5000)
def content(url, searched=False): import xbmcgui dialog = xbmcgui.Dialog() try: c = client.request(url) soup = BeautifulSoup(c, 'html.parser') r = soup.find_all('content') if (not r) and (not searched): log_utils.log( 'Scraping Error in %s:: Content of request: %s' % (base_name.title(), str(c)), log_utils.LOGERROR) kodi.notify(msg='Scraping Error: Info Added To Log File', duration=6000, sound=True) except Exception as e: if (not searched): log_utils.log( 'Fatal Error in %s:: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR) kodi.notify(msg='Fatal Error', duration=4000, sound=True) quit() else: pass dirlst = [] for i in r: try: title = i.find('title').text url2 = i.find('media').text icon = i.find('icon').text fanarts = i.find('fanart').text description = i.find('desc').text dirlst.append({ 'name': title, 'url': url2, 'mode': player_mode, 'icon': icon, 'fanart': fanarts, 'description': description, 'folder': False }) except Exception as e: log_utils.log( 'Error adding menu item %s Error: %s' % (title, str(e)), log_utils.LOGERROR) if dirlst: buildDirectory(dirlst, stopend=True, isVideo=True, isDownloadable=True) else: if (not searched): kodi.notify(msg='No Content Found') quit() if searched: return str(len(r)) if not searched: try: search_pattern = '''\<link\s*rel\=['"]next['"]\s*href\=['"]([^'"]+)''' parse = base_domain helper.scraper().get_next_page(content_mode, url, search_pattern, filename) except Exception as e: log_utils.log( 'Error getting next page for %s :: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR)
def content(url, searched=False): try: c = client.request(url) r = re.findall( '<div class="panel-body">(.*?)<div class="panel bg-dark">', c, flags=re.DOTALL)[1] pattern = r'''<a\s+href=['"]([^'"]+)".+?\s+.+?src=['"]([^'"]+).+?\s+.+?>\s+.+?>(.*?)<.+?\s+<p>(.*?)</p>''' i = re.findall(pattern, r, flags=re.DOTALL) if (not r) and (not searched): log_utils.log( 'Scraping Error in %s:: Content of request: %s' % (base_name.title(), str(c)), log_utils.LOGERROR) kodi.notify(msg='Scraping Error: Info Added To Log File', duration=6000, sound=True) except Exception as e: if (not searched): log_utils.log( 'Fatal Error in %s:: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR) kodi.notify(msg='Fatal Error', duration=4000, sound=True) quit() else: pass dirlst = [] for url2, icon, name, desc in i: try: fanarts = xbmc.translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/%s/fanart.jpg' % filename)) dirlst.append({ 'name': name, 'url': url2, 'mode': player_mode, 'icon': icon, 'fanart': fanarts, 'description': desc, 'folder': False }) except Exception as e: log_utils.log( 'Error adding menu item %s in %s:: Error: %s' % (i[1].title(), base_name.title(), str(e)), log_utils.LOGERROR) if dirlst: buildDirectory(dirlst, stopend=True, isVideo=True, isDownloadable=True) else: if (not searched): kodi.notify(msg='No Content Found') quit() if searched: return str(len(r)) if not searched: try: # Broke The Regex On Purpose as Next Page Pulls In Different Format search_pattern = '''<a\s*href=['"]([^'"]+)['"]\s*>NEXT<''' parse = url helper.scraper().get_next_page(content_mode, url, search_pattern, filename) except Exception as e: log_utils.log( 'Error getting next page for %s :: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR)
def _callnetworks(self, uri, data=None, params=None, auth=False, cache=False, timeout=None): url = '%s%s' % (BASE_URL, uri) if timeout is not None: self.timetout = timeout json_data = json.dumps(data) if data else None headers = { 'Content-Type': 'application/json', 'trakt-api-key': CLIENT_ID, 'trakt-api-version': 2 } if auth: self._authorize() if self.token is None: raise TraktError('Trakt Authorization Required: 400') headers.update({'Authorization': 'Bearer %s' % (self.token)}) #url = '%s%s' % (BASE_URL, uri) #print "URL IS = "+url if params and not uri.endswith('/token'): params['limit'] = 200 else: params = {'limit': 200} url = url + '?' + urllib.urlencode(params) #START CACHE STUFF created, cached_result = cache_stat.get_cached_url(url) now = time.time() #print "API NOW TIME IS :"+str(now) limit = 60 * 60 * int(kodi.get_setting('cache_limit')) #print "API LIMIT IS : "+str(limit) age = now - created #print "API AGE IS :"+str(age) if cached_result and age < limit: result = cached_result #print 'Using cached result for: %s' % (url) response = json.loads(result) return response #END CACHE STUFF else: try: request = urllib2.Request(url, data=json_data, headers=headers) f = urllib2.urlopen(request, timeout=self.timeout) result = f.read() response = json.loads(result) except HTTPError as e: print "ERROR IS = " + str(e) kodi.notify(header='Trakt Error', msg='(error) %s %s' % (str(e), ''), duration=5000, sound=None) if not uri.endswith('/token'): print "ERROR IS = " + str(e) kodi.notify(header='Trakt Error', msg='(error) %s %s' % (str(e), ''), duration=5000, sound=None) #ADDON.show_error_dialog(['Trakt Error', 'HTTP ERROR', str(e)]) #raise TraktError('Trakt-HTTP-Error: %s' % e) return False except URLError as e: print "URLERROR IS = " + str(e) #ADDON.log(url, LOG_LEVEL.VERBOSE) if not uri.endswith('/token'): #ADDON.show_error_dialog(['Trakt Error', 'URLLib ERROR', str(e)]) kodi.notify(header='Trakt Error', msg='(error) %s %s' % (str(e), ''), duration=5000, sound=None) raise TraktError('Trakt-URL-Error: %s' % e) return False else: if cache == 'true': cache_stat.set_cache_url(url, result) return response else: return response
def content(url, searched=False): try: c = client.request(url) match = re.findall('<div class="6u">(.*?)</section>', c, flags=re.DOTALL) except Exception as e: if (not searched): log_utils.log( 'Fatal Error in %s:: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR) kodi.notify(msg='Fatal Error', duration=4000, sound=True) quit() else: pass dirlst = [] for items in match: try: name = re.findall('alt="(.*?)"', items, flags=re.DOTALL)[0] name = name.title() url2 = re.findall('<a href="(.*?)"', items, flags=re.DOTALL)[0] icon = re.findall('''<div.*?onmouseleave=.*?\(['"](.*?)['"]''', items, flags=re.DOTALL)[0] length = re.findall( '<span class="icon fa-clock-o meta-data">(.*?)</span>', items, flags=re.DOTALL)[0] if not 'https:' in url2: url2 = 'https://hqporner.com' + url2 if not 'https:' in icon: icon = 'https:' + icon #icon = '' desc = '[COLOR yellow]Video Length :: [/COLOR]' + length fanarts = xbmc.translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/%s/fanart.jpg' % filename)) dirlst.append({ 'name': name, 'url': url2, 'mode': player_mode, 'icon': icon, 'fanart': fanarts, 'description': desc, 'folder': False }) except Exception as e: log_utils.log( 'Error adding menu item. %s:: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR) if dirlst: buildDirectory(dirlst, stopend=True, isVideo=True, isDownloadable=True) else: if (not searched): kodi.notify(msg='No Content Found') quit() if searched: return str(len(r)) if not searched: search_pattern = '''<a\s*href=['"]([^'"]+)['"]\s*class=['"]button\s*mobile-pagi pagi-btn['"]>Next<\/a>''' parse = base_domain helper.scraper().get_next_page(content_mode, url, search_pattern, filename, parse)
def download_media(url, path, file_name): try: progress = int(kodi.get_setting('down_progress')) request = urllib2.Request(url) request.add_header('User-Agent', USER_AGENT) request.add_unredirected_header('Host', request.get_host()) response = urllib2.urlopen(request) content_length = 0 if 'Content-Length' in response.info(): content_length = int(response.info()['Content-Length']) file_name = file_name.replace('.strm', get_extension(url, response)) full_path = os.path.join(path, file_name) log_utils.log('Downloading: %s -> %s' % (url, full_path), log_utils.LOGDEBUG) path = xbmc.makeLegalFilename(path) if not xbmcvfs.exists(path): try: try: xbmcvfs.mkdirs(path) except: os.mkdir(path) except Exception as e: raise Exception(i18n('failed_create_dir')) file_desc = xbmcvfs.File(full_path, 'w') total_len = 0 if progress: if progress == PROGRESS.WINDOW: dialog = xbmcgui.DialogProgress() else: dialog = xbmcgui.DialogProgressBG() dialog.create('Stream All The Sources', i18n('downloading') % (file_name)) dialog.update(0) while True: data = response.read(CHUNK_SIZE) if not data: break if progress == PROGRESS.WINDOW and dialog.iscanceled(): break total_len += len(data) if not file_desc.write(data): raise Exception('failed_write_file') percent_progress = ( total_len) * 100 / content_length if content_length > 0 else 0 log_utils.log( 'Position : %s / %s = %s%%' % (total_len, content_length, percent_progress), log_utils.LOGDEBUG) if progress == PROGRESS.WINDOW: dialog.update(percent_progress) elif progress == PROGRESS.BACKGROUND: dialog.update(percent_progress, 'Stream All The Sources') else: kodi.notify(msg=i18n('download_complete') % (file_name), duration=5000) log_utils.log('Download Complete: %s -> %s' % (url, full_path), log_utils.LOGDEBUG) file_desc.close() if progress: dialog.close() except Exception as e: log_utils.log( 'Error (%s) during download: %s -> %s' % (str(e), url, file_name), log_utils.LOGERROR) kodi.notify(msg=i18n('download_error') % (str(e), file_name), duration=5000)
def content(url, searched=False): if not base_domain in url: url = base_domain + url try: c = client.request(url) r = re.findall( '<div class="preloadLine">(.*?)<span class="video_count">', c, flags=re.DOTALL) if (not r) and (not searched): log_utils.log( 'Scraping Error in %s:: Content of request: %s' % (base_name.title(), str(c)), log_utils.LOGERROR) kodi.notify(msg='Scraping Error: Info Added To Log File', duration=6000, sound=True) except Exception as e: if (not searched): log_utils.log( 'Fatal Error in %s:: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR) kodi.notify(msg='Fatal Error', duration=4000, sound=True) quit() else: pass dirlst = [] for i in r: try: name = re.findall('alt="(.*?)"', i, flags=re.DOTALL)[0] url2 = re.findall('<a.+?href="(.*?)"', i, flags=re.DOTALL)[0] if not base_domain in url2: url2 = base_domain + url2 icon = re.findall('data-thumb_url\s* =\s*"(.*?)"', i, flags=re.DOTALL)[0] desc = re.findall('<span class="duration">(.*?)</span>', i, flags=re.DOTALL)[0].strip() fanarts = xbmc.translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/%s/fanart.jpg' % filename)) dirlst.append({ 'name': name, 'url': url2, 'mode': player_mode, 'icon': icon, 'fanart': fanarts, 'description': desc, 'folder': False }) except Exception as e: log_utils.log( 'Error adding menu item %s in %s:: Error: %s' % (i[1].title(), base_name.title(), str(e)), log_utils.LOGERROR) if dirlst: buildDirectory(dirlst, stopend=True, isVideo=True, isDownloadable=True) else: if (not searched): kodi.notify(msg='No Content Found') quit() if searched: return str(len(r)) if not searched: try: search_pattern = '''<li id="wp_navNext".+?\s*<a\s*href=['"]([^'"]+)['"]\s*>''' parse = base_domain helper.scraper().get_next_page(content_mode, url, search_pattern, filename) except Exception as e: log_utils.log( 'Error getting next page for %s :: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR)
def content(url, searched=False): r = client.request(url) r = dom_parser2.parse_dom(r, 'li') r = [(dom_parser2.parse_dom(i, 'div', {'class': 'title'}), \ dom_parser2.parse_dom(i, 'img', req='src'), \ dom_parser2.parse_dom(i, 'div', {'class': re.compile('thumbnail_label.+?')}), \ dom_parser2.parse_dom(i, 'li', {'title': re.compile('.+?')}), \ dom_parser2.parse_dom(i, 'li', {'class': 'location'}), \ dom_parser2.parse_dom(i, 'li', {'class': 'cams'}) \ ) for i in r if '<div class="title">' in i.content] r = [(dom_parser2.parse_dom(i[0], 'a'), \ dom_parser2.parse_dom(i[0], 'span'), \ i[2][0].content, \ i[1][0].attrs['src'], \ i[3][0].content if i[3] else 'Unknown', \ i[4][0].content, \ i[5][0].content, \ ) for i in r] r = [(urlparse.urljoin(base_domain, i[0][0].attrs['href']), i[0][0].content, i[1][0].content, i[2], i[3], i[6], i[5], i[4]) for i in r] dirlst = [] for i in r: try: name = '%s - [ %s ]' % (kodi.sortX(i[1].encode('utf-8')).title(), kodi.sortX(i[3].encode('utf-8'))) description = 'Name: %s \nAge: %s \nLocation: %s \nStats: %s \n\nDescription: %s' % \ (kodi.sortX(i[1].encode('utf-8')),i[2],kodi.sortX(i[6].encode('utf-8')),kodi.sortX(i[5].encode('utf-8')),kodi.sortX(i[7].encode('utf-8'))) content_url = i[0] + '|SPLIT|%s' % base_name fanarts = xbmc.translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/%s/fanart.jpg' % filename)) dirlst.append({ 'name': name, 'url': content_url, 'mode': player_mode, 'icon': i[4], 'fanart': fanarts, 'description': description, 'folder': False }) except Exception as e: log_utils.log( 'Error adding menu item %s in %s:: Error: %s' % (i[1].title(), base_name.title(), str(e)), log_utils.LOGERROR) if dirlst: buildDirectory(dirlst, stopend=True, isVideo=False, isDownloadable=False, chaturbate=True) else: kodi.notify(msg='No Content Found') quit() search_pattern = '''<li><a\s*href=['"]([^'"]+)['"]\s*class=['"]next endless_page_link['"]>next<\/a><\/li>''' parse = base_domain helper.scraper().get_next_page(content_mode, url, search_pattern, filename, parse)
def menu(): scraper_updater.check(filename) url = base_domain r = client.request(url) r = dom_parser2.parse_dom(r, 'dd') r = dom_parser2.parse_dom(r, 'a', req='href') r = [i for i in r if 'private-cams' not in i.attrs['href']] r = [(urlparse.urljoin(base_domain, i.attrs['href']), i.content) for i in r if i] dirlst = [] icon = xbmc.translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/main/%s.png' % filename)) fanarts = xbmc.translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/%s/fanart.jpg' % filename)) dirlst.append({ 'name': 'Monitored Performers', 'url': 'none', 'mode': 30, 'icon': icon, 'fanart': fanarts, 'folder': True }) dirlst.append({ 'name': 'Search By Username', 'url': 'none', 'mode': 32, 'icon': icon, 'fanart': fanarts, 'folder': False }) dirlst.append({ 'name': 'Rooms By Tag', 'url': 'tags', 'mode': 302, 'icon': icon, 'fanart': fanarts, 'folder': True }) for i in r: try: name = kodi.sortX(i[1].encode('utf-8')).title() dirlst.append({ 'name': name, 'url': i[0], 'mode': content_mode, 'icon': icon, 'fanart': fanarts, 'folder': True }) except Exception as e: log_utils.log( 'Error adding menu item %s in %s:: Error: %s' % (i[1].title(), base_name.title(), str(e)), log_utils.LOGERROR) if dirlst: buildDirectory(dirlst) else: kodi.notify(msg='No Menu Items Found') quit()
def content(url, searched=False): try: c = client.request(url) soup = BeautifulSoup(c, 'html5lib') r = soup.find_all('div', class_={'thumb_box'}) if (not r) and (not searched): log_utils.log( 'Scraping Error in %s:: Content of request: %s' % (base_name.title(), str(c)), log_utils.LOGERROR) kodi.notify(msg='Scraping Error: Info Added To Log File', duration=6000, sound=True) except Exception as e: if (not searched): log_utils.log( 'Fatal Error in %s:: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR) kodi.notify(msg='Fatal Error', duration=4000, sound=True) quit() else: pass dirlst = [] for i in r: try: name = i.img['alt'] url2 = i.a['href'] icon = i.img['data-thumb'] fanarts = xbmc.translatePath( os.path.join('special://home/addons/script.xxxodus.artwork', 'resources/art/%s/fanart.jpg' % filename)) dirlst.append({ 'name': name, 'url': url2, 'mode': player_mode, 'icon': icon, 'fanart': fanarts, 'folder': False }) except: pass if dirlst: buildDirectory(dirlst, stopend=True, isVideo=True, isDownloadable=True) else: if (not searched): kodi.notify(msg='No Content Found') quit() if searched: return str(len(r)) if not searched: try: search_pattern = '''<link\s*rel=['"]next['"]\s*href=['"]([^'"]+)''' parse = base_domain helper.scraper().get_next_page(content_mode, url, search_pattern, filename) except Exception as e: log_utils.log( 'Error getting next page for %s :: Error: %s' % (base_name.title(), str(e)), log_utils.LOGERROR)
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