Esempio n. 1
0
def scan_library(type="video"):
    while not xbmc.abortRequested and \
     (xbmc.getCondVisibility('Library.IsScanning') or \
     xbmc.getCondVisibility('Window.IsActive(progressdialog)')):
        xbmc.sleep(1000)
    xbmc.executebuiltin('UpdateLibrary(video)')
    xbmc.executebuiltin('UpdateLibrary(music)')
Esempio n. 2
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) + ".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) + ".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)")
    if xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"):
        xbmc.executebuiltin("RunScript(script.extendedinfo,info=afteradd)")
    return changed
Esempio n. 3
0
def list_episodes_tvdb(id, season_num):
    import_tvdb()
    id = int(id)
    season_num = int(season_num)
    show = tvdb[id]
    show_info = get_tvshow_metadata_tvdb(show, banners=False)
    title = show_info['name']
    season = show[season_num]
    season_info = get_season_metadata_tvdb(show_info, season, banners=True)
    items = []
    for (episode_num, episode) in season.items():
        if episode_num == 0 or not episode.has_aired(flexible=True):
            break
        episode_info = get_episode_metadata_tvdb(season_info, episode)
        if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): context_menu = [(_("[COLOR ff0084ff]Q[/COLOR]lick[COLOR ff0084ff]P[/COLOR]lay"), "RunScript(script.qlickplay,info=episodeinfo,tvshow={0},season={1},episode={2})".format(title, season_num, episode_num)), (_("TV trailer"),"RunScript(script.qlickplay,info=playtvtrailer,tvdb_id={0})".format(id)), (_("Recommended tv shows (TMDb)"),"ActivateWindow(10025,plugin://script.qlickplay/?info=similartvshows&tvdb_id={0})".format(id))]
        elif xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"): context_menu = [(_("Extended episode info"), "RunScript(script.extendedinfo,info=episodeinfo,tvshow={0},season={1},episode={2})".format(title, season_num, episode_num)), (_("TV trailer"),"RunScript(script.extendedinfo,info=playtvtrailer,tvdb_id={0})".format(id)), (_("Recommended tv shows (TMDb)"),"ActivateWindow(10025,plugin://script.extendedinfo/?info=similartvshows&tvdb_id={0})".format(id))]
        else: context_menu = []
        context_menu.append((_("Select stream..."),"PlayMedia({0})".format(plugin.url_for("tv_play", id=id, season=season_num, episode=episode_num, mode='select'))))
        context_menu.append((_("Add to list"), "RunPlugin({0})".format(plugin.url_for("lists_add_episode_to_list", src='tvdb', id=id, season=season_num, episode = episode_num))))
        context_menu.append((_("Show info"),'Action(Info)'))
        items.append({'label': episode_info.get('title'),
                      'path': plugin.url_for("tv_play", id=id, season=season_num, episode=episode_num, mode='default'),
                      'context_menu': context_menu,
                      'info': episode_info,
                      'is_playable': True,
                      'info_type': 'video',
                      'stream_info': {'video': {}},
                      'thumbnail': episode_info['poster'],
                      'poster': season_info['poster'],
                      'icon': "DefaultVideo.png",
                      'properties' : {'fanart_image' : episode_info['fanart']},
                      })
    return items
Esempio n. 4
0
def scan_library(type="video"):
    while not xbmc.abortRequested and \
     (xbmc.getCondVisibility('Library.IsScanning') or \
     xbmc.getCondVisibility('Window.IsActive(progressdialog)')):
        xbmc.sleep(1000)
    xbmc.executebuiltin('UpdateLibrary(video)')
    xbmc.executebuiltin('UpdateLibrary(music)')
def list_library():
    while not xbmc.abortRequested and \
     (xbmc.getCondVisibility('Library.IsScanning') or \
     xbmc.getCondVisibility('Window.IsActive(progressdialog)') or \
     xbmc.getCondVisibility('Window.IsActive(extendedprogressdialog)')):
        xbmc.sleep(100)
    xbmc.sleep(5000)
    library = {}
    medias = ["movies", "tvshows"]
    #    medias = ["movies", "tvshows", "musicvideos", "music", "live"]
    for m in medias:
        if m == "movies":
            lib = plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode)
            prite = RPC.videolibrary.get_movies(properties=[
                "title", "year", "playcount", "fanart", "originaltitle",
                "imdbnumber", "thumbnail", "file"
            ])
            if "movies" in prite: ite = prite["movies"]
            else: ite = []
        elif m == "tvshows":
            lib = plugin.get_setting(SETTING_TV_LIBRARY_FOLDER, unicode)
            prite = RPC.videolibrary.get_tvshows(properties=[
                "title", "year", "playcount", "fanart", "originaltitle",
                "imdbnumber", "thumbnail", "file"
            ])
            if "tvshows" in prite: ite = prite["tvshows"]
            else: ite = []
#        elif m == "musicvideos":
#            lib = plugin.get_setting(SETTING_TV_LIBRARY_FOLDER, unicode)
#            ite = RPC.videolibrary.get_tvshows(properties=["title","year","playcount","fanart","originaltitle","imdbnumber","thumbnail","file"])["tvshows"]
        else:
            continue
        liq = xbmcvfs.listdir(lib)[0]
        for i in ite:
            try:
                f = xbmcvfs.File(
                    os.path.join(lib, i["imdbnumber"], "player.info"))
                i["player"] = f.read()
                f.close()
            except:
                i["player"] = "na"
        f = xbmcvfs.File("{0}library.nfo".format(lib), 'w')
        f.write(str(ite))
        f.close()
        if len(ite) > 0:
            players = dict(zip(ite[0],
                               zip(*[d.values() for d in ite])))["player"]
        else:
            players = "()"
        f = xbmcvfs.File("{0}players.nfo".format(lib), 'w')
        f.write(str(players))
        f.close()
