示例#1
0
def batch_add_movies_to_library(library_folder, id):
    if id == None:
        return
    changed = False
    movie_folder = os.path.join(library_folder, str(id)+'/')
    if not xbmcvfs.exists(movie_folder):
        try: xbmcvfs.mkdir(movie_folder)
        except: pass
    nfo_filepath = os.path.join(movie_folder, str(id)+ "%s" % plugin.get_setting(SETTING_LIBRARY_TAGS, unicode) + ".nfo")
    if not xbmcvfs.exists(nfo_filepath):
        changed = True
        nfo_file = xbmcvfs.File(nfo_filepath, 'w')
        content = "http://www.imdb.com/title/%s/" % str(id)
        nfo_file.write(content)
        nfo_file.close()
    strm_filepath = os.path.join(movie_folder, str(id) + "%s" % plugin.get_setting(SETTING_LIBRARY_TAGS, unicode) + ".strm")
    src = "imdb"
    if not xbmcvfs.exists(strm_filepath):
        changed = True
        strm_file = xbmcvfs.File(strm_filepath, 'w')
        try:
            content = plugin.url_for("movies_play", src=src, id=id, mode='library')
            strm_file.write(content)
            strm_file.close()
        except:
            pass
#    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 changed
示例#2
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
示例#3
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, 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
示例#4
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)')
示例#5
0
def play_music(artist_name, track_name, album_name, mode = "default"):
    # Get players to use
    if mode == 'select':
        play_plugin = ADDON_SELECTOR.id
    elif mode == 'context':
        play_plugin = plugin.get_setting(SETTING_MUSIC_DEFAULT_PLAYER_FROM_CONTEXT)
    elif mode == 'library':
        play_plugin = plugin.get_setting(SETTING_MUSIC_DEFAULT_PLAYER_FROM_LIBRARY)
    elif mode == 'default':
        play_plugin = plugin.get_setting(SETTING_MUSIC_DEFAULT_PLAYER)
    else:
        play_plugin = mode
    players = active_players("music")
    players = [p for p in players if p.id == play_plugin] or players
    if not players:
        xbmc.executebuiltin("Action(Info)")
        action_cancel()
        return

    # Get parameters
    params = {}
    for lang in get_needed_langs(players):
        params[lang] = get_music_parameters(artist_name, album_name, track_name)
        params[lang] = to_unicode(params[lang])

    # Go for it
    link = on_play_video(mode, players, params)
    if link:
        action_play({
            'label': "{0} - {1} - {2}".format(artist_name, album_name, track_name),
            'path': link,
            'is_playable': True,
            'info_type': 'music',
        })
示例#6
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)")
示例#7
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    metalliq_playlist_folder = "special://profile/playlists/mixed/MetalliQ/"
    if not xbmcvfs.exists(metalliq_playlist_folder):
        xbmcvfs.mkdir(metalliq_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, converter=str)
    if plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, converter=str)[-1] != "/":
        playlist_folder += "/"
    # create folders
    if not xbmcvfs.exists(playlist_folder):
        xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        # auto configure folder
        msg = _(
            "Would you like to automatically set [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] as a movies video source?"
        )
        if dialogs.yesno(_("Library setup"), msg):
            source_thumbnail = get_icon_path("movies")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("Movies")
            source_content = '(\'{0}\',\'movies\',\'metadata.themoviedb.org\',\'\',2147483647,1,\'<settings><setting id="RatingS" value="TMDb" /><setting id="certprefix" value="Rated " /><setting id="fanart" value="true" /><setting id="keeporiginaltitle" value="false" /><setting id="language" value="{1}" /><setting id="tmdbcertcountry" value="us" /><setting id="trailer" value="true" /></settings>\',0,0,NULL,NULL)'.format(
                library_folder, LANG
            )
            add_source(source_name, library_folder, source_content, source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
示例#8
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
示例#9
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, unicode)
    elif mode == 'library':
        play_plugin = plugin.get_setting(SETTING_LIVE_DEFAULT_PLAYER_FROM_LIBRARY, unicode)
    elif mode == 'default':
        play_plugin = plugin.get_setting(SETTING_LIVE_DEFAULT_PLAYER, unicode)
    else:
        play_plugin = mode
    players = active_players("live")
    players = [p for p in players if p.id == play_plugin] or players
    if not players:
        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(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',
        })
示例#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 __init__(self):
        Thread.__init__(self)
        
        self.active = True
        self.search_term = None
        self.owner_thread = None
        self.lock = Lock()
        self.access_lock = RLock()

        self.hide_keyboard = plugin.get_setting(SETTING_AUTO_HIDE_DIALOGS, bool) and plugin.get_setting(SETTING_AUTO_HIDE_DIALOGS_KEYBOARD, bool)
