def browse():
    header = [
        {
            'label': lang(40401),
            'path': plugin.url_for('browse_all_series')
        },
        {
            'label': lang(40421),
            'path': plugin.url_for('browse_new')
        },
        {
            'label': lang(40411),
            'path': plugin.url_for('browse_favorites')
        },
        {
            'label': lang(40418),
            'path': plugin.url_for('browse_trailers')
        },
        {
            'label': lang(40422),
            'path': plugin.url_for('search')
        },
    ]
    plugin.add_items(with_fanart(header), len(header))
    plugin.finish(sort_methods=['unsorted', 'label'])
def library_menu(s):
    """
    :type s: Series
    """
    items = library_items()
    if s.id in items:
        return [(lang(40310), actions.background(plugin.url_for('remove_from_library', series_id=s.id)))]
    else:
        return [(lang(40309), actions.background(plugin.url_for('add_to_library', series_id=s.id)))]
def library_menu(s):
    """
    :type s: Series
    """
    items = library_items()
    if s.id in items:
        return [(lang(40310), actions.background(plugin.url_for('remove_from_library', series_id=s.id)))]
    else:
        return [(lang(40309), actions.background(plugin.url_for('add_to_library', series_id=s.id)))]
def episode_url(e, select_quality=None):
    """
    :type e: Episode
    """
    if e.is_complete_season:
        return plugin.url_for('browse_season', series=e.series_id, season=e.season_number,
                              select_quality=select_quality)
    else:
        return plugin.url_for('play_episode', series=e.series_id, season=e.season_number,
                              episode=e.episode_number, select_quality=select_quality)
def episode_url(e, select_quality=None):
    """
    :type e: Episode
    """
    if e.is_complete_season:
        return plugin.url_for('browse_season', series=e.series_id, season=e.season_number,
                              select_quality=select_quality)
    else:
        return plugin.url_for('play_episode', series=e.series_id, season=e.season_number,
                              episode=e.episode_number, select_quality=select_quality)
def index():
    plugin.set_content('episodes')
    skip = plugin.request.arg('skip')
    per_page = plugin.get_setting('per-page', int)
    scraper = get_scraper()
    episodes = scraper.browse_episodes(skip)
    if episodes and not skip:
        check_last_episode(episodes[0])
    check_first_start()
    new_episodes = library_new_episodes()
    new_str = "(%s) " % tf.color(str(
        len(new_episodes)), NEW_LIBRARY_ITEM_COLOR) if new_episodes else ""
    total = len(episodes)
    header = [
        {
            'label': lang(40401),
            'path': plugin.url_for('browse_all_series')
        },
        {
            'label': lang(40407) % new_str,
            'path': plugin.url_for('browse_library'),
            'context_menu': update_library_menu()
        },
    ]
    items = []
    if skip:
        skip_prev = max(skip - per_page, 0)
        total += 1
        items.append({
            'label': lang(34003),
            'path': plugin.request.url_with_params(skip=skip_prev)
        })
    elif header:
        items.extend(header)
        total += len(header)
    plugin.add_items(with_fanart(items), total)
    for batch_res in batch(episodes, BATCH_EPISODES_COUNT):
        if abort_requested():
            break
        items = itemify_episodes(batch_res)
        plugin.add_items(with_fanart(items), total)
    items = []
    if scraper.has_more:
        skip_next = (skip or 0) + per_page
        items.append({
            'label': lang(34004),
            'path': plugin.request.url_with_params(skip=skip_next)
        })
    plugin.finish(items=with_fanart(items),
                  cache_to_disc=False,
                  update_listing=skip is not None)
def itemify_file(path, series, season, f):
    """
    :type series: Series
    :type season: string
    :type f: TorrentFile
    """
    item = itemify_common(series)
    item.update({
        'label':
        f.path,
        'path':
        plugin.url_for('play_file',
                       path=path,
                       series=series.id,
                       season=season,
                       file_id=f.index),
        'context_menu':
        info_menu(series) + toggle_watched_menu(),
        'is_playable':
        True,
    })
    item['info'].update({
        'season': season,
        'title': f,
    })
    return item
def mark_series_watched_menu(series):
    """
    :type series: Series
    """
    return [(lang(40312),
             actions.background(
                 plugin.url_for('mark_series_watched', series_id=series.id)))]
