Example #1
0
def series(series_id, series_title, season, single_update=True):
    filename = utility.clean_filename(series_title, ' .')
    series_file = xbmc.translatePath(utility.tv_dir() + filename)
    if not xbmcvfs.exists(series_file):
        xbmcvfs.mkdir(series_file)
    content = get.series_info(series_id)
    content = json.loads(content)['video']['seasons']
    for test in content:
        episode_season = unicode(test['seq'])
        if episode_season == season or season == '':
            season_dir = utility.create_pathname(series_file, test['title'])
            if not xbmcvfs.exists(season_dir):
                xbmcvfs.mkdir(season_dir)
            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 + '.strm'
                filename = utility.clean_filename(filename, ' .')
                file_handler = xbmcvfs.File(utility.create_pathname(season_dir, filename), 'w')
                file_handler.write(
                    utility.encode('plugin://%s/?mode=play_video&url=%s' % (utility.addon_id, episode_id)))
                file_handler.close()
    if utility.get_setting('update_db') and single_update:
        xbmc.executebuiltin('UpdateLibrary(video)')
Example #2
0
def series(series_id, series_title, season, single_update=True):
    filename = utility.clean_filename(series_title, ' .')
    series_file = xbmc.translatePath(utility.tv_dir() + filename)
    if not xbmcvfs.exists(series_file):
        xbmcvfs.mkdir(series_file)
    content = get.series_info(series_id)
    content = json.loads(content)['video']['seasons']
    for test in content:
        episode_season = unicode(test['seq'])
        if episode_season == season or season == '':
            season_dir = utility.create_pathname(series_file, test['title'])
            if not xbmcvfs.exists(season_dir):
                xbmcvfs.mkdir(season_dir)
            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 + '.strm'
                filename = utility.clean_filename(filename, ' .')
                file_handler = xbmcvfs.File(
                    utility.create_pathname(season_dir, filename), 'w')
                file_handler.write(
                    utility.encode('plugin://%s/?mode=play_video&url=%s' %
                                   (utility.addon_id, episode_id)))
                file_handler.close()
    if utility.get_setting('update_db') and single_update:
        xbmc.executebuiltin('UpdateLibrary(video)')
Example #3
0
def cover(video_type, video_id, title, year):
    filename = utility.clean_filename(video_id) + '.jpg'
    filename_none = utility.clean_filename(video_id) + '.none'
    cover_file = xbmc.translatePath(utility.cover_cache_dir() + filename)
    cover_file_none = xbmc.translatePath(utility.cover_cache_dir() + filename_none)
    fanart_file = xbmc.translatePath(utility.fanart_cache_dir() + filename)
    content = search.tmdb(video_type, title, year)
    if content['total_results'] > 0:
        content = content['results'][0]
        try:
            cover_url = utility.picture_url + content['poster_path']
            content_jpg = connect.load_site(cover_url)
            file_handler = open(cover_file, 'wb')
            file_handler.write(content_jpg)
            file_handler.close()
        except Exception:
            file_handler = open(cover_file_none, 'wb')
            file_handler.write('')
            file_handler.close()
            pass
        try:
            fanart_url = utility.picture_url + content['backdrop_path']
            content_jpg = connect.load_site(fanart_url)
            file_handler = open(fanart_file, 'wb')
            file_handler.write(content_jpg)
            file_handler.close()
        except Exception:
            pass
Example #4
0
def cover(video_type, video_id, title, year):
    filename = utility.clean_filename(video_id) + '.jpg'
    filename_none = utility.clean_filename(video_id) + '.none'
    cover_file = xbmc.translatePath(utility.cover_cache_dir() + filename)
    cover_file_none = xbmc.translatePath(utility.cover_cache_dir() +
                                         filename_none)
    fanart_file = xbmc.translatePath(utility.fanart_cache_dir() + filename)
    content = search.tmdb(video_type, title, year)
    if content['total_results'] > 0:
        content = content['results'][0]
        try:
            cover_url = utility.picture_url + content['poster_path']
            content_jpg = connect.load_site(cover_url)
            file_handler = open(cover_file, 'wb')
            file_handler.write(content_jpg)
            file_handler.close()
        except Exception:
            file_handler = open(cover_file_none, 'wb')
            file_handler.write('')
            file_handler.close()
            pass
        try:
            fanart_url = utility.picture_url + content['backdrop_path']
            content_jpg = connect.load_site(fanart_url)
            file_handler = open(fanart_file, 'wb')
            file_handler.write(content_jpg)
            file_handler.close()
        except Exception:
            pass
