コード例 #1
0
ファイル: add.py プロジェクト: jwhite/plugin.video.flix2kodi
def add_context_menu_show(entries, removable, thumb_url, title, video_id):
    if generic_utility.get_setting('browse_tv_shows') == 'true':
        entries.append((generic_utility.get_string(30151),
                        'Container.Update(plugin://%s/?mode=play_video_main&url=%s&thumb=%s)' % (
                            generic_utility.addon_id, urllib.quote_plus(video_id), urllib.quote_plus(thumb_url))))
    else:
        entries.append((generic_utility.get_string(30152),
                        'Container.Update(plugin://%s/?mode=list_seasons&url=%s&thumb=%s)' % (
                            generic_utility.addon_id, urllib.quote_plus(video_id), urllib.quote_plus(thumb_url))))
    if removable:
        entries.append((generic_utility.get_string(30154), 'RunPlugin(plugin://%s/?mode=remove_from_queue&url=%s)' % (
            generic_utility.addon_id, urllib.quote_plus(video_id))))
    else:
        entries.append((generic_utility.get_string(30155), 'RunPlugin(plugin://%s/?mode=add_to_queue&url=%s)' % (
            generic_utility.addon_id, urllib.quote_plus(video_id))))
    series_dir = library.get_series_dir(title.strip())
    #        generic_utility.log('series-dir: '+series_dir)
    if xbmcvfs.exists(series_dir + os.sep) == False:
        entries.append((generic_utility.get_string(30150),
                        'RunPlugin(plugin://%s/?mode=add_series_to_library&url=&name=%s&series_id=%s)' % (
                            generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title.strip())),
                            urllib.quote_plus(video_id))))
    else:
        entries.append((generic_utility.get_string(301501),
                        'RunPlugin(plugin://%s/?mode=remove_series_from_library&url=&name=%s)' % (
                            generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title.strip())))))
コード例 #2
0
def add_context_menu_show(entries, removable, thumb_url, title, video_id):
    if generic_utility.get_setting('browse_tv_shows') == 'true':
        entries.append((generic_utility.get_string(30151),
                        'RunPlugin(plugin://%s/?mode=play_video_main&url=%s&thumb=%s)' % (
                            generic_utility.addon_id, urllib.quote_plus(video_id), urllib.quote_plus(thumb_url))))

    else:
        entries.append((generic_utility.get_string(30152),
                        'Container.Update(plugin://%s/?mode=list_seasons&url=%s&thumb=%s)' % (
                            generic_utility.addon_id, urllib.quote_plus(video_id), urllib.quote_plus(thumb_url))))
    if removable:
        entries.append((generic_utility.get_string(30154), 'RunPlugin(plugin://%s/?mode=remove_from_queue&url=%s)' % (
            generic_utility.addon_id, urllib.quote_plus(video_id))))
    else:
        entries.append((generic_utility.get_string(30155), 'RunPlugin(plugin://%s/?mode=add_to_queue&url=%s)' % (
            generic_utility.addon_id, urllib.quote_plus(video_id))))
    series_dir = library.get_series_dir(title.strip())
    #        generic_utility.log('series-dir: '+series_dir)
    if xbmcvfs.exists(series_dir + os.sep) == False:
        entries.append((generic_utility.get_string(30150),
                        'RunPlugin(plugin://%s/?mode=add_series_to_library&url=&name=%s&series_id=%s)' % (
                            generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title.strip())),
                            urllib.quote_plus(video_id))))
    else:
        entries.append((generic_utility.get_string(301501),
                        'RunPlugin(plugin://%s/?mode=remove_series_from_library&url=&name=%s)' % (
                            generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title.strip())))))
コード例 #3
0
def tmdb(video_type, title, year=None):
    search = tmdbsimple.Search()
    if video_type.startswith('tv'):
        content = search.tv(query=generic_utility.encode(title), first_air_date_year=year, language=language,
                            include_adult='true')
        if content['total_results'] == 0:
            content = search.tv(query=generic_utility.encode(title), language=language, include_adult='true')
            if content['total_results'] == 0:
                if '(' in title:
                    title = title[:title.find('(')]
                    content = search.tv(query=generic_utility.encode(title), first_air_date_year=year, language=language,
                                        include_adult='true')
                elif ':' in title:
                    title = title.replace(':', '+')
                    content = search.tv(query=generic_utility.encode(title), first_air_date_year=year, language=language,
                                        include_adult='true')
    else:
        content = search.movie(query=generic_utility.encode(title), year=year, language=language, include_adult='true')
        if content['total_results'] == 0:
            content = search.movie(query=generic_utility.encode(title), language=language, include_adult='true')
            if content['total_results'] == 0:
                if '(' in title:
                    title = title[:title.find('(')]
                    content = search.movie(query=generic_utility.encode(title), year=year, language=language,
                                           include_adult='true')
                elif ':' in title:
                    title = title.replace(':', '+')
                    content = search.movie(query=generic_utility.encode(title), year=year, language=language,
                                           include_adult='true')
    if content['total_results'] == 0:
        content = search.movie(query=generic_utility.encode(title), year=year, language=language, include_adult='true')
    return content
コード例 #4
0
ファイル: add.py プロジェクト: jwhite/plugin.video.flix2kodi
def add_context_menu_movie(entries, removable, title, type, video_id, year):
    entries.append((
        generic_utility.get_string(30153), 'RunPlugin(plugin://%s/?mode=play_trailer&url=%s&type=%s)' % (
            generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title)), type)))
    entries.append((generic_utility.get_string(30156),
                    'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=movie)' % (
                        generic_utility.addon_id, urllib.quote_plus(
                                generic_utility.main_url + 'WiMovie/' + video_id))))
    entries.append(
            (generic_utility.get_string(30157), 'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=tv)' % (
                generic_utility.addon_id, urllib.quote_plus(generic_utility.main_url + 'WiMovie/' + video_id))))
    if removable:
        entries.append((generic_utility.get_string(30154), 'RunPlugin(plugin://%s/?mode=remove_from_queue&url=%s)' % (
            generic_utility.addon_id, urllib.quote_plus(video_id))))
    else:
        entries.append((generic_utility.get_string(30155), 'RunPlugin(plugin://%s/?mode=add_to_queue&url=%s)' % (
            generic_utility.addon_id, urllib.quote_plus(video_id))))
    title_utf8 = title.strip() + ' (' + str(year) + ')'
    title = urllib.quote_plus(title_utf8.encode('utf-8'))
    movie_dir = library.get_movie_dir(title_utf8)[0]
    if xbmcvfs.exists(movie_dir + os.sep) == False:
        entries.append((generic_utility.get_string(30150),
                        'RunPlugin(plugin://%s/?mode=add_movie_to_library&url=%s&name=%s)' % (
                            generic_utility.addon_id, urllib.quote_plus(video_id),
                            title)))
    else:
        entries.append((generic_utility.get_string(301501),
                        'RunPlugin(plugin://%s/?mode=remove_movie_from_library&url=&name=%s)' % (
                            generic_utility.addon_id, title)))