Esempio n. 6
0
def make_movie_item(movie_info, is_list = False):
    try: tmdb_id = movie_info.get('tmdb')
    except: tmdb_id = ""
    if tmdb_id == "": 
        try: tmdb_id = info['tmdb']
        except: tmdb_id = False
    try: imdb_id = movie_info.get('imdb')
    except: imdb_id = ""
    if imdb_id == "": 
        try: imdb_id = info['imdb']
        except: imdb_id = False
    if movie_info['poster'] == None or movie_info['poster'] == "": movie_info['poster'] = "https://raw.githubusercontent.com/OpenELEQ/Style/master/MetalliQ/default/unavailable.png"
    if movie_info['fanart'] == None or movie_info['fanart'] == "": movie_info['fanart'] = get_background_path()
    if tmdb_id:
        id = tmdb_id 
        src = 'tmdb'
    elif imdb_id:
        id = imdb_id 
        src = 'imdb'
    else: dialogs.notify(msg="tmdb or imdb id", title=_("%s not found").replace("%s ",""), delay=3000, image=get_icon_path("movies"))
    if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): context_menu = [(_("Scan item to library"),"RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id))), ("%s %s" % (_("Movie"), _("Trailer").lower()),"RunScript(script.qlickplay,info=playtrailer,id={0})".format(id)), ("[COLOR ff0084ff]Q[/COLOR]lick[COLOR ff0084ff]P[/COLOR]lay", "RunScript(script.qlickplay,info=movieinfo,id={0})".format(id)), ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"),"ActivateWindow(10025,plugin://script.qlickplay/?info=similarmovies&id={0})".format(id))]
    elif xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"): context_menu = [(_("Scan item to library"),"RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id))), ("%s %s" % (_("Movie"), _("Trailer").lower()),"RunScript(script.extendedinfo,info=playtrailer,id={0})".format(id)), (_("Extended movie info"), "RunScript(script.extendedinfo,info=extendedinfo,id={0})".format(id)), ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"),"ActivateWindow(10025,plugin://script.extendedinfo/?info=similarmovies&id={0})".format(id))]
    else: context_menu = [(_("Scan item to library"),"RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id)))]
    context_menu.append(("%s %s (%s)" % ("Related", _("movies"), "Trakt"),"ActivateWindow(10025,{0})".format(plugin.url_for("movies_related", id=id, page=1))))
    context_menu.append(("{0} {1}...".format(_("Select"), _("Stream").lower()),"PlayMedia({0})".format(plugin.url_for("movies_play", src=src, id=id, mode='select'))))
    context_menu.append((_("Add to playlist"),"RunPlugin({0})".format(plugin.url_for("lists_add_movie_to_list", src=src, id=id))))
    context_menu.append((_("Movie information"),'Action(Info)'))
    if is_list:
        context_menu.append(
            (
                "{0}".format(_("Remove from library").replace(_("Library").lower(),_("Playlist").lower())),
                "RunPlugin({0})".format(plugin.url_for("lists_remove_movie_from_list", src=src, id=id))
            )
        )
    return {
        'label': movie_info['title'],
        'path': plugin.url_for("movies_play", src=src, id=id, mode='default'),
        'context_menu': context_menu,
        'thumbnail': movie_info['poster'],
        'icon': movie_info['poster'],
        'banner': movie_info['fanart'],
        'poster': movie_info['poster'],
        'properties' : {'fanart_image' : movie_info['fanart']},
        'is_playable': True,
        'info_type': 'video',
        'stream_info': {'video': {}},
        'info': movie_info
    }
Esempio n. 7
0
def make_movie_item(movie_info, is_list = False):
    try: tmdb_id = movie_info.get('tmdb')
    except: tmdb_id = ""
    if tmdb_id == "": 
        try: tmdb_id = info['tmdb']
        except: tmdb_id = False
    try: imdb_id = movie_info.get('imdb')
    except: imdb_id = ""
    if imdb_id == "": 
        try: imdb_id = info['imdb']
        except: imdb_id = False
    if movie_info['poster'] == None or movie_info['poster'] == "": movie_info['poster'] = "http://mrblamo.xyz/chappaaiunavailable.png"
    if movie_info['fanart'] == None or movie_info['fanart'] == "": movie_info['fanart'] = get_background_path()
    if tmdb_id:
        id = tmdb_id 
        src = 'tmdb'
    elif imdb_id:
        id = imdb_id 
        src = 'imdb'
    else: dialogs.notify(msg="tmdb or imdb id", title=_("%s not found").replace("%s ",""), delay=3000, image=get_icon_path("movies"))
    if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): context_menu = [(_("Scan item to library"),"RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id))), ("%s %s" % (_("Movie"), _("Trailer").lower()),"RunScript(script.qlickplay,info=playtrailer,id={0})".format(id)), ("[COLOR purple]Mr Blamo[/COLOR]lick[COLOR ff0084ff]P[/COLOR]lay", "RunScript(script.qlickplay,info=movieinfo,id={0})".format(id)), ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"),"ActivateWindow(10025,plugin://script.qlickplay/?info=similarmovies&id={0})".format(id))]
    elif xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"): context_menu = [(_("Scan item to library"),"RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id))), ("%s %s" % (_("Movie"), _("Trailer").lower()),"RunScript(script.extendedinfo,info=playtrailer,id={0})".format(id)), (_("Extended movie info"), "RunScript(script.extendedinfo,info=extendedinfo,id={0})".format(id)), ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"),"ActivateWindow(10025,plugin://script.extendedinfo/?info=similarmovies&id={0})".format(id))]
    else: context_menu = [(_("Scan item to library"),"RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id)))]
    context_menu.append(("%s %s (%s)" % ("Related", _("movies"), "Trakt"),"ActivateWindow(10025,{0})".format(plugin.url_for("movies_related", id=id, page=1))))
    context_menu.append(("{0} {1}...".format(_("Select"), _("Stream").lower()),"PlayMedia({0})".format(plugin.url_for("movies_play", src=src, id=id, mode='select'))))
    context_menu.append((_("Add to playlist"),"RunPlugin({0})".format(plugin.url_for("lists_add_movie_to_list", src=src, id=id))))
    context_menu.append((_("Movie information"),'Action(Info)'))
    if is_list:
        context_menu.append(
            (
                "{0}".format(_("Remove from library").replace(_("Library").lower(),_("Playlist").lower())),
                "RunPlugin({0})".format(plugin.url_for("lists_remove_movie_from_list", src=src, id=id))
            )
        )
    return {
        'label': movie_info['title'],
        'path': plugin.url_for("movies_play", src=src, id=id, mode='default'),
        'context_menu': context_menu,
        'thumbnail': movie_info['poster'],
        'icon': movie_info['poster'],
        'banner': movie_info['fanart'],
        'poster': movie_info['poster'],
        'properties' : {'fanart_image' : movie_info['fanart']},
        'is_playable': True,
        'info_type': 'video',
        'stream_info': {'video': {}},
        'info': movie_info
    }
Esempio n. 8
0
def action_prerun(link):
#    xbmc.executebuiltin('ActivateWindow(10025,addons://user/xbmc.addon.video/plugin.video.zen/,return)')
    if link.startswith("plugin://"):
        id = link.split("/")
        xbmc.executebuiltin('RunAddon(%s)' % id[2])
        while xbmc.getInfoLabel('Container.PluginName') != id[2] or xbmc.getCondVisibility('Window.IsActive(busydialog)'): xbmc.sleep(250)
        xbmc.sleep(250)
        xbmc.executebuiltin('Container.Update("%s")' % link)
Esempio n. 9
0
def make_tvshow_item(info):
    tvdb_id = info['tvdb_id']
    if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): context_menu = [(_("Add to library"),"RunPlugin({0})".format(plugin.url_for("tv_add_to_library", id=tvdb_id))), (_("TV trailer"),"RunScript(script.qlickplay,info=playtvtrailer,tvdb_id={0})".format(tvdb_id)), (_("[COLOR ff0084ff]Q[/COLOR]lick[COLOR ff0084ff]P[/COLOR]lay"), "RunScript(script.qlickplay,info=tvinfo,tvdb_id={0})".format(tvdb_id)), (_("Recommended tv shows (TMDb)"),"ActivateWindow(10025,plugin://script.qlickplay/?info=similartvshows&tvdb_id={0})".format(tvdb_id))]
    elif xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"): context_menu = [(_("Add to library"),"RunPlugin({0})".format(plugin.url_for("tv_add_to_library", id=tvdb_id))), (_("TV trailer"),"RunScript(script.extendedinfo,info=playtvtrailer,tvdb_id={0})".format(tvdb_id)), (_("Extended TV show info"), "RunScript(script.extendedinfo,info=extendedtvinfo,tvdb_id={0})".format(tvdb_id)), (_("Recommended tv shows (TMDb)"),"ActivateWindow(10025,plugin://script.extendedinfo/?info=similartvshows&tvdb_id={0})".format(tvdb_id))]
    else: context_menu = [(_("Add to library"),"RunPlugin({0})".format(plugin.url_for("tv_add_to_library", id=tvdb_id)))]
    context_menu.append((_("Add to list"), "RunPlugin({0})".format(plugin.url_for("lists_add_show_to_list", src='tvdb', id=tvdb_id))))
    context_menu.append((_("Show info"),'Action(Info)'))
    return {'label': to_utf8(info['title']),
            'path': plugin.url_for("tv_tvshow", id=tvdb_id),
            'context_menu': context_menu,
            'thumbnail': info['poster'],
            'icon': "DefaultVideo.png",
            'poster': info['poster'],
            'properties' : {'fanart_image' : info['fanart']},
            'info_type': 'video',
            'stream_info': {'video': {}},
            'info': info}
Esempio n. 10
0
def wait_for_dialog(dialog_id, timeout=None, interval=500):
    start = time.time()

    while not xbmc.getCondVisibility("Window.IsActive(%s)" % dialog_id):
        if xbmc.abortRequested or (timeout and time.time() - start >= timeout):
            return False
        xbmc.sleep(interval)

    return True
def action_prerun(link):
    #    xbmc.executebuiltin('ActivateWindow(10025,addons://user/xbmc.addon.video/plugin.video.zen/,return)')
    if link.startswith("plugin://"):
        id = link.split("/")
        xbmc.executebuiltin('RunAddon(%s)' % id[2])
        while xbmc.getInfoLabel('Container.PluginName') != id[
                2] or xbmc.getCondVisibility('Window.IsActive(busydialog)'):
            xbmc.sleep(250)
        xbmc.sleep(250)
        xbmc.executebuiltin('Container.Update("%s")' % link)
Esempio n. 12
0
def wait_for_dialog(dialog_id, timeout=None, interval=500):
    start = time.time()
    
    while not xbmc.getCondVisibility("Window.IsActive(%s)" % dialog_id):
        if xbmc.abortRequested or \
         (timeout and time.time() - start >= timeout):
            return False
        xbmc.sleep(interval)
        
    return True
Esempio n. 13
0
 def background_task(self):
     xbmc.sleep(1000)
     while not xbmc.abortRequested and self.active:
         if self.hide_progress:
             active_window = xbmcgui.getCurrentWindowDialogId()
             if active_window in [10101,10151]:
                 xbmc.executebuiltin("Dialog.Close(%d, true)" % active_window)
         if self.hide_info:
             if xbmc.getCondVisibility("Window.IsActive(infodialog)"):
                 xbmc.executebuiltin('Dialog.Close(infodialog, true)')                
         xbmc.sleep(100)
Esempio n. 14
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) + ".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) + ".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)")
    if 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
Esempio n. 15
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) + ".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) + ".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)")
    if 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