示例#12
0
def play_movie(tmdb_id, mode):
    import_tmdb()
    # Get players to use
    if mode == 'select':
        play_plugin = ADDON_SELECTOR.id
    elif mode == 'context':
        play_plugin = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_CONTEXT, unicode)
    elif mode == 'library':
        play_plugin = get_movie_player_plugin_from_library(tmdb_id)
        if not play_plugin or play_plugin == "default":
            play_plugin = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY, unicode)
    elif mode == 'default':
        play_plugin = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER, unicode)
    else:
        play_plugin = mode
    if mode == 'default' or mode == 'select': players = active_players("movies")
    else: players = get_players("movies")
    players = [p for p in players if p.id == play_plugin] or players
    if not players:
        xbmc.executebuiltin( "Action(Info)")
        action_cancel()
        return
    # Get movie data from TMDB
    movie = tmdb.Movies(tmdb_id).info(language=LANG, append_to_response="external_ids,videos")
    movie_info = get_movie_metadata(movie)
    # Get movie ids from Trakt
    trakt_ids = get_trakt_ids("tmdb", tmdb_id, movie['original_title'],
                    "movie", parse_year(movie['release_date']))
    # Get parameters
    params = {}
    for lang in get_needed_langs(players):
        if lang == LANG:
            tmdb_data = movie
        else:
            tmdb_data = tmdb.Movies(tmdb_id).info(language=lang)
        params[lang] = get_movie_parameters(tmdb_data)
        if trakt_ids != None:
            params[lang].update(trakt_ids)
        params[lang]['info'] = movie_info
        params[lang] = to_unicode(params[lang])
    # Go for it
    link = on_play_video(mode, players, params, trakt_ids)
    if link:
        movie = tmdb.Movies(tmdb_id).info(language=LANG)
        action_play({
            'label': movie_info['title'],
            'path': link,
            'info': movie_info,
            'is_playable': True,
            'info_type': 'video',
            'thumbnail': movie_info['poster'],
            'poster': movie_info['poster'],
            'properties' : {'fanart_image' : movie_info['fanart']},
        })
示例#13
0
def main():
    go_idle(45)
    if plugin.get_setting(SETTING_TOTAL_SETUP_DONE, bool) == False:
        xbmc.executebuiltin('RunPlugin(plugin://plugin.video.metalliq/setup/total)')
        plugin.set_setting(SETTING_TOTAL_SETUP_DONE, "true")
    #xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/movies/batch_add_to_library)")
    next_update = future(0)
    while not xbmc.abortRequested:
        if next_update <= future(0):
            next_update = future(plugin.get_setting(SETTING_UPDATE_LIBRARY_INTERVAL, int) * 60 * 60)
            update_library()
        go_idle(30*60)
示例#14
0
def live_add_to_library(channel, mode):
    if mode != None and plugin.get_setting(SETTING_LIVE_DEFAULT_AUTO_ADD, bool):
        player = mode
    else:
        players = active_players("live", filters = {'network': channel.get('network')})
        players.insert(0, ADDON_SELECTOR)
        selection = dialogs.select(_("Play using..."), [p.title for p in players])
        if selection == -1:
            return
        player = players[selection]
    library_folder = setup_library(plugin.get_setting(SETTING_LIVE_LIBRARY_FOLDER, unicode))
    add_channel_to_library(library_folder, channel, player)
示例#15
0
 def __init__(self):
     self.active = False
     
     self.hide_progress = False
     self.hide_info = False
     
     self.autohidedialogs = plugin.get_setting(SETTING_AUTO_HIDE_DIALOGS, bool)
     if self.autohidedialogs:
         self.hide_progress = plugin.get_setting(SETTING_AUTO_HIDE_DIALOGS_PROGRESS, bool)
         self.hide_info = plugin.get_setting(SETTING_AUTO_HIDE_DIALOGS_INFO, bool)
     
     if not self.hide_progress and not self.hide_info:
         self.autohidedialogs = False
示例#16
0
def auto_tvshows_setup(library_folder):
    if library_folder[-1] != "/": library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)[-1] != "/": playlist_folder += "/"
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        try:
            xbmcvfs.mkdir(library_folder)
            source_thumbnail = get_icon_path("tv")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("TV shows")
            source_content = "('{0}','tvshows','metadata.tvdb.com','',0,0,'<settings><setting id=\"RatingS\" value=\"TheTVDB\" /><setting id=\"absolutenumber\" value=\"false\" /><setting id=\"dvdorder\" value=\"false\" /><setting id=\"fallback\" value=\"true\" /><setting id=\"fanart\" value=\"true\" /><setting id=\"language\" value=\"{1}\" /></settings>',0,0,NULL,NULL)".format(library_folder, LANG)
            add_source(source_name, library_folder, source_content, source_thumbnail)
            return True
        except: False
示例#17
0
def silent_setup():
    xbmc.executebuiltin('SetProperty(running,totalmetalliq,home)')
    movielibraryfolder = plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode)
    try: meta.library.movies.auto_movie_setup(movielibraryfolder)
    except: pass
    tvlibraryfolder = plugin.get_setting(SETTING_TV_LIBRARY_FOLDER, unicode)
    try: meta.library.tvshows.auto_tvshows_setup(tvlibraryfolder)
    except: pass
    musiclibraryfolder = plugin.get_setting(SETTING_MUSIC_LIBRARY_FOLDER, unicode)
    try: meta.library.music.auto_music_setup(musiclibraryfolder)
    except: pass
    livelibraryfolder = plugin.get_setting(SETTING_LIVE_LIBRARY_FOLDER, unicode)
    try: meta.library.live.auto_live_setup(livelibraryfolder)
    except: pass
