def update_subscriptions(self, suppress_extras=False): from datetime import datetime, timedelta self.db_type = 'tvshow' self.action = 'add' self.path = settings.tv_show_directory() subscriptions = self.get_subscriptions() if not subscriptions: return notification('No TV Show Subscriptions to Update', 1200) close_all_dialog() bg_dialog = xbmcgui.DialogProgressBG() bg_dialog.create('Please Wait', 'Preparing Subscription Update...') for count, item in enumerate(subscriptions, 1): self.tmdb_id = item['media_id'] self.add_remove_constants() self.add_remove_tvshow(silent=True) display = 'Fen Updating - [B][I]%s[/I][/B]' % self.rootname bg_dialog.update( int(float(count) / float(len(subscriptions)) * 100), 'Please Wait', '%s' % display) xbmc.sleep(300) if int(__addon__.getSetting('subsciptions.update_type')) == 0: hours = settings.subscription_timer() __addon__.setSetting( 'service_time', str(datetime.now() + timedelta(hours=hours)).split('.')[0]) xbmc.sleep(500) bg_dialog.close() notification('Fen Subscriptions Updated', 4500) if settings.update_library_after_service() and not suppress_extras: xbmc.executebuiltin('UpdateLibrary(video)')
def _process_additions_removals(db_type, action, list_contents): function = _process_additions if action == 'add' else _process_removals media_id_key = 'media_ids' if action == 'add' else 'media_id' dialog_db = '[B]Movies[/B]' if db_type in ( 'movie', 'movies') else '[B]TV Shows[/B]' dialog_line2 = 'Adding [B]%s[/B] %s' if action == 'add' else 'Removing [B]%s[/B] %s' path = settings.movies_directory() if db_type in ( 'movie', 'movies') else settings.tv_show_directory() threads = [] list_length = len(list_contents) dialog.update(0, dialog_db, dialog_line2 % (list_length, dialog_db)) for count, item in enumerate(list_contents, 1): function(db_type, item[media_id_key], count, list_length, path, dialog)
def __init__(self, db_type=None, tmdb_id=None, action=None, orig_mode=None): tikimeta.check_meta_database() self.db_type = db_type self.tmdb_id = tmdb_id #str self.action = action self.orig_mode = orig_mode self.meta_user_info = tikimeta.retrieve_user_info() if self.db_type: self.path = settings.movies_directory( ) if self.db_type == 'movie' else settings.tv_show_directory() self.add_release_date = settings.add_release_date() window.setProperty('fen_fanart_error', 'true')
def clear_subscriptions(self, confirm=True, silent=False, db_type=None): if confirm: if not self.subscription_choice( 'Choose Subscriptions to Erase', 'Continuing will erase all your %s'): return self.db_type = self.choice[1] if not db_type else db_type self.path = settings.movies_directory( ) if self.db_type == 'movie' else settings.tv_show_directory() subscriptions = self.get_subscriptions() if len(subscriptions) == 0: return notification( '%s Subscriptions is already Empty' % self.db_type.upper(), 4500) self.remove_folder(self.path) self.make_folder(self.path) if not silent: notification( '%s Subscriptions has been Cleared' % self.db_type.upper(), 4500)
def subscriptions_add_list(db_type): from modules.trakt_cache import clear_trakt_list_data from apis.trakt_api import get_trakt_list_selection from modules.nav_utils import show_busy_dialog, hide_busy_dialog, open_settings movie_subscriptions = Subscriptions('movie') tvshow_subscriptions = Subscriptions('tvshow') variables = ('Movies', 'movies', 'movie', 'trakt.subscriptions_movie', 'trakt.subscriptions_movie_display', '8.14', movie_subscriptions) if db_type == 'movie' else ( 'TV Shows', 'shows', 'show', 'trakt.subscriptions_show', 'trakt.subscriptions_show_display', '8.15', tvshow_subscriptions) dialog_display = variables[0] trakt_list_type = variables[1] trakt_dbtype = variables[2] main_setting = variables[3] display_setting = variables[4] open_setting = variables[5] subscription_function = variables[6] clear_library, cancelled, supplied_list = (False for _ in range(3)) path = settings.movies_directory( ) if db_type == 'movie' else settings.tv_show_directory() if xbmcgui.Dialog().yesno( 'Fen Subscriptions', 'Are you sure you have set your Fen [B]%s[/B] Subscription Folder as a Source for the Kodi Library?' % db_type.upper(), '', '', 'Already Done', 'I\'ll Do It Now'): return xbmc.executebuiltin('ActivateWindow(videos,files,return)') for i in ('my_lists', 'liked_lists'): try: clear_trakt_list_data(i) except: pass trakt_list = get_trakt_list_selection(list_choice='subscriptions') if not trakt_list: return open_settings(open_setting) __addon__.setSetting(main_setting, json.dumps(trakt_list)) __addon__.setSetting(display_setting, trakt_list['name']) if trakt_list['name'].lower() == 'none': return open_settings(open_setting) if not xbmcgui.Dialog().yesno( 'Are you sure?', 'Fen will add all [B]%s[/B] from [B]%s[/B] to your Fen Subscriptions, and monitor this list for changes. Do you wish to continue?' % (dialog_display, trakt_list['name'])): __addon__.setSetting(main_setting, '') __addon__.setSetting(display_setting, 'none') return open_settings(open_setting) current_subscriptions = subscription_function.get_subscriptions() if len(current_subscriptions) > 0: if not xbmcgui.Dialog().yesno( 'Current Subscriptions Found!', 'You have items in your [B]%s[/B] Subscription. Fen will delete these before continuing (may take some time). Do you wish to continue?' % (dialog_display)): return open_settings(open_setting) clear_library = True show_busy_dialog() subscription_function.clear_subscriptions(confirm=False, silent=True, db_type=db_type) hide_busy_dialog() dialog = xbmcgui.DialogProgressBG() dialog.create('Please Wait', 'Preparing Trakt List Info...') if trakt_list['name'] in ('Collection', 'Watchlist'): from modules.trakt_cache import clear_trakt_collection_watchlist_data from apis.trakt_api import trakt_fetch_collection_watchlist list_contents = trakt_fetch_collection_watchlist( trakt_list['name'].lower(), trakt_list_type) else: from apis.trakt_api import get_trakt_list_contents from modules.trakt_cache import clear_trakt_list_contents_data list_contents = get_trakt_list_contents(trakt_list['user'], trakt_list['slug']) list_contents = [{ 'media_ids': i[trakt_dbtype]['ids'], 'title': i[trakt_dbtype]['title'] } for i in list_contents if i['type'] == trakt_dbtype] for i in list_contents: if i['media_ids']['tmdb'] == None: i['media_ids']['tmdb'] = get_trakt_tvshow_id(i['media_ids']) threads = [] list_length = len(list_contents) for count, item in enumerate(list_contents, 1): subscription_function.add_trakt_subscription_listitem( db_type, item['media_ids'], count, list_length, path, dialog) dialog.close() end_dialog = 'Operation Cancelled! Not all items from [B]%s[/B] were added.' if cancelled else '[B]%s[/B] added to Subscriptions.' xbmcgui.Dialog().ok('Fen Subscriptions', end_dialog % trakt_list['name']) if clear_library: if xbmcgui.Dialog().yesno( 'Fen Subscriptions', 'Do you wish to clear Kodi\'s Library of your previous Subscription items?' ): import time xbmc.executebuiltin('CleanLibrary(video)') time.sleep(3) while xbmc.getCondVisibility("Window.IsVisible(ProgressDialog)"): time.sleep(1) if xbmcgui.Dialog().yesno( 'Fen Subscriptions', 'Do you wish to scan your new Subscription list into Kodi\'s Library?' ): xbmc.executebuiltin('UpdateLibrary(video)')