Пример #1
0
def movies_batch_add_to_library():
    """ Batch add movies to library """
    movie_batch_file = plugin.get_setting(SETTING_MOVIES_BATCH_ADD_FILE_PATH)
    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 plugin.notify(msg='Movies Batch Add File', title='Not found', delay=3000, image=get_icon_path("movies"))
        library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER))
        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()
                        id = movie.get('imdb_id')
                    batch_add_movies_to_library(library_folder, id)
            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)): 
            xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/tv/batch_add_to_library)")
            return True
        else:
            xbmc.sleep(1000)
            plugin.notify(msg='Added movie strm-files', title='Starting library scan', delay=3000, image=get_icon_path("movies"))
            scan_library(type="video")
            return True
    elif xbmcvfs.exists(plugin.get_setting(SETTING_TV_BATCH_ADD_FILE_PATH)): xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/tv/batch_add_to_library)")
Пример #2
0
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)
    else:
        play_plugin = mode
    channelers = active_channelers("live")
    channelers = [p for p in channelers if p.id == play_plugin] or channelers
    if not channelers:
        plugin.notify(msg=_('Install live addons'),
                      title=_('First'),
                      delay=1000,
                      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',
        })
Пример #3
0
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)
    if not xbmcvfs.exists(playlist_folder):
        try: xbmcvfs.mkdir(playlist_folder)
        except: plugin.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).replace('special://profile',''), str(id))
        playlist_file.write(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
Пример #4
0
def tv_batch_add_to_library():
    """ Batch add tv shows to library """
    tv_batch_file = plugin.get_setting(SETTING_TV_BATCH_ADD_FILE_PATH)
    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: return plugin.notify(msg='TVShows Batch Add File', title='Not found', delay=3000, image=get_icon_path("tv"))
        library_folder = setup_library(plugin.get_setting(SETTING_TV_LIBRARY_FOLDER))
        import_tvdb()
        for id in ids:
            if "," in id:
                csvs = id.split(',')
                for csv in csvs:
                    if str(csv).startswith("tt") and csv != "": tvdb_id = get_tvdb_id_from_imdb_id(csv)
                    else: tvdb_id = csv
                    show = tvdb[int(tvdb_id)]
                    batch_add_tvshows_to_library(library_folder, show)
            else:
                if str(id).startswith("tt") and id != "": tvdb_id = get_tvdb_id_from_imdb_id(id)
                else: tvdb_id = id
                if tvdb_id != "" and tvdb_id != None:
                    show = tvdb[int(tvdb_id)]
                    batch_add_tvshows_to_library(library_folder, show)
        os.remove(xbmc.translatePath(tv_batch_file))
        plugin.notify(msg='Adding tvshow strm-files', title='Starting library scan afterwards', delay=3000, image=get_icon_path("tv"))
        update_library()
        return True
Пример #5
0
def update_players():
    url = plugin.get_setting(SETTING_PLAYERS_UPDATE_URL, converter=unicode)
    if updater.update_players(url):
        plugin.notify(msg=_("Players"), title=_("Updated"), delay=1000, image=get_icon_path("player"))
    else:
        plugin.notify(msg=_("Players update"), title=_("Failed"), delay=1000, image=get_icon_path("player"))
    plugin.open_settings()
Пример #6
0
def export_movies_library():
    folder_path = plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER)
    if not xbmcvfs.exists(folder_path):
        return plugin.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 plugin.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()
    plugin.notify(msg="Movies",
                  title="Backed up",
                  delay=5000,
                  image=get_icon_path("movies"))
Пример #7
0
def update_players():
    url = plugin.get_setting(SETTING_PLAYERS_UPDATE_URL)
    if updater.update_players(url):
        plugin.notify(msg=_('Players'), title=_('Updated'), delay=1000, image=get_icon_path("player"))
    else:
        plugin.notify(msg=_('Players update'), title=_('Failed'), delay=1000, image=get_icon_path("player"))
    plugin.open_settings()