示例#18
0
def update_library():
    """ Update library """
    url = plugin.get_setting(SETTING_MOVIES_SERVER_URL, converter=str)
    if not url:
        return
    
    # Get movies list from movies-server
    movies = query_movies_server(url)
    
    # setup library folder
    library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER))

    changed = False

    # add new movies
    for movie in movies:
        date = int(movie.get('date', 0))
        imdb = movie.get('imdb')
        tmdb = movie.get('tmdb')
        
        if imdb:
            if add_movie_to_library(library_folder, "imdb", imdb, date):
                changed = True
        elif tmdb:
            if add_movie_to_library(library_folder, "tmdb", tmdb, date):
                changed = True
        
    # remove old movies from DB
    keep_movies = [movie['imdb'] for movie in movies]
    
    db_movies = RPC.video_library.get_movies(properties=['title', 'imdbnumber','file'])    
    for movie in db_movies.get('movies', []):
        file = xbmc.translatePath(movie['file'])
        imdb = os.path.splitext(os.path.basename(file))[0]
        if imdb not in keep_movies and plugin.id in file:
            
            # remove movie
            RPC.video_library.remove_movie(movieid=movie["movieid"])
            
            # remove strm and nfo files
            os.remove(file)
            try:
                os.remove(file.replace(".strm", ".nfo"))
            except:
                pass
            
            changed = True
    
    if changed:
        scan_library()
示例#19
0
def play_channel(channel, program, language, mode="default"):
    # Get players to use
    if mode == 'select':
        play_plugin = ADDON_SELECTOR.id
    else:
        play_plugin = plugin.get_setting(SETTING_LIVE_DEFAULT_PLAYER)
    players = active_players("live", filters = {"channel": channel})
    players = [p for p in players if p.id == play_plugin] or players
    if not players:
        xbmc.executebuiltin( "Action(Info)")
        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',
        })
示例#20
0
def guide_tv_play_by_name_only(name, lang):
    tvdb_id = get_tvdb_id_from_name(name, lang)
    if tvdb_id:
        season = None
        episode = None
        show = tv_tvshow(tvdb_id)
        while season is None or episode is None:
            selection = dialogs.select(_("Choose season"), [item["label"] for item in show])
            if selection != -1:
                season = show[selection]["info"]["season"]
                season = int(season)
            else:
                return
            items = []
            episodes = tv_season(tvdb_id, season)
            for item in episodes:
                label = "S{0}E{1} - {2}".format(item["info"]["season"], item["info"]["episode"],
                                                to_utf8(item["info"]["title"]))
                if item["info"]["plot"] is not None:
                    label += " - {0}".format(to_utf8(item["info"]["plot"]))
                items.append(label)
            selection = dialogs.select(_("Choose episode"), items)
            if selection != -1:
                episode = episodes[selection]["info"]["episode"]
                episode = int(episode)
                guide_tv_play(tvdb_id, season, episode, "default")
                if plugin.get_setting(SETTING_TV_PLAYED_BY_ADD, converter=bool) == True:
                    tv_add_to_library(tvdb_id)
示例#21
0
def get_recommendations(type):
    return call_trakt("/recommendations/{0}".format(type),
                      params={
                          'extended': 'full',
                          'limit': plugin.get_setting(SETTING_ITEMS_PER_PAGE,
                                                      int)
                      })
示例#22
0
def trakt_get_liked_lists(page=1):
    result, pages = call_trakt(
        "users/likes/lists",
        params={'limit': plugin.get_setting(SETTING_ITEMS_PER_PAGE, int)},
        pagination=True,
        page=page)
    return result, pages
示例#23
0
def music_add_album_to_library(artist_name, album_name):
    library_folder = setup_library(plugin.get_setting(SETTING_MUSIC_LIBRARY_FOLDER, unicode))
    results = lastfm.get_album_info(artist_name, album_name)
    for track in results["tracks"]["track"]:
        track_name = to_utf8(track["name"])
        add_music_to_library(library_folder, artist_name, album_name, track_name)
    scan_library(type="music")
示例#24
0
def guide_movies_play_by_name(name, lang="en"):
    import_tmdb()
    from meta.utils.text import parse_year
    items = tmdb.Search().movie(query=name, language=lang, page=1)["results"]
    if not items:
        return dialogs.ok(
            _("%s not found") % _("Movie"),
            "{0} {1}".format(_("No movie information found on TMDB for"),
                             name))
    if len(items) > 1:
        selection = dialogs.select(
            "{0}".format(
                _("Choose thumbnail").replace(
                    _("Thumbnail").lower(),
                    _("Movie").lower())), [
                        "{0} ({1})".format(to_utf8(s["title"]),
                                           parse_year(s["release_date"]))
                        for s in items
                    ])
    else:
        selection = 0
    if selection != -1:
        id = items[selection]["id"]
        guide_movies_play("tmdb", id, "default")
        if plugin.get_setting(SETTING_MOVIES_PLAYED_BY_ADD, bool) == True:
            movies_add_to_library("tmdb", id)