コード例 #5
0
ファイル: add.py プロジェクト: daitj/plugin.video.flix2kodi
def season(name, url, thumb, series_name, series_id):
    entries = []
    cover_file, fanart_file = generic_utility.cover_fanart(series_id)
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(unicode(url))
    u += '&mode=list_episodes'
    u += '&series_id=' + urllib.quote_plus(series_id)
    list_item = xbmcgui.ListItem(name)
    list_item.setArt({'icon': 'DefaultTVShows.png', 'thumb': thumb})
    list_item.setInfo(type='video', infoLabels={'title': name})
    if xbmcvfs.exists(fanart_file):
        list_item.setProperty('fanart_image', fanart_file)
    elif xbmcvfs.exists(cover_file):
        list_item.setProperty('fanart_image', cover_file)
    else:
        list_item.setProperty('fanart_image', generic_utility.addon_fanart())
    entries.append((
        generic_utility.get_string(30150),
        'RunPlugin(plugin://%s/?mode=add_series_to_library&url=%s&name=%s&series_id=%s)'
        % (generic_utility.addon_id, urllib.quote_plus(unicode(url)),
           urllib.quote_plus(generic_utility.encode(
               series_name.strip())), series_id)))
    list_item.addContextMenuItems(entries)
    directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle,
                                                 url=u,
                                                 listitem=list_item,
                                                 isFolder=True)
    return directory_item
コード例 #6
0
def add_series(series_id, series_title, season, single_update=True):
    series_file = get_series_dir(series_title)
    if not xbmcvfs.exists(series_file+os.sep):
        xbmcvfs.mkdir(series_file+os.sep)
    content = get.series_info(series_id)
    generic_utility.log(str(content))
    content = json.loads(content)['video']['seasons']
    for test in content:
        episode_season = unicode(test['seq'])
        if episode_season == season or season == '':
            season_dir = generic_utility.create_pathname(series_file.decode('utf-8'), test['title'])
            if not xbmcvfs.exists(season_dir+os.sep):
                xbmcvfs.mkdir(season_dir+os.sep)
            for item in test['episodes']:
                episode_id = unicode(item['episodeId'])
                episode_nr = unicode(item['seq'])
                episode_title = item['title']
                if len(episode_nr) == 1:
                    episode_nr = '0' + episode_nr
                season_nr = episode_season
                if len(season_nr) == 1:
                    season_nr = '0' + season_nr
                filename = 'S' + season_nr + 'E' + episode_nr + ' - ' + episode_title + '.V' + episode_id + 'V'+ '.strm'
                filename = generic_utility.clean_filename(filename, ' .')
                file_handler = xbmcvfs.File(generic_utility.create_pathname(season_dir, filename), 'w')
                file_handler.write(
                    generic_utility.encode('plugin://%s/?mode=play_video&url=%s' % (
                    generic_utility.addon_id, episode_id)))
                file_handler.close()
    if generic_utility.get_setting('update_db') and single_update:
        xbmc.executebuiltin('UpdateLibrary(video)')
コード例 #7
0
def tmdb(video_type, title, year=None):
    search = tmdbsimple.Search()
    if video_type.startswith('tv'):
        content = search.tv(query=generic_utility.encode(title),
                            first_air_date_year=year,
                            language=language,
                            include_adult='true')
        if content['total_results'] == 0:
            content = search.tv(query=generic_utility.encode(title),
                                language=language,
                                include_adult='true')
            if content['total_results'] == 0:
                if '(' in title:
                    title = title[:title.find('(')]
                    content = search.tv(query=generic_utility.encode(title),
                                        first_air_date_year=year,
                                        language=language,
                                        include_adult='true')
                elif ':' in title:
                    title = title.replace(':', '+')
                    content = search.tv(query=generic_utility.encode(title),
                                        first_air_date_year=year,
                                        language=language,
                                        include_adult='true')
    else:
        content = search.movie(query=generic_utility.encode(title),
                               year=year,
                               language=language,
                               include_adult='true')
        if content['total_results'] == 0:
            content = search.movie(query=generic_utility.encode(title),
                                   language=language,
                                   include_adult='true')
            if content['total_results'] == 0:
                if '(' in title:
                    title = title[:title.find('(')]
                    content = search.movie(query=generic_utility.encode(title),
                                           year=year,
                                           language=language,
                                           include_adult='true')
                elif ':' in title:
                    title = title.replace(':', '+')
                    content = search.movie(query=generic_utility.encode(title),
                                           year=year,
                                           language=language,
                                           include_adult='true')
    if content['total_results'] == 0:
        content = search.movie(query=generic_utility.encode(title),
                               year=year,
                               language=language,
                               include_adult='true')
    return content
