def tv_add_to_library(id): library_folder = lib_tvshows.setup_library(plugin.get_setting('tv_library_folder', unicode)) show = TVDB[int(id)] imdb = show['imdb_id'] library_folder = lib_tvshows.setup_library(plugin.get_setting('tv_library_folder', unicode)) if lib_tvshows.add_tvshow_to_library(library_folder, show): plugin.setProperty('plugin.video.openmeta.clean_library', 'true') tools.scan_library(path=plugin.get_setting('tv_library_folder', unicode))
def tv_add_to_library_parsed(id, player): if id.startswith('tt'): try: id = TVDB.search_by_imdb(id) except: plugin.ok('TV show not found', 'no show information found for %s in TheTVDB' % id) library_folder = lib_tvshows.setup_library(plugin.get_setting('tv_library_folder', unicode)) show = TVDB[int(id)] imdb = show['imdb_id'] library_folder = lib_tvshows.setup_library(plugin.get_setting('tv_library_folder', unicode)) if lib_tvshows.add_tvshow_to_library(library_folder, show, player): plugin.setProperty('plugin.video.openmeta.clean_library', 'true') tools.scan_library(path=plugin.get_setting('tv_library_folder', unicode))
def tv_add_all_to_library(items, noscan=False): library_folder = lib_tvshows.setup_library( plugin.get_setting('tv_library_folder', unicode)) ids = '' if 'results' in items: preids = [] for tvdb_show, tmdb_show in executor.execute(tmdb_to_tvdb, items['results'], workers=10): if tvdb_show is not None: preids.append(tvdb_show['id']) ids = '\n'.join(preids) else: ids = '\n'.join([ str(i['show']['ids']['tvdb']) if i['show']['ids']['tvdb'] != None and i['show']['ids']['tvdb'] != '' else i['show']['ids']['imdb'] for i in items ]) shows_batch_add_file = plugin.get_setting('tv_batch_add_file_path', unicode) if xbmcvfs.exists(shows_batch_add_file): batch_add_file = xbmcvfs.File(shows_batch_add_file) pre_ids = batch_add_file.read() xids = pre_ids.split('\n') for id in xids: if id != '' and id != None and id not in ids: ids = ids + str(id) + '\n' batch_add_file.close() xbmcvfs.delete(shows_batch_add_file) batch_add_file = xbmcvfs.File(shows_batch_add_file, 'w') batch_add_file.write(str(ids)) batch_add_file.close() xbmc.executebuiltin( 'RunPlugin(plugin://plugin.video.openmeta/tv/batch_add_to_library)')
def tv_batch_add_to_library(): tv_batch_file = plugin.get_setting('tv_batch_add_file_path', unicode) if xbmcvfs.exists(tv_batch_file): try: f = open(xbmc.translatePath(tv_batch_file), 'r') r = f.read() f.close() ids = r.split('\n') except: plugin.notify('TV shows', 'not found', plugin.get_addon_icon(), 3000) library_folder = lib_tvshows.setup_library( plugin.get_setting('tv_library_folder', unicode)) ids_index = 0 for id in ids: if id == None or id == 'None': pass elif ',' in id: csvs = id.split(',') for csv in csvs: if csv == None or csv == 'None': pass elif str(csv).startswith('tt') and csv != '': tvdb_id = get_tvdb_id_from_imdb_id(csv) else: tvdb_id = csv show = TVDB[int(tvdb_id)] lib_tvshows.batch_add_tvshows_to_library( library_folder, show) else: if id == None or id == 'None' or id == '': pass elif str(id).startswith('tt'): tvdb_id = get_tvdb_id_from_imdb_id(id) else: tvdb_id = id try: show = TVDB[int(tvdb_id)] lib_tvshows.batch_add_tvshows_to_library( library_folder, show) except: # plugin.notify('Failed to add', '%s' % id, plugin.get_addon_icon(), 3000) xbmc.log('Failed to add' + '%s' % id, xbmc.LOGERROR) ids_index += 1 os.remove(xbmc.translatePath(tv_batch_file)) lib_tvshows.update_library() return True