示例#25
0
文件: music.py 项目: helloman37/repo
def music_add_artist_to_library(artist_name):
    import math
    library_folder = setup_library(
        plugin.get_setting(SETTING_MUSIC_LIBRARY_FOLDER, unicode))
    album_results = lastfm.get_artist_top_albums(artist_name)
    total_albums = len(album_results)
    index = 0
    pDialog = xbmcgui.DialogProgress()
    pDialog.create(
        'MetalliQ',
        _("{0} {1} {2}").format(_("Adding"), artist_name, _("to library")))
    for album in album_results["album"]:
        album_name = to_utf8(album["name"])
        percent_done = int(math.floor((float(index) / total_albums) * 100))
        pDialog.update(
            percent_done,
            _("{0} {1} - {2} {3}").format(_("Adding"), artist_name, album_name,
                                          _("to library")))
        track_results = lastfm.get_album_info(artist_name, album_name)
        for track in track_results["tracks"]["track"]:
            if pDialog.iscanceled():
                pDialog.update(0)
                return
            track_name = to_utf8(track["name"])
            add_music_to_library(library_folder, artist_name, album_name,
                                 track_name)
        index += 1
        pDialog.update(0)
    scan_library(type="music")
示例#26
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, 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',
        })
示例#27
0
    def __init__(self):
        self.active = False

        self.hide_progress = False
        self.hide_info = False

        self.autohidedialogs = plugin.get_setting(SETTING_AUTO_HIDE_DIALOGS,
                                                  bool)
        if self.autohidedialogs:
            self.hide_progress = plugin.get_setting(
                SETTING_AUTO_HIDE_DIALOGS_PROGRESS, bool)
            self.hide_info = plugin.get_setting(SETTING_AUTO_HIDE_DIALOGS_INFO,
                                                bool)

        if not self.hide_progress and not self.hide_info:
            self.autohidedialogs = False
示例#28
0
文件: music.py 项目: uguer30/Project
def auto_music_setup(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER, unicode)[-1] != "/": playlist_folder += "/"
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        try:
            xbmcvfs.mkdir(library_folder)
            source_thumbnail = get_icon_path("musicvideos")
            source_name = "Chappaai "  + _("Music videos")
            source_content = "('{0}','musicvideos','metadata.musicvideos.theaudiodb.com','',2147483647,0,'<settings><setting id=\"fanarttvalbumthumbs\" value=\"true\" /><setting id=\"tadbalbumthumbs\" value=\"true\" /></settings>',0,0,NULL,NULL)".format(library_folder)
            add_source(source_name, library_folder, source_content, source_thumbnail)
            return True
        except:
            False
示例#29
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, 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
示例#30
0
def tv_add_to_library(id):
    import_tvdb()    
    show = tvdb[int(id)]
    
    # get active players
    players = active_players("tvshows", filters = {'network': show.get('network')})

    # add default and selector options
    players.insert(0, ADDON_SELECTOR)
    players.insert(0, ADDON_DEFAULT)

    # let the user select one player
    selection = dialogs.select(_("Play with..."), [p.title for p in players])
    if selection == -1:
        return
    
    # get selected player
    player = players[selection]
    
    # setup library folder
    library_folder = setup_library(plugin.get_setting(SETTING_TV_LIBRARY_FOLDER))

    # add to library
    if add_tvshow_to_library(library_folder, show, player.id):
        set_property("clean_library", 1)
        
    # start scan 
    scan_library()
示例#31
0
def update_library():
    # setup library folder
    library_folder = plugin.get_setting(SETTING_MUSIC_LIBRARY_FOLDER)
    if not xbmcvfs.exists(library_folder):
        return
    scan_library(type="music")
    scan_library(type="video")
示例#32
0
def live_add_to_library(channel, mode):
    if mode != None and plugin.get_setting(SETTING_LIVE_DEFAULT_AUTO_ADD,
                                           bool):
        player = mode
    else:
        players = active_players("live",
                                 filters={'network': channel.get('network')})
        players.insert(0, ADDON_SELECTOR)
        selection = dialogs.select(_("Play using..."),
                                   [p.title for p in players])
        if selection == -1:
            return
        player = players[selection]
    library_folder = setup_library(
        plugin.get_setting(SETTING_LIVE_LIBRARY_FOLDER, unicode))
    add_channel_to_library(library_folder, channel, player)