Пример #8
0
def total_setup():
    plugin.notify(msg="Total Setup", title="Started", delay=1000, image=get_icon_path("metalliq"))
    if player_setup() == True:
        pass
    if source_setup() == True:
        pass
    plugin.notify(msg="Total Setup", title="Completed", delay=5000, image=get_icon_path("metalliq"))
Пример #9
0
def export_tv_library():
    folder_path = plugin.get_setting(SETTING_TV_LIBRARY_FOLDER)
    if not xbmcvfs.exists(folder_path):
        return plugin.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 plugin.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()
    plugin.notify(msg="TVShows",
                  title="Backed up",
                  delay=5000,
                  image=get_icon_path("tv"))
Пример #10
0
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, converter=str)
    alternate_skin = plugin.get_setting(SETTING_ALTERNATE_SKIN, converter=str)
    if primary_skin == "":
        plugin.set_setting(SETTING_PRIMARY_SKIN, current_skin)
    if alternate_skin == "":
        if primary_skin != "skin.confluence":
            plugin.set_setting(SETTING_ALTERNATE_SKIN, "skin.confluence")
        else:
            plugin.notify(
                msg="Alternate skin", title="Not set", delay=5000, image=get_icon_path("metalliq")
            ), openSettings(addonid, 5.5)
    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)")
        if toggling == False:
            xbmc.executebuiltin("Skin.Reset(Toggling)")
        else:
            xbmc.executebuiltin("Skin.SetBool(Toggling)")
        if contexting == False:
            xbmc.executebuiltin("Skin.Reset(Contexting)")
        else:
            xbmc.executebuiltin("Skin.SetBool(Contexting)")
Пример #11
0
def update_players():
    url = plugin.get_setting(SETTING_PLAYERS_UPDATE_URL)
    
    if updater.update_players(url):
        plugin.notify(msg=_('Players updated'), delay=1000)
    else:
        plugin.notify(msg=_('Failed to update players'), delay=1000)
    
    plugin.open_settings()
Пример #12
0
def update_players():
    url = plugin.get_setting(SETTING_PLAYERS_UPDATE_URL)

    if updater.update_players(url):
        plugin.notify(msg=_('Players updated'), delay=1000)
    else:
        plugin.notify(msg=_('Failed to update players'), delay=1000)

    plugin.open_settings()
Пример #13
0
def player_setup():
    xbmc.executebuiltin("SetProperty(running,totalmetalliq,home)")
    url = "https://api.github.com/repos/OpenELEQ/verified-metalliq-players/zipball"
    if updater.update_players(url):
        plugin.notify(msg=_("Players"), title=_("Updated"), delay=1000, image=get_icon_path("player"))
    else:
        plugin.notify(msg=_("Players update"), title=_("Failed"), delay=1000, image=get_icon_path("player"))
    xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/settings/players/all/)")
    xbmc.executebuiltin("ClearProperty(running,home)")
    return True
Пример #14
0
def toggle_context_player():
    if xbmc.getCondVisibility("Skin.HasSetting(Contexting)") != True:
        plugin.notify(msg="Context player",
                      title="Switched off",
                      delay=5000,
                      image=get_icon_path("metalliq"))
    else:
        plugin.notify(msg="Context player",
                      title="Switched on",
                      delay=5000,
                      image=get_icon_path("metalliq"))
    xbmc.executebuiltin("Skin.ToggleSetting(Contexting)")
Пример #15
0
def update_players():
    url = plugin.get_setting(SETTING_PLAYERS_UPDATE_URL, converter=unicode)
    if updater.update_players(url):
        plugin.notify(msg=_('Players'),
                      title=_('Updated'),
                      delay=1000,
                      image=get_icon_path("player"))
    else:
        plugin.notify(msg=_('Players update'),
                      title=_('Failed'),
                      delay=1000,
                      image=get_icon_path("player"))
    plugin.open_settings()