Esempio n. 16
0
 def background_task(self):
     xbmc.sleep(1000)
     while not xbmc.abortRequested and self.active:
         if self.hide_progress:
             active_window = xbmcgui.getCurrentWindowDialogId()
             if active_window in [10101, 10151]:
                 xbmc.executebuiltin("Dialog.Close(%d, true)" %
                                     active_window)
         if self.hide_info:
             if xbmc.getCondVisibility("Window.IsActive(infodialog)"):
                 xbmc.executebuiltin('Dialog.Close(infodialog, true)')
         xbmc.sleep(100)
Esempio n. 17
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
        player_filepath = os.path.join(movie_folder, 'player.info')
        player_file = xbmcvfs.File(player_filepath, 'w')
        content = "{0}".format(
            plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY,
                               unicode))
        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')
        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.extendedinfo)"):
        xbmc.executebuiltin("RunScript(script.extendedinfo,info=afteradd)")
    #    if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): xbmc.executebuiltin("RunScript(script.qlickplay,info=afteradd)")

    return changed
Esempio n. 18
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) + ".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) + ".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)")
    if xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"):
        xbmc.executebuiltin("RunScript(script.extendedinfo,info=afteradd)")
    return changed
Esempio n. 19
0
def make_movie_item(movie_info, is_list = False):
    tmdb_id = movie_info.get('tmdb')
    imdb_id = movie_info.get('imdb')
    if tmdb_id:
        id = tmdb_id 
        src = 'tmdb'
    else:
        id = imdb_id 
        src = 'imdb'
    if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): context_menu = [(_("Movie trailer"),"RunScript(script.qlickplay,info=playtrailer,id={0})".format(id)), (_("Add to library"),"RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id))), (_("[COLOR ff0084ff]Q[/COLOR]lick[COLOR ff0084ff]P[/COLOR]lay"), "RunScript(script.qlickplay,info=movieinfo,id={0})".format(id)), (_("Recommended movies (TMDb)"),"ActivateWindow(10025,plugin://script.qlickplay/?info=similarmovies&id={0})".format(id))]
    elif xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"): context_menu = [(_("Movie trailer"),"RunScript(script.extendedinfo,info=playtrailer,id={0})".format(id)), (_("Add to library"),"RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id))), (_("Extended movie info"), "RunScript(script.extendedinfo,info=extendedinfo,id={0})".format(id)), (_("Recommended movies (TMDb)"),"ActivateWindow(10025,plugin://script.extendedinfo/?info=similarmovies&id={0})".format(id))]
    else: context_menu = [(_("Add to library"),"RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id)))]
    context_menu.append((_("Related Movies (Trakt)"),"ActivateWindow(10025,{0})".format(plugin.url_for("movies_related", id=id))))
    context_menu.append((_("Select stream..."),"PlayMedia({0})".format(plugin.url_for("movies_play", src=src, id=id, mode='select'))))
    context_menu.append((_("Add to list"),"RunPlugin({0})".format(plugin.url_for("lists_add_movie_to_list", src=src, id=id))))
    context_menu.append((_("Show info"),'Action(Info)'))
    if is_list:
        context_menu.append(
            (
                _("Remove from list"),
                "RunPlugin({0})".format(plugin.url_for("lists_remove_movie_from_list", src=src, id=id))
            )
        )
    return {
        'label': movie_info['title'],
        'path': plugin.url_for("movies_play", src=src, id=id, mode='default'),
        'context_menu': context_menu,
        'thumbnail': movie_info['poster'],
        'icon': "DefaultVideo.png",
        'poster': movie_info['poster'],
        'properties' : {'fanart_image' : movie_info['fanart']},
        'is_playable': True,
        'info_type': 'video',
        'stream_info': {'video': {}},
        'info': movie_info
    }
Esempio n. 20
0
def list_seasons_tvdb(id):
    import_tvdb()
    id = int(id)
    show = tvdb[id]
    show_info = get_tvshow_metadata_tvdb(show, banners=False)
    title = show_info['name']
    items = []
    for (season_num, season) in show.items():
        if season_num == 0 or not season.has_aired(flexible=True):
            continue
        season_info = get_season_metadata_tvdb(show_info, season)
        if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): context_menu = [(_("[COLOR ff0084ff]Q[/COLOR]lick[COLOR ff0084ff]P[/COLOR]lay"), "RunScript(script.qlickplay,info=seasoninfo,tvshow={0},season={1})".format(title, season_num)), (_("TV trailer"),"RunScript(script.qlickplay,info=playtvtrailer,tvdb_id={0})".format(id)), (_("Recommended tv shows (TMDb)"),"ActivateWindow(10025,plugin://script.qlickplay/?info=similartvshows&tvdb_id={0})".format(id))]
        elif xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"): context_menu = [(_("Extended season info"), "RunScript(script.extendedinfo,info=seasoninfo,tvshow={0},season={1})".format(title, season_num)), (_("TV trailer"),"RunScript(script.extendedinfo,info=playtvtrailer,tvdb_id={0})".format(id)), (_("Recommended tv shows (TMDb)"),"ActivateWindow(10025,plugin://script.extendedinfo/?info=similartvshows&tvdb_id={0})".format(id))]
        else: context_menu = []
        items.append({'label': u"%s %d" % (_("Season"), season_num),
                      'path': plugin.url_for(tv_season, id=id, season_num=season_num),
                      'context_menu': context_menu,
                      'info': season_info,
                      'thumbnail': season_info['poster'],
                      'icon': "DefaultVideo.png",
                      'poster': season_info['poster'],
                      'properties' : {'fanart_image' : season_info['fanart']},
                      })
    return items
 def action_prerun(self, link):
     #    xbmc.executebuiltin('ActivateWindow(10025,addons://user/xbmc.addon.video/plugin.video.zen/,return)')
     if link.startswith("plugin://"):
         id = link.split("/")
         xbmc.executebuiltin('RunAddon(%s)' % id[2])
         while xbmc.getInfoLabel(
                 'Container.PluginName') != id[2] or xbmc.getCondVisibility(
                     'Window.IsActive(busydialog)'):
             xbmc.sleep(250)
         xbmc.sleep(250)
         self.play(link)
     while xbmc.getInfoLabel(
             'Container.PluginName') == id[2] and xbmc.getInfoLabel(
                 'Container.FolderPath') != "plugin://%s/" % id[2] and id[
                     2] in xbmc.getInfoLabel('Container.FolderPath'):
         xbmc.sleep(250)
         if xbmc.getInfoLabel(
                 'Container.FolderPath') == "plugin://%s/" % id[2] or id[
                     2] not in xbmc.getInfoLabel('Container.FolderPath'):
             break
     xbmc.executebuiltin('Container.Update("%s", replace)' %
                         self.returnlink)
Esempio n. 22
0
 def is_scanning_library():
     return xbmc.getCondVisibility(
         'Library.IsScanningVideo') or xbmc.getCondVisibility(
             'Library.IsScanningMusic')
Esempio n. 23
0
 def onAction(self, action):
     if action.getId() in (9, 10, 92, 216, 247, 257, 275, 61467, 61448, ):
         self.close_dialog(True)
     if (action.getId() == 7 or action.getId() == 100) and xbmc.getCondVisibility(
             "Control.HasFocus(3) | Control.HasFocus(6)"):
         self.close_dialog()
Esempio n. 24
0
def _lists_trakt_show_list(list_items):
    genres_dict = trakt.trakt_get_genres("tv")
    if type(list_items) == str:
        import urllib
        list_items = eval(urllib.unquote(list_items))
    items = []
    for list_item in list_items:
        item = None
        item_type = list_item["type"]
        if item_type == "show":
            tvdb_id = list_item["show"]["ids"]["tvdb"]
            if tvdb_id != "" and tvdb_id != None:
                show = list_item["show"]
                info = get_tvshow_metadata_trakt(show, genres_dict)
                context_menu = [
                    (_("Scan item to library"), "RunPlugin({0})".format(
                        plugin.url_for("tv_add_to_library", id=tvdb_id))),
                    (_("TV show information"), 'Action(Info)'),
                    ("{0}".format(
                        _("Remove from library").replace(
                            _("Library").lower(),
                            _("Playlist").lower())), "RunPlugin({0})".format(
                                plugin.url_for("lists_remove_show_from_list",
                                               src="tvdb",
                                               id=tvdb_id)))
                ]
                if plugin.get_setting(SETTING_TRAKT_LIST_ARTWORK,
                                      bool) == False:
                    item = ({
                        'label': info['title'],
                        'path': plugin.url_for("tv_tvshow", id=tvdb_id),
                        'context_menu': context_menu,
                        'thumbnail': info['poster'],
                        'icon': get_icon_path("tv"),
                        'poster': info['poster'],
                        'properties': {
                            'fanart_image': info['fanart']
                        },
                        'info_type': 'video',
                        'stream_info': {
                            'video': {}
                        },
                        'info': info
                    })
                else:
                    item = make_tvshow_item(info)
            else:
                item = None
        elif item_type == "season":
            tvdb_id = list_item["show"]["ids"]["tvdb"]
            season = list_item["season"]
            show = list_item["show"]
            show_info = get_tvshow_metadata_trakt(show, genres_dict)
            season_info = get_season_metadata_trakt(show_info, season,
                                                    genres_dict)
            label = "{0} - Season {1}".format(show["title"], season["number"])
            context_menu = [
                (_("Scan item to library"), "RunPlugin({0})".format(
                    plugin.url_for("tv_add_to_library", id=tvdb_id))),
                ("%s %s" % (_("Season"), _("Information").lower()),
                 'Action(Info)'),
                ("{0}".format(
                    _("Remove from library").replace(
                        _("Library").lower(),
                        _("Playlist").lower())),
                 "RunPlugin({0})".format(
                     plugin.url_for("lists_remove_season_from_list",
                                    src="tvdb",
                                    id=tvdb_id,
                                    season=list_item["season"]["number"])))
            ]
            item = ({
                'label':
                label,
                'path':
                plugin.url_for("tv_season",
                               id=tvdb_id,
                               season_num=list_item["season"]["number"]),
                'context_menu':
                context_menu,
                'info':
                season_info,
                'thumbnail':
                season_info['poster'],
                'icon':
                get_icon_path("tv"),
                'poster':
                season_info['poster'],
                'properties': {
                    'fanart_image': season_info['fanart']
                },
            })
        elif item_type == "episode":
            tvdb_id = list_item["show"]["ids"]["tvdb"]
            episode = list_item["episode"]
            show = list_item["show"]
            season_number = episode["season"]
            episode_number = episode["number"]
            show_info = get_tvshow_metadata_trakt(show, genres_dict)
            episode_info = get_episode_metadata_trakt(show_info, episode)
            label = "{0} - S{1}E{2} - {3}".format(show_info["title"],
                                                  season_number,
                                                  episode_number,
                                                  episode_info["title"])
            context_menu = [
                ("{0} {1}...".format(_("Select"),
                                     _("Stream").lower()),
                 "PlayMedia({0})".format(
                     plugin.url_for("tv_play",
                                    id=tvdb_id,
                                    season=season_number,
                                    episode=episode_number,
                                    mode='select'))),
                ("%s %s" % (_("Episode"), _("Information").lower()),
                 'Action(Info)'),
                (_("Add to playlist"), "RunPlugin({0})".format(
                    plugin.url_for("lists_add_episode_to_list",
                                   src='tvdb',
                                   id=tvdb_id,
                                   season=season_number,
                                   episode=episode_number))),
                ("{0}".format(
                    _("Remove from library").replace(
                        _("Library").lower(),
                        _("Playlist").lower())), "RunPlugin({0})".format(
                            plugin.url_for("lists_remove_season_from_list",
                                           src="tvdb",
                                           id=tvdb_id,
                                           season=season_number,
                                           episode=episode_number)))
            ]
            item = ({
                'label':
                label,
                'path':
                plugin.url_for("tv_play",
                               id=tvdb_id,
                               season=season_number,
                               episode=episode_number,
                               mode='default'),
                'context_menu':
                context_menu,
                'info':
                episode_info,
                'is_playable':
                True,
                'info_type':
                'video',
                'stream_info': {
                    'video': {}
                },
                'thumbnail':
                episode_info['poster'],
                'poster':
                episode_info['poster'],
                'icon':
                get_icon_path("tv"),
                'properties': {
                    'fanart_image': episode_info['fanart']
                },
            })
        elif item_type == "movie":
            movie = list_item["movie"]
            movie_info = get_trakt_movie_metadata(movie)
            try:
                tmdb_id = movie_info['tmdb']
            except:
                tmdb_id = ""
            try:
                imdb_id = movie_info['imdb']
            except:
                imdb_id = ""
            if tmdb_id != None and tmdb_id != "":
                src = "tmdb"
                id = tmdb_id
            elif imdb_id != None and mdb_id != "":
                src = "imdb"
                id = imdb_id
            else:
                src = ""
                id = ""
            if src == "": item = None
            else:
                if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"):
                    context_menu = [
                        (_("Scan item to library"), "RunPlugin({0})".format(
                            plugin.url_for("movies_add_to_library",
                                           src=src,
                                           id=id))),
                        ("%s %s" % (_("Movie"), _("Trailer").lower()),
                         "RunScript(script.qlickplay,info=playtrailer,id={0})".
                         format(id)),
                        ("[COLOR ff0084ff]Q[/COLOR]lick[COLOR ff0084ff]P[/COLOR]lay",
                         "RunScript(script.qlickplay,info=movieinfo,id={0})".
                         format(id)),
                        ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"),
                         "ActivateWindow(10025,plugin://script.qlickplay/?info=similarmovies&id={0})"
                         .format(id))
                    ]
                elif xbmc.getCondVisibility(
                        "system.hasaddon(script.extendedinfo)"):
                    context_menu = [
                        (_("Scan item to library"), "RunPlugin({0})".format(
                            plugin.url_for("movies_add_to_library",
                                           src=src,
                                           id=id))),
                        ("%s %s" % (_("Movie"), _("Trailer").lower()),
                         "RunScript(script.extendedinfo,info=playtrailer,id={0})"
                         .format(id)),
                        ((_("Extended movie info"), _("Extended movie info"),
                          "RunScript(script.extendedinfo,info=extendedinfo,id={0})"
                          .format(id)),
                         ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"),
                          "ActivateWindow(10025,plugin://script.extendedinfo/?info=similarmovies&id={0})"
                          .format(id)))
                    ]
                else:
                    context_menu = [
                        (_("Scan item to library"), "RunPlugin({0})".format(
                            plugin.url_for("movies_add_to_library",
                                           src=src,
                                           id=id)))
                    ]
                    context_menu.append(
                        ("%s %s (%s)" % ("Related", _("movies"), "Trakt"),
                         "ActivateWindow(10025,{0})".format(
                             plugin.url_for("movies_related", id=id, page=1))))
                    context_menu.append(
                        ("{0} {1}...".format(_("Select"),
                                             _("Stream").lower()),
                         "PlayMedia({0})".format(
                             plugin.url_for("movies_play",
                                            src=src,
                                            id=id,
                                            mode='select'))))
                    context_menu.append(
                        (_("Add to playlist"), "RunPlugin({0})".format(
                            plugin.url_for("lists_add_movie_to_list",
                                           src=src,
                                           id=id))))
                    context_menu.append(
                        (_("Movie information"), 'Action(Info)'))
                if imdb_id != None and imdb_id != "":
                    context_menu.append(
                        ("Show Actors", "ActivateWindow(10025,{0})".format(
                            plugin.url_for("people_list_movie_people",
                                           id=imdb_id,
                                           source="imdb",
                                           fanart=get_background_path()))))
                elif tmdb_id != None and tmdb_id != "":
                    context_menu.append(
                        ("Show Actors", "ActivateWindow(10025,{0})".format(
                            plugin.url_for("people_list_movie_people",
                                           id=tmdb_id,
                                           source="tmdb",
                                           fanart=get_background_path()))))
            item = make_movie_item(movie_info, True)
        elif item_type == "person":
            person_id = list_item['person']['ids']['trakt']
            person_tmdb_id = list_item['person']['ids']['tmdb']
            context_menu = []
            try:
                import_tmdb()
                person_images = tmdb.People(
                    person_tmdb_id).images()['profiles']
                person_image = 'https://image.tmdb.org/t/p/w640' + person_images[
                    0]['file_path']
            except:
                person_image = ''
            person_name = to_utf8(list_item['person']['name'])
            item = ({
                'label':
                person_name,
                'path':
                plugin.url_for("trakt_movies_person", person_id=person_id),
                'context_menu':
                context_menu,
                #'info': season_info,
                'thumbnail':
                person_image,
                'icon':
                get_icon_path("movies"),
                'poster':
                person_image,
                'properties': {
                    'fanart_image': person_image
                },
            })
        if item is not None:
            items.append(item)
    for item in items:
        item['properties'] = {'fanart_image': get_background_path()}
    return items