示例#33
0
def get_video_link(players, params, mode, use_simple=False):
    lister = Lister()
    # Extend parameters
    for lang, lang_params in params.items():
        for key, value in lang_params.items():
            if isinstance(value, basestring):
                params[lang][key + "_+"] = value.replace(" ", "+")
                params[lang][key + "_-"] = value.replace(" ", "-")
                params[lang][key + "_escaped"] = value.replace(" ", "%2520")
                params[lang][key + "_escaped+"] = value.replace(" ", "%252B")
    pDialog = None
    selection = None
    try:
        if len(players) > 1 and use_simple:
            index = dialogs.select(_("Play using..."), [player.title for player in players])
            if index == -1: return None
            players = [players[index]]
        resolve_f = lambda p : resolve_player(p, lister, params)
        if len(players) > 1:
            pool_size = plugin.get_setting(SETTING_POOL_SIZE, int)
            populator = lambda : execute(resolve_f, players, lister.stop_flag, pool_size)
            selection = dialogs.select_ext(_("Play using..."), populator, len(players))
        else:
            result = resolve_f(players[0])
            if result:
                title, links = result
                if len(links) == 1: selection = links[0]
                else:
                    index = dialogs.select(_("Play using..."), [x['label'] for x in links])
                    if index > -1: selection = links[index]
            else: dialogs.ok(_("Error"), _("%s not found") % _("Video"))
    finally: lister.stop()
    return selection
示例#34
0
def music_add_artist_to_library(artist_name):
    import math

    library_folder = setup_library(plugin.get_setting(SETTING_MUSIC_LIBRARY_FOLDER))
    album_results = lastfm.get_artist_top_albums(artist_name)
    total_albums = len(album_results)
    index = 0
    pDialog = xbmcgui.DialogProgress()
    pDialog.create(
        "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR]",
        _("{0} {1} {2}").format(_("Adding"), artist_name, _("to library")),
    )
    for album in album_results["album"]:
        album_name = to_utf8(album["name"])
        percent_done = int(math.floor((float(index) / total_albums) * 100))
        pDialog.update(
            percent_done, _("{0} {1} - {2} {3}").format(_("Adding"), artist_name, album_name, _("to library"))
        )
        track_results = lastfm.get_album_info(artist_name, album_name)
        for track in track_results["tracks"]["track"]:
            if pDialog.iscanceled():
                pDialog.update(0)
                return
            track_name = to_utf8(track["name"])
            add_music_to_library(library_folder, artist_name, album_name, track_name)
        index += 1
        pDialog.update(0)
    scan_library(type="music")
示例#35
0
文件: music.py 项目: helloman37/repo
def music_play(artist_name, track_name, album_name, mode):
    items = [{
        'label':
        "{0} {1}".format(_("Play"),
                         _("Audio").lower()),
        'path':
        plugin.url_for("music_play_audio",
                       artist_name=artist_name,
                       track_name=track_name,
                       album_name=album_name,
                       mode=mode)
    }, {
        'label':
        "{0} {1}".format(_("Play"),
                         _("Video").lower()),
        'path':
        plugin.url_for("music_play_video",
                       artist_name=artist_name,
                       track_name=track_name,
                       album_name=album_name,
                       mode=mode)
    }]
    if plugin.get_setting(SETTING_PREFERRED_MUSIC_TYPE, unicode) == "audio":
        music_play_audio(artist_name, track_name, album_name, mode)
    else:
        music_play_video(artist_name, track_name, album_name, mode)