コード例 #8
0
ファイル: add.py プロジェクト: daitj/plugin.video.flix2kodi
def create_video_listitem(removable, video_metadata, viewing_activity):
    title = video_metadata['title']
    video_id = video_metadata['video_id']
    thumb_url = video_metadata['thumb_url']
    type = video_metadata['type']
    description = video_metadata['description']
    duration = video_metadata['duration']
    year = video_metadata['year']
    mpaa = video_metadata['mpaa']
    director = video_metadata['director']
    genre = video_metadata['genre']
    rating = video_metadata['rating']
    playcount = video_metadata['playcount']
    next_mode = 'play_video_main'
    if viewing_activity == False and generic_utility.get_setting(
            'browse_tv_shows') == 'true' and (type == 'show'):
        next_mode = 'list_seasons'
    entries = []
    cover_file, fanart_file = generic_utility.cover_fanart(video_id)
    if xbmcvfs.exists(cover_file):
        thumb_url = cover_file
    url = sys.argv[0]
    url += '?url=' + urllib.quote_plus(video_id)
    url += '&mode=' + next_mode
    url += '&name=' + urllib.quote_plus(generic_utility.encode(title))
    url += '&thumb=' + urllib.quote_plus(thumb_url)
    list_item = xbmcgui.ListItem(title)
    list_item.setArt({'icon': 'DefaultTVShows.png', 'thumb': thumb_url})
    list_item.setInfo(type='video',
                      infoLabels={
                          'title': title,
                          'plot': description,
                          'duration': unicode(duration),
                          'year': int(year),
                          'mpaa': mpaa,
                          'director': director,
                          'genre': genre,
                          'rating': rating,
                          'playcount': playcount
                      })
    list_item.setProperty('IsPlayable', 'true')
    if xbmcvfs.exists(fanart_file):
        list_item.setProperty('fanart_image', fanart_file)
    elif xbmcvfs.exists(cover_file):
        list_item.setProperty('fanart_image', cover_file)
    else:
        list_item.setProperty('fanart_image', thumb_url)
    if type == 'show':
        add_context_menu_show(entries, removable, thumb_url, title, video_id)
    else:
        add_context_menu_movie(entries, removable, title, type, video_id, year)
    list_item.addContextMenuItems(entries)
    folder = True
    if next_mode == 'play_video_main':
        folder = False
    #    utility.log(u)
    return url, list_item, folder
コード例 #9
0
ファイル: add.py プロジェクト: jwhite/plugin.video.flix2kodi
def video(video_metadata, removable = False, viewing_activity = False):
#    utility.log(str(video_metadata))

    title = video_metadata['title']
    video_id = video_metadata['video_id']
    thumb_url = video_metadata['thumb_url']
    type = video_metadata['type']
    description = video_metadata['description']
    duration = video_metadata['duration']
    year = video_metadata['year']
    mpaa = video_metadata['mpaa']
    director = video_metadata['director']
    genre = video_metadata['genre']
    rating = video_metadata['rating']
    playcount = video_metadata['playcount']

    next_mode = 'play_video_main'
    if viewing_activity == False and generic_utility.get_setting('browse_tv_shows') == 'true' and (type == 'show'):
        next_mode = 'list_seasons'

    entries = []
    cover_file, fanart_file = generic_utility.cover_fanart(video_id)
    if xbmcvfs.exists(cover_file):
        thumb_url = cover_file
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(video_id)
    u += '&mode=' + next_mode
    u += '&name=' + urllib.quote_plus(generic_utility.encode(title))
    u += '&thumb=' + urllib.quote_plus(thumb_url)
    list_item = xbmcgui.ListItem(title)
    list_item.setArt({'icon': 'DefaultTVShows.png', 'thumb': thumb_url})
    list_item.setInfo(type='video',
                      infoLabels={'title': title, 'plot': description, 'duration': unicode(duration), 'year': int(year),
                                  'mpaa': mpaa, 'director': director, 'genre': genre, 'rating': rating,
                                  'playcount': playcount})
    list_item.setProperty('IsPlayable', 'true');
    if xbmcvfs.exists(fanart_file):
        list_item.setProperty('fanart_image', fanart_file)
    elif xbmcvfs.exists(cover_file):
        list_item.setProperty('fanart_image', cover_file)
    else:
        list_item.setProperty('fanart_image', thumb_url)
    if type == 'show':
        add_context_menu_show(entries, removable, thumb_url, title, video_id)
    else:
        add_context_menu_movie(entries, removable, title, type, video_id, year)
    list_item.addContextMenuItems(entries)

    folder = True
    if next_mode == 'play_video_main':
        folder = False
#    utility.log(u)
    directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle, url=u, listitem=list_item, isFolder=folder)
    return directory_item
コード例 #10
0
ファイル: add.py プロジェクト: jwhite/plugin.video.flix2kodi
def add_next_item(name, page, url, video_type, mode, iconimage):
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(url)
    u += '&mode=' + mode
    u += '&type=' + video_type
    u += '&page=' + str(page)
    u += '&name=' + urllib.quote_plus(generic_utility.encode(name))
    liz=xbmcgui.ListItem(unicode(name), iconImage="DefaultFolder.png",thumbnailImage=iconimage)
    liz.setInfo( type="Video", infoLabels={ "Title": name })
    ok=xbmcplugin.addDirectoryItem(handle=plugin_handle,url=u,listitem=liz,isFolder=True)
    return ok
コード例 #11
0
def season(item):
    entries = []
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(unicode(item.get("season")))
    u += '&mode=list_episodes'
    u += '&series_id=' + urllib.quote_plus(item.get("series_id"))
    
    if generic_utility.get_setting('use_tmdb') == 'true':
        extended_info = get.extended_artwork(item.get("tvshowtitle"),item.get("tvshowyear"),"show",item.get("series_id"))
    else:
        extended_info = {}
    
    list_item = xbmcgui.ListItem(item.get("name"))
    artwork = {
        'icon': 'DefaultTVShows.png', 
        'thumb': extended_info.get("poster", item.get("seriesthumb","")), 
        'landscape': extended_info.get("landscape",item.get("seriesthumb","")), 
        'poster': extended_info.get("poster",""), 
        'clearlogo': extended_info.get("clearlogo",""), 
        'clearart': extended_info.get("clearart",""), 
        'fanart': extended_info.get("fanart",""), 
        'characterart': extended_info.get("characterart",""), 
        'discart': extended_info.get("discart",""), 
        'banner': extended_info.get("banner","")
    }
    list_item.setArt(artwork)
    
    list_item.setInfo(type='video',infoLabels={
        'title': item.get("name",""),
        'year': item.get("year"), 
        'playcount': item.get("playcount"), 
        'tvshowtitle':item.get("tvshowtitle"),
        'castandrole': eval(extended_info.get("castandrole","[]")), 
        'trailer': extended_info.get("trailer",""),
        'genre': extended_info.get("genre",""), 
        'studio': extended_info.get("studio",""), 
        'plot': extended_info.get("plot",item.get("description","")),
        'plotoutline': item.get("description",""),
        'director': extended_info.get("director",""),
        'writer': extended_info.get("writer",""),
        'rating': float(extended_info.get("rating","0")),
        })
    list_item.setProperty("totalepisodes", str(item.get("total_episodes","")))
    list_item.setProperty("watchedepisodes", str(item.get("watched_episodes","")))
    list_item.setProperty("unwatchedepisodes", str(item.get("unwatched_episodes","")))
    entries.append((generic_utility.get_string(30150),
                    'RunPlugin(plugin://%s/?mode=add_series_to_library&url=%s&name=%s&series_id=%s)' % (
                        generic_utility.addon_id, urllib.quote_plus(unicode(item.get("season"))),
                        urllib.quote_plus(generic_utility.encode(item.get("tvshowtitle").strip())),
                        item.get("series_id"))))
    list_item.addContextMenuItems(entries)
    directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle, url=u, listitem=list_item, isFolder=True)
    return directory_item