Example #5
0
def video(name, url, mode, thumb, video_type='', description='', duration='', year='', mpaa='', director='', genre='',
          rating=0.0, playcount=0, remove=False):
    entries = []
    filename = utility.clean_filename(url) + '.jpg'
    cover_file = xbmc.translatePath(utility.cover_cache_dir() + filename)
    fanart_file = xbmc.translatePath(utility.fanart_cache_dir() + filename)
    if xbmcvfs.exists(cover_file):
        thumb = cover_file
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(url)
    u += '&mode=' + mode
    u += '&name=' + urllib.quote_plus(utility.encode(name))
    u += '&thumb=' + urllib.quote_plus(thumb)
    list_item = xbmcgui.ListItem(name)
    list_item.setArt({'icon': 'DefaultTVShows.png', 'thumb': thumb})
    list_item.setInfo(type='video',
                      infoLabels={'title': name, 'plot': description, 'duration': duration, 'year': int(year),
                                  'mpaa': mpaa, 'director': director, 'genre': genre, 'rating': rating,
                                  'playcount': playcount})
    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', utility.addon_fanart())
    if video_type == 'tvshow':
        if utility.get_setting('browse_tv_shows') == 'true':
            entries.append((utility.get_string(30151),
                            'Container.Update(plugin://%s/?mode=play_video_main&url=%s&thumb=%s)' % (
                                utility.addon_id, urllib.quote_plus(url), urllib.quote_plus(thumb))))
        else:
            entries.append((utility.get_string(30152),
                            'Container.Update(plugin://%s/?mode=list_seasons&url=%s&thumb=%s)' % (
                                utility.addon_id, urllib.quote_plus(url), urllib.quote_plus(thumb))))
    if video_type != 'episode':
        entries.append((utility.get_string(30153), 'RunPlugin(plugin://%s/?mode=play_trailer&url=%s&type=%s)' % (
            utility.addon_id, urllib.quote_plus(utility.encode(name)), video_type)))
        if remove:
            entries.append((utility.get_string(30154), 'RunPlugin(plugin://%s/?mode=remove_from_queue&url=%s)' % (
                utility.addon_id, urllib.quote_plus(url))))
        else:
            entries.append((utility.get_string(30155), 'RunPlugin(plugin://%s/?mode=add_to_queue&url=%s)' % (
                utility.addon_id, urllib.quote_plus(url))))
        entries.append((utility.get_string(30156),
                        'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=movie)' % (
                            utility.addon_id, urllib.quote_plus(utility.main_url + '/WiMovie/' + url))))
        entries.append((utility.get_string(30157), 'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=tv)' % (
            utility.addon_id, urllib.quote_plus(utility.main_url + '/WiMovie/' + url))))
    if video_type == 'tvshow':
        entries.append((utility.get_string(30150),
                        'RunPlugin(plugin://%s/?mode=add_series_to_library&url=&name=%s&series_id=%s)' % (
                            utility.addon_id, urllib.quote_plus(utility.encode(name.strip())), urllib.quote_plus(url))))
    elif video_type == 'movie':
        entries.append((utility.get_string(30150),
                        'RunPlugin(plugin://%s/?mode=add_movie_to_library&url=%s&name=%s)' % (
                            utility.addon_id, urllib.quote_plus(url),
                            urllib.quote_plus(utility.encode(name.strip())) + ' (' + unicode(year) + ')')))
    list_item.addContextMenuItems(entries)
    directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle, url=u, listitem=list_item, isFolder=True)
    return directory_item