示例#36
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()
示例#37
0
文件: live.py 项目: helloman37/repo
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    metalliq_playlist_folder = "special://profile/playlists/mixed/MetalliQ/"
    if not xbmcvfs.exists(metalliq_playlist_folder):
        xbmcvfs.mkdir(metalliq_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_LIVE_PLAYLIST_FOLDER, unicode)
    # create folders
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        # auto configure folder
        msg = _(
            "Would you like to automatically set MetalliQ as a channel video source?"
        )
        if dialogs.yesno("{0} {1}".format(_("Library"), "setup"), msg):
            source_thumbnail = get_icon_path("live")
            source_name = "MetalliQ " + _("Channels")
            source_content = "('{0}','','','',0,0,'<settings></settings>',0,0,NULL,NULL)".format(
                library_folder)
            add_source(source_name, library_folder, source_content,
                       source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
示例#38
0
def update_library():
    import_tvdb()

    folder_path = plugin.get_setting(SETTING_TV_LIBRARY_FOLDER)
    if not xbmcvfs.exists(folder_path):
        return

    # get library folder
    library_folder = setup_library(folder_path)

    # get shows in library
    try:
        shows = xbmcvfs.listdir(library_folder)[0]
    except:
        shows = []

    # update each show
    clean_needed = False
    updated = 0
    for id in shows:
        id = int(id)

        # add to library
        with tvdb.session.cache_disabled():
            if add_tvshow_to_library(library_folder, tvdb[id]):
                clean_needed = True
        updated += 1

    if clean_needed:
        set_property("clean_library", 1)

    # start scan
    if updated > 0:
        scan_library()
示例#39
0
def library_tv_strm(show, folder, id, season, episode):
    # Create season folder
    enc_season = ('Season %s' % season).translate(None, '\/:*?"<>|').strip('.')
    folder = os.path.join(folder, enc_season)
    try:
        xbmcvfs.mkdir(folder)
    except:
        pass

    # Create episode strm
    enc_name = 'S%02dE%02d' % (season, episode)
    stream = os.path.join(folder, enc_name + '.strm')
    if not xbmcvfs.exists(stream):
        file = xbmcvfs.File(stream, 'w')
        content = plugin.url_for("tv_play",
                                 id=id,
                                 season=season,
                                 episode=episode,
                                 mode='library')
        file.write(str(content))
        file.close()

        if plugin.get_setting(SETTING_LIBRARY_SET_DATE, converter=bool):
            try:
                firstaired = show[season][episode]['firstaired']
                t = date_to_timestamp(firstaired)
                os.utime(stream, (t, t))
            except:
                pass
示例#40
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()
示例#41
0
def trakt_updated_shows(page):
    from datetime import date, timedelta
    start_date = str(date.today() - timedelta(
        days=plugin.get_setting(SETTING_TRAKT_DAYS, int)))
    results, pages = call_trakt("shows/updates/{0}?".format(start_date),
                                params={
                                    'extended':
                                    'full',
                                    'limit':
                                    plugin.get_setting(SETTING_ITEMS_PER_PAGE,
                                                       int)
                                },
                                pagination=True,
                                page=page,
                                with_auth=False)
    return results, pages
示例#42
0
def music_add_album_to_library(artist_name, album_name):
    library_folder = setup_library(plugin.get_setting(SETTING_MUSIC_LIBRARY_FOLDER, unicode))
    results = lastfm.get_album_info(artist_name, album_name)
    for track in results["tracks"]["track"]:
        track_name = to_utf8(track["name"])
        add_music_to_library(library_folder, artist_name, album_name, track_name)
    scan_library(type="music")
示例#43
0
def play_channel(channel, mode="default"):
    # Get players to use
    if mode == 'select':
        play_plugin = ADDON_SELECTOR.id
    else:
        play_plugin = plugin.get_setting(SETTING_LIVE_DEFAULT_PLAYER)
    players = active_players("live", filters = {"channel": channel})
    players = [p for p in players if p.id == play_plugin] or players
    if not players:
        xbmc.executebuiltin( "Action(Info)")
        action_cancel()
        return

    # Get parameters
    params = {}
    for lang in get_needed_langs(players):
        params[lang] = get_channel_parameters(channel)
        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',
        })
示例#44
0
def update_library():
    import_tvdb()
    
    folder_path = plugin.get_setting(SETTING_TV_LIBRARY_FOLDER)
    if not xbmcvfs.exists(folder_path):
        return
        
    # get library folder
    library_folder = setup_library(folder_path)
    
    # get shows in library
    try:
        shows = xbmcvfs.listdir(library_folder)[0]
    except:
        shows = []

    # update each show
    clean_needed = False
    updated = 0
    for id in shows:
        id = int(id)
        
        # add to library
        with tvdb.session.cache_disabled():
            if add_tvshow_to_library(library_folder, tvdb[id]):
                clean_needed = True
        updated += 1
                
    if clean_needed:
        set_property("clean_library", 1)
        
    # start scan
    if updated > 0:
        scan_library()
示例#45
0
def library_tv_strm(show, folder, id, season, episode):        
    # Create season folder
    enc_season = ('Season %s' % season).translate(None, '\/:*?"<>|').strip('.')
    folder = os.path.join(folder, enc_season)
    try: 
        xbmcvfs.mkdir(folder)
    except: 
        pass
        
    # Create episode strm
    enc_name = 'S%02dE%02d' % (season, episode)
    stream = os.path.join(folder, enc_name + '.strm')
    if not xbmcvfs.exists(stream):
        file = xbmcvfs.File(stream, 'w')
        content = plugin.url_for("tv_play", id=id, season=season, episode=episode, mode='library')
        file.write(str(content))
        file.close()
        
        if plugin.get_setting(SETTING_LIBRARY_SET_DATE, converter=bool):
            try:
                firstaired = show[season][episode]['firstaired']
                t = date_to_timestamp(firstaired)
                os.utime(stream, (t,t))
            except:
                pass
示例#46
0
def on_play_video(mode, players, params, trakt_ids=None):
    assert players
    # Cancel resolve
    action_cancel()
    # Get video link
    use_simple_selector = plugin.get_setting(SETTING_USE_SIMPLE_SELECTOR, converter=bool)
    is_extended = not (use_simple_selector or len(players) == 1)
    if not is_extended:
        xbmc.executebuiltin("ActivateWindow(busydialog)")
    try:
        selection = get_video_link(players, params, mode, use_simple_selector)
    finally:
        if not is_extended:
            xbmc.executebuiltin("Dialog.Close(busydialog)")
    if not selection:
        return
    # Get selection details
    link = selection["path"]
    action = selection.get("action", "")
    plugin.log.info("Playing url: %s" % to_utf8(link))
    # Activate link
    if action == "ACTIVATE":
        action_activate(link)
    else:
        if trakt_ids:
            set_property("script.trakt.ids", json.dumps(trakt_ids))
        return link
    return None