コード例 #12
0
def add_movie(movie_id, title, single_update=True):
    generic_utility.log(title)
    movie_dir, title = get_movie_dir(title)
    if not xbmcvfs.exists(movie_dir+os.sep):
        xbmcvfs.mkdir(movie_dir+os.sep)

    movie_file = generic_utility.clean_filename(title + '.V' + movie_id + 'V' + '.strm', ' .').strip(' .')
    file_handler = xbmcvfs.File(generic_utility.create_pathname(movie_dir.decode('utf-8'), movie_file), 'w')
    file_handler.write(
        generic_utility.encode('plugin://%s/?mode=play_video&url=%s' % (generic_utility.addon_id, movie_id)))
    file_handler.close()
    if generic_utility.get_setting('update_db') and single_update:
        xbmc.executebuiltin('UpdateLibrary(video)')
コード例 #13
0
def tmdb(video_type, title, year=None):
    search = tmdbsimple.Search()
    if video_type.startswith("tv"):
        content = search.tv(
            query=generic_utility.encode(title), first_air_date_year=year, language=language, include_adult="true"
        )
        if content["total_results"] == 0:
            content = search.tv(query=generic_utility.encode(title), language=language, include_adult="true")
            if content["total_results"] == 0:
                if "(" in title:
                    title = title[: title.find("(")]
                    content = search.tv(
                        query=generic_utility.encode(title),
                        first_air_date_year=year,
                        language=language,
                        include_adult="true",
                    )
                elif ":" in title:
                    title = title.replace(":", "+")
                    content = search.tv(
                        query=generic_utility.encode(title),
                        first_air_date_year=year,
                        language=language,
                        include_adult="true",
                    )
    else:
        content = search.movie(query=generic_utility.encode(title), year=year, language=language, include_adult="true")
        if content["total_results"] == 0:
            content = search.movie(query=generic_utility.encode(title), language=language, include_adult="true")
            if content["total_results"] == 0:
                if "(" in title:
                    title = title[: title.find("(")]
                    content = search.movie(
                        query=generic_utility.encode(title), year=year, language=language, include_adult="true"
                    )
                elif ":" in title:
                    title = title.replace(":", "+")
                    content = search.movie(
                        query=generic_utility.encode(title), year=year, language=language, include_adult="true"
                    )
    if content["total_results"] == 0:
        content = search.movie(query=generic_utility.encode(title), year=year, language=language, include_adult="true")
    return content
コード例 #14
0
def add_next_item(page, url, video_type, mode):
    name = generic_utility.get_string(30110)
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(url)
    u += '&mode=' + mode
    u += '&type=' + video_type
    u += '&page=' + str(page)
    u += '&name=' + urllib.quote_plus(generic_utility.encode(name))
    liz=xbmcgui.ListItem(unicode(name), iconImage="DefaultFolder.png")
    liz.setInfo( type="Video", infoLabels={ "Title": name, "sorttitle": "zzzzzzz"})
    liz.setArt( { "thumb": generic_utility.addon_handle.getAddonInfo('icon'), "fanart":generic_utility.addon_handle.getAddonInfo('fanart') })
    liz.setProperty('IsPlayable', 'false');
    ok=xbmcplugin.addDirectoryItem(handle=plugin_handle,url=u,listitem=liz,isFolder=True)
    return ok
コード例 #15
0
def series_info(series_id):
    content = ''
    cache_file = xbmc.translatePath(generic_utility.cache_dir() + series_id + '_episodes.cache')
    if xbmcvfs.exists(cache_file) and (time.time() - xbmcvfs.Stat(cache_file).st_mtime() < 60 * 5):
        file_handler = xbmcvfs.File(cache_file, 'rb')
        content = generic_utility.decode(file_handler.read())
        file_handler.close()
    if not content:
        url = generic_utility.series_url % (generic_utility.get_setting('api_url'), series_id)
        content = connect.load_netflix_site(url)
        file_handler = xbmcvfs.File(cache_file, 'wb')
        file_handler.write(generic_utility.encode(content))
        file_handler.close()
    return content
コード例 #16
0
def video_info(video_id, lock = None, ignore_cache = False):
    content = ''
    cache_file = xbmc.translatePath(generic_utility.cache_dir() + video_id + '.cache')
    if not ignore_cache and xbmcvfs.exists(cache_file):
        file_handler = xbmcvfs.File(cache_file, 'rb')
        content = generic_utility.decode(file_handler.read())
        file_handler.close()
    if not content:
        post_data = generic_utility.video_info % (video_id, video_id, video_id, video_id,
                                                  generic_utility.get_setting('authorization_url'))
        content = connect.load_netflix_site(generic_utility.evaluator(), post=post_data, lock = lock)
        file_handler = xbmcvfs.File(cache_file, 'wb')
        file_handler.write(generic_utility.encode(content))
        file_handler.close()
    return content
コード例 #17
0
ファイル: add.py プロジェクト: daitj/plugin.video.flix2kodi
def add_next_item(name, page, url, video_type, mode, iconimage):
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(url)
    u += '&mode=' + mode
    u += '&type=' + video_type
    u += '&page=' + str(page)
    u += '&name=' + urllib.quote_plus(generic_utility.encode(name))
    liz = xbmcgui.ListItem(unicode(name),
                           iconImage="DefaultFolder.png",
                           thumbnailImage=iconimage)
    liz.setInfo(type="Video", infoLabels={"Title": name, "Year": 9999})
    ok = xbmcplugin.addDirectoryItem(handle=plugin_handle,
                                     url=u,
                                     listitem=liz,
                                     isFolder=True)
    return ok
