def movies_batch_add_to_library(): """ Batch add movies to library """ movie_batch_file = plugin.get_setting(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: return dialogs.notify(msg='Movies Batch Add File', title=_("%s not found").replace("%s ",""), delay=3000, image=get_icon_path("movies")) library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode)) import_tmdb() for id in ids: if "," in id: csvs = id.split(',') for csv in csvs: if not str(csv).startswith("tt") and csv != "": movie = tmdb.Movies(csv).info() csv = movie.get('imdb_id') batch_add_movies_to_library(library_folder, csv) else: if not str(id).startswith("tt") and id != "": movie = tmdb.Movies(id).info() id = movie.get('imdb_id') batch_add_movies_to_library(library_folder, id) os.remove(xbmc.translatePath(movie_batch_file)) if xbmcvfs.exists(plugin.get_setting(SETTING_TV_BATCH_ADD_FILE_PATH, unicode)): xbmc.executebuiltin("RunPlugin(plugin://plugin.video.chappaai/tv/batch_add_to_library)") return True else: xbmc.sleep(1000) dialogs.notify(msg='Added movie strm-files', title='Starting library scan', delay=3000, image=get_icon_path("movies")) scan_library(type="video") return True if xbmcvfs.exists(plugin.get_setting(SETTING_TV_BATCH_ADD_FILE_PATH, unicode)): xbmc.executebuiltin("RunPlugin(plugin://plugin.video.chappaai/tv/batch_add_to_library)")
def lists_trakt_add_my_lists_to_library(): misc_ids = [] movie_ids = [] tv_ids = [] import xbmcgui lists = trakt.trakt_get_lists() dialogs.notify(msg='Adding ' + str(len(lists)) + " lists", title='to Kodi library', delay=3000, image=get_icon_path("chappaai")) for list in lists: user = list["user"]["username"] slug = list["ids"]["slug"] items = lists_trakt_show_list(user, slug) list_misc_ids, list_movie_ids, list_tv_ids = batch_find_list_ids(items) write_list_id_files(list_misc_ids, list_tv_ids, list_movie_ids, slug, user) misc_ids.extend(list_misc_ids) movie_ids.extend(list_movie_ids) tv_ids.extend(list_tv_ids) write_batch_id_files(tv_ids, movie_ids, misc_ids) dialogs.notify(msg='Generating', title='.strm-files', delay=3000, image=get_icon_path("chappaai")) xbmc.executebuiltin( "RunPlugin(plugin://plugin.video.chappaai/movies/batch_add_to_library)" )
def toggle_between_skins(): if xbmc.getCondVisibility("Skin.HasSetting(Contexting)") != True: contexting = False else: contexting = True if xbmc.getCondVisibility("Skin.HasSetting(Toggling)") != True: toggling = False else: toggling = True current_skin = str(xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.GetSettingValue","params":{"setting":"lookandfeel.skin"}, "id":1}')).replace('{"id":1,"jsonrpc":"2.0","result":{"value":"','').replace('"}}','') primary_skin = plugin.get_setting(SETTING_PRIMARY_SKIN, unicode) if primary_skin == "": plugin.set_setting(SETTING_PRIMARY_SKIN, current_skin) alternate_skin = plugin.get_setting(SETTING_ALTERNATE_SKIN, unicode) if alternate_skin == "": if primary_skin != "skin.confluence" and primary_skin != "": plugin.set_setting(SETTING_ALTERNATE_SKIN, "skin.confluence") else: dialogs.notify(msg="Alternate skin", title="Not set", delay=5000, image=get_icon_path("metalliq")) return openSettings(addonid, 5.7) if primary_skin != alternate_skin and primary_skin != "" and alternate_skin != "" and xbmc.getCondVisibility('System.HasAddon(%s)' % primary_skin) and xbmc.getCondVisibility('System.HasAddon(%s)' % alternate_skin): if current_skin != primary_skin: xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue","params":{"setting":"lookandfeel.skin","value":"%s"}, "id":1}' % primary_skin) xbmc.executebuiltin('SetFocus(11)') xbmc.executebuiltin('Action(Select)') else: xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue","params":{"setting":"lookandfeel.skin","value":"%s"}, "id":1}' % alternate_skin) xbmc.executebuiltin('SetFocus(11)') xbmc.executebuiltin('Action(Select)') xbmc.sleep(2000) if contexting == False and xbmc.getCondVisibility("Skin.HasSetting(Contexting)") == True: toggle_context_player() elif contexting == True and xbmc.getCondVisibility("Skin.HasSetting(Contexting)") == False: toggle_context_player() else: pass if toggling == False and xbmc.getCondVisibility("Skin.HasSetting(Toggling)") == True: toggle_preferred_toggle() elif toggling == True and xbmc.getCondVisibility("Skin.HasSetting(Toggling)") == False: toggle_preferred_toggle() else: pass
def export_movies_library(): folder_path = plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode) if not xbmcvfs.exists(folder_path): return dialogs.notify(msg='Movies folder', title='Absent', delay=5000, image=get_icon_path("movies")) ids = "" movies = xbmcvfs.listdir(folder_path)[0] if len(movies) < 1: return dialogs.notify(msg='Movies folder', title='Empty', delay=5000, image=get_icon_path("movies")) else: for movie in movies: ids = ids + str(movie) + '\n' movies_backup_file_path = "special://profile/addon_data/plugin.video.metalliq/movies_to_add.bak" if xbmcvfs.exists(movies_backup_file_path): os.remove(xbmc.translatePath(movies_backup_file_path)) if not xbmcvfs.exists(movies_backup_file_path): batch_add_file = xbmcvfs.File(movies_backup_file_path, 'w') batch_add_file.write(ids) batch_add_file.close() dialogs.notify(msg="Movies", title="Backed up", delay=5000, image=get_icon_path("movies"))
def lists_trakt_add_liked_to_library(): lists, pages = trakt.trakt_get_liked_lists(1) misc_ids = [] movie_ids = [] tv_ids = [] import xbmcgui pDialog = xbmcgui.DialogProgress() pDialog.create('[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR]', 'Creating batch import files') for page in range(0, int(pages)): lists, ignore = trakt.trakt_get_liked_lists(page) list_number = 1 if (pDialog.iscanceled()): return percent = (int(page) / int(pages)) * 100 pDialog.update(int(percent), '{0} {1} of {2} ... '.format(_("Scanning for new content"), page, pages)) for list in lists: list_number += 1 pDialog.update(int(percent), '{0} {1} of {2} ... '.format(_("Scanning for new content"), page, pages), 'list {0} of {1} on page'.format(list_number, len(lists) + 1)) info = list["list"] user = info["user"]["username"] slug = info["ids"]["slug"] items = lists_trakt_show_list(user, slug) list_misc_ids, list_movie_ids, list_tv_ids = batch_find_list_ids(items) write_list_id_files(list_misc_ids, list_movie_ids, list_tv_ids, slug, user) misc_ids.extend(list_misc_ids) movie_ids.extend(list_movie_ids) tv_ids.extend(list_tv_ids) pDialog.close() write_batch_id_files(tv_ids, movie_ids, misc_ids) dialogs.notify(msg='Generating', title='.strm-files', delay=3000, image=get_icon_path("metalliq")) xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/movies/batch_add_to_library)")
def export_tv_library(): folder_path = plugin.get_setting(SETTING_TV_LIBRARY_FOLDER, unicode) if not xbmcvfs.exists(folder_path): return dialogs.notify(msg='TVShows folder', title='Absent', delay=5000, image=get_icon_path("tv")) ids = "" shows = xbmcvfs.listdir(folder_path)[0] if len(shows) < 1: return dialogs.notify(msg='TVShows folder', title='Empty', delay=5000, image=get_icon_path("tv")) else: for show in shows: ids = ids + str(show) + '\n' shows_backup_file_path = "special://profile/addon_data/plugin.video.metalliq/shows_to_add.bak" if xbmcvfs.exists(shows_backup_file_path): os.remove(xbmc.translatePath(shows_backup_file_path)) if not xbmcvfs.exists(shows_backup_file_path): batch_add_file = xbmcvfs.File(shows_backup_file_path, 'w') batch_add_file.write(ids) batch_add_file.close() dialogs.notify(msg="TVShows", title="Backed up", delay=5000, image=get_icon_path("tv"))
def movies_add_to_library(src, id): """ Add movie to library """ library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode)) date = None if src == "tmdb": import_tmdb() movie = tmdb.Movies(id).info() date = date_to_timestamp(movie.get('release_date')) imdb_id = movie.get('imdb_id') if imdb_id: src = "imdb" id = imdb_id players = active_players("movies") if plugin.get_setting(SETTING_MOVIES_DEFAULT_AUTO_ADD, bool) == True: player = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY, unicode) else: players.insert(0, ADDON_SELECTOR) players.insert(0, ADDON_DEFAULT) selection = dialogs.select(_("Play using..."), [p.title for p in players]) if selection == -1: return player = players[selection] # setup library folder library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode)) # add to library if plugin.get_setting(SETTING_MOVIES_DEFAULT_AUTO_ADD, bool) == True: add_movie_to_library(library_folder, src, id, play_plugin=plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY, unicode)) else: add_movie_to_library(library_folder, src, id, play_plugin=player.id) dialogs.notify(msg=player.id, title=_("%s not found").replace("%s ",""), delay=3000, image=get_icon_path("movies")) scan_library(type="video")
def play_channel_from_guide(channel, program, language, mode): # Get channelers to use if mode == 'select': play_plugin = ADDON_PICKER.id elif mode == 'default': play_plugin = plugin.get_setting(SETTING_LIVE_DEFAULT_CHANNELER, unicode) else: play_plugin = mode channelers = active_channelers("live") channelers = [p for p in channelers if p.id == play_plugin] or channelers if not channelers: dialogs.notify(msg="{0} {1} {2}".format(_("No cache").replace(_("Cache").lower(),_("TV")), _("Player").lower(), _("Enabled").lower()), title=_("Error"), delay=5000, image=get_icon_path("live")) action_cancel() return # Get parameters params = {} for lang in get_needed_langs(channelers): params[lang] = get_channel_parameters(channel, program, language) params[lang] = to_unicode(params[lang]) # Go for it link = on_play_video(mode, channelers, params) if link: action_play({ 'label': channel, 'path': link, 'is_playable': True, 'info_type': 'video', })
def movies_add_to_library(src, id): """ Add movie to library """ library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode)) date = None if src == "tmdb": import_tmdb() movie = tmdb.Movies(id).info() date = date_to_timestamp(movie.get('release_date')) imdb_id = movie.get('imdb_id') if imdb_id: src = "imdb" id = imdb_id players = active_players("movies") if plugin.get_setting(SETTING_MOVIES_DEFAULT_AUTO_ADD, bool) == True: player = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY, unicode) else: players.insert(0, ADDON_SELECTOR) players.insert(0, ADDON_DEFAULT) selection = dialogs.select(_("Play using..."), [p.title for p in players]) if selection == -1: return player = players[selection] # setup library folder library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode)) # add to library if plugin.get_setting(SETTING_MOVIES_DEFAULT_AUTO_ADD, bool) == True: add_movie_to_library(library_folder, src, id, play_plugin=plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY, unicode)) else: add_movie_to_library(library_folder, src, id, play_plugin=player.id) dialogs.notify(msg=player.id, title=_("%s not found").replace("%s ",""), delay=3000, image=get_icon_path("movies")) scan_library(type="video")
def toggle_between_skins(): if xbmc.getCondVisibility("Skin.HasSetting(Contexting)") != True: contexting = False else: contexting = True if xbmc.getCondVisibility("Skin.HasSetting(Toggling)") != True: toggling = False else: toggling = True current_skin = str(xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.GetSettingValue","params":{"setting":"lookandfeel.skin"}, "id":1}')).replace('{"id":1,"jsonrpc":"2.0","result":{"value":"','').replace('"}}','') primary_skin = plugin.get_setting(SETTING_PRIMARY_SKIN, unicode) if primary_skin == "": plugin.set_setting(SETTING_PRIMARY_SKIN, current_skin) alternate_skin = plugin.get_setting(SETTING_ALTERNATE_SKIN, unicode) if alternate_skin == "": if primary_skin != "skin.confluence" and primary_skin != "": plugin.set_setting(SETTING_ALTERNATE_SKIN, "skin.confluence") else: dialogs.notify(msg="Alternate skin", title="Not set", delay=5000, image=get_icon_path("metalliq")) return openSettings(addonid, 5.7) if primary_skin != alternate_skin and primary_skin != "" and alternate_skin != "" and xbmc.getCondVisibility('System.HasAddon(%s)' % primary_skin) and xbmc.getCondVisibility('System.HasAddon(%s)' % alternate_skin): if current_skin != primary_skin: xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue","params":{"setting":"lookandfeel.skin","value":"%s"}, "id":1}' % primary_skin) xbmc.executebuiltin('SetFocus(11)') xbmc.executebuiltin('Action(Select)') else: xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.SetSettingValue","params":{"setting":"lookandfeel.skin","value":"%s"}, "id":1}' % alternate_skin) xbmc.executebuiltin('SetFocus(11)') xbmc.executebuiltin('Action(Select)') xbmc.sleep(2000) if contexting == False and xbmc.getCondVisibility("Skin.HasSetting(Contexting)") == True: toggle_context_player() elif contexting == True and xbmc.getCondVisibility("Skin.HasSetting(Contexting)") == False: toggle_context_player() else: pass if toggling == False and xbmc.getCondVisibility("Skin.HasSetting(Toggling)") == True: toggle_preferred_toggle() elif toggling == True and xbmc.getCondVisibility("Skin.HasSetting(Toggling)") == False: toggle_preferred_toggle() else: pass
def lists_trakt_add_liked_to_library(): lists, pages = trakt.trakt_get_liked_lists(1) misc_ids = [] movie_ids = [] tv_ids = [] import xbmcgui pDialog = xbmcgui.DialogProgress() pDialog.create('[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR]', 'Creating batch import files') for page in range(0, int(pages)): lists, ignore = trakt.trakt_get_liked_lists(page) list_number = 1 if (pDialog.iscanceled()): return percent = (int(page) / int(pages)) * 100 pDialog.update(int(percent), '{0} {1} of {2} ... '.format(_("Scanning for new content"), page, pages)) for list in lists: list_number += 1 pDialog.update(int(percent), '{0} {1} of {2} ... '.format(_("Scanning for new content"), page, pages), 'list {0} of {1} on page'.format(list_number, len(lists) + 1)) info = list["list"] user = info["user"]["username"] slug = info["ids"]["slug"] items = lists_trakt_show_list(user, slug) list_misc_ids, list_movie_ids, list_tv_ids = batch_find_list_ids(items) write_list_id_files(list_misc_ids, list_movie_ids, list_tv_ids, slug, user) misc_ids.extend(list_misc_ids) movie_ids.extend(list_movie_ids) tv_ids.extend(list_tv_ids) pDialog.close() write_batch_id_files(tv_ids, movie_ids, misc_ids) dialogs.notify(msg='Generating', title='.strm-files', delay=3000, image=get_icon_path("metalliq")) xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/movies/batch_add_to_library)")
def lists_trakt_add_all_to_library(user, slug): items = lists_trakt_show_list(user, slug, raw=True) misc_ids, movie_ids, tv_ids = batch_find_list_ids(items) write_list_id_files(misc_ids, tv_ids, movie_ids, slug, user) write_batch_id_files(tv_ids, movie_ids, misc_ids) dialogs.notify(msg='Conversion done', title='starting batch-add', delay=3000, image=get_icon_path("metalliq")) xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/movies/batch_add_to_library)")
def movies_batch_add_to_library(): """ Batch add movies to library """ movie_batch_file = plugin.get_setting(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: return dialogs.notify(msg='Movies Batch Add File', title=_("%s not found").replace("%s ",""), delay=3000, image=get_icon_path("movies")) library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode)) import_tmdb() for id in ids: if "," in id: csvs = id.split(',') for csv in csvs: if not str(csv).startswith("tt") and csv != "": movie = tmdb.Movies(csv).info() csv = movie.get('imdb_id') batch_add_movies_to_library(library_folder, csv) else: if not str(id).startswith("tt") and id != "": movie = tmdb.Movies(id).info() id = movie.get('imdb_id') batch_add_movies_to_library(library_folder, id) os.remove(xbmc.translatePath(movie_batch_file)) if xbmcvfs.exists(plugin.get_setting(SETTING_TV_BATCH_ADD_FILE_PATH, unicode)): xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/tv/batch_add_to_library)") return True else: xbmc.sleep(1000) dialogs.notify(msg='Added movie strm-files', title='Starting library scan', delay=3000, image=get_icon_path("movies")) scan_library(type="video") return True if xbmcvfs.exists(plugin.get_setting(SETTING_TV_BATCH_ADD_FILE_PATH, unicode)): xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/tv/batch_add_to_library)")
def lists_trakt_add_all_to_library(user, slug): items = lists_trakt_show_list(user, slug, raw=True) misc_ids, movie_ids, tv_ids = batch_find_list_ids(items) write_list_id_files(misc_ids, tv_ids, movie_ids, slug, user) write_batch_id_files(tv_ids, movie_ids, misc_ids) dialogs.notify(msg='Conversion done', title='starting batch-add', delay=3000, image=get_icon_path("metalliq")) xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/movies/batch_add_to_library)")
def batch_add_tvshows_to_library(library_folder, show): id = show['id'] showname = to_utf8(show['seriesname']) playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode) if not xbmcvfs.exists(playlist_folder): try: xbmcvfs.mkdir(playlist_folder) except: dialogs.notify(msg=_('Creation of [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] Playlist Folder'), title=_('Failed'), delay=5000, image=get_icon_path("lists")) playlist_file = os.path.join(playlist_folder, id+".xsp") if not xbmcvfs.exists(playlist_file): playlist_file = xbmcvfs.File(playlist_file, 'w') content = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><smartplaylist type="tvshows"><name>%s</name><match>all</match><rule field="path" operator="contains"><value>%s%s</value></rule><rule field="playcount" operator="is"><value>0</value></rule><order direction="ascending">numepisodes</order></smartplaylist>' % (showname, plugin.get_setting(SETTING_TV_LIBRARY_FOLDER, unicode).replace('special://profile',''), str(id)) playlist_file.write(str(content)) playlist_file.close() show_folder = os.path.join(library_folder, str(id)+'/') if not xbmcvfs.exists(show_folder): try: xbmcvfs.mkdir(show_folder) except: pass player_filepath = os.path.join(show_folder, 'player.info') player_file = xbmcvfs.File(player_filepath, 'w') content = "default" player_file.write(content) player_file.close() nfo_filepath = os.path.join(show_folder, 'tvshow.nfo') if not xbmcvfs.exists(nfo_filepath): nfo_file = xbmcvfs.File(nfo_filepath, 'w') content = "http://thetvdb.com/index.php?tab=series&id=%s" % str(id) nfo_file.write(content) nfo_file.close() clean_needed = True return clean_needed
def players_setup(): xbmc.executebuiltin('SetProperty(running,totalmetalliq,home)') url = "https://api.github.com/repos/OpenELEQ/verified-metalliq-players/zipball" if updater.update_players(url): dialogs.notify(msg=_('Player'), title=_('Updated for %s') % _('Player'), delay=1000, image=get_icon_path("player")) else: dialogs.notify(msg=_('Player'), title=_('Failed for %s') % _('Player'), delay=1000, image=get_icon_path("player")) xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/settings/players/all/)") xbmc.executebuiltin('ClearProperty(running,home)') return True
def players_setup(): xbmc.executebuiltin('SetProperty(running,totalmetalliq,home)') url = "https://api.github.com/repos/OpenELEQ/verified-metalliq-players/zipball" if updater.update_players(url): dialogs.notify(msg=_('Player'), title=_('Updated for %s') % _('Player'), delay=1000, image=get_icon_path("player")) else: dialogs.notify(msg=_('Player'), title=_('Failed for %s') % _('Player'), delay=1000, image=get_icon_path("player")) xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/settings/players/all/)") xbmc.executebuiltin('ClearProperty(running,home)') return True
def total_setup(): dialogs.notify(msg='Total Setup', title=_("Start"), delay=1000, image=get_icon_path("metalliq")) if sources_setup() == True: pass if players_setup() == True: pass dialogs.notify(msg='Total Setup', title=_("Done"), delay=5000, image=get_icon_path("metalliq"))
def toggle_preferred_toggle(): if xbmc.getCondVisibility("Skin.HasSetting(Toggling)") != True: dialogs.notify(msg="Toggling", title="Switched on", delay=5000, image=get_icon_path("metalliq")) else: dialogs.notify(msg="Toggling", title="Switched off", delay=5000, image=get_icon_path("metalliq")) xbmc.executebuiltin("Skin.ToggleSetting(Toggling)")
def toggle_context_player(): if xbmc.getCondVisibility("Skin.HasSetting(Contexting)") != True: dialogs.notify(msg="Context player", title="Switched off", delay=5000, image=get_icon_path("metalliq")) else: dialogs.notify(msg="Context player", title="Switched on", delay=5000, image=get_icon_path("metalliq")) xbmc.executebuiltin("Skin.ToggleSetting(Contexting)")
def update_players(url=None): if url is None: url = plugin.get_setting(SETTING_PLAYERS_UPDATE_URL, unicode) if updater.update_players(url): dialogs.notify(msg=_('Update'), title=_('Updated for %s') % _('Player'), delay=1000, image=get_icon_path("player")) else: dialogs.notify(msg=_('Update'), title=_('Failed for %s') % _('Player'), delay=1000, image=get_icon_path("player")) plugin.open_settings()
def export_tv_library(): folder_path = plugin.get_setting(SETTING_TV_LIBRARY_FOLDER, unicode) if not xbmcvfs.exists(folder_path): return dialogs.notify(msg='TVShows folder', title='Absent', delay=5000, image=get_icon_path("tv")) ids = "" shows = xbmcvfs.listdir(folder_path)[0] if len(shows) < 1: return dialogs.notify(msg='TVShows folder', title='Empty', delay=5000, image=get_icon_path("tv")) else : for show in shows: ids = ids + str(show) + '\n' shows_backup_file_path = "special://profile/addon_data/plugin.video.metalliq/shows_to_add.bak" if xbmcvfs.exists(shows_backup_file_path): os.remove(xbmc.translatePath(shows_backup_file_path)) if not xbmcvfs.exists(shows_backup_file_path): batch_add_file = xbmcvfs.File(shows_backup_file_path, 'w') batch_add_file.write(ids) batch_add_file.close() dialogs.notify(msg="TVShows", title="Backed up", delay=5000, image=get_icon_path("tv"))
def export_movies_library(): folder_path = plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode) if not xbmcvfs.exists(folder_path): return dialogs.notify(msg='Movies folder', title='Absent', delay=5000, image=get_icon_path("movies")) ids = "" movies = xbmcvfs.listdir(folder_path)[0] if len(movies) < 1: return dialogs.notify(msg='Movies folder', title='Empty', delay=5000, image=get_icon_path("movies")) else : for movie in movies: ids = ids + str(movie) + '\n' movies_backup_file_path = "special://profile/addon_data/plugin.video.metalliq/movies_to_add.bak" if xbmcvfs.exists(movies_backup_file_path): os.remove(xbmc.translatePath(movies_backup_file_path)) if not xbmcvfs.exists(movies_backup_file_path): batch_add_file = xbmcvfs.File(movies_backup_file_path, 'w') batch_add_file.write(ids) batch_add_file.close() dialogs.notify(msg="Movies", title="Backed up", delay=5000, image=get_icon_path("movies"))
def make_movie_item(movie_info, is_list = False): try: tmdb_id = movie_info.get('tmdb') except: tmdb_id = "" if tmdb_id == "": try: tmdb_id = info['tmdb'] except: tmdb_id = False try: imdb_id = movie_info.get('imdb') except: imdb_id = "" if imdb_id == "": try: imdb_id = info['imdb'] except: imdb_id = False if movie_info['poster'] == None or movie_info['poster'] == "": movie_info['poster'] = "https://raw.githubusercontent.com/OpenELEQ/Style/master/MetalliQ/default/unavailable.png" if movie_info['fanart'] == None or movie_info['fanart'] == "": movie_info['fanart'] = get_background_path() if tmdb_id: id = tmdb_id src = 'tmdb' elif imdb_id: id = imdb_id src = 'imdb' else: dialogs.notify(msg="tmdb or imdb id", title=_("%s not found").replace("%s ",""), delay=3000, image=get_icon_path("movies")) if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): context_menu = [(_("Scan item to library"),"RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id))), ("%s %s" % (_("Movie"), _("Trailer").lower()),"RunScript(script.qlickplay,info=playtrailer,id={0})".format(id)), ("[COLOR ff0084ff]Q[/COLOR]lick[COLOR ff0084ff]P[/COLOR]lay", "RunScript(script.qlickplay,info=movieinfo,id={0})".format(id)), ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"),"ActivateWindow(10025,plugin://script.qlickplay/?info=similarmovies&id={0})".format(id))] elif xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"): context_menu = [(_("Scan item to library"),"RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id))), ("%s %s" % (_("Movie"), _("Trailer").lower()),"RunScript(script.extendedinfo,info=playtrailer,id={0})".format(id)), (_("Extended movie info"), "RunScript(script.extendedinfo,info=extendedinfo,id={0})".format(id)), ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"),"ActivateWindow(10025,plugin://script.extendedinfo/?info=similarmovies&id={0})".format(id))] else: context_menu = [(_("Scan item to library"),"RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id)))] context_menu.append(("%s %s (%s)" % ("Related", _("movies"), "Trakt"),"ActivateWindow(10025,{0})".format(plugin.url_for("movies_related", id=id, page=1)))) context_menu.append(("{0} {1}...".format(_("Select"), _("Stream").lower()),"PlayMedia({0})".format(plugin.url_for("movies_play", src=src, id=id, mode='select')))) context_menu.append((_("Add to playlist"),"RunPlugin({0})".format(plugin.url_for("lists_add_movie_to_list", src=src, id=id)))) context_menu.append((_("Movie information"),'Action(Info)')) if is_list: context_menu.append( ( "{0}".format(_("Remove from library").replace(_("Library").lower(),_("Playlist").lower())), "RunPlugin({0})".format(plugin.url_for("lists_remove_movie_from_list", src=src, id=id)) ) ) return { 'label': movie_info['title'], 'path': plugin.url_for("movies_play", src=src, id=id, mode='default'), 'context_menu': context_menu, 'thumbnail': movie_info['poster'], 'icon': movie_info['poster'], 'banner': movie_info['fanart'], 'poster': movie_info['poster'], 'properties' : {'fanart_image' : movie_info['fanart']}, 'is_playable': True, 'info_type': 'video', 'stream_info': {'video': {}}, 'info': movie_info }
def make_movie_item(movie_info, is_list = False): try: tmdb_id = movie_info.get('tmdb') except: tmdb_id = "" if tmdb_id == "": try: tmdb_id = info['tmdb'] except: tmdb_id = False try: imdb_id = movie_info.get('imdb') except: imdb_id = "" if imdb_id == "": try: imdb_id = info['imdb'] except: imdb_id = False if movie_info['poster'] == None or movie_info['poster'] == "": movie_info['poster'] = "http://mrblamo.xyz/chappaaiunavailable.png" if movie_info['fanart'] == None or movie_info['fanart'] == "": movie_info['fanart'] = get_background_path() if tmdb_id: id = tmdb_id src = 'tmdb' elif imdb_id: id = imdb_id src = 'imdb' else: dialogs.notify(msg="tmdb or imdb id", title=_("%s not found").replace("%s ",""), delay=3000, image=get_icon_path("movies")) if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): context_menu = [(_("Scan item to library"),"RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id))), ("%s %s" % (_("Movie"), _("Trailer").lower()),"RunScript(script.qlickplay,info=playtrailer,id={0})".format(id)), ("[COLOR purple]Mr Blamo[/COLOR]lick[COLOR ff0084ff]P[/COLOR]lay", "RunScript(script.qlickplay,info=movieinfo,id={0})".format(id)), ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"),"ActivateWindow(10025,plugin://script.qlickplay/?info=similarmovies&id={0})".format(id))] elif xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"): context_menu = [(_("Scan item to library"),"RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id))), ("%s %s" % (_("Movie"), _("Trailer").lower()),"RunScript(script.extendedinfo,info=playtrailer,id={0})".format(id)), (_("Extended movie info"), "RunScript(script.extendedinfo,info=extendedinfo,id={0})".format(id)), ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"),"ActivateWindow(10025,plugin://script.extendedinfo/?info=similarmovies&id={0})".format(id))] else: context_menu = [(_("Scan item to library"),"RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id)))] context_menu.append(("%s %s (%s)" % ("Related", _("movies"), "Trakt"),"ActivateWindow(10025,{0})".format(plugin.url_for("movies_related", id=id, page=1)))) context_menu.append(("{0} {1}...".format(_("Select"), _("Stream").lower()),"PlayMedia({0})".format(plugin.url_for("movies_play", src=src, id=id, mode='select')))) context_menu.append((_("Add to playlist"),"RunPlugin({0})".format(plugin.url_for("lists_add_movie_to_list", src=src, id=id)))) context_menu.append((_("Movie information"),'Action(Info)')) if is_list: context_menu.append( ( "{0}".format(_("Remove from library").replace(_("Library").lower(),_("Playlist").lower())), "RunPlugin({0})".format(plugin.url_for("lists_remove_movie_from_list", src=src, id=id)) ) ) return { 'label': movie_info['title'], 'path': plugin.url_for("movies_play", src=src, id=id, mode='default'), 'context_menu': context_menu, 'thumbnail': movie_info['poster'], 'icon': movie_info['poster'], 'banner': movie_info['fanart'], 'poster': movie_info['poster'], 'properties' : {'fanart_image' : movie_info['fanart']}, 'is_playable': True, 'info_type': 'video', 'stream_info': {'video': {}}, 'info': movie_info }
def remove_unlisted_movie(movie_delete_list): msg_str = str(len(movie_delete_list)) + ' movies not in list' dialogs.notify(msg=msg_str, title='Deleting unlisted movies', delay=3000, image=get_icon_path("metalliq")) # Remove unlisted movies and series clean_needed = False movies_library_folder = setup_library( plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode)) for id in movie_delete_list: movie_folder = os.path.join(movies_library_folder, str(id) + '/') if os.path.exists(movie_folder): shutil.rmtree(movie_folder) clean_needed = True if clean_needed: set_property("clean_library", 1)
def lists_trakt_add_my_lists_to_library(): misc_ids = [] movie_ids = [] tv_ids = [] import xbmcgui lists = trakt.trakt_get_lists() dialogs.notify(msg='Adding ' + str(len(lists)) + " lists", title='to Kodi library', delay=3000, image=get_icon_path("metalliq")) for list in lists: user = list["user"]["username"] slug = list["ids"]["slug"] items = lists_trakt_show_list(user, slug) list_misc_ids, list_movie_ids, list_tv_ids = batch_find_list_ids(items) write_list_id_files(list_misc_ids, list_tv_ids, list_movie_ids, slug, user) misc_ids.extend(list_misc_ids) movie_ids.extend(list_movie_ids) tv_ids.extend(list_tv_ids) write_batch_id_files(tv_ids, movie_ids, misc_ids) dialogs.notify(msg='Generating', title='.strm-files', delay=3000, image=get_icon_path("metalliq")) xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/movies/batch_add_to_library)")
def write_batch_id_files(tv_ids, movie_ids, misc_ids): if len(tv_ids) > 0: shows_import_file_path = "special://profile/addon_data/plugin.video.metalliq/shows_to_add.txt" if xbmcvfs.exists(shows_import_file_path): os.remove(xbmc.translatePath(shows_import_file_path)) tv_id_list = "" for id in tv_ids: tv_id_list = tv_id_list + str(id) + '\n' if not xbmcvfs.exists(shows_import_file_path): batch_add_file = xbmcvfs.File(shows_import_file_path, 'w') batch_add_file.write(tv_id_list) batch_add_file.close() dialogs.notify(msg='Converting tvshows, seasons & episodes', title='to id-list for batch-adding', delay=3000, image=get_icon_path("tvshows")) if len(movie_ids) > 0: movies_import_file_path = "special://profile/addon_data/plugin.video.metalliq/movies_to_add.txt" if xbmcvfs.exists(movies_import_file_path): os.remove(xbmc.translatePath(movies_import_file_path)) movie_id_list = "" for id in movie_ids: movie_id_list = movie_id_list + str(id) + '\n' if not xbmcvfs.exists(movies_import_file_path): batch_add_file = xbmcvfs.File(movies_import_file_path, 'w') batch_add_file.write(movie_id_list) batch_add_file.close() dialogs.notify(msg='Converting movies', title='to id-list for batch-adding', delay=3000, image=get_icon_path("movies")) if len(misc_ids) > 0: misc_import_file_path = "special://profile/addon_data/plugin.video.metalliq/misc_to_add.txt" if xbmcvfs.exists(misc_import_file_path): os.remove(xbmc.translatePath(misc_import_file_path)) misc_id_list = "" for id in misc_ids: misc_id_list = misc_id_list + str(id) + '\n' if not xbmcvfs.exists(misc_import_file_path): batch_add_file = xbmcvfs.File(misc_import_file_path, 'w') batch_add_file.write(misc_id_list) batch_add_file.close() dialogs.notify(msg='Converting miscellaneous', title='to id-list for batch-adding', delay=3000, image=get_icon_path("tvshows"))
def write_batch_id_files(tv_ids, movie_ids, misc_ids): if len(tv_ids) > 0: shows_import_file_path = "special://profile/addon_data/plugin.video.metalliq/shows_to_add.txt" if xbmcvfs.exists(shows_import_file_path): os.remove(xbmc.translatePath(shows_import_file_path)) tv_id_list = "" for id in tv_ids: tv_id_list = tv_id_list + str(id) + '\n' if not xbmcvfs.exists(shows_import_file_path): batch_add_file = xbmcvfs.File(shows_import_file_path, 'w') batch_add_file.write(tv_id_list) batch_add_file.close() dialogs.notify(msg='Converting tvshows, seasons & episodes', title='to id-list for batch-adding', delay=3000, image=get_icon_path("tvshows")) if len(movie_ids) > 0: movies_import_file_path = "special://profile/addon_data/plugin.video.metalliq/movies_to_add.txt" if xbmcvfs.exists(movies_import_file_path): os.remove(xbmc.translatePath(movies_import_file_path)) movie_id_list = "" for id in movie_ids: movie_id_list = movie_id_list + str(id) + '\n' if not xbmcvfs.exists(movies_import_file_path): batch_add_file = xbmcvfs.File(movies_import_file_path, 'w') batch_add_file.write(movie_id_list) batch_add_file.close() dialogs.notify(msg='Converting movies', title='to id-list for batch-adding', delay=3000, image=get_icon_path("movies")) if len(misc_ids) > 0: misc_import_file_path = "special://profile/addon_data/plugin.video.metalliq/misc_to_add.txt" if xbmcvfs.exists(misc_import_file_path): os.remove(xbmc.translatePath(misc_import_file_path)) misc_id_list = "" for id in misc_ids: misc_id_list = misc_id_list + str(id) + '\n' if not xbmcvfs.exists(misc_import_file_path): batch_add_file = xbmcvfs.File(misc_import_file_path, 'w') batch_add_file.write(misc_id_list) batch_add_file.close() dialogs.notify(msg='Converting miscellaneous', title='to id-list for batch-adding', delay=3000, image=get_icon_path("tvshows"))
def batch_find_list_ids(items): tv_ids = [] misc_ids = [] movie_ids = [] import_tvdb() for item in items: if not isinstance(item, type): if "'tvdb': " in str(item) or "'tvdb_id': " in str(item): if "'tvdb': " in str(item): pre_tvdb = str(item).split("'tvdb': ") elif "'tvdb_id': " in str(item): pre_tvdb = str(item).split("'tvdb_id': ") if len(pre_tvdb) == 2: pro_tvdb = str(pre_tvdb[1]).split(",") elif len(pre_tvdb) == 3: pro_tvdb = str(pre_tvdb[2]).split(",") tvdb_id = str(pro_tvdb[0]) if not tvdb_id or tvdb_id == None or tvdb_id =="None": pre_imdb = str(item).split("u'imdb': u'") pro_imdb = str(pre_imdb[1]).split("'") imdb = str(pro_imdb[0]) tvdb_id = tvdb.search_by_imdb(imdb) if not tvdb_id: misc_ids.append(imdb) if not tvdb_id in tv_ids and tvdb_id != None and tvdb_id !="None": tv_ids.append(tvdb_id) elif "'tmdb': " in str(item): pre_tmdb = str(item).split("'tmdb': ") pro_tmdb = str(pre_tmdb[1]).split(",") tmdb = str(pro_tmdb[0]) if not tmdb or tmdb == None or tmdb =="None": pre_imdb = str(item).split("u'imdb': u'") pro_imdb = str(pre_imdb[1]).split("'") imdb = str(pro_imdb[0]) tvdb_id = tvdb.search_by_imdb(imdb) if not imdb and not tvdb_id: return dialogs.notify(msg="No id found for item", title='', delay=3000, image=get_icon_path("metalliq")) if imdb and not tvdb_id: if imdb not in movie_ids and imdb != None and imdb !="None": movie_ids.append(imdb) elif tvdb_id: if not tvdb_id in tv_ids and tvdb_id != None and tvdb_id !="None": tv_ids.append(tvdb_id) if not tmdb in movie_ids and tmdb != None and tmdb !="None": movie_ids.append(tmdb) else: if "tvshowtitle" in str(item["info"]): if item["info"]["tvdb_id"] != None and item["info"]["tvdb_id"] != "" and str(item["info"]["tvdb_id"]) not in tv_ids: tv_ids.append(str(item["info"]["tvdb_id"])) elif item["info"]["imdb_id"] != None and item["info"]["imdb_id"] != "" and str(item["info"]["imdb_id"]) not in tv_ids: tv_ids.append(str(item["info"]["imdb_id"])) else: if item["info"]["tmdb"] != None and item["info"]["tmdb"] != "" and str(item["info"]["tmdb"]) not in movie_ids: movie_ids.append(str(item["info"]["tmdb"])) elif item["info"]["imdb_id"] != None and item["info"]["imdb_id"] != "" and str(item["info"]["imdb_id"]) not in movie_ids: movie_ids.append(str(item["info"]["imdb_id"])) return misc_ids, movie_ids, tv_ids
def batch_find_list_ids(items): tv_ids = [] misc_ids = [] movie_ids = [] import_tvdb() for item in items: if not isinstance(item, type): if "'tvdb': " in str(item) or "'tvdb_id': " in str(item): if "'tvdb': " in str(item): pre_tvdb = str(item).split("'tvdb': ") elif "'tvdb_id': " in str(item): pre_tvdb = str(item).split("'tvdb_id': ") if len(pre_tvdb) == 2: pro_tvdb = str(pre_tvdb[1]).split(",") elif len(pre_tvdb) == 3: pro_tvdb = str(pre_tvdb[2]).split(",") tvdb_id = str(pro_tvdb[0]) if not tvdb_id or tvdb_id == None or tvdb_id =="None": pre_imdb = str(item).split("u'imdb': u'") pro_imdb = str(pre_imdb[1]).split("'") imdb = str(pro_imdb[0]) tvdb_id = tvdb.search_by_imdb(imdb) if not tvdb_id: misc_ids.append(imdb) if not tvdb_id in tv_ids and tvdb_id != None and tvdb_id !="None": tv_ids.append(tvdb_id) elif "'tmdb': " in str(item): pre_tmdb = str(item).split("'tmdb': ") pro_tmdb = str(pre_tmdb[1]).split(",") tmdb = str(pro_tmdb[0]) if not tmdb or tmdb == None or tmdb =="None": pre_imdb = str(item).split("u'imdb': u'") pro_imdb = str(pre_imdb[1]).split("'") imdb = str(pro_imdb[0]) tvdb_id = tvdb.search_by_imdb(imdb) if not imdb and not tvdb_id: return dialogs.notify(msg="No id found for item", title='', delay=3000, image=get_icon_path("metalliq")) if imdb and not tvdb_id: if imdb not in movie_ids and imdb != None and imdb !="None": movie_ids.append(imdb) elif tvdb_id: if not tvdb_id in tv_ids and tvdb_id != None and tvdb_id !="None": tv_ids.append(tvdb_id) if not tmdb in movie_ids and tmdb != None and tmdb !="None": movie_ids.append(tmdb) else: if "tvshowtitle" in str(item["info"]): if item["info"]["tvdb_id"] != None and item["info"]["tvdb_id"] != "" and str(item["info"]["tvdb_id"]) not in tv_ids: tv_ids.append(str(item["info"]["tvdb_id"])) elif item["info"]["imdb_id"] != None and item["info"]["imdb_id"] != "" and str(item["info"]["imdb_id"]) not in tv_ids: tv_ids.append(str(item["info"]["imdb_id"])) else: if item["info"]["tmdb"] != None and item["info"]["tmdb"] != "" and str(item["info"]["tmdb"]) not in movie_ids: movie_ids.append(str(item["info"]["tmdb"])) elif item["info"]["imdb_id"] != None and item["info"]["imdb_id"] != "" and str(item["info"]["imdb_id"]) not in movie_ids: movie_ids.append(str(item["info"]["imdb_id"])) return misc_ids, movie_ids, tv_ids
if FORCE == True: plugin.set_view_mode(VIEW); return items else: return items @plugin.route('/clear_cache') def clear_cache(): """ Clear all caches """ for filename in os.listdir(plugin.storage_path): file_path = os.path.join(plugin.storage_path, filename) try: if os.path.isfile(file_path): os.unlink(file_path) elif os.path.isdir(file_path): shutil.rmtree(file_path) except Exception, e: traceback.print_exc() dialogs.notify(msg='Cache', title='Deleted', delay=5000, image=get_icon_path("metalliq")) @plugin.route('/update_library') def update_library(): is_updating = get_property("updating_library") is_syncing = get_property("syncing_library") now = time.time() if is_syncing and now - int(is_syncing) < plugin.get_setting(SETTING_UPDATE_LIBRARY_INTERVAL, int) * 60: plugin.log.info("Skipping library sync") else: if plugin.get_setting(SETTING_LIBRARY_SYNC_COLLECTION, bool) == True or plugin.get_setting( SETTING_LIBRARY_SYNC_WATCHLIST, bool) == True: try: set_property("syncing_library", int(now)) if plugin.get_setting(SETTING_LIBRARY_SYNC_COLLECTION, bool) == True: meta.library.tvshows.sync_trakt_collection()
def sources_setup(): movielibraryfolder = plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode) try: meta.library.movies.auto_movie_setup(movielibraryfolder) dialogs.notify(msg="{0}: {1} {2}".format(_('Movies'), _('Configure'), _("Library").lower()), title=_('Done'), delay=1000, image=get_icon_path("movies")) except: dialogs.notify(msg="{0}: {1} {2}".format(_("Movies"), _('Configure'), _("Library").lower()), title=_('Failed for %s') % _('Movies'), delay=1000, image=get_icon_path("movies")) tvlibraryfolder = plugin.get_setting(SETTING_TV_LIBRARY_FOLDER, unicode) try: meta.library.tvshows.auto_tvshows_setup(tvlibraryfolder) dialogs.notify(msg="{0}: {1} {2}".format(_('TV shows'), _('Configure'), _("Library").lower()), title=_('Done'), delay=1000, image=get_icon_path("tv")) except: dialogs.notify(msg="{0}: {1} {2}".format(_("TV shows"), _('Configure'), _("Library").lower()), title=_('Failed for %s') % _('TV shows'), delay=1000, image=get_icon_path("tv")) musiclibraryfolder = plugin.get_setting(SETTING_MUSIC_LIBRARY_FOLDER, unicode) try: meta.library.music.auto_music_setup(musiclibraryfolder) dialogs.notify(msg="{0}: {1} {2}".format(_('Music'), _('Configure'), _("Library").lower()), title=_('Done'), delay=1000, image=get_icon_path("music")) except: dialogs.notify(msg="{0}: {1} {2}".format(_("Music"), _('Configure'), _("Library").lower()), title=_('Failed for %s') % _('Music'), delay=1000, image=get_icon_path("music")) livelibraryfolder = plugin.get_setting(SETTING_LIVE_LIBRARY_FOLDER, unicode) try: meta.library.live.auto_live_setup(livelibraryfolder) dialogs.notify(msg="{0}: {1} {2}".format(_('TV'), _('Configure'), _("Library").lower()), title=_('Done'), delay=1000, image=get_icon_path("live")) except: dialogs.notify(msg="{0}: {1} {2}".format(_('TV'), _('Configure'), _("Library").lower()), title=_('Failed for %s') % _('TV'), delay=1000, image=get_icon_path("live")) return True
def settings_set_players(media): playericon = get_icon_path("player") medias = ["movies","tvshows","musicvideos","music","live"] if media == "all": for med in medias: mediatype = med.replace('es','e').replace('ws','w').replace('all','').replace('os','o').replace('vs','v s').replace('tv','TV').replace('musicvideo','Music video').replace('live','TV') players = get_players(med) selected = [p.id for p in players] if selected is not None: if med == "movies": plugin.set_setting(SETTING_MOVIES_ENABLED_PLAYERS, selected) elif med == "tvshows": plugin.set_setting(SETTING_TV_ENABLED_PLAYERS, selected) elif med == "musicvideos": plugin.set_setting(SETTING_MUSICVIDEOS_ENABLED_PLAYERS, selected) elif med == "music": plugin.set_setting(SETTING_MUSIC_ENABLED_PLAYERS, selected) elif med == "live": plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected) else: raise Exception("invalid parameter %s" % media) dialogs.notify(msg="{0} {1}".format(_(mediatype).capitalize(), _("Player").lower()), title=_('Enabled'), delay=1000, image=get_icon_path("player")) dialogs.notify(msg="{0}".format(_("Player")), title="{0} {1}".format(_("All"), _('Enabled').lower()), delay=1000, image=get_icon_path("player")) return True elif media == "tvportal": players = get_players("live") selected = [p.id for p in players] plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected) return else: mediatype = media.replace('es','e').replace('ws','w').replace('all','').replace('os','o').replace('vs','v s').replace('tv','TV').replace('musicvideo','Music video').replace('live','TV') players = get_players(media) players = sorted(players,key=lambda player: player.clean_title.lower()) version = xbmc.getInfoLabel('System.BuildVersion') selected = None if version.startswith('16') or version.startswith('17'): msg = "Do you want to enable all "+mediatype+"players?" if dialogs.yesno(_("Enable all "+mediatype+"players"), _(msg)): selected = [p.id for p in players] else: result = dialogs.multiselect(_("Select "+mediatype+"players to enable"), [p.clean_title for p in players]) if result is not None: selected = [players[i].id for i in result] else: selected = None msg = "Kodi 16 is required for multi-selection. Do you want to enable all "+mediatype+"players instead?" if dialogs.yesno("{0} {1} {2} {3}s".format(_("Enable"), _("All").lower(), mediatype, _("Player").lower()), _(msg)): selected = [p.id for p in players] else: result = dialogs.multichoice("{0}: {1} {2} {3}".format(_("Enable"), _("Select"), _("Player").lower()), [p.clean_title for p in players]) if result is not None: selected = [players[i].id for i in result] if selected is not None: if media == "movies": plugin.set_setting(SETTING_MOVIES_ENABLED_PLAYERS, selected) elif media == "tvshows": plugin.set_setting(SETTING_TV_ENABLED_PLAYERS, selected) elif media == "musicvideos": plugin.set_setting(SETTING_MUSICVIDEOS_ENABLED_PLAYERS, selected) elif media == "music": plugin.set_setting(SETTING_MUSIC_ENABLED_PLAYERS, selected) elif media == "live": plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected) else: raise Exception("invalid parameter %s" % media) dialogs.notify(msg="{0} {1} {2}".format(_("Enable"), _(mediatype).lower(), _("Player").lower()), title=_('Done'), delay=1000, image=get_icon_path("player")) plugin.open_settings()
def update_players(url = None): if url is None: url = plugin.get_setting(SETTING_PLAYERS_UPDATE_URL, unicode) if updater.update_players(url): dialogs.notify(msg=_('Update'), title=_('Updated for %s') % _('Player'), delay=1000, image=get_icon_path("player")) else: dialogs.notify(msg=_('Update'), title=_('Failed for %s') % _('Player'), delay=1000, image=get_icon_path("player")) plugin.open_settings()
def toggle_context_player(): if xbmc.getCondVisibility("Skin.HasSetting(Contexting)") != True: dialogs.notify(msg="Context player", title="Switched off", delay=5000, image=get_icon_path("metalliq")) else: dialogs.notify(msg="Context player", title="Switched on", delay=5000, image=get_icon_path("metalliq")) xbmc.executebuiltin("Skin.ToggleSetting(Contexting)")
@plugin.route('/clear_cache') def clear_cache(): """ Clear all caches """ for filename in os.listdir(plugin.storage_path): file_path = os.path.join(plugin.storage_path, filename) try: if os.path.isfile(file_path): os.unlink(file_path) elif os.path.isdir(file_path): shutil.rmtree(file_path) except Exception, e: traceback.print_exc() dialogs.notify(msg='Cache', title='Deleted', delay=5000, image=get_icon_path("metalliq")) @plugin.route('/update_library') def update_library(): is_updating = get_property("updating_library") is_syncing = get_property("syncing_library") now = time.time() if is_syncing and now - int(is_syncing) < plugin.get_setting( SETTING_UPDATE_LIBRARY_INTERVAL, int) * 60: plugin.log.info("Skipping library sync") else: if plugin.get_setting(SETTING_LIBRARY_SYNC_COLLECTION, bool) == True or plugin.get_setting( SETTING_LIBRARY_SYNC_WATCHLIST,
def total_setup(): dialogs.notify(msg='Total Setup', title=_("Start"), delay=1000, image=get_icon_path("metalliq")) if sources_setup() == True: pass if players_setup() == True: pass dialogs.notify(msg='Total Setup', title=_("Done"), delay=5000, image=get_icon_path("metalliq"))
def sources_setup(): movielibraryfolder = plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode) try: meta.library.movies.auto_movie_setup(movielibraryfolder) dialogs.notify(msg="{0}: {1} {2}".format(_('Movies'), _('Configure'), _("Library").lower()), title=_('Done'), delay=1000, image=get_icon_path("movies")) except: dialogs.notify(msg="{0}: {1} {2}".format(_("Movies"), _('Configure'), _("Library").lower()), title=_('Failed for %s') % _('Movies'), delay=1000, image=get_icon_path("movies")) tvlibraryfolder = plugin.get_setting(SETTING_TV_LIBRARY_FOLDER, unicode) try: meta.library.tvshows.auto_tvshows_setup(tvlibraryfolder) dialogs.notify(msg="{0}: {1} {2}".format(_('TV shows'), _('Configure'), _("Library").lower()), title=_('Done'), delay=1000, image=get_icon_path("tv")) except: dialogs.notify(msg="{0}: {1} {2}".format(_("TV shows"), _('Configure'), _("Library").lower()), title=_('Failed for %s') % _('TV shows'), delay=1000, image=get_icon_path("tv")) musiclibraryfolder = plugin.get_setting(SETTING_MUSIC_LIBRARY_FOLDER, unicode) try: meta.library.music.auto_music_setup(musiclibraryfolder) dialogs.notify(msg="{0}: {1} {2}".format(_('Music'), _('Configure'), _("Library").lower()), title=_('Done'), delay=1000, image=get_icon_path("music")) except: dialogs.notify(msg="{0}: {1} {2}".format(_("Music"), _('Configure'), _("Library").lower()), title=_('Failed for %s') % _('Music'), delay=1000, image=get_icon_path("music")) livelibraryfolder = plugin.get_setting(SETTING_LIVE_LIBRARY_FOLDER, unicode) try: meta.library.live.auto_live_setup(livelibraryfolder) dialogs.notify(msg="{0}: {1} {2}".format(_('TV'), _('Configure'), _("Library").lower()), title=_('Done'), delay=1000, image=get_icon_path("live")) except: dialogs.notify(msg="{0}: {1} {2}".format(_('TV'), _('Configure'), _("Library").lower()), title=_('Failed for %s') % _('TV'), delay=1000, image=get_icon_path("live")) return True
def toggle_preferred_toggle(): if xbmc.getCondVisibility("Skin.HasSetting(Toggling)") != True: dialogs.notify(msg="Toggling", title="Switched on", delay=5000, image=get_icon_path("metalliq")) else: dialogs.notify(msg="Toggling", title="Switched off", delay=5000, image=get_icon_path("metalliq")) xbmc.executebuiltin("Skin.ToggleSetting(Toggling)")
def settings_set_players(media): playericon = get_icon_path("player") medias = ["movies", "tvshows", "musicvideos", "music", "live"] if media == "all": for med in medias: mediatype = med.replace('es', 'e').replace('ws', 'w').replace( 'all', '').replace('os', 'o').replace('vs', 'v s').replace( 'tv', 'TV').replace('musicvideo', 'Music video').replace('live', 'TV') players = get_players(med) selected = [p.id for p in players] if selected is not None: if med == "movies": plugin.set_setting(SETTING_MOVIES_ENABLED_PLAYERS, selected) elif med == "tvshows": plugin.set_setting(SETTING_TV_ENABLED_PLAYERS, selected) elif med == "musicvideos": plugin.set_setting(SETTING_MUSICVIDEOS_ENABLED_PLAYERS, selected) elif med == "music": plugin.set_setting(SETTING_MUSIC_ENABLED_PLAYERS, selected) elif med == "live": plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected) else: raise Exception("invalid parameter %s" % media) dialogs.notify(msg="{0} {1}".format( _(mediatype).capitalize(), _("Player").lower()), title=_('Enabled'), delay=1000, image=get_icon_path("player")) dialogs.notify(msg="{0}".format(_("Player")), title="{0} {1}".format(_("All"), _('Enabled').lower()), delay=1000, image=get_icon_path("player")) return True elif media == "tvportal": players = get_players("live") selected = [p.id for p in players] plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected) return else: mediatype = media.replace('es', 'e').replace('ws', 'w').replace( 'all', '').replace('os', 'o').replace('vs', 'v s').replace( 'tv', 'TV').replace('musicvideo', 'Music video').replace('live', 'TV') players = get_players(media) players = sorted(players, key=lambda player: player.clean_title.lower()) version = xbmc.getInfoLabel('System.BuildVersion') selected = None if version.startswith('16') or version.startswith('17'): msg = "Do you want to enable all " + mediatype + "players?" if dialogs.yesno(_("Enable all " + mediatype + "players"), _(msg)): selected = [p.id for p in players] else: result = dialogs.multiselect( _("Select " + mediatype + "players to enable"), [p.clean_title for p in players]) if result is not None: selected = [players[i].id for i in result] else: selected = None msg = "Kodi 16 is required for multi-selection. Do you want to enable all " + mediatype + "players instead?" if dialogs.yesno( "{0} {1} {2} {3}s".format(_("Enable"), _("All").lower(), mediatype, _("Player").lower()), _(msg)): selected = [p.id for p in players] else: result = dialogs.multichoice( "{0}: {1} {2} {3}".format(_("Enable"), _("Select"), _("Player").lower()), [p.clean_title for p in players]) if result is not None: selected = [players[i].id for i in result] if selected is not None: if media == "movies": plugin.set_setting(SETTING_MOVIES_ENABLED_PLAYERS, selected) elif media == "tvshows": plugin.set_setting(SETTING_TV_ENABLED_PLAYERS, selected) elif media == "musicvideos": plugin.set_setting(SETTING_MUSICVIDEOS_ENABLED_PLAYERS, selected) elif media == "music": plugin.set_setting(SETTING_MUSIC_ENABLED_PLAYERS, selected) elif media == "live": plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected) else: raise Exception("invalid parameter %s" % media) dialogs.notify(msg="{0} {1} {2}".format(_("Enable"), _(mediatype).lower(), _("Player").lower()), title=_('Done'), delay=1000, image=get_icon_path("player")) plugin.open_settings()
def add_tvshow_to_library(library_folder, show, play_plugin=None): clean_needed = False id = show['id'] showname = to_utf8(show['seriesname']) if showname == "None" or showname == None: show_folder = os.path.join(library_folder, str(id) + '/') if os.path.isdir(show_folder): return shutil.rmtree(show_folder) playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode) if not xbmcvfs.exists(playlist_folder): try: xbmcvfs.mkdir(playlist_folder) except: dialogs.notify(msg=_( 'Creation of [COLOR limegreen]M[/COLOR]etalli[COLOR limegreen]Q[/COLOR] 4[COLOR limegreen]Q[/COLOR]ed Playlist Folder' ), title=_('Failed'), delay=5000, image=get_icon_path("lists")) playlist_file = os.path.join(playlist_folder, id + ".xsp") if not xbmcvfs.exists(playlist_file): playlist_file = xbmcvfs.File(playlist_file, 'w') content = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><smartplaylist type="tvshows"><name>%s</name><match>all</match><rule field="path" operator="contains"><value>%s%s</value></rule><rule field="playcount" operator="is"><value>0</value></rule><order direction="ascending">numepisodes</order></smartplaylist>' % ( showname, plugin.get_setting( SETTING_TV_LIBRARY_FOLDER, str).replace( 'special://profile', ''), str(id)) playlist_file.write(str(content)) playlist_file.close() ## Create show folder enc_show = showname.translate(None, '\/:*?"<>|').strip('.') show_folder = os.path.join(library_folder, str(id) + '/') if not xbmcvfs.exists(show_folder): try: xbmcvfs.mkdir(show_folder) except: pass # Create play with file if play_plugin is not None: player_filepath = os.path.join(show_folder, 'player.info') player_file = xbmcvfs.File(player_filepath, 'w') content = "{0}".format(play_plugin) player_file.write(content) player_file.close() # Create nfo file nfo_filepath = os.path.join(show_folder, 'tvshow.nfo') if not xbmcvfs.exists(nfo_filepath): nfo_file = xbmcvfs.File(nfo_filepath, 'w') content = "http://thetvdb.com/index.php?tab=series&id=%s" % str(id) nfo_file.write(content) nfo_file.close() ## Get existing items in library # get all ids of the show ids = [id, show.get('imdb_id', None)] # TODO: add tmdb! ids = [x for x in ids if x] # get show episodes in library try: # get tvshow from library libshows = RPC.VideoLibrary.GetTVShows( properties=["imdbnumber", "title", "year"])['tvshows'] libshows = [ i for i in libshows if str(i['imdbnumber']) in ids or ( str(i['year']) == str(show.get('year', 0)) and equals(show['seriesname'], i['title'])) ] libshow = libshows[0] # get existing (non strm) episodes in library libepisodes = RPC.VideoLibrary.GetEpisodes( filter={ "and": [{ "field": "tvshow", "operator": "is", "value": to_utf8(libshow['title']) }] }, properties=["season", "episode", "file"])['episodes'] libepisodes = [(int(i['season']), int(i['episode'])) for i in libepisodes if not i['file'].endswith(".strm")] except: libepisodes = [] ## Create content strm files for (season_num, season) in show.items(): if season_num == 0: # or not season.has_aired(): continue for (episode_num, episode) in season.items(): if episode_num == 0: continue delete = False if plugin.get_setting(SETTING_AIRED_UNKNOWN, bool) == True: aired_unknown = True else: aired_unknown = False if not episode.has_aired(flexible=aired_unknown): delete = True #break if delete or (season_num, episode_num) in libepisodes: if library_tv_remove_strm(show, show_folder, id, season_num, episode_num): clean_needed = True else: library_tv_strm(show, show_folder, id, season_num, episode_num) files, dirs = xbmcvfs.listdir(show_folder) if not dirs: shutil.rmtree(show_folder) clean_needed = True # if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): xbmc.executebuiltin("RunScript(script.qlickplay,info=afteradd)") # elif xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"): xbmc.executebuiltin("RunScript(script.extendedinfo,info=afteradd)") return clean_needed
def add_tvshow_to_library(library_folder, show, play_plugin = None): clean_needed = False id = show['id'] showname = to_utf8(show['seriesname']) if showname == "None" or showname == None: show_folder = os.path.join(library_folder, str(id)+'/') if os.path.isdir(show_folder): return shutil.rmtree(show_folder) playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode) if not xbmcvfs.exists(playlist_folder): try: xbmcvfs.mkdir(playlist_folder) except: dialogs.notify(msg=_('Creation of [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] Playlist Folder'), title=_('Failed'), delay=5000, image=get_icon_path("lists")) playlist_file = os.path.join(playlist_folder, id+".xsp") if not xbmcvfs.exists(playlist_file): playlist_file = xbmcvfs.File(playlist_file, 'w') content = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><smartplaylist type="tvshows"><name>%s</name><match>all</match><rule field="path" operator="contains"><value>%s%s</value></rule><rule field="playcount" operator="is"><value>0</value></rule><order direction="ascending">numepisodes</order></smartplaylist>' % (showname, plugin.get_setting(SETTING_TV_LIBRARY_FOLDER, str).replace('special://profile',''), str(id)) playlist_file.write(str(content)) playlist_file.close() ## Create show folder enc_show = showname.translate(None, '\/:*?"<>|').strip('.') show_folder = os.path.join(library_folder, str(id)+'/') if not xbmcvfs.exists(show_folder): try: xbmcvfs.mkdir(show_folder) except: pass # Create play with file if play_plugin is not None: player_filepath = os.path.join(show_folder, 'player.info') player_file = xbmcvfs.File(player_filepath, 'w') content = "{0}".format(play_plugin) player_file.write(content) player_file.close() # Create nfo file nfo_filepath = os.path.join(show_folder, 'tvshow.nfo') if not xbmcvfs.exists(nfo_filepath): nfo_file = xbmcvfs.File(nfo_filepath, 'w') content = "http://thetvdb.com/index.php?tab=series&id=%s" % str(id) nfo_file.write(content) nfo_file.close() ## Get existing items in library # get all ids of the show ids = [id, show.get('imdb_id', None)] # TODO: add tmdb! ids = [x for x in ids if x] # get show episodes in library try: # get tvshow from library libshows = RPC.VideoLibrary.GetTVShows(properties=["imdbnumber", "title", "year"])['tvshows'] libshows = [i for i in libshows if str(i['imdbnumber']) in ids or (str(i['year']) == str(show.get('year', 0)) and equals(show['seriesname'], i['title']))] libshow = libshows[0] # get existing (non strm) episodes in library libepisodes = RPC.VideoLibrary.GetEpisodes(filter={"and": [ {"field": "tvshow", "operator": "is", "value": to_utf8(libshow['title'])}]}, properties=["season", "episode", "file"])['episodes'] libepisodes = [(int(i['season']), int(i['episode'])) for i in libepisodes if not i['file'].endswith(".strm")] except: libepisodes = [] ## Create content strm files for (season_num,season) in show.items(): if season_num == 0 and not plugin.get_setting(SETTING_INCLUDE_SPECIALS, bool): continue if not season.has_aired(flexible=plugin.get_setting(SETTING_AIRED_UNKNOWN, bool)): continue for (episode_num, episode) in season.items(): if not season_num == 0 and not episode.has_aired(flexible=plugin.get_setting(SETTING_AIRED_UNKNOWN, bool)): continue delete = False if not episode.has_aired(flexible=plugin.get_setting(SETTING_AIRED_UNKNOWN, bool)): delete = True if delete or (season_num, episode_num) in libepisodes: if library_tv_remove_strm(show, show_folder, id, season_num, episode_num): clean_needed = True else: library_tv_strm(show, show_folder, id, season_num, episode_num) files, dirs = xbmcvfs.listdir(show_folder) if not dirs: shutil.rmtree(show_folder) clean_needed = True # if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): xbmc.executebuiltin("RunScript(script.qlickplay,info=afteradd)") # elif xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"): xbmc.executebuiltin("RunScript(script.extendedinfo,info=afteradd)") return clean_needed