def download_menu(e):
    from xbmcswift2 import actions
    if plugin.get_setting('torrent-client', int):
        return [(lang(40308), actions.background(plugin.url_for('download', series=e.series_id,
                                                                season=e.season_number,
                                                                episode=e.episode_number)))]
    else:
        return []
def download_menu(e):
    from xbmcswift2 import actions
    if plugin.get_setting('torrent-client', int):
        return [(lang(40308), actions.background(plugin.url_for('download', series=e.series_id,
                                                                season=e.season_number,
                                                                episode=e.episode_number)))]
    else:
        return []
def toggle_episode_watched_menu(episode):
    """
    :type episode: Episode
    """
    return [(lang(40151), actions.background(plugin.url_for('toggle_episode_watched',
                                                            series_id=episode.series_id,
                                                            episode=episode.episode_number,
                                                            season=episode.season_number)))]
def toggle_episode_watched_menu(episode):
    """
    :type episode: Episode
    """
    return [(lang(40151), actions.background(plugin.url_for('toggle_episode_watched',
                                                            series_id=episode.series_id,
                                                            episode=episode.episode_number,
                                                            season=episode.season_number)))]
def index():
    plugin.set_content('episodes')
    skip = plugin.request.arg('skip')
    per_page = plugin.get_setting('per-page', int)
    scraper = get_scraper()
    episodes = scraper.browse_episodes(skip)
    if episodes and not skip:
        check_last_episode(episodes[0])
    check_first_start()
    new_episodes = library_new_episodes()
    new_str = "(%s) " % tf.color(str(len(new_episodes)), NEW_LIBRARY_ITEM_COLOR) if new_episodes else ""
    total = len(episodes)
    header = [
        {'label': lang(40401), 'path': plugin.url_for('browse_all_series')},
        {'label': lang(40407) % new_str, 'path': plugin.url_for('browse_library'),
         'context_menu': update_library_menu()},
    ]
    items = []
    if skip:
        skip_prev = max(skip - per_page, 0)
        total += 1
        items.append({
            'label': lang(34003),
            'path': plugin.request.url_with_params(skip=skip_prev)
        })
    elif header:
        items.extend(header)
        total += len(header)
    plugin.add_items(with_fanart(items), total)
    for batch_res in batch(episodes, BATCH_EPISODES_COUNT):
        if abort_requested():
            break
        items = itemify_episodes(batch_res)
        plugin.add_items(with_fanart(items), total)
    items = []
    if scraper.has_more:
        skip_next = (skip or 0) + per_page
        items.append({
            'label': lang(34004),
            'path': plugin.request.url_with_params(skip=skip_next)
        })
    plugin.finish(items=with_fanart(items),
                  cache_to_disc=False,
                  update_listing=skip is not None)
Exemple #14
0
def itemify_trailers(trailers):
    items = []
    for t in trailers:
        item = {
            'thumbnail': t.img,
            'icon': t.img,
            'label': t.title,
            'path': plugin.url_for('play', path=t.url),
            'is_playable': True,
            'info': {
                'plot': t.desc,
            },
            'properties': {
                'fanart_image': t.img,
            }
        }
        items.append(item)
    return items
def itemify_file(path, series, season, f):
    """
    :type series: Series
    :type season: string
    :type f: TorrentFile
    """
    item = itemify_common(series)
    item.update({
        'label': f.path,
        'path': plugin.url_for('play_file', path=path, series=series.id, season=season, file_id=f.index),
        'context_menu':
            info_menu(series) + toggle_watched_menu(),
        'is_playable': True,
    })
    item['info'].update({
        'season': season,
        'title': f,
    })
    return item
def update_library_menu():
    return [(lang(40311), actions.background(plugin.url_for('update_library_on_demand')))]
def series_url(s):
    """
    :type s: Series
    """
    return plugin.url_for('browse_series', series_id=s.id)
def update_library_menu():
    return [(lang(40311), actions.background(plugin.url_for('update_library_on_demand')))]
def series_url(s):
    """
    :type s: Series
    """
    return plugin.url_for('browse_series', series_id=s.id)
def mark_series_watched_menu(series):
    """
    :type series: Series
    """
    return [(lang(40312), actions.background(plugin.url_for('mark_series_watched',
                                                            series_id=series.id)))]