コード例 #18
0
def add_context_menu_movie(entries, removable, title, type, video_id, year):
    entries.append(
        (generic_utility.get_string(30153),
         'RunPlugin(plugin://%s/?mode=play_trailer&url=%s&type=%s)' %
         (generic_utility.addon_id,
          urllib.quote_plus(generic_utility.encode(title)), type)))
    entries.append((
        generic_utility.get_string(30156),
        'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=movie)' %
        (generic_utility.addon_id,
         urllib.quote_plus(generic_utility.main_url + 'WiMovie/' + video_id))))
    entries.append((
        generic_utility.get_string(30157),
        'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=tv)' %
        (generic_utility.addon_id,
         urllib.quote_plus(generic_utility.main_url + 'WiMovie/' + video_id))))
    if removable:
        entries.append(
            (generic_utility.get_string(30154),
             'RunPlugin(plugin://%s/?mode=remove_from_queue&url=%s)' %
             (generic_utility.addon_id, urllib.quote_plus(video_id))))
    else:
        entries.append(
            (generic_utility.get_string(30155),
             'RunPlugin(plugin://%s/?mode=add_to_queue&url=%s)' %
             (generic_utility.addon_id, urllib.quote_plus(video_id))))
    title_utf8 = title.strip() + ' (' + str(year) + ')'
    title = urllib.quote_plus(title_utf8.encode('utf-8'))
    movie_dir = library.get_movie_dir(title_utf8)[0]
    if xbmcvfs.exists(movie_dir + os.sep) == False:
        entries.append(
            (generic_utility.get_string(30150),
             'RunPlugin(plugin://%s/?mode=add_movie_to_library&url=%s&name=%s)'
             % (generic_utility.addon_id, urllib.quote_plus(video_id), title)))
    else:
        entries.append((generic_utility.get_string(
            301501
        ), 'RunPlugin(plugin://%s/?mode=remove_movie_from_library&url=&name=%s)'
                        % (generic_utility.addon_id, title)))
コード例 #19
0
ファイル: add.py プロジェクト: jwhite/plugin.video.flix2kodi
def season(name, url, thumb, series_name, series_id):
    entries = []
    cover_file, fanart_file = generic_utility.cover_fanart(series_id)
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(unicode(url))
    u += '&mode=list_episodes'
    u += '&series_id=' + urllib.quote_plus(series_id)
    list_item = xbmcgui.ListItem(name)
    list_item.setArt({'icon': 'DefaultTVShows.png', 'thumb': thumb})
    list_item.setInfo(type='video', infoLabels={'title': name})
    if xbmcvfs.exists(fanart_file):
        list_item.setProperty('fanart_image', fanart_file)
    elif xbmcvfs.exists(cover_file):
        list_item.setProperty('fanart_image', cover_file)
    else:
        list_item.setProperty('fanart_image', generic_utility.addon_fanart())
    entries.append((generic_utility.get_string(30150),
                    'RunPlugin(plugin://%s/?mode=add_series_to_library&url=%s&name=%s&series_id=%s)' % (
                        generic_utility.addon_id, urllib.quote_plus(unicode(url)),
                        urllib.quote_plus(generic_utility.encode(series_name.strip())),
                        series_id)))
    list_item.addContextMenuItems(entries)
    directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle, url=u, listitem=list_item, isFolder=True)
    return directory_item