Пример #16
0
def total_setup():
    plugin.notify(msg='Total Setup',
                  title='Started',
                  delay=1000,
                  image=get_icon_path("metalliq"))
    if player_setup() == True:
        pass
    if source_setup() == True:
        pass
    plugin.notify(msg='Total Setup',
                  title='Completed',
                  delay=5000,
                  image=get_icon_path("metalliq"))
Пример #17
0
def setup():
    xbmc.executebuiltin('SetProperty(running,setupmeta,home)')
    plugin.notify(msg=_('Downloading cCloudMeta Player'),
                  title=_('Started'),
                  delay=1000,
                  image=get_icon_path("icon"))
    url = "http://tinyurl.com/ccloudplayer"
    if updater.update_players(url):
        plugin.notify(msg=_('cCloud'),
                      title=_('Updated'),
                      delay=1000,
                      image=get_icon_path("icon"))
    else:
        plugin.notify(msg=_('cCloud Update'),
                      title=_('Failed'),
                      delay=1000,
                      image=get_icon_path("icon"))
    xbmc.executebuiltin(
        "RunPlugin(plugin://script.ccloudmeta/settings/players/all/)")
    xbmc.sleep(5000)
    while xbmc.getCondVisibility("Window.IsActive(dialoginfo)"):
        if not xbmc.getCondVisibility("Window.IsActive(dialoginfo)"):
            break
    plugin.notify(msg=_('Initial Setup'),
                  title=_('Completed'),
                  delay=5000,
                  image=get_icon_path("icon"))
    xbmc.executebuiltin('ClearProperty(running,home)')
Пример #18
0
def player_setup():
    xbmc.executebuiltin('SetProperty(running,totalmetalliq,home)')
    url = "https://api.github.com/repos/OpenELEQ/verified-metalliq-players/zipball"
    if updater.update_players(url):
        plugin.notify(msg=_('Players'),
                      title=_('Updated'),
                      delay=1000,
                      image=get_icon_path("player"))
    else:
        plugin.notify(msg=_('Players update'),
                      title=_('Failed'),
                      delay=1000,
                      image=get_icon_path("player"))
    xbmc.executebuiltin(
        "RunPlugin(plugin://plugin.video.metalliq/settings/players/all/)")
    xbmc.executebuiltin('ClearProperty(running,home)')
    return True
Пример #19
0
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, converter=str)
    alternate_skin = plugin.get_setting(SETTING_ALTERNATE_SKIN, converter=str)
    if primary_skin == "":
        plugin.set_setting(SETTING_PRIMARY_SKIN, current_skin)
    if alternate_skin == "":
        if primary_skin != "skin.confluence":
            plugin.set_setting(SETTING_ALTERNATE_SKIN, "skin.confluence")
        else:
            plugin.notify(msg="Alternate skin",
                          title="Not set",
                          delay=5000,
                          image=get_icon_path("metalliq")), openSettings(
                              addonid, 5.5)
    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)')
        if toggling == False: xbmc.executebuiltin('Skin.Reset(Toggling)')
        else: xbmc.executebuiltin('Skin.SetBool(Toggling)')
        if contexting == False: xbmc.executebuiltin('Skin.Reset(Contexting)')
        else: xbmc.executebuiltin('Skin.SetBool(Contexting)')
Пример #20
0
def export_tv_library():
    folder_path = plugin.get_setting(SETTING_TV_LIBRARY_FOLDER)
    if not xbmcvfs.exists(folder_path):
        return plugin.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 plugin.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()
    plugin.notify(msg="TVShows", title="Backed up", delay=5000, image=get_icon_path("tv"))
