def movies_batch_add_to_library(): from resources.lib.TheMovieDB import Movies movie_batch_file = plugin.get_setting('movies_batch_add_file_path', unicode) if xbmcvfs.exists(movie_batch_file): try: f = open(xbmc.translatePath(movie_batch_file), 'r') r = f.read() f.close() ids = r.split('\n') except: plugin.notify('Movies', 'not found', plugin.get_addon_icon(), 3000) library_folder = lib_movies.setup_library(plugin.get_setting('movies_library_folder', unicode)) for id in ids: if ',' in id: csvs = id.split(',') for csv in csvs: if not str(csv).startswith('tt') and csv != '': movie = Movies(csv).info() csv = movie.get('imdb_id') lib_movies.batch_add_movies_to_library(library_folder, csv) else: if not str(id).startswith('tt') and id != '': movie = Movies(id).info() id = movie.get('imdb_id') lib_movies.batch_add_movies_to_library(library_folder, id) os.remove(xbmc.translatePath(movie_batch_file)) lib_movies.update_library() return True
def movies_add_to_library(src, id): from resources.lib.TheMovieDB import Movies library_folder = lib_movies.setup_library(plugin.get_setting('movies_library_folder', unicode)) if library_folder == False: return date = None if src == 'tmdb': movie = Movies(id).info() date = text.date_to_timestamp(movie.get('release_date')) imdb_id = movie.get('imdb_id') if imdb_id: src = 'imdb' id = imdb_id ids = [str(movie.get('id')), str(movie.get('imdb_id', None))] try: libmovies = RPC.VideoLibrary.GetMovies(properties=['imdbnumber', 'title', 'year'])['movies'] libmovies = [i for i in libmovies if str(i['imdbnumber']) in ids or (str(i['year']) == str(movie.get('year', 0)) and equals(movie.get['title'], i['title']))] libmovie = libmovies[0] except: libmovie = [] else: ids = [str(id), 'None'] try: libmovies = RPC.VideoLibrary.GetMovies(properties=['imdbnumber', 'title', 'year'])['movies'] libmovies = [i for i in libmovies if str(i['imdbnumber']) in ids] libmovie = libmovies[0] except: libmovie = [] if libmovie != []: return lib_movies.add_movie_to_library(library_folder, src, id) tools.scan_library(path=plugin.get_setting('movies_library_folder', unicode))
def movies_add_to_library_parsed(src, id, player): from resources.lib.TheMovieDB import Movies library_folder = lib_movies.setup_library(plugin.get_setting('movies_library_folder', unicode)) date = None if src == 'tmdb': movie = Movies(id).info() date = text.date_to_timestamp(movie.get('release_date')) imdb_id = movie.get('imdb_id') if imdb_id: if imdb_id != None and imdb_id != '': src = 'imdb' id = imdb_id lib_movies.add_movie_to_library(library_folder, src, id, player) tools.scan_library(path=plugin.get_setting('movies_library_folder', unicode))
def item_images(type, tmdb_id=None, imdb_id=None, tvdb_id=None, name=None, season=None, episode=None): from resources.lib.TheMovieDB import Movies, TV, Find, TV_Episodes poster = '' fanart = '' response = '' if not tmdb_id and not imdb_id and not tvdb_id and not tvrage_id and not name: return None if type == 'movie' and tmdb_id != None and tmdb_id != '': response = Movies(tmdb_id).info() elif type == 'tv' and tmdb_id != None and tmdb_id != '': response = TV(tmdb_id).info() elif type == 'tv' and tvdb_id != None and tvdb_id != '': response = Find(tvdb_id).info(external_source='tvdb_id') elif type == 'episode' and tmdb_id != None and tmdb_id != '': response = TV_Episodes(tmdb_id, season, episode).info() return 'https://image.tmdb.org/t/p/original/%s' % response.get( 'still_path') elif type == 'episode' and tvdb_id != None and tvdb_id != '': response = TV_Episodes( Find(tvdb_id).info( external_source='tvdb_id').get('tv_results')[0].get('id'), season, episode).info() return 'https://image.tmdb.org/t/p/original/%s' % response.get( 'still_path') elif imdb_id != None and imdb_id != '': response = Find(imdb_id).info(external_source='imdb_id') if response == '': return False if tmdb_id == None or tmdb_id == '': if type == 'movie': response = response.get('movie_results') elif type == 'tv': response = response.get('tv_results')[0] elif type == 'season': response = response.get('season_results') elif type == 'episode': response = response.get('episode_results') if isinstance(response, dict): fanart = 'https://image.tmdb.org/t/p/original/%s' % response.get( 'backdrop_path') poster = 'https://image.tmdb.org/t/p/original/%s' % response.get( 'poster_path') elif isinstance(response, list): fanart = 'https://image.tmdb.org/t/p/original/%s' % response[ 'backdrop_path'] poster = 'https://image.tmdb.org/t/p/original/%s' % response[ 'poster_path'] images = [poster, fanart] return images