コード例 #20
0
def create_video_listitem(removable, video_metadata, viewing_activity):
    title = video_metadata['title']
    video_id = video_metadata['video_id']
    thumb_url = video_metadata['thumb_url']
    type = video_metadata['type']
    description = video_metadata['description']
    duration = video_metadata['duration']
    year = video_metadata['year']
    mpaa = video_metadata['mpaa']
    director = video_metadata['director']
    genre = video_metadata['genre']
    rating = video_metadata['rating']
    playcount = video_metadata['playcount']
    next_mode = 'play_video_main'
    fanart = generic_utility.addon_handle.getAddonInfo('fanart')

    if viewing_activity == False and generic_utility.get_setting(
            'browse_tv_shows') == 'true' and (type == 'show'):
        next_mode = 'list_seasons'
    entries = []
    url = sys.argv[0]
    url += '?url=' + urllib.quote_plus(video_id)
    url += '&mode=' + next_mode
    url += '&name=' + urllib.quote_plus(generic_utility.encode(title))
    url += '&thumb=' + urllib.quote_plus(thumb_url)

    #get extended artwork if tmdb lookups are enabled
    if generic_utility.get_setting('use_tmdb') == 'true' and type in [
            "movie", "show"
    ]:
        extended_info = get.extended_artwork(title, year, type,
                                             video_metadata['video_id'])
    elif generic_utility.get_setting(
            'use_tmdb') == 'true' and type == "episode":
        extended_info = get.extended_artwork(video_metadata['series_title'],
                                             year, type,
                                             video_metadata['series_id'])
    else:
        extended_info = {}

    defaulticon = "DefaultMovies.png"
    if type in ['season', 'show', 'episode']:
        defaulticon = "DefaultTVShows.png"

    #prepend watchdate to label for viewing_activity listings
    if viewing_activity:
        list_item = xbmcgui.ListItem(
            "%s - %s" % (video_metadata.get("date_watched", ""), title))
    else:
        list_item = xbmcgui.ListItem(title)

    artwork = {
        'icon': defaulticon,
        'thumb': extended_info.get("poster", thumb_url),
        'landscape': extended_info.get("landscape", thumb_url),
        'poster': extended_info.get("poster", thumb_url),
        'clearlogo': extended_info.get("clearlogo", thumb_url),
        'clearart': extended_info.get("clearart", thumb_url),
        'fanart': extended_info.get("fanart", thumb_url),
        'characterart': extended_info.get("characterart", thumb_url),
        'discart': extended_info.get("discart", thumb_url),
        'banner': extended_info.get("banner", thumb_url)
    }
    list_item.setArt(artwork)

    if type == 'show':
        add_context_menu_show(entries, removable, thumb_url, title, video_id)
        #get playcount from episodes

        #TODO: Commented to prevent request flood and consequent ban
        #playcount, total_episodes, watched_episodes, unwatched_episodes = get.series_playcounts(video_id)
        #list_item.setProperty("totalepisodes", str(total_episodes))
        #list_item.setProperty("watchedepisodes", str(watched_episodes))
        #list_item.setProperty("unwatchedepisodes", str(unwatched_episodes))
    else:
        add_context_menu_movie(entries, removable, title, type, video_id, year)

    list_item.setInfo(type='video',
                      infoLabels={
                          'title':
                          title,
                          'duration':
                          unicode(duration),
                          'year':
                          int(year),
                          'mpaa':
                          mpaa,
                          'playcount':
                          playcount,
                          'cast':
                          video_metadata.get("actors", []),
                          'castandrole':
                          eval(extended_info.get("castandrole", "[]")),
                          'code':
                          extended_info.get("imdb_id", ""),
                          'tagline':
                          extended_info.get("tagline", ""),
                          'trailer':
                          extended_info.get("trailer", ""),
                          'genre':
                          extended_info.get("genre", genre),
                          'studio':
                          extended_info.get("studio", ""),
                          'plot':
                          extended_info.get("plot", description),
                          'plotoutline':
                          description,
                          'director':
                          extended_info.get("director", director),
                          'writer':
                          extended_info.get("writer", ""),
                          'rating':
                          float(extended_info.get("rating", rating)),
                          'datewatched':
                          video_metadata.get("date_watched", "")
                      })
    if type == "episode":
        list_item.setInfo(type='video',
                          infoLabels={
                              'tvshowtitle':
                              video_metadata.get("series_title", ""),
                              'episode': video_metadata.get("episode", None),
                              'season': video_metadata.get("season", None)
                          })

    list_item.setProperty('IsPlayable', 'true')

    list_item.addContextMenuItems(entries)
    folder = True
    if next_mode == 'play_video_main':
        folder = False

    #always set streaminfo to prevent kodi from probing the listitems
    if video_metadata.get("hd"):
        list_item.addStreamInfo(
            "video", {
                "codec": "h264",
                "aspect": 1.78,
                "width": 1920,
                "height": 1080,
                "duration": duration
            })
        list_item.addStreamInfo("audio", {
            "codec": "pcm_s16le",
            "channels": "2"
        })
    else:
        list_item.addStreamInfo(
            "video", {
                "codec": "h264",
                "aspect": 1.78,
                "width": 720,
                "height": 480,
                "duration": duration
            })
        list_item.addStreamInfo("audio", {
            "codec": "pcm_s16le",
            "channels": "2"
        })

    return url, list_item, folder
コード例 #21
0
ファイル: add.py プロジェクト: badcrc/plugin.video.flix2kodi
def create_video_listitem(removable, video_metadata, viewing_activity):
    title = video_metadata['title']
    video_id = video_metadata['video_id']
    thumb_url = video_metadata['thumb_url']
    type = video_metadata['type']
    description = video_metadata['description']
    duration = video_metadata['duration']
    year = video_metadata['year']
    mpaa = video_metadata['mpaa']
    director = video_metadata['director']
    genre = video_metadata['genre']
    rating = video_metadata['rating']
    playcount = video_metadata['playcount']
    next_mode = 'play_video_main'
    fanart = generic_utility.addon_handle.getAddonInfo('fanart')

    if viewing_activity == False and generic_utility.get_setting('browse_tv_shows') == 'true' and (type == 'show'):
        next_mode = 'list_seasons'
    entries = []
    url = sys.argv[0]
    url += '?url=' + urllib.quote_plus(video_id)
    url += '&mode=' + next_mode
    url += '&name=' + urllib.quote_plus(generic_utility.encode(title))
    url += '&thumb=' + urllib.quote_plus(thumb_url)
    
    #get extended artwork if tmdb lookups are enabled
    if generic_utility.get_setting('use_tmdb') == 'true' and type in ["movie","show"]:
        extended_info = get.extended_artwork(title,year,type,video_metadata['video_id'])
    elif generic_utility.get_setting('use_tmdb') == 'true' and type == "episode":
        extended_info = get.extended_artwork(video_metadata['series_title'],year,type,video_metadata['series_id'])
    else: extended_info = {}
    
    defaulticon = "DefaultMovies.png"
    if type in ['season','show','episode']:
        defaulticon = "DefaultTVShows.png"
    
    #prepend watchdate to label for viewing_activity listings
    if viewing_activity:
        list_item = xbmcgui.ListItem("%s - %s" %(video_metadata.get("date_watched",""),title))
    else:
        list_item = xbmcgui.ListItem(title)
    
    artwork = {
        'icon': defaulticon, 
        'thumb': extended_info.get("poster",thumb_url), 
        'landscape': extended_info.get("landscape",thumb_url), 
        'poster': extended_info.get("poster",""), 
        'clearlogo': extended_info.get("clearlogo",""), 
        'clearart': extended_info.get("clearart",""), 
        'fanart': extended_info.get("fanart",fanart), 
        'characterart': extended_info.get("characterart",""), 
        'discart': extended_info.get("discart",""), 
        'banner': extended_info.get("banner","")
    }
    list_item.setArt(artwork)
    
    if type == 'show':
        add_context_menu_show(entries, removable, thumb_url, title, video_id)
        #get playcount from episodes
        playcount, total_episodes, watched_episodes, unwatched_episodes = get.series_playcounts(video_id)
        list_item.setProperty("totalepisodes", str(total_episodes))
        list_item.setProperty("watchedepisodes", str(watched_episodes))
        list_item.setProperty("unwatchedepisodes", str(unwatched_episodes))
    else:
        add_context_menu_movie(entries, removable, title, type, video_id, year)
    
    list_item.setInfo(type='video', infoLabels= {
        'title': title,
        'duration': unicode(duration),
        'year': int(year),
        'mpaa': mpaa,
        'playcount': playcount,
        'cast': video_metadata.get("actors",[]),
        'castandrole': eval(extended_info.get("castandrole","[]")), 
        'code': extended_info.get("imdb_id",""), 
        'tagline': extended_info.get("tagline",""), 
        'trailer': extended_info.get("trailer",""),
        'genre': extended_info.get("genre",genre), 
        'studio': extended_info.get("studio",""), 
        'plot': extended_info.get("plot",description),
        'plotoutline': description,
        'director': extended_info.get("director",director),
        'writer': extended_info.get("writer",""),
        'rating': float(extended_info.get("rating",rating)),
        'datewatched': video_metadata.get("date_watched","")
    })
    if type == "episode":
        list_item.setInfo(type='video', infoLabels= {
            'tvshowtitle': video_metadata.get("series_title",""),
            'episode': video_metadata.get("episode",None),
            'season': video_metadata.get("season",None)
        })

    list_item.setProperty('IsPlayable', 'true');
    
    list_item.addContextMenuItems(entries)
    folder = True
    if next_mode == 'play_video_main':
        folder = False
    
    #always set streaminfo to prevent kodi from probing the listitems
    if video_metadata.get("hd"):
        list_item.addStreamInfo("video", {"codec":"h264", "aspect":1.78, "width":1920, "height":1080, "duration":duration} )
        list_item.addStreamInfo("audio", {"codec":"pcm_s16le","channels":"2" })
    else:
        list_item.addStreamInfo("video", {"duration":duration} )
    
    return url, list_item, folder