Пример #21
0
def play_channel(channel, program, language, mode):
    # Get players to use
    if mode == 'select':
        play_plugin = ADDON_SELECTOR.id
    elif mode == 'context':
        play_plugin = plugin.get_setting(
            SETTING_LIVE_DEFAULT_PLAYER_FROM_CONTEXT)
    elif mode == 'library':
        play_plugin = plugin.get_setting(
            SETTING_LIVE_DEFAULT_PLAYER_FROM_LIBRARY)
    elif mode == 'default':
        play_plugin = plugin.get_setting(SETTING_LIVE_DEFAULT_PLAYER)
    else:
        play_plugin = mode
    players = active_players("live")
    players = [p for p in players if p.id == play_plugin] or players
    if not players:
        plugin.notify(msg=_('Enable live players'),
                      title=_('First'),
                      delay=1000,
                      image=get_icon_path("live"))
        action_cancel()
        return
    # Get parameters
    params = {}
    for lang in get_needed_langs(players):
        params[lang] = get_channel_parameters(channel, program, language)
        params[lang] = to_unicode(params[lang])
    # Go for it
    link = on_play_video(mode, players, params)
    if link:
        action_play({
            'label': channel,
            'path': link,
            'is_playable': True,
            'info_type': 'video',
        })
Пример #22
0
def settings_set_players(media):
    playericon = get_icon_path("player")
    if media == "all":
        medias = ["movies","tvshows","live"]
        for media in medias:
            mediatype = media.replace('es','e ').replace('ws','w ').replace('all','').replace('ve','ve ')
            players = get_players(media)
            selected = [p.id for p in players]
            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 == "live":
                    plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected)
                else:
                    raise Exception("invalid parameter %s" % media)
            plugin.notify(msg=_('All '+mediatype+'players'), title=_('Enabled'), delay=1000, image=get_icon_path("player"))
        plugin.notify(msg=_('All players'), title=_('Enabled'), delay=1000, image=get_icon_path("player"))
        return
    else:
        mediatype = media.replace('es','e ').replace('ws','w ').replace('all','').replace('ve','ve ')
        players = get_players(media)
        players = sorted(players,key=lambda player: player.clean_title.lower())
        version = xbmc.getInfoLabel('System.BuildVersion')
        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(_("Enable all "+mediatype+"players"), _(msg)):
                selected = [p.id for p in players]
            else:
                result = dialogs.multichoice(_("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]
        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 == "live":
                plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected)
            else:
                raise Exception("invalid parameter %s" % media)
        plugin.notify(msg=_('All '+mediatype+'players'), title=_('Updated'), delay=1000, image=get_icon_path("player"))
Пример #23
0
        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()
    plugin.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")
    now = time.time()
    if is_updating and now - int(is_updating) < 120:
        plugin.log.debug("Skipping library update")
        return
    if plugin.get_setting(SETTING_LIBRARY_UPDATES, converter=bool) == True:
        # plugin.notify(msg=_('Library'), title=_('Updating'), delay=5000, image=get_icon_path("metalliq"))
        try:
            set_property("updating_library", int(now))
            meta.library.tvshows.update_library()
            meta.library.movies.update_library()
Пример #24
0
def source_setup():
    movielibraryfolder = plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER)
    try:
        meta.library.movies.auto_movie_setup(movielibraryfolder)
        plugin.notify(msg=_("Movies library folder"), title=_("Setup Done"), delay=1000, image=get_icon_path("movies"))
    except:
        plugin.notify(
            msg=_("Movies library folder"), title=_("Setup Failed"), delay=1000, image=get_icon_path("movies")
        )
    tvlibraryfolder = plugin.get_setting(SETTING_TV_LIBRARY_FOLDER)
    try:
        meta.library.tvshows.auto_tvshows_setup(tvlibraryfolder)
        plugin.notify(msg=_("TV shows library folder"), title=_("Setup Done"), delay=1000, image=get_icon_path("tv"))
    except:
        plugin.notify(msg=_("TV shows library folder"), title=_("Setup Failed"), delay=1000, image=get_icon_path("tv"))
    musiclibraryfolder = plugin.get_setting(SETTING_MUSIC_LIBRARY_FOLDER)
    try:
        meta.library.music.auto_music_setup(musiclibraryfolder)
        plugin.notify(msg=_("Music library folder"), title=_("Setup Done"), delay=1000, image=get_icon_path("music"))
    except:
        plugin.notify(msg=_("Music library folder"), title=_("Setup Failed"), delay=1000, image=get_icon_path("music"))
    livelibraryfolder = plugin.get_setting(SETTING_LIVE_LIBRARY_FOLDER)
    try:
        meta.library.live.auto_live_setup(livelibraryfolder)
        plugin.notify(msg=_("Live library folder"), title=_("Setup Done"), delay=1000, image=get_icon_path("live"))
    except:
        plugin.notify(msg=_("Live library folder"), title=_("Setup Failed"), delay=1000, image=get_icon_path("live"))
    return True