示例#47
0
def tv_add_to_library(id):
    import_tvdb()    
    show = tvdb[int(id)]
    
    # get active players
    players = active_players("tvshows", filters = {'network': show.get('network')})
    
    # add default and selector options
    players.insert(0, ADDON_SELECTOR)
    players.insert(0, ADDON_DEFAULT)
    
    # let the user select one player
    selection = dialogs.select(_("Play with..."), [p.title for p in players])
    if selection == -1:
        return
        
    # get selected player
    player = players[selection]
    
    # setup library folder
    library_folder = setup_library(plugin.get_setting(SETTING_TV_LIBRARY_FOLDER))

    # add to library
    if add_tvshow_to_library(library_folder, show, player.id):
        set_property("clean_library", 1)
        
    # start scan 
    scan_library()
示例#48
0
def guide_tv_play_by_name(name, season, episode, lang):
    """ Activate tv search """
    tvdb_id = get_tvdb_id_from_name(name, lang)
    if tvdb_id:
        guide_tv_play(tvdb_id, season, episode, "default")
        if plugin.get_setting(SETTING_TV_PLAYED_BY_ADD, converter=bool) == True:
            tv_add_to_library(tvdb_id)
示例#49
0
def add_movie_to_library(library_folder, src, id, play_plugin=None):
    changed = False
    # create movie folder
    movie_folder = os.path.join(library_folder, str(id) + '/')
    if not xbmcvfs.exists(movie_folder):
        try:
            xbmcvfs.mkdir(movie_folder)
        except:
            pass
        # Create play with file
        if play_plugin is not None:
            player_filepath = os.path.join(movie_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(
        movie_folder,
        str(id) + "%s" % plugin.get_setting(SETTING_LIBRARY_TAGS, unicode) +
        ".nfo")
    if not xbmcvfs.exists(nfo_filepath):
        changed = True
        nfo_file = xbmcvfs.File(nfo_filepath, 'w')
        if src == "imdb":
            content = "http://www.imdb.com/title/%s/" % str(id)
        else:
            content = "http://www.themoviedb.org/movie/%s" % str(id)
        nfo_file.write(content)
        nfo_file.close()
    # create strm file
    strm_filepath = os.path.join(
        movie_folder,
        str(id) + "%s" % plugin.get_setting(SETTING_LIBRARY_TAGS, unicode) +
        ".strm")
    if not xbmcvfs.exists(strm_filepath):
        changed = True
        strm_file = xbmcvfs.File(strm_filepath, 'w')
        content = plugin.url_for("movies_play", src=src, id=id, mode='library')
        strm_file.write(content)
        strm_file.close()


#    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)")
#    xbmc.executebuiltin("RunScript(script.artworkdownloader,mediatype=movie,dbid=%s)" % xbmc.getInfoLabel('ListItem.DBID'))
    return changed
示例#50
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)')
示例#51
0
文件: movies.py 项目: helloman37/repo
def auto_movie_setup(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, unicode)[-1] != "/": playlist_folder += "/"
    # create folders
    if not xbmcvfs.exists(library_folder):
        try:
            if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
            xbmcvfs.mkdir(library_folder)
            source_thumbnail = get_icon_path("movies")
            source_name = "MetalliQ " + _("Movies")
            source_content = "('{0}','movies','metadata.themoviedb.org','',2147483647,1,'<settings><setting id=\"RatingS\" value=\"TMDb\" /><setting id=\"certprefix\" value=\"Rated \" /><setting id=\"fanart\" value=\"true\" /><setting id=\"keeporiginaltitle\" value=\"false\" /><setting id=\"language\" value=\"{1}\" /><setting id=\"tmdbcertcountry\" value=\"us\" /><setting id=\"trailer\" value=\"true\" /></settings>',0,0,NULL,NULL)".format(library_folder, LANG)
            add_source(source_name, library_folder, source_content, source_thumbnail)
            return True
        except:
            False
示例#52
0
def music_add_to_library(artist_name, track_name, album_name):
    if album_name == "None":
        album_name = lastfm.get_track_info(artist_name, track_name)["album"]["title"]

    library_folder = setup_library(plugin.get_setting(SETTING_MUSIC_LIBRARY_FOLDER))

    add_music_to_library(library_folder, artist_name, album_name, track_name)
    scan_library(type="music")
示例#53
0
def music_add_to_library(artist_name, track_name, album_name):
    if album_name == "None":
        album_name = lastfm.get_track_info(artist_name, track_name)["album"]["title"]

    library_folder = setup_library(plugin.get_setting(SETTING_MUSIC_LIBRARY_FOLDER, unicode))

    add_music_to_library(library_folder, artist_name, album_name, track_name)
    scan_library(type="music")
示例#54
0
 def send_query():
     if with_auth:
         try:
             expires_at = plugin.get_setting(SETTING_TRAKT_EXPIRES_AT, int)
             if time.time() > expires_at:
                 trakt_refresh_token()
         except:
             pass
         token = plugin.get_setting(SETTING_TRAKT_ACCESS_TOKEN, unicode)
         if token:
             headers['Authorization'] = 'Bearer ' + token
     if data is not None:
         assert not params
         return requests.post("{0}/{1}".format(API_ENDPOINT, path), json=data, headers=headers)
     elif is_delete:
         return requests.delete("{0}/{1}".format(API_ENDPOINT, path), headers=headers)
     else:
         return requests.get("{0}/{1}".format(API_ENDPOINT, path), params, headers=headers)