Example #6
0
def season(name, url, mode, thumb, series_name, series_id):
    entries = []
    filename = utility.clean_filename(series_id) + '.jpg'
    cover_file = xbmc.translatePath(utility.cover_cache_dir() + filename)
    fanart_file = xbmc.translatePath(utility.fanart_cache_dir() + filename)
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(unicode(url))
    u += '&mode=' + mode
    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', utility.addon_fanart())
    entries.append((utility.get_string(30150),
                    'RunPlugin(plugin://%s/?mode=add_series_to_library&url=%s&name=%s&seriesID=%s)' % (
                        utility.addon_id, urllib.quote_plus(unicode(url)),
                        urllib.quote_plus(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
Example #7
0
def season(name, url, mode, thumb, series_name, series_id):
    entries = []
    filename = utility.clean_filename(series_id) + '.jpg'
    cover_file = xbmc.translatePath(utility.cover_cache_dir() + filename)
    fanart_file = xbmc.translatePath(utility.fanart_cache_dir() + filename)
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(unicode(url))
    u += '&mode=' + mode
    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', utility.addon_fanart())
    entries.append((utility.get_string(
        30150
    ), 'RunPlugin(plugin://%s/?mode=add_series_to_library&url=%s&name=%s&seriesID=%s)'
                    % (utility.addon_id, urllib.quote_plus(unicode(url)),
                       urllib.quote_plus(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
Example #8
0
def movie(movie_id, title, single_update=True):
    filename = utility.clean_filename(title + '.strm', ' .').strip(' .')
    movie_file = xbmc.translatePath(utility.movie_dir() + filename)
    file_handler = xbmcvfs.File(movie_file, 'w')
    file_handler.write(utility.encode('plugin://%s/?mode=play_video&url=%s' % (utility.addon_id, movie_id)))
    file_handler.close()
    if utility.get_setting('update_db') and single_update:
        xbmc.executebuiltin('UpdateLibrary(video)')
Example #9
0
def movie(movie_id, title, single_update=True):
    filename = utility.clean_filename(title + '.strm', ' .').strip(' .')
    movie_file = xbmc.translatePath(utility.movie_dir() + filename)
    file_handler = xbmcvfs.File(movie_file, 'w')
    file_handler.write(
        utility.encode('plugin://%s/?mode=play_video&url=%s' %
                       (utility.addon_id, movie_id)))
    file_handler.close()
    if utility.get_setting('update_db') and single_update:
        xbmc.executebuiltin('UpdateLibrary(video)')
Example #10
0
def episode(name,
            url,
            mode,
            thumb,
            description='',
            duration='',
            season_nr='',
            episode_nr='',
            series_id='',
            playcount=''):
    if duration:
        duration = unicode(int(duration) * 60)
    filename = utility.clean_filename(series_id) + '.jpg'
    cover_file = xbmc.translatePath(utility.cover_cache_dir() + filename)
    fanart_file = xbmc.translatePath(utility.fanart_cache_dir() + filename)
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(unicode(url))
    u += '&mode=' + mode
    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,
                          'plot': description,
                          'duration': duration,
                          'season': season_nr,
                          'episode': episode_nr,
                          'playcount': playcount
                      })
    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', utility.addon_fanart())
    directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle,
                                                 url=u,
                                                 listitem=list_item,
                                                 isFolder=True)
    return directory_item
Example #11
0
def episode(name, url, mode, thumb, description='', duration='', season_nr='', episode_nr='', series_id='',
            playcount=''):
    if duration:
        duration = unicode(int(duration) * 60)
    filename = utility.clean_filename(series_id) + '.jpg'
    cover_file = xbmc.translatePath(utility.cover_cache_dir() + filename)
    fanart_file = xbmc.translatePath(utility.fanart_cache_dir() + filename)
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(unicode(url))
    u += '&mode=' + mode
    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, 'plot': description, 'duration': duration, 'season': season_nr,
                                  'episode': episode_nr, 'playcount': playcount})
    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', utility.addon_fanart())
    directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle, url=u, listitem=list_item, isFolder=True)
    return directory_item
Example #12
0
def video(video_id, title, thumb_url, is_episode, hide_movies, video_type,
          url):
    added = False
    year = ''
    mpaa = ''
    duration = ''
    description = ''
    director = ''
    genre = ''
    rating = 0.0
    video_details = get.video_info(video_id)
    match = re.compile('<span class="title.*?>(.+?)</span',
                       re.DOTALL).findall(video_details)
    if not title:
        title = match[0].strip()
    match = re.compile('<span class="year.*?>(.+?)</span',
                       re.DOTALL).findall(video_details)
    if match:
        year = match[0].partition('-')[0]
    if not thumb_url:
        match = re.compile('src="(.+?)"', re.DOTALL).findall(video_details)
        thumb_url = match[0].replace('/webp/',
                                     '/images/').replace('.webp', '.jpg')
    match = re.compile('<span class="mpaaRating.*?>(.+?)</span',
                       re.DOTALL).findall(video_details)
    if match:
        mpaa = match[0].strip()
    match = re.compile('<span class="duration.*?>(.+?)</span',
                       re.DOTALL).findall(video_details)
    if match:
        duration = match[0].lower()
    if duration.split(' ')[-1].startswith('min'):
        type = 'movie'
        video_type_temp = type
        duration = duration.split(' ')[0]
    else:
        video_type_temp = 'tv'
        if is_episode:
            type = 'episode'
        else:
            type = 'tvshow'
        duration = ''
    if utility.get_setting('use_tmdb') == 'true':
        year_temp = year
        title_temp = title
        if ' - ' in title_temp:
            title_temp = title_temp[title_temp.index(' - '):]
        if '-' in year_temp:
            year_temp = year_temp.split('-')[0]
        filename = utility.clean_filename(video_id) + '.jpg'
        filename_none = utility.clean_filename(video_id) + '.none'
        cover_file = xbmc.translatePath(utility.cover_cache_dir() + filename)
        cover_file_none = xbmc.translatePath(utility.cover_cache_dir() +
                                             filename_none)
        if not (xbmcvfs.exists(cover_file) or xbmcvfs.exists(cover_file_none)):
            utility.log(
                'Downloading cover art. type: %s, video_id: %s, title: %s, year: %s'
                % (video_type_temp, video_id, title_temp, year_temp))
            get.cover(video_type_temp, video_id, title_temp, year_temp)
    match = re.compile('src=".+?">.*?<.*?>(.+?)<',
                       re.DOTALL).findall(video_details)
    if match:
        description_temp = match[0]
        # replace all embedded unicode in unicode (Norwegian problem)
        description_temp = description_temp.replace('u2013',
                                                    unicode('\u2013')).replace(
                                                        'u2026',
                                                        unicode('\u2026'))
        description = utility.unescape(description_temp)
    match = re.compile('Director:</dt><dd>(.+?)<',
                       re.DOTALL).findall(video_details)
    if match:
        director = match[0].strip()
    match = re.compile('<span class="genre.*?>(.+?)</span',
                       re.DOTALL).findall(video_details)
    if match:
        genre = match[0]
    match = re.compile('<span class="rating">(.+?)</span',
                       re.DOTALL).findall(video_details)
    if len(match) > 0:
        rating = float(match[0])
    title = utility.unescape(title)
    next_mode = 'play_video_main'
    if utility.get_setting('browse_tv_shows') == 'true' and type == 'tvshow':
        next_mode = 'list_seasons'
    if '/my-list' in url and video_type_temp == video_type:
        add.video(title,
                  video_id,
                  next_mode,
                  thumb_url,
                  type,
                  description,
                  duration,
                  year,
                  mpaa,
                  director,
                  genre,
                  rating,
                  remove=True)
        added = True
    elif type == 'movie' and hide_movies:
        pass
    elif video_type_temp == video_type or video_type == 'both':
        add.video(title, video_id, next_mode, thumb_url, type, description,
                  duration, year, mpaa, director, genre, rating)
        added = True
    return added
Example #13
0
def video(video_id, title, thumb_url, is_episode, hide_movies, video_type, url):
    added = False
    year = ''
    mpaa = ''
    duration = ''
    description = ''
    director = ''
    genre = ''
    rating = 0.0
    video_details = get.video_info(video_id)
    match = re.compile('<span class="title.*?>(.+?)</span', re.DOTALL).findall(video_details)
    if not title:
        title = match[0].strip()
    match = re.compile('<span class="year.*?>(.+?)</span', re.DOTALL).findall(video_details)
    if match:
        year = match[0].partition('-')[0]
    if not thumb_url:
        match = re.compile('src="(.+?)"', re.DOTALL).findall(video_details)
        thumb_url = match[0].replace('/webp/', '/images/').replace('.webp', '.jpg')
    match = re.compile('<span class="mpaaRating.*?>(.+?)</span', re.DOTALL).findall(video_details)
    if match:
        mpaa = match[0].strip()
    match = re.compile('<span class="duration.*?>(.+?)</span', re.DOTALL).findall(video_details)
    if match:
        duration = match[0].lower()
    if duration.split(' ')[-1].startswith('min'):
        type = 'movie'
        video_type_temp = type
        duration = duration.split(' ')[0]
    else:
        video_type_temp = 'tv'
        if is_episode:
            type = 'episode'
        else:
            type = 'tvshow'
        duration = ''
    if utility.get_setting('use_tmdb') == 'true':
        year_temp = year
        title_temp = title
        if ' - ' in title_temp:
            title_temp = title_temp[title_temp.index(' - '):]
        if '-' in year_temp:
            year_temp = year_temp.split('-')[0]
        filename = utility.clean_filename(video_id) + '.jpg'
        filename_none = utility.clean_filename(video_id) + '.none'
        cover_file = xbmc.translatePath(utility.cover_cache_dir() + filename)
        cover_file_none = xbmc.translatePath(utility.cover_cache_dir() + filename_none)
        if not (xbmcvfs.exists(cover_file) or xbmcvfs.exists(cover_file_none)):
            utility.log('Downloading cover art. type: %s, video_id: %s, title: %s, year: %s' % (video_type_temp,
                                                                                                video_id, title_temp,
                                                                                                year_temp))
            get.cover(video_type_temp, video_id, title_temp, year_temp)
    match = re.compile('src=".+?">.*?<.*?>(.+?)<', re.DOTALL).findall(video_details)
    if match:
        description_temp = match[0]
        # replace all embedded unicode in unicode (Norwegian problem)
        description_temp = description_temp.replace('u2013', unicode('\u2013')).replace('u2026', unicode('\u2026'))
        description = utility.unescape(description_temp)
    match = re.compile('Director:</dt><dd>(.+?)<', re.DOTALL).findall(video_details)
    if match:
        director = match[0].strip()
    match = re.compile('<span class="genre.*?>(.+?)</span', re.DOTALL).findall(video_details)
    if match:
        genre = match[0]
    match = re.compile('<span class="rating">(.+?)</span', re.DOTALL).findall(video_details)
    if len(match) > 0:
        rating = float(match[0])
    title = utility.unescape(title)
    next_mode = 'play_video_main'
    if utility.get_setting('browse_tv_shows') == 'true' and type == 'tvshow':
        next_mode = 'list_seasons'
    if '/my-list' in url and video_type_temp == video_type:
        add.video(title, video_id, next_mode, thumb_url, type, description, duration, year, mpaa,
                  director, genre, rating, remove=True)
        added = True
    elif type == 'movie' and hide_movies:
        pass
    elif video_type_temp == video_type or video_type == 'both':
        add.video(title, video_id, next_mode, thumb_url, type, description, duration, year, mpaa,
                  director, genre, rating)
        added = True
    return added
Example #14
0
def video(name,
          url,
          mode,
          thumb,
          video_type='',
          description='',
          duration='',
          year='',
          mpaa='',
          director='',
          genre='',
          rating=0.0,
          remove=False):
    entries = []
    if duration:
        duration = unicode(int(duration) * 60)
    filename = utility.clean_filename(url) + '.jpg'
    cover_file = xbmc.translatePath(utility.cover_cache_dir() + filename)
    fanart_file = xbmc.translatePath(utility.fanart_cache_dir() + filename)
    if xbmcvfs.exists(cover_file):
        thumb = cover_file
    u = sys.argv[0]
    u += '?url=' + urllib.quote_plus(url)
    u += '&mode=' + mode
    u += '&name=' + urllib.quote_plus(utility.encode(name))
    u += '&thumb=' + urllib.quote_plus(thumb)
    list_item = xbmcgui.ListItem(name)
    list_item.setArt({'icon': 'DefaultTVShows.png', 'thumb': thumb})
    list_item.setInfo(type='video',
                      infoLabels={
                          'title': name,
                          'plot': description,
                          'duration': duration,
                          'year': int(year),
                          'mpaa': mpaa,
                          'director': director,
                          'genre': genre,
                          'rating': rating
                      })
    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', utility.addon_fanart())
    if video_type == 'tvshow':
        if utility.get_setting('browse_tv_shows') == 'true':
            entries.append((utility.get_string(
                30151
            ), 'Container.Update(plugin://%s/?mode=play_video_main&url=%s&thumb=%s)'
                            % (utility.addon_id, urllib.quote_plus(url),
                               urllib.quote_plus(thumb))))
        else:
            entries.append((utility.get_string(
                30152
            ), 'Container.Update(plugin://%s/?mode=list_seasons&url=%s&thumb=%s)'
                            % (utility.addon_id, urllib.quote_plus(url),
                               urllib.quote_plus(thumb))))
    if video_type != 'episode':
        entries.append(
            (utility.get_string(30153),
             'RunPlugin(plugin://%s/?mode=play_trailer&url=%s&type=%s)' %
             (utility.addon_id, urllib.quote_plus(
                 utility.encode(name)), video_type)))
        if remove:
            entries.append(
                (utility.get_string(30154),
                 'RunPlugin(plugin://%s/?mode=remove_from_queue&url=%s)' %
                 (utility.addon_id, urllib.quote_plus(url))))
        else:
            entries.append(
                (utility.get_string(30155),
                 'RunPlugin(plugin://%s/?mode=add_to_queue&url=%s)' %
                 (utility.addon_id, urllib.quote_plus(url))))
        entries.append((
            utility.get_string(30156),
            'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=movie)'
            % (utility.addon_id,
               urllib.quote_plus(utility.main_url + '/WiMovie/' + url))))
        entries.append(
            (utility.get_string(30157),
             'Container.Update(plugin://%s/?mode=list_videos&url=%s&type=tv)' %
             (utility.addon_id,
              urllib.quote_plus(utility.main_url + '/WiMovie/' + url))))
    if video_type == 'tvshow':
        entries.append(
            (utility.get_string(30150),
             'RunPlugin(plugin://%s/?mode=add_series_to_library&url=&name=%s'
             '&seriesID=%s)' %
             (utility.addon_id, urllib.quote_plus(utility.encode(
                 name.strip())), urllib.quote_plus(url))))
    elif video_type == 'movie':
        entries.append(
            (utility.get_string(30150),
             'RunPlugin(plugin://%s/?mode=add_movie_to_library&url=%s&name=%s)'
             % (utility.addon_id, urllib.quote_plus(url),
                urllib.quote_plus(utility.encode(name.strip())) + ' (' + year +
                ')')))
    list_item.addContextMenuItems(entries)
    directory_item = xbmcplugin.addDirectoryItem(handle=plugin_handle,
                                                 url=u,
                                                 listitem=list_item,
                                                 isFolder=True)
    return directory_item