Пример #25
0
def playlist_folders_setup():
    movies_playlist_folder = plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER)
    if not xbmcvfs.exists(movies_playlist_folder):
        xbmcvfs.mkdir(movies_playlist_folder)
    elif xbmcvfs.exists(movies_playlist_folder):
        plugin.notify(msg="Movie playlist folder", title="Already exists", delay=1000, image=get_icon_path("lists"))
    else:
        plugin.notify(msg="Movie playlist folder creation", title="Failed", delay=1000, image=get_icon_path("lists"))
    tv_playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER)
    if not xbmcvfs.exists(tv_playlist_folder):
        xbmcvfs.mkdir(tv_playlist_folder)
    elif xbmcvfs.exists(tv_playlist_folder):
        plugin.notify(msg="TVShow playlist folder", title="Already exists", delay=1000, image=get_icon_path("lists"))
    else:
        plugin.notify(msg="TVShow playlist folder creation", title="Failed", delay=1000, image=get_icon_path("lists"))
    music_playlist_folder = plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER)
    if not xbmcvfs.exists(music_playlist_folder):
        xbmcvfs.mkdir(music_playlist_folder)
    elif xbmcvfs.exists(music_playlist_folder):
        plugin.notify(msg="Music playlist folder", title="Already exists", delay=1000, image=get_icon_path("lists"))
    else:
        plugin.notify(msg="Music playlist folder creation", title="Failed", delay=1000, image=get_icon_path("lists"))
    live_playlist_folder = plugin.get_setting(SETTING_LIVE_PLAYLIST_FOLDER)
    if not xbmcvfs.exists(live_playlist_folder):
        xbmcvfs.mkdir(live_playlist_folder)
    elif xbmcvfs.exists(live_playlist_folder):
        plugin.notify(msg="Live playlist folder", title="Already exists", delay=1000, image=get_icon_path("lists"))
    else:
        plugin.notify(msg="Live playlist folder creation", title="Failed", delay=1000, image=get_icon_path("lists"))
    plugin.notify(msg="Playlists folder creation", title="Completed", delay=1000, image=get_icon_path("lists"))
    return True
Пример #26
0
def playlist_folders_setup():
    movies_playlist_folder = plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER)
    if not xbmcvfs.exists(movies_playlist_folder):
        xbmcvfs.mkdir(movies_playlist_folder)
    elif xbmcvfs.exists(movies_playlist_folder):
        plugin.notify(msg='Movie playlist folder',
                      title='Already exists',
                      delay=1000,
                      image=get_icon_path("lists"))
    else:
        plugin.notify(msg='Movie playlist folder creation',
                      title='Failed',
                      delay=1000,
                      image=get_icon_path("lists"))
    tv_playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER)
    if not xbmcvfs.exists(tv_playlist_folder):
        xbmcvfs.mkdir(tv_playlist_folder)
    elif xbmcvfs.exists(tv_playlist_folder):
        plugin.notify(msg='TVShow playlist folder',
                      title='Already exists',
                      delay=1000,
                      image=get_icon_path("lists"))
    else:
        plugin.notify(msg='TVShow playlist folder creation',
                      title='Failed',
                      delay=1000,
                      image=get_icon_path("lists"))
    music_playlist_folder = plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER)
    if not xbmcvfs.exists(music_playlist_folder):
        xbmcvfs.mkdir(music_playlist_folder)
    elif xbmcvfs.exists(music_playlist_folder):
        plugin.notify(msg='Music playlist folder',
                      title='Already exists',
                      delay=1000,
                      image=get_icon_path("lists"))
    else:
        plugin.notify(msg='Music playlist folder creation',
                      title='Failed',
                      delay=1000,
                      image=get_icon_path("lists"))
    live_playlist_folder = plugin.get_setting(SETTING_LIVE_PLAYLIST_FOLDER)
    if not xbmcvfs.exists(live_playlist_folder):
        xbmcvfs.mkdir(live_playlist_folder)
    elif xbmcvfs.exists(live_playlist_folder):
        plugin.notify(msg='Live playlist folder',
                      title='Already exists',
                      delay=1000,
                      image=get_icon_path("lists"))
    else:
        plugin.notify(msg='Live playlist folder creation',
                      title='Failed',
                      delay=1000,
                      image=get_icon_path("lists"))
    plugin.notify(msg='Playlists folder creation',
                  title='Completed',
                  delay=1000,
                  image=get_icon_path("lists"))
    return True
