def __get_movie_sources(self, source_url): hosters = [] query = kodi.parse_query(urlparse.urlparse(source_url).query) movie_id = query.get('movie_id') or self.__get_movie_id(source_url) if not movie_id: return hosters details_url = scraper_utils.urljoin(self.movie_base_url, MOVIE_DETAILS_URL) detail_data = self._json_get(details_url, params={'movie_id': movie_id}, cache_limit=24) try: torrents = detail_data['data']['movie']['torrents'] except KeyError: torrents = [] try: hashes = [torrent['hash'].lower() for torrent in torrents] except KeyError: hashes = [] hash_data = self.__get_hash_data(hashes) for torrent in torrents: hash_id = torrent['hash'].lower() try: status = hash_data['hashes'][hash_id]['status'] except KeyError: status = '' if status.lower() != 'finished': continue stream_url = 'hash_id=%s' % (hash_id) host = scraper_utils.get_direct_hostname(self, stream_url) quality = QUALITY_MAP.get(torrent['quality'], QUALITIES.HD720) hoster = {'multi-part': False, 'class': self, 'views': None, 'url': stream_url, 'rating': None, 'host': host, 'quality': quality, 'direct': True} if 'size_bytes' in torrent: hoster['size'] = scraper_utils.format_size(torrent['size_bytes'], 'B') if torrent['quality'] == '3D': hoster['3D'] = True hosters.append(hoster) return hosters
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 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.LOGDEBUG) log_utils.log('Args: |%s|' % argv, log_utils.LOGDEBUG) mode = queries.get('mode', None) DISPATCHER.dispatch(mode, queries)
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.log('Args: |%s|' % (argv)) # 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 mode = queries.get('mode', None) url_dispatcher.dispatch(mode, queries)
def main(argv=None): if sys.argv: argv = sys.argv queries = kodi.parse_query(sys.argv[2]) logger.log('Version: |%s| Queries: |%s|' % (kodi.get_version(), queries)) logger.log('Args: |%s|' % (argv)) # 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 mode = queries.get('mode', None) url_dispatcher.dispatch(mode, queries)
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 main(argv=None): if sys.argv: argv = sys.argv queries = kodi.parse_query(sys.argv[2]) logger.log('Version: |%s| Queries: |%s|' % (kodi.get_version(), queries), log_utils.LOGNOTICE) logger.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: logger.log(str(e), log_utils.LOGERROR) kodi.notify(msg=str(e), duration=5000)
def __get_widget_details(filename, title, year): if not isinstance(title, unicode): title = title.decode('utf-8') path = '' media_type = None try: _filename, extra = filename.split('?') except: _filename, extra = filename.split('?')[0], '' tokens = _filename.split('/') queries = kodi.parse_query(extra) for value in queries.itervalues(): try: js_data = json.loads(value) except: js_data = {} js_type = js_data.get('type') if js_type == 'tvshows': media_type = VIDEO_TYPES.TVSHOW break elif js_type == 'episodes': media_type = VIDEO_TYPES.EPISODE break elif js_type == 'movies': media_type = VIDEO_TYPES.MOVIE break else: for token in tokens: if 'movie' in token: media_type = VIDEO_TYPES.MOVIE break elif 'tvshow' in token: media_type = VIDEO_TYPES.TVSHOW break elif 'episode' in token: media_type = VIDEO_TYPES.EPISODE break if media_type == VIDEO_TYPES.MOVIE: lib_id = 'libMovies' method = 'VideoLibrary.GetMovieDetails' id_type = 'movieid' details = 'moviedetails' properties = ['file', 'title', 'year'] elif media_type == VIDEO_TYPES.TVSHOW: lib_id = 'libTvShows' method = 'VideoLibrary.GetTVShowDetails' id_type = 'tvshowid' details = 'tvshowdetails' properties = ['file', 'title', 'year'] elif media_type == VIDEO_TYPES.EPISODE: lib_id = 'libTvShows' method = 'VideoLibrary.GetEpisodeDetails' id_type = 'episodeid' details = 'episodedetails' properties = ['file', 'title'] if media_type is not None: for token in tokens: if token.isdigit(): cmd = { 'jsonrpc': '2.0', 'method': method, 'params': { id_type: int(token), 'properties': properties }, 'id': lib_id } response = kodi.execute_jsonrpc(cmd) logger.log('Details Result: %s' % (response), log_utils.LOGDEBUG) if 'result' in response and details in response['result']: details = response['result'][details] if details['title'] == title and ('year' not in details or details['year'] == year): path = details['file'] logger.log('Widget ID: |%s| -> (%s): |%s|' % (filename, media_type, path)) return media_type, path