示例#55
0
 def onDatabaseUpdated(self, database):
     if database == "video":
         if get_property("clean_library"):
             xbmc.executebuiltin("XBMC.CleanLibrary(video, false)")
             clear_property("clean_library")
     if database == "music":
         # need to manualy change the database file to add strm files to it
         music_directory = plugin.get_setting(SETTING_MUSIC_LIBRARY_FOLDER, unicode)
         self.add_folder_to_music_database(music_directory)
示例#56
0
文件: live.py 项目: uguer30/Project
def get_library_channels():
    folder_path = plugin.get_setting(SETTING_LIVE_LIBRARY_FOLDER, unicode)
    library_folder = setup_library(folder_path)
    # get channels in library
    try:
        library_channels = xbmcvfs.listdir(folder_path)[0]
    except:
        library_channels = []
    return library_channels
示例#57
0
文件: music.py 项目: uguer30/Project
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER, unicode)[-1] != "/": playlist_folder += "/"
    # create folders
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        msg = _("Would you like to automatically set Chappaai as a music source?")
        if dialogs.yesno("{0} {1}".format(_("Library"), "setup"), msg):
            source_thumbnail = get_icon_path("musicvideos")
            source_name = "Chappaai "  + _("Music videos")
            source_content = "('{0}','musicvideos','metadata.musicvideos.theaudiodb.com','',2147483647,0,'<settings><setting id=\"fanarttvalbumthumbs\" value=\"true\" /><setting id=\"tadbalbumthumbs\" value=\"true\" /></settings>',0,0,NULL,NULL)".format(library_folder)
            add_source(source_name, library_folder, source_content, source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
示例#58
0
def auto_tvshows_setup(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    metalliq_playlist_folder = "special://profile/playlists/mixed/MetalliQ/"
    if not xbmcvfs.exists(metalliq_playlist_folder): xbmcvfs.mkdir(metalliq_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, converter=str)
    if plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, converter=str)[-1] != "/": playlist_folder += "/"
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        try:
            xbmcvfs.mkdir(library_folder)
            source_thumbnail = get_icon_path("tv")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("TV Shows")
            source_content = "('{0}','tvshows','metadata.tvdb.com','',0,0,'<settings><setting id=\"RatingS\" value=\"TheTVDB\" /><setting id=\"absolutenumber\" value=\"false\" /><setting id=\"dvdorder\" value=\"false\" /><setting id=\"fallback\" value=\"true\" /><setting id=\"fanart\" value=\"true\" /><setting id=\"language\" value=\"{1}\" /></settings>',0,0,NULL,NULL)".format(library_folder, LANG)
            add_source(source_name, library_folder, source_content, source_thumbnail)
            return True
        except:
            False
示例#59
0
文件: tvshows.py 项目: KingPug75/repo
def auto_tvshows_setup(library_folder):
    if library_folder[-1] != "/": library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)[-1] != "/":
        playlist_folder += "/"
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        try:
            xbmcvfs.mkdir(library_folder)
            source_thumbnail = get_icon_path("tv")
            source_name = "Chappaai " + _("TV shows")
            source_content = "('{0}','tvshows','metadata.tvdb.com','',0,0,'<settings><setting id=\"RatingS\" value=\"TheTVDB\" /><setting id=\"absolutenumber\" value=\"false\" /><setting id=\"dvdorder\" value=\"false\" /><setting id=\"fallback\" value=\"true\" /><setting id=\"fanart\" value=\"true\" /><setting id=\"language\" value=\"{1}\" /></settings>',0,0,NULL,NULL)".format(
                library_folder, LANG)
            add_source(source_name, library_folder, source_content,
                       source_thumbnail)
            return True
        except:
            False
示例#60
0
def setup_library(library_folder):
    if library_folder[-1] != "/": library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)[-1] != "/": playlist_folder += "/"
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        xbmcvfs.mkdir(library_folder)
        # auto configure folder
        msg = _("Would you like to automatically set [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] as a tv shows source?")
        if dialogs.yesno("{0} {1}".format(_("Library"), "setup"), msg):
            try:
                source_thumbnail = get_icon_path("tv")
                source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("TV shows")
                source_content = "('{0}','tvshows','metadata.tvdb.com','',0,0,'<settings><setting id=\"RatingS\" value=\"TheTVDB\" /><setting id=\"absolutenumber\" value=\"false\" /><setting id=\"dvdorder\" value=\"false\" /><setting id=\"fallback\" value=\"true\" /><setting id=\"fanart\" value=\"true\" /><setting id=\"language\" value=\"{1}\" /></settings>',0,0,NULL,NULL)".format(library_folder, LANG)
                add_source(source_name, library_folder, source_content, source_thumbnail)
            except: pass
    # return translated path
    return xbmc.translatePath(library_folder)