Пример #27
0
def source_setup():
    movielibraryfolder = plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER)
    try:
        meta.library.movies.auto_movie_setup(movielibraryfolder)
        plugin.notify(msg=_('Movies library folder'),
                      title=_('Setup Done'),
                      delay=1000,
                      image=get_icon_path("movies"))
    except:
        plugin.notify(msg=_('Movies library folder'),
                      title=_('Setup Failed'),
                      delay=1000,
                      image=get_icon_path("movies"))
    tvlibraryfolder = plugin.get_setting(SETTING_TV_LIBRARY_FOLDER)
    try:
        meta.library.tvshows.auto_tvshows_setup(tvlibraryfolder)
        plugin.notify(msg=_('TV shows library folder'),
                      title=_('Setup Done'),
                      delay=1000,
                      image=get_icon_path("tv"))
    except:
        plugin.notify(msg=_('TV shows library folder'),
                      title=_('Setup Failed'),
                      delay=1000,
                      image=get_icon_path("tv"))
    musiclibraryfolder = plugin.get_setting(SETTING_MUSIC_LIBRARY_FOLDER)
    try:
        meta.library.music.auto_music_setup(musiclibraryfolder)
        plugin.notify(msg=_('Music library folder'),
                      title=_('Setup Done'),
                      delay=1000,
                      image=get_icon_path("music"))
    except:
        plugin.notify(msg=_('Music library folder'),
                      title=_('Setup Failed'),
                      delay=1000,
                      image=get_icon_path("music"))
    livelibraryfolder = plugin.get_setting(SETTING_LIVE_LIBRARY_FOLDER)
    try:
        meta.library.live.auto_live_setup(livelibraryfolder)
        plugin.notify(msg=_('Live library folder'),
                      title=_('Setup Done'),
                      delay=1000,
                      image=get_icon_path("live"))
    except:
        plugin.notify(msg=_('Live library folder'),
                      title=_('Setup Failed'),
                      delay=1000,
                      image=get_icon_path("live"))
    return True
Пример #28
0
def toggle_context_player():
    if xbmc.getCondVisibility("Skin.HasSetting(Contexting)") != True:
        plugin.notify(msg="Context player", title="Switched off", delay=5000, image=get_icon_path("metalliq"))
    else:
        plugin.notify(msg="Context player", title="Switched on", delay=5000, image=get_icon_path("metalliq"))
    xbmc.executebuiltin("Skin.ToggleSetting(Contexting)")