コード例 #22
0
def video(video_metadata, removable = False, viewing_activity = False):
#    utility.log(str(video_metadata))

    title = video_metadata['title']
    video_id = video_metadata['video_id']
    thumb_url = video_metadata['thumb_url']
    type = video_metadata['type']
    description = video_metadata['description']
    duration = video_metadata['duration']
    year = video_metadata['year']
    mpaa = video_metadata['mpaa']
    director = video_metadata['director']
    genre = video_metadata['genre']
    rating = video_metadata['rating']
    playcount = video_metadata['playcount']

    next_mode = 'play_video_main'
    if viewing_activity == False and generic_utility.get_setting('browse_tv_shows') == 'true' and (type == 'tvshow' or type == 'episode'):
        next_mode = 'list_seasons'

    entries = []
    cover_file, fanart_file = generic_utility.cover_fanart(video_id)
    if xbmcvfs.exists(cover_file):
        thumb_url = cover_file
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(video_id)
    u += '&mode=' + next_mode
    u += '&name=' + urllib.quote_plus(generic_utility.encode(title))
    u += '&thumb=' + urllib.quote_plus(thumb_url)
    list_item = xbmcgui.ListItem(title)
    list_item.setArt({'icon': 'DefaultTVShows.png', 'thumb': thumb_url})
    list_item.setInfo(type='video',
                      infoLabels={'title': title, 'plot': description, 'duration': unicode(duration), 'year': int(year),
                                  'mpaa': mpaa, 'director': director, 'genre': genre, 'rating': rating,
                                  'playcount': playcount})
    list_item.setProperty('IsPlayable', 'true');
    if xbmcvfs.exists(fanart_file):
        list_item.setProperty('fanart_image', fanart_file)
    elif xbmcvfs.exists(cover_file):
        list_item.setProperty('fanart_image', cover_file)
    else:
        list_item.setProperty('fanart_image', thumb_url)
    if type == 'tvshow':
        if generic_utility.get_setting('browse_tv_shows') == 'true':
            entries.append((generic_utility.get_string(30151),
                            'Container.Update(plugin://%s/?mode=play_video_main&url=%s&thumb=%s)' % (
                                generic_utility.addon_id, urllib.quote_plus(video_id), urllib.quote_plus(thumb_url))))
        else:
            entries.append((generic_utility.get_string(30152),
                            'Container.Update(plugin://%s/?mode=list_seasons&url=%s&thumb=%s)' % (
                                generic_utility.addon_id, urllib.quote_plus(video_id), urllib.quote_plus(thumb_url))))
    if type != 'episode':
        entries.append((
                       generic_utility.get_string(30153), 'RunPlugin(plugin://%s/?mode=play_trailer&url=%s&type=%s)' % (
                           generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title)), type)))
        if removable:
            entries.append((generic_utility.get_string(30154), 'RunPlugin(plugin://%s/?mode=remove_from_queue&url=%s)' % (
                generic_utility.addon_id, urllib.quote_plus(video_id))))
        else:
            entries.append((generic_utility.get_string(30155), 'RunPlugin(plugin://%s/?mode=add_to_queue&url=%s)' % (
                generic_utility.addon_id, urllib.quote_plus(video_id))))
        entries.append((generic_utility.get_string(30156),
                        'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=movie)' % (
                            generic_utility.addon_id, urllib.quote_plus(
                                generic_utility.main_url + 'WiMovie/' + video_id))))
        entries.append((generic_utility.get_string(30157), 'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=tv)' % (
            generic_utility.addon_id, urllib.quote_plus(generic_utility.main_url + 'WiMovie/' + video_id))))
#    generic_utility.log(type)
    if type in ('tvshow', 'episode'):
        series_dir = library.get_series_dir(title.strip())
#        generic_utility.log('series-dir: '+series_dir)
        if xbmcvfs.exists(series_dir+os.sep) == False:
            entries.append((generic_utility.get_string(30150),
                            'RunPlugin(plugin://%s/?mode=add_series_to_library&url=&name=%s&series_id=%s)' % (
                                generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title.strip())), urllib.quote_plus(video_id))))
        else:
            entries.append((generic_utility.get_string(301501),
                            'RunPlugin(plugin://%s/?mode=remove_series_from_library&url=&name=%s)' % (
                                generic_utility.addon_id, urllib.quote_plus(generic_utility.encode(title.strip())))))

    elif type == 'movie':
        title_utf8 = title.strip() + ' (' + str(year) + ')'
        title = urllib.quote_plus(title_utf8.encode('utf-8'))
        movie_dir = library.get_movie_dir(title_utf8)[0]
        if xbmcvfs.exists(movie_dir+os.sep) == False:
            entries.append((generic_utility.get_string(30150),
                            'RunPlugin(plugin://%s/?mode=add_movie_to_library&url=%s&name=%s)' % (
                                generic_utility.addon_id, urllib.quote_plus(video_id),
                                title)))
        else:
            entries.append((generic_utility.get_string(301501),
                            'RunPlugin(plugin://%s/?mode=remove_movie_from_library&url=&name=%s)' % (
                                generic_utility.addon_id, title)))