Esempio n. 25
0
def _lists_trakt_show_list(list_items):
    genres_dict = trakt.trakt_get_genres("tv")
    if type(list_items) == str:
        import urllib
        list_items = eval(urllib.unquote(list_items))
    items = []
    for list_item in list_items:
        item = None
        item_type = list_item["type"]
        if item_type == "show":
            tvdb_id = list_item["show"]["ids"]["tvdb"]
            if tvdb_id != "" and tvdb_id != None:
                show = list_item["show"]
                info = get_tvshow_metadata_trakt(show, genres_dict)
                context_menu = [
                    (
                        _("Scan item to library"),
                        "RunPlugin({0})".format(plugin.url_for("tv_add_to_library", id=tvdb_id))
                    ),
                    (
                        _("TV show information"), 'Action(Info)'
                    ),
                    (
                        "{0}".format(_("Remove from library").replace(_("Library").lower(),_("Playlist").lower())),
                        "RunPlugin({0})".format(plugin.url_for("lists_remove_show_from_list", src="tvdb", id=tvdb_id))
                    )
                ]
                if plugin.get_setting(SETTING_TRAKT_LIST_ARTWORK, bool) == False:
                    item = ({
                        'label': info['title'],
                        'path': plugin.url_for("tv_tvshow", id=tvdb_id),
                        'context_menu': context_menu,
                        'thumbnail': info['poster'],
                        'icon': get_icon_path("tv"),
                        'poster': info['poster'],
                        'properties' : {'fanart_image' : info['fanart']},
                        'info_type': 'video',
                        'stream_info': {'video': {}},
                        'info': info
                    })
                else: item = make_tvshow_item(info)
            else: item = None
        elif item_type == "season":
            tvdb_id = list_item["show"]["ids"]["tvdb"]
            season = list_item["season"]
            show = list_item["show"]
            show_info = get_tvshow_metadata_trakt(show, genres_dict)
            season_info = get_season_metadata_trakt(show_info,season, genres_dict)
            label = "{0} - Season {1}".format(show["title"],season["number"])
            context_menu = [
                (
                    _("Scan item to library"),
                    "RunPlugin({0})".format(plugin.url_for("tv_add_to_library", id=tvdb_id))
                ),
                (
                    "%s %s" % (_("Season"), _("Information").lower()), 'Action(Info)'
                ),
                (
                    "{0}".format(_("Remove from library").replace(_("Library").lower(),_("Playlist").lower())),
                    "RunPlugin({0})".format(plugin.url_for("lists_remove_season_from_list", src="tvdb",
                                                           id=tvdb_id, season=list_item["season"]["number"]))
                )
            ]
            item = ({
                'label': label,
                'path': plugin.url_for("tv_season", id=tvdb_id, season_num=list_item["season"]["number"]),
                'context_menu': context_menu,
                'info': season_info,
                'thumbnail': season_info['poster'],
                'icon': get_icon_path("tv"),
                'poster': season_info['poster'],
                'properties': {'fanart_image': season_info['fanart']},
            })
        elif item_type == "episode":
            tvdb_id = list_item["show"]["ids"]["tvdb"]
            episode = list_item["episode"]
            show = list_item["show"]
            season_number = episode["season"]
            episode_number = episode["number"]
            show_info = get_tvshow_metadata_trakt(show, genres_dict)
            episode_info = get_episode_metadata_trakt(show_info, episode)
            label = "{0} - S{1}E{2} - {3}".format(show_info["title"], season_number,
                                                  episode_number, episode_info["title"])
            context_menu = [
                (
                    "{0} {1}...".format(_("Select"), _("Stream").lower()),
                    "PlayMedia({0})".format(
                        plugin.url_for("tv_play", id=tvdb_id, season=season_number,
                                       episode=episode_number, mode='select'))
                ),
                (
                    "%s %s" % (_("Episode"), _("Information").lower()),
                    'Action(Info)'
                ),
                (
                    _("Add to playlist"),
                    "RunPlugin({0})".format(plugin.url_for("lists_add_episode_to_list", src='tvdb', id=tvdb_id,
                                                           season=season_number, episode=episode_number))
                ),
                (
                    "{0}".format(_("Remove from library").replace(_("Library").lower(),_("Playlist").lower())),
                    "RunPlugin({0})".format(plugin.url_for("lists_remove_season_from_list", src="tvdb", id=tvdb_id,
                                                           season=season_number, episode = episode_number))
                )
            ]
            item = ({
                'label': label,
                'path': plugin.url_for("tv_play", id=tvdb_id, season=season_number,
                                       episode=episode_number, mode='default'),
                'context_menu': context_menu,
                'info': episode_info,
                'is_playable': True,
                'info_type': 'video',
                'stream_info': {'video': {}},
                'thumbnail': episode_info['poster'],
                'poster': episode_info['poster'],
                'icon': get_icon_path("tv"),
                'properties': {'fanart_image': episode_info['fanart']},
                })
        elif item_type == "movie":
            movie = list_item["movie"]
            movie_info = get_trakt_movie_metadata(movie)
            try: tmdb_id = movie_info['tmdb']
            except: tmdb_id = ""
            try: imdb_id = movie_info['imdb']
            except: imdb_id = ""
            if tmdb_id != None and tmdb_id != "":
                src = "tmdb"
                id = tmdb_id
            elif imdb_id != None and mdb_id != "":
                src = "imdb"
                id = imdb_id
            else:
                src = ""
                id = ""
            if src == "": item = None
            else:
                if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"):
                    context_menu = [( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id))), 
                                    ("%s %s" % (_("Movie"), _("Trailer").lower()), "RunScript(script.qlickplay,info=playtrailer,id={0})".format(id)), 
                                    ("[COLOR ff0084ff]Q[/COLOR]lick[COLOR ff0084ff]P[/COLOR]lay", "RunScript(script.qlickplay,info=movieinfo,id={0})".format(id)), 
                                    ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"), "ActivateWindow(10025,plugin://script.qlickplay/?info=similarmovies&id={0})".format(id))]
                elif xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"):
                    context_menu = [( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id))),
                                    ("%s %s" % (_("Movie"), _("Trailer").lower()), "RunScript(script.extendedinfo,info=playtrailer,id={0})".format(id)), (
                                    (_("Extended movie info"),_("Extended movie info"), "RunScript(script.extendedinfo,info=extendedinfo,id={0})".format(id)), 
                                    ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"), "ActivateWindow(10025,plugin://script.extendedinfo/?info=similarmovies&id={0})".format(id)))]
                else:
                    context_menu = [( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id)))]
                    context_menu.append(("%s %s (%s)" % ("Related", _("movies"), "Trakt"), "ActivateWindow(10025,{0})".format(plugin.url_for("movies_related", id=id, page=1))))
                    context_menu.append(("{0} {1}...".format(_("Select"), _("Stream").lower()), "PlayMedia({0})".format(plugin.url_for("movies_play", src=src, id=id, mode='select'))))
                    context_menu.append((_("Add to playlist"), "RunPlugin({0})".format(plugin.url_for("lists_add_movie_to_list", src=src, id=id))))
                    context_menu.append((_("Movie information"), 'Action(Info)'))
                if imdb_id != None and imdb_id != "":
                    context_menu.append(("Show Actors", "ActivateWindow(10025,{0})".format(plugin.url_for("people_list_movie_people", id=imdb_id, source="imdb", fanart=get_background_path()))))
                elif tmdb_id != None and tmdb_id != "":
                    context_menu.append(("Show Actors", "ActivateWindow(10025,{0})".format(plugin.url_for("people_list_movie_people", id=tmdb_id, source="tmdb", fanart=get_background_path()))))
            item = make_movie_item(movie_info, True)
        elif item_type == "person":
            person_id = list_item['person']['ids']['trakt']
            person_tmdb_id = list_item['person']['ids']['tmdb']
            context_menu= []
            try:
                import_tmdb()
                person_images = tmdb.People(person_tmdb_id).images()['profiles']
                person_image = 'https://image.tmdb.org/t/p/w640' + person_images[0]['file_path']
            except: person_image = ''
            person_name = to_utf8(list_item['person']['name'])
            item = ({
                'label': person_name,
                'path': plugin.url_for("trakt_movies_person", person_id=person_id),
                'context_menu': context_menu,
                #'info': season_info,
                'thumbnail': person_image,
                'icon': get_icon_path("movies"),
                'poster': person_image,
                'properties': {'fanart_image': person_image},
            })
        if item is not None:
            items.append(item)
    for item in items:
        item['properties'] = {'fanart_image' : get_background_path()}
    return items
 def is_scanning_library():
     return xbmc.getCondVisibility('Library.IsScanningVideo') or xbmc.getCondVisibility('Library.IsScanningMusic')