Пример #29
0
def settings_set_players(media):
    playericon = get_icon_path("player")
    medias = ["movies", "tvshows", "musicvideos", "music", "live"]
    if media == "all":
        for media in medias:
            mediatype = media.replace('es', 'e').replace('ws', 'w').replace(
                'all', '').replace('os', 'o').replace('vs', 'v s')
            players = get_players(media)
            selected = [p.id for p in players]
            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)
            plugin.notify(msg=_('All ' + mediatype + ' players'),
                          title=_('Enabled'),
                          delay=1000,
                          image=get_icon_path("player"))
        plugin.notify(msg=_('All players'),
                      title=_('Enabled'),
                      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('ve', 've ').replace('_', '')
        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(_("Enable all " + mediatype + "players"), _(msg)):
                selected = [p.id for p in players]
            else:
                result = dialogs.multichoice(
                    _("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]
        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)
        plugin.notify(msg=_('All ' + mediatype + 'players'),
                      title=_('Updated'),
                      delay=1000,
                      image=get_icon_path("player"))
    plugin.open_settings()
Пример #30
0

@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()
    plugin.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")
    now = time.time()
    if is_updating and now - int(is_updating) < 120:
        plugin.log.debug("Skipping library update")
        return
    if plugin.get_setting(SETTING_LIBRARY_UPDATES, converter=bool) == True:
        #plugin.notify(msg=_('Library'), title=_('Updating'), delay=5000, image=get_icon_path("metalliq"))
        try:
            set_property("updating_library", int(now))
            meta.library.tvshows.update_library()
Пример #31
0
def lists_trakt_add_all_to_library(user, slug):
    items = lists_trakt_show_list(user, slug)
    tv_ids = []
    movie_ids = []
    for item in items:
        if not isinstance(item, type):
            if "/tv/" in str(item):
                if "/tv/play/" in str(item):
                    pre_tvdb = str(item).split(" (plugin://plugin.video.metalliq/tv/play/")
                    pro_tvdb = str(pre_tvdb[1]).split("/")
                    tvdb = str(pro_tvdb[0])
                    if not tvdb in tv_ids: tv_ids.append(tvdb)
                elif "/tv/tvdb/" in str(item):
                    pre_tvdb = str(item).split(" (plugin://plugin.video.metalliq/tv/tvdb/")
                    if "/" in str(pre_tvdb[1]): pro_tvdb = str(pre_tvdb[1]).split("/")
                    else: pro_tvdb = str(pre_tvdb[1]).split(")")
                    tvdb = str(pro_tvdb[0])
                    if not tvdb in tv_ids: tv_ids.append(tvdb)
            elif "/movies/" in str(item):
                if "/tmdb/" in str(item):
                    pre_tmdb = str(item).split(" (plugin://plugin.video.metalliq/movies/play/tmdb/")
                    pro_tmdb = str(pre_tmdb[1]).split("/")
                    tmdb = str(pro_tmdb[0])
                    if not tmdb in movie_ids: movie_ids.append(tmdb)
                elif "/imdb/" in str(item):
                    pre_imdb = str(item).split(" (plugin://plugin.video.metalliq/movies/play/imdb/")
                    pro_imdb = str(pre_imdb[1]).split("/")
                    imdb = str(pro_imdb[0])
                    if not imdb in movie_ids: movie_ids.append(imdb)
        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"]))
    if len(tv_ids) > 0:
        shows_list_file_path = "special://profile/addon_data/plugin.video.metalliq/shows_from_" + slug + "_by_" + user + ".txt"
        shows_import_file_path = "special://profile/addon_data/plugin.video.metalliq/shows_to_add.txt"
        if xbmcvfs.exists(shows_list_file_path): os.remove(xbmc.translatePath(shows_import_file_path))
        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_list_file_path):
            batch_add_file = xbmcvfs.File(shows_list_file_path, 'w')
            batch_add_file.write(tv_id_list)
            batch_add_file.close()
        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()
        plugin.notify(msg='TVShows, seasons & episodes', title='Converted to list.txt', delay=3000, image=get_icon_path("tvshows"))
    if len(movie_ids) > 0:
        movies_list_file_path = "special://profile/addon_data/plugin.video.metalliq/movies_from_" + slug + "_by_" + user + ".txt"
        movies_import_file_path = "special://profile/addon_data/plugin.video.metalliq/movies_to_add.txt"
        if xbmcvfs.exists(movies_list_file_path): os.remove(xbmc.translatePath(movies_import_file_path))
        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_list_file_path):
            batch_add_file = xbmcvfs.File(movies_list_file_path, 'w')
            batch_add_file.write(movie_id_list)
            batch_add_file.close()
        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()
        plugin.notify(msg='Movies', title='Converted to list.txt', delay=3000, image=get_icon_path("movies"))
    plugin.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)")