#    utility.log(str(entries))
    list_item.addContextMenuItems(entries)

    folder = True
    if next_mode == 'play_video_main':
        folder = False
#    utility.log(u)
    directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle, url=u, listitem=list_item, isFolder=folder)
    return directory_item
コード例 #23
0
def video(video_metadata, removable=False, viewing_activity=False):
    #    utility.log(str(video_metadata))

    title = video_metadata['title']
    video_id = video_metadata['video_id']
    thumb_url = video_metadata['thumb_url']
    type = video_metadata['type']
    description = video_metadata['description']
    duration = video_metadata['duration']
    year = video_metadata['year']
    mpaa = video_metadata['mpaa']
    director = video_metadata['director']
    genre = video_metadata['genre']
    rating = video_metadata['rating']
    playcount = video_metadata['playcount']

    next_mode = 'play_video_main'
    if viewing_activity == False and generic_utility.get_setting(
            'browse_tv_shows') == 'true' and (type == 'tvshow'
                                              or type == 'episode'):
        next_mode = 'list_seasons'

    entries = []
    cover_file, fanart_file = generic_utility.cover_fanart(video_id)
    if xbmcvfs.exists(cover_file):
        thumb_url = cover_file
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(video_id)
    u += '&mode=' + next_mode
    u += '&name=' + urllib.quote_plus(generic_utility.encode(title))
    u += '&thumb=' + urllib.quote_plus(thumb_url)
    list_item = xbmcgui.ListItem(title)
    list_item.setArt({'icon': 'DefaultTVShows.png', 'thumb': thumb_url})
    list_item.setInfo(type='video',
                      infoLabels={
                          'title': title,
                          'plot': description,
                          'duration': unicode(duration),
                          'year': int(year),
                          'mpaa': mpaa,
                          'director': director,
                          'genre': genre,
                          'rating': rating,
                          'playcount': playcount
                      })
    list_item.setProperty('IsPlayable', 'true')
    if xbmcvfs.exists(fanart_file):
        list_item.setProperty('fanart_image', fanart_file)
    elif xbmcvfs.exists(cover_file):
        list_item.setProperty('fanart_image', cover_file)
    else:
        list_item.setProperty('fanart_image', thumb_url)
    if type == 'tvshow':
        if generic_utility.get_setting('browse_tv_shows') == 'true':
            entries.append((
                generic_utility.get_string(30151),
                'Container.Update(plugin://%s/?mode=play_video_main&url=%s&thumb=%s)'
                % (generic_utility.addon_id, urllib.quote_plus(video_id),
                   urllib.quote_plus(thumb_url))))
        else:
            entries.append((
                generic_utility.get_string(30152),
                'Container.Update(plugin://%s/?mode=list_seasons&url=%s&thumb=%s)'
                % (generic_utility.addon_id, urllib.quote_plus(video_id),
                   urllib.quote_plus(thumb_url))))
    if type != 'episode':
        entries.append(
            (generic_utility.get_string(30153),
             'RunPlugin(plugin://%s/?mode=play_trailer&url=%s&type=%s)' %
             (generic_utility.addon_id,
              urllib.quote_plus(generic_utility.encode(title)), type)))
        if removable:
            entries.append(
                (generic_utility.get_string(30154),
                 'RunPlugin(plugin://%s/?mode=remove_from_queue&url=%s)' %
                 (generic_utility.addon_id, urllib.quote_plus(video_id))))
        else:
            entries.append(
                (generic_utility.get_string(30155),
                 'RunPlugin(plugin://%s/?mode=add_to_queue&url=%s)' %
                 (generic_utility.addon_id, urllib.quote_plus(video_id))))
        entries.append((
            generic_utility.get_string(30156),
            'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=movie)'
            % (generic_utility.addon_id,
               urllib.quote_plus(generic_utility.main_url + 'WiMovie/' +
                                 video_id))))
        entries.append(
            (generic_utility.get_string(30157),
             'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=tv)' %
             (generic_utility.addon_id,
              urllib.quote_plus(generic_utility.main_url + 'WiMovie/' +
                                video_id))))
#    generic_utility.log(type)
    if type in ('tvshow', 'episode'):
        series_dir = library.get_series_dir(title.strip())
        #        generic_utility.log('series-dir: '+series_dir)
        if xbmcvfs.exists(series_dir + os.sep) == False:
            entries.append((generic_utility.get_string(
                30150
            ), 'RunPlugin(plugin://%s/?mode=add_series_to_library&url=&name=%s&series_id=%s)'
                            % (generic_utility.addon_id,
                               urllib.quote_plus(
                                   generic_utility.encode(title.strip())),
                               urllib.quote_plus(video_id))))
        else:
            entries.append((generic_utility.get_string(
                301501
            ), 'RunPlugin(plugin://%s/?mode=remove_series_from_library&url=&name=%s)'
                            % (generic_utility.addon_id,
                               urllib.quote_plus(
                                   generic_utility.encode(title.strip())))))

    elif type == 'movie':
        title_utf8 = title.strip() + ' (' + str(year) + ')'
        title = urllib.quote_plus(title_utf8.encode('utf-8'))
        movie_dir = library.get_movie_dir(title_utf8)[0]
        if xbmcvfs.exists(movie_dir + os.sep) == False:
            entries.append((generic_utility.get_string(
                30150
            ), 'RunPlugin(plugin://%s/?mode=add_movie_to_library&url=%s&name=%s)'
                            % (generic_utility.addon_id,
                               urllib.quote_plus(video_id), title)))
        else:
            entries.append((generic_utility.get_string(
                301501
            ), 'RunPlugin(plugin://%s/?mode=remove_movie_from_library&url=&name=%s)'
                            % (generic_utility.addon_id, title)))

#    utility.log(str(entries))
    list_item.addContextMenuItems(entries)

    folder = True
    if next_mode == 'play_video_main':
        folder = False


#    utility.log(u)
    directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle,
                                                 url=u,
                                                 listitem=list_item,
                                                 isFolder=folder)
    return directory_item