Esempio n. 27
0
 def is_empty(self):
     if self.pluginid and \
      not xbmc.getCondVisibility('System.HasAddon(%s)' % self.pluginid):
         return True
     return not bool(self.commands)
 def has_addon(addon_id):
     return bool(xbmc.getCondVisibility('System.HasAddon(%s)' % addon_id))
Esempio n. 29
0
 def is_empty(self):
     if self.pluginid and not xbmc.getCondVisibility(
             'System.HasAddon(%s)' % self.pluginid):
         return True
     return not bool(self.commands)
Esempio n. 30
0
def add_tvshow_to_library(library_folder, show, play_plugin=None):
    clean_needed = False
    id = show['id']
    showname = to_utf8(show['seriesname'])
    if showname == "None" or showname == None:
        show_folder = os.path.join(library_folder, str(id) + '/')
        if os.path.isdir(show_folder): return shutil.rmtree(show_folder)
    playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)
    if not xbmcvfs.exists(playlist_folder):
        try:
            xbmcvfs.mkdir(playlist_folder)
        except:
            dialogs.notify(msg=_('Creation of Chappaai Playlist Folder'),
                           title=_('Failed'),
                           delay=5000,
                           image=get_icon_path("lists"))
    playlist_file = os.path.join(playlist_folder, id + ".xsp")
    if not xbmcvfs.exists(playlist_file):
        playlist_file = xbmcvfs.File(playlist_file, 'w')
        content = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><smartplaylist type="tvshows"><name>%s</name><match>all</match><rule field="path" operator="contains"><value>%s%s</value></rule><rule field="playcount" operator="is"><value>0</value></rule><order direction="ascending">numepisodes</order></smartplaylist>' % (
            showname, plugin.get_setting(SETTING_TV_LIBRARY_FOLDER,
                                         str).replace('special://home',
                                                      ''), str(id))
        playlist_file.write(str(content))
        playlist_file.close()
    ## Create show folder
    enc_show = showname.translate(None, '\/:*?"<>|').strip('.')
    show_folder = os.path.join(library_folder, str(id) + '/')
    if not xbmcvfs.exists(show_folder):
        try:
            xbmcvfs.mkdir(show_folder)
        except:
            pass
        # Create play with file
        if play_plugin is not None:
            player_filepath = os.path.join(show_folder, 'player.info')
            player_file = xbmcvfs.File(player_filepath, 'w')
            content = "{0}".format(play_plugin)
            player_file.write(content)
            player_file.close()
        # Create nfo file
        nfo_filepath = os.path.join(show_folder, 'tvshow.nfo')
        if not xbmcvfs.exists(nfo_filepath):
            nfo_file = xbmcvfs.File(nfo_filepath, 'w')
            content = "http://thetvdb.com/index.php?tab=series&id=%s" % str(id)
            nfo_file.write(content)
            nfo_file.close()
    ## Get existing items in library
    # get all ids of the show
    ids = [id, show.get('imdb_id', None)]  # TODO: add tmdb!
    ids = [x for x in ids if x]
    # get show episodes in library
    try:
        # get tvshow from library
        libshows = RPC.VideoLibrary.GetTVShows(
            properties=["imdbnumber", "title", "year"])['tvshows']
        libshows = [
            i for i in libshows if str(i['imdbnumber']) in ids or (
                str(i['year']) == str(show.get('year', 0))
                and equals(show['seriesname'], i['title']))
        ]
        libshow = libshows[0]
        # get existing (non strm) episodes in library
        libepisodes = RPC.VideoLibrary.GetEpisodes(
            filter={
                "and": [{
                    "field": "tvshow",
                    "operator": "is",
                    "value": to_utf8(libshow['title'])
                }]
            },
            properties=["season", "episode", "file"])['episodes']
        libepisodes = [(int(i['season']), int(i['episode']))
                       for i in libepisodes if not i['file'].endswith(".strm")]
    except:
        libepisodes = []
    ## Create content strm files
    for (season_num, season) in show.items():
        if season_num == 0:  # or not season.has_aired():
            continue
        for (episode_num, episode) in season.items():
            if episode_num == 0:
                continue
            delete = False
            if plugin.get_setting(SETTING_AIRED_UNKNOWN, bool) == True:
                aired_unknown = True
            else:
                aired_unknown = False
            if not episode.has_aired(flexible=aired_unknown):
                delete = True
                #break
            if delete or (season_num, episode_num) in libepisodes:
                if library_tv_remove_strm(show, show_folder, id, season_num,
                                          episode_num):
                    clean_needed = True
            else:
                library_tv_strm(show, show_folder, id, season_num, episode_num)
    files, dirs = xbmcvfs.listdir(show_folder)
    if not dirs:
        shutil.rmtree(show_folder)
        clean_needed = True
    if xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"):
        xbmc.executebuiltin("RunScript(script.extendedinfo,info=afteradd)")
    #    if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): xbmc.executebuiltin("RunScript(script.qlickplay,info=afteradd)")

    return clean_needed
Esempio n. 31
0
 def has_addon(addon_id):
     return bool(xbmc.getCondVisibility('System.HasAddon(%s)' % addon_id))