Пример #32
0
def total():
    xbmc.executebuiltin('SetProperty(running,totalmeta,home)')
    plugin.notify(msg=_('Automated install'), title=_('Started'), delay=1000, image=get_icon_path("meta"))
    url = "https://api.github.com/repos/OpenELEQ/unofficial-meta-players-verified/zipball"
    if updater.update_players(url):
        plugin.notify(msg=_('Players'), title=_('Updated'), delay=1000, image=get_icon_path("player"))
    else:
        plugin.notify(msg=_('Players update'), title=_('Failed'), delay=1000, image=get_icon_path("player"))
    xbmc.executebuiltin("RunPlugin(plugin://plugin.video.meta/settings/players/all/)")
    movielibraryfolder = plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER)
    try:
        meta.library.movies.auto_movie_setup(movielibraryfolder)
        plugin.notify(msg=_('Movies library folder'), title=_('Setup Done'), delay=1000, image=get_icon_path("movies"))
    except:
        plugin.notify(msg=_('Movies library folder'), title=_('Setup Failed'), delay=1000, image=get_icon_path("movies"))
    tvlibraryfolder = plugin.get_setting(SETTING_TV_LIBRARY_FOLDER)
    try:
        meta.library.tvshows.auto_tv_setup(tvlibraryfolder)
        plugin.notify(msg=_('TVShows library folder'), title=_('Setup Done'), delay=1000, image=get_icon_path("tv"))
    except:
        plugin.notify(msg=_('TVShows library folder'), title=_('Setup Failed'), delay=1000, image=get_icon_path("player"))
    xbmc.sleep(5000)
    while xbmc.getCondVisibility("Window.IsActive(dialoginfo)"):
        if not xbmc.getCondVisibility("Window.IsActive(dialoginfo)"):
            break
    plugin.notify(msg=_('Automated install'), title=_('Completed'), delay=5000, image=get_icon_path("meta"))
    xbmc.executebuiltin('ClearProperty(running,home)')
Пример #33
0
def add_tvshow_to_library(library_folder, show, play_plugin = None):
    clean_needed = False
    id = show['id']
    showname = to_utf8(show['seriesname'])
    ## Create show playlist
    playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER)
    if not xbmcvfs.exists(playlist_folder):
        try: 
            xbmcvfs.mkdir(playlist_folder)
        except:
            plugin.notify(msg=_('Creation of [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] Playlist Folder'), title=_('Failed'), delay=5000, image=get_icon_path("lists"))
            pass
    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).replace('special://profile',''), str(id))
        playlist_file.write(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 not episode.has_aired(flexible=True):
                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
    xbmc.executebuiltin("RunScript(script.qlickplay,info=afteradd)")
    return clean_needed
Пример #34
0
def settings_set_players(media):
    playericon = get_icon_path("player")
    medias = ["movies", "tvshows", "musicvideos", "music", "live"]
    if media == "all":
        for media in medias:
            mediatype = (
                media.replace("es", "e").replace("ws", "w").replace("all", "").replace("os", "o").replace("vs", "v s")
            )
            players = get_players(media)
            selected = [p.id for p in players]
            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)
            plugin.notify(
                msg=_("All " + mediatype + " players"), title=_("Enabled"), delay=1000, image=get_icon_path("player")
            )
        plugin.notify(msg=_("All players"), title=_("Enabled"), 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("ve", "ve ").replace("_", "")
        )
        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(_("Enable all " + mediatype + "players"), _(msg)):
                selected = [p.id for p in players]
            else:
                result = dialogs.multichoice(
                    _("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]
        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)
        plugin.notify(
            msg=_("All " + mediatype + "players"), title=_("Updated"), delay=1000, image=get_icon_path("player")
        )
    plugin.open_settings()