def _grab_meta(self): meta_user_info = metadata.retrieve_user_info() if self.vid_type == 'movie': self.meta = metadata.movie_meta('tmdb_id', self.tmdb_id, meta_user_info) else: self.meta = metadata.tvshow_meta('tmdb_id', self.tmdb_id, meta_user_info) episodes_data = metadata.season_episodes_meta( self.season, self.meta, meta_user_info) try: episode_data = [ i for i in episodes_data if i['episode'] == int(self.episode) ][0] self.meta.update({ 'vid_type': 'episode', 'season': episode_data['season'], 'episode': episode_data['episode'], 'premiered': episode_data['premiered'], 'ep_name': episode_data['title'], 'plot': episode_data['plot'] }) except: pass
def get_in_progress_tvshows(dummy_arg, page_no, letter): def _process(item): tmdb_id = item['media_id'] meta = metadata.tvshow_meta('tmdb_id', tmdb_id, meta_user_info) watched_status = get_watched_status_tvshow(watched_info, tmdb_id, meta.get('total_aired_eps')) if watched_status[0] == 0: append(item) check_trakt_refresh() duplicates = set() data = [] append = data.append watched_indicators = settings.watched_indicators() paginate = settings.paginate() limit = settings.page_limit() meta_user_info = metadata.retrieve_user_info() watched_info = get_watched_info_tv(watched_indicators) prelim_data = [{ 'media_id': i[0], 'title': i[3] } for i in watched_info if not (i[0] in duplicates or duplicates.add(i[0]))] threads = list(make_thread_list(_process, prelim_data, Thread)) [i.join() for i in threads] original_list = sort_for_article(data, 'title', settings.ignore_articles()) if paginate: final_list, total_pages = paginate_list(original_list, page_no, letter, limit) else: final_list, total_pages = original_list, 1 return final_list, total_pages
def get_info(self): self.meta_user_info = metadata.retrieve_user_info() self.watched_indicators = settings.watched_indicators() self.watched_info = get_watched_info_tv(self.watched_indicators) self.all_episodes = settings.default_all_episodes() self.include_year_in_title = settings.include_year_in_title('tvshow') self.open_extras = settings.extras_open_action('tvshow')
def get_info(self): self.meta_user_info = metadata.retrieve_user_info() self.watched_indicators = settings.watched_indicators() self.watched_info = get_watched_info_movie(self.watched_indicators) self.bookmarks = get_bookmarks('movie', self.watched_indicators) self.include_year_in_title = settings.include_year_in_title('movie') self.open_extras = settings.extras_open_action('movie')
def get_tvshow_info(): meta_user_info = metadata.retrieve_user_info() watched_indicators = settings.watched_indicators() watched_info = get_watched_info_tv(watched_indicators) all_episodes = settings.default_all_episodes() include_year_in_title = settings.include_year_in_title('tvshow') open_extras = settings.extras_open_action('tvshow') return meta_user_info, watched_indicators, watched_info, all_episodes, include_year_in_title, open_extras
def extras_menu(params): function = metadata.movie_meta if params[ 'db_type'] == 'movie' else metadata.tvshow_meta meta_user_info = metadata.retrieve_user_info() meta = function('tmdb_id', params['tmdb_id'], meta_user_info) open_window(['windows.extras', 'Extras'], 'extras.xml', meta=meta, is_widget=params.get('is_widget', 'false'), is_home=params.get('is_home', 'false'))
def get_episode_info(): meta_user_info = metadata.retrieve_user_info() watched_indicators = settings.watched_indicators() watched_info = indicators.get_watched_info_tv(watched_indicators) show_unaired = settings.show_unaired() thumb_fanart = settings.thumb_fanart() is_widget = kodi_utils.external_browse() current_date = get_datetime() adjust_hours = settings.date_offset() bookmarks = indicators.get_bookmarks('episode', watched_indicators) return meta_user_info, watched_indicators, watched_info, show_unaired, thumb_fanart, is_widget, current_date, adjust_hours, bookmarks
def nextep_playback_info(meta): def _build_next_episode_play(): ep_data = season_episodes_meta(season, meta, meta_user_info) if not ep_data: return 'no_next_episode' ep_data = [i for i in ep_data if i['episode'] == episode][0] airdate = ep_data['premiered'] d = airdate.split('-') episode_date = date(int(d[0]), int(d[1]), int(d[2])) if current_date < episode_date: return 'no_next_episode' custom_title = meta_get('custom_title', None) title = custom_title or meta_get('title') display_name = '%s - %dx%.2d' % (title, int(season), int(episode)) meta.update({ 'vid_type': 'episode', 'rootname': display_name, 'season': season, 'ep_name': ep_data['title'], 'episode': episode, 'premiered': airdate, 'plot': ep_data['plot'] }) url_params = { 'mode': 'play_media', 'vid_type': 'episode', 'tmdb_id': tmdb_id, 'tvshowtitle': meta_get('rootname'), 'season': season, 'episode': episode, 'background': 'true' } if custom_title: url_params['custom_title'] = custom_title return url_params meta_get = meta.get meta_user_info = retrieve_user_info() tmdb_id, current_season, current_episode = meta_get('tmdb_id'), int( meta_get('season')), int(meta_get('episode')) try: current_date = get_datetime() season_data = meta_get('season_data') curr_season_data = [ i for i in season_data if i['season_number'] == current_season ][0] season = current_season if current_episode < curr_season_data[ 'episode_count'] else current_season + 1 episode = current_episode + 1 if current_episode < curr_season_data[ 'episode_count'] else 1 nextep_info = _build_next_episode_play() except: nextep_info = 'error' return meta, nextep_info
def mark_as_watched_unwatched_tvshow(params): action = params.get('action') tmdb_id = params.get('tmdb_id') try: tvdb_id = int(params.get('tvdb_id', '0')) except: tvdb_id = 0 watched_indicators = settings.watched_indicators() kodi_utils.progressDialogBG.create(ls(32577), '') if watched_indicators == 1: if not trakt_watched_unwatched(action, 'shows', tmdb_id, tvdb_id): return kodi_utils.notification(32574) clear_trakt_collection_watchlist_data('watchlist', 'tvshow') data_base = TRAKT_DB else: data_base = WATCHED_DB title = params.get('title', '') year = params.get('year', '') meta_user_info = metadata.retrieve_user_info() adjust_hours = settings.date_offset() current_date = get_datetime() insert_list = [] insert_append = insert_list.append meta = metadata.tvshow_meta('tmdb_id', tmdb_id, meta_user_info) season_data = meta['season_data'] season_data = [i for i in season_data if i['season_number'] > 0] total = len(season_data) last_played = get_last_played_value(data_base) for count, item in enumerate(season_data, 1): season_number = item['season_number'] ep_data = metadata.season_episodes_meta(season_number, meta, meta_user_info) for ep in ep_data: season_number = ep['season'] ep_number = ep['episode'] display = 'S%.2dE%.2d' % (int(season_number), int(ep_number)) kodi_utils.progressDialogBG.update( int(float(count) / float(total) * 100), ls(32577), '%s' % display) episode_date, premiered = adjust_premiered_date( ep['premiered'], adjust_hours) if not episode_date or current_date < episode_date: continue insert_append( make_batch_insert(action, 'episode', tmdb_id, season_number, ep_number, last_played, title)) batch_mark_as_watched_unwatched(insert_list, action, data_base) batch_erase_bookmark(insert_list, action, watched_indicators) kodi_utils.progressDialogBG.close() if settings.sync_kodi_library_watchstatus(): batch_mark_kodi_library(action, insert_list, title, year) refresh_container()
def play_fetch_random(tmdb_id): meta_user_info = metadata.retrieve_user_info() meta = metadata.tvshow_meta('tmdb_id', tmdb_id, meta_user_info) adjust_hours = date_offset() current_date = get_datetime() episodes_data = metadata.all_episodes_meta(meta, meta_user_info) episodes_data = [ i for i in episodes_data if not i['season'] == 0 and adjust_premiered_date(i['premiered'], adjust_hours)[0] <= current_date ] if not episodes_data: return {'pass': True} chosen_episode = choice(episodes_data) title = meta['title'] season = int(chosen_episode['season']) episode = int(chosen_episode['episode']) query = title + ' S%.2dE%.2d' % (season, episode) display_name = '%s - %dx%.2d' % (title, season, episode) ep_name = chosen_episode['title'] plot = chosen_episode['plot'] try: premiered = adjust_premiered_date(chosen_episode['premiered'], adjust_hours)[1] except: premiered = chosen_episode['premiered'] meta.update({ 'vid_type': 'episode', 'rootname': display_name, 'season': season, 'episode': episode, 'premiered': premiered, 'ep_name': ep_name, 'plot': plot, 'random': 'true' }) url_params = { 'mode': 'play_media', 'vid_type': 'episode', 'tmdb_id': meta['tmdb_id'], 'query': query, 'tvshowtitle': meta['rootname'], 'season': season, 'episode': episode, 'autoplay': 'True' } return execute_builtin('RunPlugin(%s)' % build_url(url_params))
def get_watched_items(db_type, page_no, letter): paginate = settings.paginate() limit = settings.page_limit() watched_indicators = settings.watched_indicators() if db_type == 'tvshow': from threading import Thread from modules.utils import make_thread_list def _process(item): tmdb_id = item['media_id'] meta = metadata.tvshow_meta('tmdb_id', tmdb_id, meta_user_info) watched_status = get_watched_status_tvshow( watched_info, tmdb_id, meta.get('total_aired_eps')) if watched_status[0] == 1: append(item) meta_user_info = metadata.retrieve_user_info() watched_info = get_watched_info_tv(watched_indicators) duplicates = set() data = [] append = data.append prelim_data = [{ 'media_id': i[0], 'title': i[3] } for i in watched_info if not (i[0] in duplicates or duplicates.add(i[0]))] threads = list(make_thread_list(_process, prelim_data, Thread)) [i.join() for i in threads] original_list = sort_for_article(data, 'title', settings.ignore_articles()) else: watched_info = get_watched_info_movie(watched_indicators) data = [{'media_id': i[0], 'title': i[1]} for i in watched_info] original_list = sort_for_article(data, 'title', settings.ignore_articles()) if paginate: final_list, total_pages = paginate_list(original_list, page_no, letter, limit) else: final_list, total_pages = original_list, 1 return final_list, total_pages
def _get_search_title(self, meta): if 'custom_title' in meta: search_title = meta['custom_title'] else: if self.language == 'en': search_title = meta['title'] else: search_title = None if 'english_title' in meta: search_title = meta['english_title'] else: try: db_type = 'movie' if self.vid_type == 'movie' else 'tv' meta_user_info = metadata.retrieve_user_info() english_title = metadata.english_translation( db_type, meta['tmdb_id'], meta_user_info) if english_title: search_title = english_title else: search_title = meta['original_title'] except: pass if not search_title: search_title = meta['original_title'] if '(' in search_title: search_title = search_title.split('(')[0] if '/' in search_title: search_title = search_title.replace('/', ' ') return search_title
def pack_enable_check(meta, season, episode): try: extra_info = meta['extra_info'] status = extra_info['status'].lower() if status in ('ended', 'canceled'): return True, True from metadata import season_episodes_meta, retrieve_user_info from modules.utils import adjust_premiered_date, get_datetime adjust_hours = date_offset() current_date = get_datetime() meta_user_info = retrieve_user_info() episodes_data = season_episodes_meta(season, meta, meta_user_info) unaired_episodes = [ adjust_premiered_date(i['premiered'], adjust_hours)[0] for i in episodes_data ] if None in unaired_episodes or any(i > current_date for i in unaired_episodes): return False, False else: return True, False except: pass return False, False
def build_season_list(params): def _process(): running_ep_count = total_aired_eps def _unaired_status(): if episode_count == 0: return True season_date_start = adjust_premiered_date(air_date, 0)[0] if not season_date_start or current_date < season_date_start: return True return False for item in season_data: try: listitem = make_listitem() set_property = listitem.setProperty cm = [] cm_append = cm.append item_get = item.get overview = item_get('overview') name = item_get('name') poster_path = item_get('poster_path') air_date = item_get('air_date') season_number = item_get('season_number') episode_count = item_get('episode_count') season_poster = 'https://image.tmdb.org/t/p/%s%s' % ( image_resolution, poster_path) if poster_path is not None else show_poster if season_number == 0: unaired = False else: unaired = _unaired_status() if unaired: if not show_unaired: return episode_count = 0 else: running_ep_count -= episode_count if running_ep_count < 0: episode_count = running_ep_count + episode_count try: year = air_date.split('-')[0] except: year = show_year plot = overview if overview != '' else show_plot title = name if use_season_title and name != '' else '%s %s' % ( season_str, string(season_number)) if unaired: title = unaired_label % title playcount, overlay, watched, unwatched = get_watched_status_season( watched_info, string(tmdb_id), season_number, episode_count) url_params = build_url({ 'mode': 'build_episode_list', 'tmdb_id': tmdb_id, 'season': season_number }) extras_params = build_url({ 'mode': 'extras_menu_choice', 'tmdb_id': tmdb_id, 'db_type': 'tvshow', 'is_widget': is_widget }) options_params = build_url({ 'mode': 'options_menu_choice', 'content': 'season', 'tmdb_id': tmdb_id }) cm_append((extras_str, run_plugin % extras_params)) cm_append((options_str, run_plugin % options_params)) if not playcount: watched_params = build_url({ 'mode': 'mark_as_watched_unwatched_season', 'action': 'mark_as_watched', 'title': show_title, 'year': show_year, 'tmdb_id': tmdb_id, 'tvdb_id': tvdb_id, 'season': season_number }) cm_append((watched_str % watched_title, run_plugin % watched_params)) if watched: unwatched_params = build_url({ 'mode': 'mark_as_watched_unwatched_season', 'action': 'mark_as_unwatched', 'title': show_title, 'year': show_year, 'tmdb_id': tmdb_id, 'tvdb_id': tvdb_id, 'season': season_number }) cm_append((unwatched_str % watched_title, run_plugin % unwatched_params)) listitem.setLabel(title) listitem.setContentLookup(False) listitem.addContextMenuItems(cm) listitem.setArt({ 'poster': season_poster, 'icon': season_poster, 'thumb': season_poster, 'fanart': fanart, 'banner': banner, 'clearart': clearart, 'clearlogo': clearlogo, 'landscape': landscape, 'tvshow.clearart': clearart, 'tvshow.clearlogo': clearlogo, 'tvshow.landscape': landscape, 'tvshow.banner': banner }) listitem.setCast(cast) listitem.setUniqueIDs({ 'imdb': imdb_id, 'tmdb': string(tmdb_id), 'tvdb': string(tvdb_id) }) listitem.setInfo( 'video', { 'mediatype': 'season', 'trailer': trailer, 'title': title, 'size': '0', 'duration': episode_run_time, 'plot': plot, 'rating': rating, 'premiered': premiered, 'studio': studio, 'year': year, 'genre': genre, 'mpaa': mpaa, 'tvshowtitle': show_title, 'imdbnumber': imdb_id, 'votes': votes, 'season': season_number, 'playcount': playcount, 'overlay': overlay }) set_property('watchedepisodes', string(watched)) set_property('unwatchedepisodes', string(unwatched)) set_property('totalepisodes', string(episode_count)) if is_widget: set_property('fen_widget', 'true') set_property('fen_playcount', string(playcount)) set_property('fen_extras_menu_params', extras_params) set_property('fen_options_menu_params', options_params) else: set_property('fen_widget', 'false') yield (url_params, listitem, True) except: pass __handle__ = int(argv[1]) meta_user_info = metadata.retrieve_user_info() watched_indicators = settings.watched_indicators() watched_info = get_watched_info_tv(watched_indicators) show_unaired = settings.show_unaired() is_widget = kodi_utils.external_browse() current_date = get_datetime() image_resolution = meta_user_info['image_resolution']['poster'] poster_main, poster_backup, fanart_main, fanart_backup = settings.get_art_provider( ) meta = metadata.tvshow_meta('tmdb_id', params['tmdb_id'], meta_user_info) meta_get = meta.get season_data = meta_get('season_data') if not season_data: return tmdb_id, tvdb_id, imdb_id = meta_get('tmdb_id'), meta_get( 'tvdb_id'), meta_get('imdb_id') show_title, show_year, show_plot, banner = meta_get('title'), meta_get( 'year'), meta_get('plot'), meta_get('banner') show_poster = meta_get(poster_main) or meta_get( poster_backup) or poster_empty fanart = meta_get(fanart_main) or meta_get(fanart_backup) or fanart_empty clearlogo, clearart, landscape = meta_get('clearlogo'), meta_get( 'clearart'), meta_get('landscape') cast, mpaa, votes = meta_get('cast'), meta_get('mpaa'), meta_get('votes') trailer, genre, studio = string( meta_get('trailer')), meta_get('genre'), meta_get('studio') episode_run_time, rating, premiered = meta_get( 'episode_run_time'), meta_get('rating'), meta_get('premiered') total_seasons = meta_get('total_seasons') total_aired_eps = meta_get('total_aired_eps') if not settings.show_specials(): season_data = [i for i in season_data if not i['season_number'] == 0] season_data.sort(key=lambda k: k['season_number']) use_season_title = settings.use_season_title() watched_title = 'Trakt' if watched_indicators == 1 else 'Fen' kodi_utils.add_items(__handle__, list(_process())) kodi_utils.set_content(__handle__, 'seasons') kodi_utils.end_directory(__handle__) kodi_utils.set_view_mode('view.seasons', 'seasons')
def options_menu(params, meta=None): def _builder(): for item in listing: line1 = item[0] line2 = item[1] if line2 == '': line2 = line1 yield {'line1': line1, 'line2': line2} content = params.get('content', None) if not content: content = kodi_utils.container_content()[:-1] season = params.get('season', None) episode = params.get('episode', None) if not meta: function = metadata.movie_meta if content == 'movie' else metadata.tvshow_meta meta_user_info = metadata.retrieve_user_info() meta = function('tmdb_id', params['tmdb_id'], meta_user_info) watched_indicators = settings.watched_indicators() on_str, off_str, currently_str, open_str, settings_str = ls(32090), ls( 32027), ls(32598), ls(32641), ls(32247) autoplay_status, autoplay_toggle, quality_setting = (on_str, 'false', 'autoplay_quality_%s' % content) if settings.auto_play(content) \ else (off_str, 'true', 'results_quality_%s' % content) quality_filter_setting = 'autoplay_quality_%s' % content if autoplay_status == on_str else 'results_quality_%s' % content autoplay_next_status, autoplay_next_toggle = ( on_str, 'false') if settings.autoplay_next_episode() else (off_str, 'true') results_xml_style_status = get_setting('results.xml_style', 'Default') results_filter_ignore_status, results_filter_ignore_toggle = ( on_str, 'false') if settings.ignore_results_filter() else (off_str, 'true') results_sorting_status = get_setting('results.sort_order_display').replace( '$ADDON[plugin.video.fen 32582]', ls(32582)) current_results_highlights_action = get_setting('highlight.type') results_highlights_status = ls( 32240) if current_results_highlights_action == '0' else ls( 32583) if current_results_highlights_action == '1' else ls(32241) current_subs_action = get_setting('subtitles.subs_action') current_subs_action_status = 'Auto' if current_subs_action == '0' else ls( 32193) if current_subs_action == '1' else off_str active_internal_scrapers = [ i.replace('_', '') for i in settings.active_internal_scrapers() ] current_scrapers_status = ', '.join([ i for i in active_internal_scrapers ]) if len(active_internal_scrapers) > 0 else 'N/A' current_quality_status = ', '.join( settings.quality_filter(quality_setting)) uncached_torrents_status, uncached_torrents_toggle = ( on_str, 'false') if settings.display_uncached_torrents() else (off_str, 'true') listing = [] base_str1 = '%s%s' base_str2 = '%s: [B]%s[/B]' % (currently_str, '%s') if content in ('movie', 'episode'): multi_line = 'true' listing += [(ls(32014), '', 'clear_and_rescrape')] listing += [(ls(32006), '', 'rescrape_with_disabled')] listing += [(ls(32135), '', 'scrape_with_custom_values')] listing += [(base_str1 % (ls(32175), ' (%s)' % content), base_str2 % autoplay_status, 'toggle_autoplay')] if autoplay_status == on_str and content == 'episode': listing += [ (base_str1 % (ls(32178), ''), base_str2 % autoplay_next_status, 'toggle_autoplay_next') ] listing += [(base_str1 % (ls(32105), ' (%s)' % content), base_str2 % current_quality_status, 'set_quality')] listing += [(base_str1 % ('', '%s %s' % (ls(32055), ls(32533))), base_str2 % current_scrapers_status, 'enable_scrapers')] if autoplay_status == off_str: listing += [(base_str1 % ('', ls(32140)), base_str2 % results_xml_style_status, 'set_results_xml_display')] listing += [ (base_str1 % ('', ls(32151)), base_str2 % results_sorting_status, 'set_results_sorting') ] listing += [(base_str1 % ('', ls(32138)), base_str2 % results_highlights_status, 'set_results_highlights')] listing += [(base_str1 % ('', ls(32686)), base_str2 % results_filter_ignore_status, 'set_results_filter_ignore')] listing += [(base_str1 % ('', ls(32183)), base_str2 % current_subs_action_status, 'set_subs_action') ] if 'external' in active_internal_scrapers: listing += [(base_str1 % ('', ls(32160)), base_str2 % uncached_torrents_status, 'toggle_torrents_display_uncached')] else: multi_line = 'false' listing += [(ls(32046), '', 'extras_lists_choice')] if content in ('movie', 'tvshow') and meta: listing += [ (ls(32604) % (ls(32028) if meta['mediatype'] == 'movie' else ls(32029)), '', 'clear_media_cache') ] if watched_indicators == 1: listing += [(ls(32497) % ls(32037), '', 'clear_trakt_cache')] if content in ('movie', 'episode'): listing += [(ls(32637), '', 'clear_scrapers_cache')] listing += [('%s %s' % (ls(32118), ls(32513)), '', 'open_external_scrapers_manager')] listing += [('%s %s %s' % (open_str, ls(32522), settings_str), '', 'open_scraper_settings')] listing += [('%s %s %s' % (open_str, ls(32036), settings_str), '', 'open_fen_settings')] listing += [(ls(32640), '', 'save_and_exit')] list_items = list(_builder()) heading = ls(32646).replace('[B]', '').replace('[/B]', '') kwargs = { 'items': json.dumps(list_items), 'heading': heading, 'enumerate': 'false', 'multi_choice': 'false', 'multi_line': multi_line } choice = kodi_utils.select_dialog([i[2] for i in listing], **kwargs) if choice in (None, 'save_and_exit'): return elif choice == 'clear_and_rescrape': return clear_and_rescrape(content, meta, season, episode) elif choice == 'rescrape_with_disabled': return rescrape_with_disabled(content, meta, season, episode) elif choice == 'scrape_with_custom_values': return scrape_with_custom_values(content, meta, season, episode) elif choice == 'toggle_autoplay': set_setting('auto_play_%s' % content, autoplay_toggle) elif choice == 'toggle_autoplay_next': set_setting('autoplay_next_episode', autoplay_next_toggle) elif choice == 'enable_scrapers': enable_scrapers_choice() elif choice == 'set_results_xml_display': results_layout_choice() elif choice == 'set_results_sorting': results_sorting_choice() elif choice == 'set_results_filter_ignore': set_setting('ignore_results_filter', results_filter_ignore_toggle) elif choice == 'set_results_highlights': results_highlights_choice() elif choice == 'set_quality': set_quality_choice(quality_filter_setting) elif choice == 'set_subs_action': set_subtitle_choice() elif choice == 'extras_lists_choice': extras_lists_choice() elif choice == 'clear_media_cache': return refresh_cached_data(meta['mediatype'], 'tmdb_id', meta['tmdb_id'], meta['tvdb_id'], settings.get_language()) elif choice == 'toggle_torrents_display_uncached': set_setting('torrent.display.uncached', uncached_torrents_toggle) elif choice == 'clear_trakt_cache': return clear_cache('trakt') elif choice == 'clear_scrapers_cache': return clear_scrapers_cache() elif choice == 'open_external_scrapers_manager': return external_scrapers_manager() elif choice == 'open_scraper_settings': return kodi_utils.execute_builtin( 'Addon.OpenSettings(script.module.fenomscrapers)') elif choice == 'open_fen_settings': return open_settings('0.0') if choice == 'clear_trakt_cache' and content in ('movie', 'tvshow', 'season', 'episode'): kodi_utils.execute_builtin('Container.Refresh') kodi_utils.show_busy_dialog() kodi_utils.sleep(200) kodi_utils.hide_busy_dialog() options_menu(params, meta=meta)
def set_bookmark_kodi_library(db_type, tmdb_id, curr_time, total_time, season='', episode=''): meta_user_info = retrieve_user_info() try: info = movie_meta( 'tmdb_id', tmdb_id, meta_user_info) if db_type == 'movie' else tvshow_meta( 'tmdb_id', tmdb_id, meta_user_info) title = info['title'] year = info['year'] years = (str(year), str(int(year) + 1), str(int(year) - 1)) if db_type == 'movie': r = execute_JSON( '{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": {"filter":{"or": [{"field": "year", "operator": "is", "value": "%s"}, {"field": "year", "operator": "is", "value": "%s"}, {"field": "year", "operator": "is", "value": "%s"}]}, "properties": ["title"]}, "id": 1}' % years) else: r = execute_JSON( '{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": {"filter":{"or": [{"field": "year", "operator": "is", "value": "%s"}, {"field": "year", "operator": "is", "value": "%s"}, {"field": "year", "operator": "is", "value": "%s"}]}, "properties": ["title"]}, "id": 1}' % years) r = to_utf8(r) r = json.loads( r)['result']['movies'] if db_type == 'movie' else json.loads( r)['result']['tvshows'] if db_type == 'movie': r = [ i for i in r if clean_file_name(title).lower() in clean_file_name( to_utf8(i['title'])).lower() ][0] else: r = [ i for i in r if clean_file_name(title).lower() in ( clean_file_name(to_utf8(i['title'])).lower( ) if not ' (' in to_utf8(i['title']) else clean_file_name( to_utf8(i['title'])).lower().split(' (')[0]) ][0] if db_type == 'episode': r = execute_JSON( '{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"filter":{"and": [{"field": "season", "operator": "is", "value": "%s"}, {"field": "episode", "operator": "is", "value": "%s"}]}, "properties": ["file"], "tvshowid": %s }, "id": 1}' % (str(season), str(episode), str(r['tvshowid']))) r = to_utf8(r) r = json.loads(r)['result']['episodes'][0] (method, id_name, library_id) = ('SetMovieDetails', 'movieid', r['movieid']) if db_type == 'movie' else ( 'SetEpisodeDetails', 'episodeid', r['episodeid']) query = { "jsonrpc": "2.0", "id": "setResumePoint", "method": "VideoLibrary." + method, "params": { id_name: library_id, "resume": { "position": curr_time, "total": total_time } } } execute_JSON(json.dumps(query)) except: pass