示例#1
0
def live_tv(provider=None, **kwargs):
    providers = _providers()

    if len(providers) == 1:
        provider = list(providers.keys())[0]

    if provider is None:
        folder = plugin.Folder(_.LIVE_TV)

        for slug in sorted(
                providers,
                key=lambda x:
            (providers[x]['sort'], providers[x]['name'].lower())):
            provider = providers[slug]

            folder.add_item(
                label=_(u'{name} ({count})'.format(name=provider['name'],
                                                   count=len(
                                                       provider['channels']))),
                art={'thumb': provider['logo']},
                path=plugin.url_for(live_tv, provider=slug),
            )

        return folder

    provider = _providers()[provider]
    folder = plugin.Folder(provider['name'])
    items = _get_channels(provider['channels'])
    folder.add_items(items)
    return folder
示例#2
0
def featured(index=None, **kwargs):
    folder = plugin.Folder(_.FEATURED)
    index = int(index) if index else None

    for count, row in enumerate(api.featured()):
        if row['type'] == 'heroes':
            continue

        if index is None:
            folder.add_item(
                label=row['title'],
                path=plugin.url_for(featured, index=count),
            )

        elif count == index:
            folder = plugin.Folder(row['title'])

            if row['type'] in ('latest_videos', ):
                items = _parse_videos(row['items'])
                folder.add_items(items)

            elif row['type'] in ('podcast_channels', ):
                items = _parse_podcast_creators(row['items'])
                folder.add_items(items)

            elif row['type'] in ('featured_creators', 'video_channels'):
                items = _parse_creators(row['items'])
                folder.add_items(items)

    return folder
示例#3
0
def user_catalog(catalog_name, **kwargs):
    data = api.user_catalog(catalog_name)
    if not data:
        return plugin.Folder()

    folder = plugin.Folder(data['name'])

    items = _parse_elements(data['assets'], from_menu=True)
    folder.add_items(items)

    return folder
示例#4
0
def series(slug, season=None, **kwargs):
    data = api.content(slug, tab=season)

    if len(data['seasons']) > 1:
        folder = plugin.Folder(data['titles']['full'],
                               fanart=_image(data['images'].get('tile'),
                                             size='1920x1080'))

        for row in data['seasons']:
            folder.add_item(
                label=row['titles']['full'],
                info={'plot': row['summaries']['short']},
                art={'thumb': _image(data['images'].get('tileburnedin'))},
                path=plugin.url_for(series, slug=slug, season=row['id']),
            )
    else:
        folder = plugin.Folder(data['titles']['full'],
                               fanart=_image(data['images'].get('tile'),
                                             size='1920x1080'),
                               sort_methods=[
                                   xbmcplugin.SORT_METHOD_EPISODE,
                                   xbmcplugin.SORT_METHOD_UNSORTED,
                                   xbmcplugin.SORT_METHOD_LABEL,
                                   xbmcplugin.SORT_METHOD_DATEADDED
                               ])

        for row in data['episodes']:
            folder.add_item(
                label=row['titles']['full'],
                art={'thumb': _image(row['images'].get('tileburnedin'))},
                info={
                    'plot':
                    row['summaries']['short'],
                    'duration':
                    row['duration'],
                    'tvshowtitle':
                    row['seriesTitles']['full'],
                    'season':
                    row.get('seasonNumber', 1),
                    'episode':
                    row.get('numberInSeason', row.get('numberInSeries', 1)),
                    'mediatype':
                    'episode'
                },
                path=_get_play_path(row['id']),
                playable=True,
            )

    return folder
示例#5
0
def home(**kwargs):
    folder = plugin.Folder(cacheToDisc=False)

    if not api.logged_in:
        folder.add_item(label=_(_.LOGIN, _bold=True),
                        path=plugin.url_for(login),
                        bookmark=False)
    else:
        folder.add_item(label=_(_.LIVE_CHANNELS, _bold=True),
                        path=plugin.url_for(live_channels))
        folder.add_item(label=_(_.CATCH_UP, _bold=True),
                        path=plugin.url_for(catch_up))
        # folder.add_item(label=_(_.MATCH_HIGHLIGHTS, _bold=True), path=plugin.url_for(catch_up, catalog_id='Match_Highlights', title=_.MATCH_HIGHLIGHTS))
        # folder.add_item(label=_(_.INTERVIEWS, _bold=True),       path=plugin.url_for(catch_up, catalog_id='Interviews', title=_.INTERVIEWS))
        # folder.add_item(label=_(_.SPECIALS, _bold=True),         path=plugin.url_for(catch_up, catalog_id='Specials', title=_.SPECIALS))

        if settings.getBool('bookmarks', True):
            folder.add_item(label=_(_.BOOKMARKS, _bold=True),
                            path=plugin.url_for(plugin.ROUTE_BOOKMARKS),
                            bookmark=False)

        folder.add_item(label=_.LOGOUT,
                        path=plugin.url_for(logout),
                        _kiosk=False,
                        bookmark=False)

    folder.add_item(label=_.SETTINGS,
                    path=plugin.url_for(plugin.ROUTE_SETTINGS),
                    _kiosk=False,
                    bookmark=False)

    return folder
示例#6
0
def channels(**kwargs):
    folder = plugin.Folder(_.CHANNELS)

    rows = api.live_channels()
    folder.add_items(_process_rows(rows))

    return folder
示例#7
0
def playlists(**kwargs):
    folder = plugin.Folder(_.PLAYLISTS)

    playlists = Playlist.select().order_by(Playlist.order)

    for playlist in playlists:
        context = [
            (_.DISABLE_PLAYLIST if playlist.enabled else _.ENABLE_PLAYLIST, 'RunPlugin({})'.format(plugin.url_for(edit_playlist_value, playlist_id=playlist.id, method=Playlist.toggle_enabled.__name__))),
            (_.DELETE_PLAYLIST, 'RunPlugin({})'.format(plugin.url_for(delete_playlist, playlist_id=playlist.id))),
            (_.INSERT_PLAYLIST, 'RunPlugin({})'.format(plugin.url_for(new_playlist, position=playlist.order))),
        ]

        if playlist.order > 1:
            context.append((_.MOVE_UP, 'RunPlugin({})'.format(plugin.url_for(shift_playlist, playlist_id=playlist.id, shift=-1))))

        if playlist.order < len(playlists)+1:
            context.append((_.MOVE_DOWN, 'RunPlugin({})'.format(plugin.url_for(shift_playlist, playlist_id=playlist.id, shift=1))))

        folder.add_item(
            label   = playlist.name,
            info    = {'plot': playlist.plot},
            art     = {'thumb': playlist.thumb},
            path    = plugin.url_for(edit_playlist, playlist_id=playlist.id),
            context = context,
        )

    folder.add_item(
        label = _(_.ADD_PLAYLIST, _bold=True),
        path  = plugin.url_for(new_playlist),
    )

    return folder
示例#8
0
def search_channel(query=None, radio=0, page=1, **kwargs):
    radio  = int(radio)
    page   = int(page)

    if not query:
        query = gui.input(_.SEARCH, default=userdata.get('search', '')).strip()
        if not query:
            return

        userdata.set('search', query)

    folder = plugin.Folder(_(_.SEARCH_FOR, query=query))

    page_size = settings.getInt('page_size', 0)
    db_query  = Channel.channel_list(radio=radio, page=page, search=query, page_size=page_size)

    items = _process_channels(db_query)
    folder.add_items(items)

    if len(items) == page_size:
        folder.add_item(
            label = _(_.NEXT_PAGE, page=page+1, _bold=True),
            path  = plugin.url_for(search_channel, query=query, radio=radio, page=page+1),
        )

    return folder
示例#9
0
def race(slug, **kwargs):
    races = api.races()
    if slug not in races:
        raise Error(_.RACE_NOT_FOUND)

    race = races[slug]
    folder = plugin.Folder(race['title'], no_items_label=_.NO_STREAMS)

    for stream in race['streams']:
        if not stream['slug']:
            continue

        item = plugin.Item(
            label = stream['label'],
            path  = plugin.url_for(play, slug=stream['slug']),
            playable = True,
        )

        if stream['live']:
            item.label = _(_.LIVE_LABEL, title=stream['label'])

            item.context.append((_.PLAY_FROM_LIVE, "PlayMedia({})".format(
                plugin.url_for(play, slug=stream['slug'], play_type=PLAY_FROM_LIVE, _is_live=True)
            )))

            item.context.append((_.PLAY_FROM_START, "PlayMedia({})".format(
                plugin.url_for(play, slug=stream['slug'], play_type=PLAY_FROM_START, _is_live=True)
            )))

            item.path = plugin.url_for(play, slug=stream['slug'], play_type=settings.getEnum('live_play_type', PLAY_FROM_TYPES, PLAY_FROM_ASK), _is_live=True)

        folder.add_items([item])

    return folder
示例#10
0
def content(label, section='', genre=None, channels='', start=0, **kwargs):
    start = int(start)
    folder = plugin.Folder(label)

    if section and genre is None:
        genres = GENRES.get(section, [])

        for row in genres:
            folder.add_item(label=row[0], path=plugin.url_for(content, label=row[0], section=section, genre=row[1]))

        if genres:
            return folder

    data  = api.content(section, genre=genre, channels=channels, start=start)
    items = _process_content(data['data'])
    folder.add_items(items)

    if items and data['index'] < data['available']:
        folder.add_item(
            label = _(_.NEXT_PAGE, _bold=True),
            path  = plugin.url_for(content, label=label, section=section, genre=genre, channels=channels, start=data['index']),
            specialsort = 'bottom',
        )

    return folder
示例#11
0
def search(query=None, page=1, **kwargs):
    page = int(page)

    if not query:
        query = gui.input(_.SEARCH, default=userdata.get('search', '')).strip()
        if not query:
            return
        userdata.set('search', query)

    data = api.filter_media('keyword', query, page=page)
    total_pages = int(data['paginator']['total_pages'])

    folder = plugin.Folder(
        _(_.SEARCH_FOR, query=query, page=page, total_pages=total_pages))

    for row in data['data']:
        item = _process_media(row)
        folder.add_items([item])

    if total_pages > page:
        folder.add_item(
            label=_(_.NEXT_PAGE, next_page=page + 1),
            path=plugin.url_for(search, query=query, page=page + 1),
        )

    return folder
示例#12
0
def categories(id=None, **kwargs):
    folder = plugin.Folder(_.CATEGORIES)

    rows = api.categories()
    if id:
        row = _search_category(rows, id)
        if not row:
            raise PluginError(_(_.CATEGORY_NOT_FOUND, category_id=id))

        folder.title = row['label']
        rows = row.get('subcategories', [])

    for row in rows:
        subcategories = row.get('subcategories', [])

        if subcategories:
            path = plugin.url_for(categories, id=row['id'])
        else:
            path = plugin.url_for(media,
                                  title=row['label'],
                                  filterby='category',
                                  term=row['name'])

        folder.add_item(
            label=row['label'],
            art={'thumb': _image(row, 'image_url')},
            path=path,
        )

    return folder
示例#13
0
def lectures(course_id, chapter_id, title, page=1, **kwargs):
    page = int(page)
    folder = plugin.Folder(title)

    rows, next_page = api.lectures(course_id, chapter_id, page=page)

    for row in rows:
        folder.add_item(
            label=row['title'],
            path=plugin.url_for(play, asset_id=row['asset']['id']),
            art={'thumb': row['course']['image_480x270']},
            info={
                'title': row['title'],
                'plot': strip_tags(row['description']),
                'duration': row['asset']['length'],
                'mediatype': 'episode',
                'tvshowtitle': row['course']['title'],
            },
            playable=True,
        )

    if next_page:
        folder.add_item(
            label=_(_.NEXT_PAGE, _bold=True),
            path=plugin.url_for(lectures,
                                course_id=course_id,
                                chapter_id=chapter_id,
                                title=title,
                                page=page + 1),
        )

    return folder
示例#14
0
def chapters(course_id, title, page=1, **kwargs):
    page = int(page)
    folder = plugin.Folder(title)

    rows, next_page = api.chapters(course_id, page=page)

    for row in sorted(rows, key=lambda r: r['object_index']):
        folder.add_item(
            label=_(_.SECTION_LABEL,
                    section_number=row['object_index'],
                    section_title=row['title']),
            path=plugin.url_for(lectures,
                                course_id=course_id,
                                chapter_id=row['id'],
                                title=title),
            art={'thumb': row['course']['image_480x270']},
            info={'plot': strip_tags(row['description'])},
        )

    if next_page:
        folder.add_item(
            label=_(_.NEXT_PAGE, _bold=True),
            path=plugin.url_for(chapters,
                                course_id=course_id,
                                title=title,
                                page=page + 1),
        )

    return folder
示例#15
0
def live(**kwargs):
    folder = plugin.Folder(_.LIVE, no_items_label=_.NO_MATCHES)

    data = api.live_matches()
    for row in data['live']:
        start = arrow.get(row['match_start_date']).to('local').format(_.DATE_FORMAT)

        sources  = row['stream']['video_sources']
        priority = sources[0]['priority']

        item = plugin.Item(
            label    = row['subtitle'],
            info     = {'plot': _(_.MATCH_PLOT, series=row['seriesName'], match=row['subtitle'], start=start)},
            art      = {'thumb': TEAMS_IMAGE_URL.format(team1=row['team1'], team2=row['team2']).replace(' ', '')},
            path     = plugin.url_for(play_live, match_id=row['mid'], priority=priority),
            playable = True,
        )

        if len(sources) > 1:
            url = plugin.url_for(select_source, match_id=row['mid'], sources=json.dumps(sources))
            item.context.append((_.PLAYBACK_SOURCE, 'PlayMedia({})'.format(url)))

        folder.add_items(item)

    return folder
示例#16
0
def creators(**kwargs):
    folder = plugin.Folder(_.CREATORS)

    items = _parse_creators(api.creators())
    folder.add_items(items)

    return folder
示例#17
0
def edit_epg(epg_id, **kwargs):
    epg_id = int(epg_id)
    epg    = EPG.get_by_id(epg_id)

    folder = plugin.Folder(epg.label, thumb=epg.thumb)

    folder.add_item(
        label = _(_.SOURCE_LABEL, value=epg.label),
        path  = plugin.url_for(edit_epg_value, epg_id=epg.id, method=EPG.select_path.__name__),
    )

    folder.add_item(
        label = _(_.ENABLED_LABEL, value=epg.enabled),
        path  = plugin.url_for(edit_epg_value, epg_id=epg.id, method=EPG.toggle_enabled.__name__),
    )

    if epg.source_type == EPG.TYPE_ADDON:
        addon, data = merge_info(epg.path)
        if 'configure' in data:
            folder.add_item(
                label = _.CONFIGURE_ADDON,
                path  = plugin.url_for(configure_addon, addon_id=epg.path),
            )

        folder.add_item(
            label = _.ADDON_SETTINGS,
            path  = plugin.url_for(open_settings, addon_id=epg.path),
        )
    else:
        folder.add_item(
            label = _(_.ARCHIVE_TYPE_LABEL, value=epg.archive_type_name),
            path  = plugin.url_for(edit_epg_value, epg_id=epg.id, method=EPG.select_archive_type.__name__),
        )

    return folder
示例#18
0
def search(query=None, page=1, **kwargs):
    page = int(page)

    if not query:
        query = gui.input(_.SEARCH, default=userdata.get('search', '')).strip()
        if not query:
            return

        userdata.set('search', query)

    folder = plugin.Folder(_(_.SEARCH_FOR, query=query))

    if page == 1:
        items = _parse_creators(api.creators(query=query))
        folder.add_items(items)

    data = api.videos(query=query,
                      page=page,
                      items_per_page=settings.getInt('page_size', 20))
    items = _parse_videos(data['response'])
    folder.add_items(items)

    if data['pagination']['pages'] > page:
        folder.add_item(
            label=_(_(_.NEXT_PAGE, page=page + 1), _bold=True),
            path=plugin.url_for(search, query=query, page=page + 1),
        )

    return folder
示例#19
0
def playlist_channels(playlist_id, radio=0, page=1, **kwargs):
    playlist_id = int(playlist_id)
    radio       = int(radio)
    page        = int(page)

    playlist    = Playlist.get_by_id(playlist_id)

    folder = plugin.Folder(playlist.label)

    page_size = settings.getInt('page_size', 0)
    db_query  = Channel.channel_list(playlist_id=playlist_id, radio=radio, page=page, page_size=page_size)

    items = _process_channels(db_query)
    folder.add_items(items)

    if len(items) == page_size:
        folder.add_item(
            label = _(_.NEXT_PAGE, page=page+1, _bold=True),
            path  = plugin.url_for(playlist_channels, playlist_id=playlist_id, radio=radio, page=page+1),
        )

    if playlist.source_type == Playlist.TYPE_CUSTOM:
        folder.add_item(
            label = _(_.ADD_CHANNEL, _bold=True),
            path  = plugin.url_for(add_channel, playlist_id=playlist_id, radio=radio),
        )

    return folder
示例#20
0
def home(**kwargs):
    folder = plugin.Folder(cacheToDisc=False)

    if not api.logged_in:
        folder.add_item(label=_(_.LOGIN, _bold=True),
                        path=plugin.url_for(login),
                        bookmark=False)
    else:
        folder.add_item(label=_(_.LIVE_TV, _bold=True),
                        path=plugin.url_for(live_tv))

        if settings.getBool('bookmarks', True):
            folder.add_item(label=_(_.BOOKMARKS, _bold=True),
                            path=plugin.url_for(plugin.ROUTE_BOOKMARKS),
                            bookmark=False)

        folder.add_item(label=_.LOGOUT,
                        path=plugin.url_for(logout),
                        _kiosk=False,
                        bookmark=False)

    folder.add_item(label=_.SETTINGS,
                    path=plugin.url_for(plugin.ROUTE_SETTINGS),
                    _kiosk=False,
                    bookmark=False)

    return folder
示例#21
0
def page(page_id, **kwargs):
    data = _page(page_id)

    folder = plugin.Folder(data['title'])
    folder.add_items(data['items'])

    return folder
示例#22
0
def index(**kwargs):
    folder = plugin.Folder(cacheToDisc=False)

    if not api.logged_in:
        folder.add_item(label=_(_.LOGIN, _bold=True), path=plugin.url_for(login), bookmark=False)
    else:
        if not userdata.get('profile_kids', False):
            folder.add_item(label=_(_.FEATURED, _bold=True), path=plugin.url_for(featured, key='sitemap', title=_.FEATURED))
            folder.add_item(label=_(_.TV, _bold=True), path=plugin.url_for(nav, key='tv', title=_.TV))
            folder.add_item(label=_(_.MOVIES, _bold=True), path=plugin.url_for(nav, key='movies', title=_.MOVIES))

            if not settings.getBool('hide_sport', False):
                folder.add_item(label=_(_.SPORT, _bold=True), path=plugin.url_for(nav, key='sport', title=_.SPORT))

        folder.add_item(label=_(_.KIDS, _bold=True), path=plugin.url_for(nav, key='kids', title=_.KIDS))
        folder.add_item(label=_(_.MY_LIST, _bold=True), path=plugin.url_for(my_list))
        folder.add_item(label=_(_.CONTINUE_WATCHING, _bold=True), path=plugin.url_for(continue_watching))
        folder.add_item(label=_(_.SEARCH, _bold=True), path=plugin.url_for(search))

        if settings.getBool('bookmarks', True):
            folder.add_item(label=_(_.BOOKMARKS, _bold=True), path=plugin.url_for(plugin.ROUTE_BOOKMARKS), bookmark=False)

        if not userdata.get('kid_lockdown', False):
            folder.add_item(label=_.SELECT_PROFILE, path=plugin.url_for(select_profile), art={'thumb': userdata.get('profile_icon')}, info={'plot': userdata.get('profile_name')}, _kiosk=False, bookmark=False)

        folder.add_item(label=_.LOGOUT, path=plugin.url_for(logout), _kiosk=False, bookmark=False)

    folder.add_item(label=_.SETTINGS, path=plugin.url_for(plugin.ROUTE_SETTINGS), _kiosk=False, bookmark=False)

    return folder
示例#23
0
def collection(id, filters=None, page=1, after=None, **kwargs):
    page = int(page)
    data = api.collection(id, filters, after=after)
    folder = plugin.Folder(data['title'])

    if filters is None and data.get('namedFilters'):
        folder.add_item(
            label = _(_.ALL, _bold=True),
            path = plugin.url_for(collection, id=id, filters=""),
        )

        for row in data.get('namedFilters', []):
            folder.add_item(
                label = row['title'],
                path = plugin.url_for(collection, id=id, filters=row['id']),
            )

        return folder

    items = process_rows(data['contentPage']['content'])
    folder.add_items(items)

    if data['contentPage']['pageInfo']['hasNextPage']:
        folder.add_item(
            label = _(_.NEXT_PAGE, page=page+1),
            path = plugin.url_for(collection, id=id, filters=filters or "", page=page+1, after=data['contentPage']['pageInfo']['endCursor']),
            specialsort = 'bottom',
        )

    return folder
示例#24
0
def search(query=None, page=1, **kwargs):
    page  = int(page)
    limit = 50

    if not query:
        query = gui.input(_.SEARCH, default=userdata.get('search', '')).strip()
        if not query:
            return

        userdata.set('search', query)

    folder = plugin.Folder(_(_.SEARCH_FOR, query=query, page=page))

    data = api.search(query, page=page, limit=limit)

    items = _process_entries(data['entries'])
    folder.add_items(items)

    if len(data['entries']) == limit:
        folder.add_item(
            label = _(_.NEXT_PAGE, next=page+1, _bold=True),
            path  = plugin.url_for(search, query=query, page=page+1),
        )

    return folder
示例#25
0
def show(show_id, season=None, **kwargs):
    season = season
    data   = api.show(show_id)
    folder = plugin.Folder(data['title'], fanart=_image(data.get('widescreenImage', data['image']), 600), sort_methods=[xbmcplugin.SORT_METHOD_EPISODE, xbmcplugin.SORT_METHOD_UNSORTED, xbmcplugin.SORT_METHOD_LABEL, xbmcplugin.SORT_METHOD_DATEADDED])

    flatten = False
    seasons = data['childAssets']['items']
    if len(seasons) == 1 and len(seasons[0]['childAssets']['items']) == 1:
        flatten = True

    if season == None and not flatten:
        for item in seasons:
            folder.add_item(
                label =  _(_.SEASON, season_number=item['season']),
                info = {
                    'tvshowtitle': data['title'],
                    'mediatype': 'season',
                },
                path = plugin.url_for(show, show_id=show_id, season=item['season']),
                art = {'thumb': _image(data['image'])},
            )
    else:
        for item in seasons:
            if season and int(item['season']) != int(season):
                continue

            items = _parse_elements(item['childAssets']['items'])
            folder.add_items(items)

    return folder
示例#26
0
def episodes(url, show_title, fanart, **kwargs):
    data = api.url(url)

    extras = data.get('bonusFeature', False)

    folder = plugin.Folder(show_title, fanart=fanart)
    if not extras:
        folder.sort_methods = [xbmcplugin.SORT_METHOD_EPISODE, xbmcplugin.SORT_METHOD_UNSORTED, xbmcplugin.SORT_METHOD_LABEL, xbmcplugin.SORT_METHOD_DATEADDED]

    for row in data['entries']:
        if row['programType'] == 'episode':
            if not row['images']:
                try: row = api.url(row['url'])
                except: pass

            folder.add_item(
                label    = row['title'],
                info     = {
                    'plot': row['description'],
                    'year': row['releaseYear'],
                    'duration': row['runtime'],
                    'season': row['tvSeasonNumber'] if not extras else None,
                    'episode': row['tvSeasonEpisodeNumber'] if not extras else None,
                    'mediatype': 'episode',
                    'tvshowtitle': show_title,
                },
                art      = {'thumb': _art(row['images'], type='episode')},
                playable = True,
                path     = _get_play_path(program_id=row['id']),
            )

    return folder
示例#27
0
def catch_up(catalog_id='CATCHUP', title=_.CATCH_UP, **kwargs):
    folder = plugin.Folder(title)

    for row in api.catch_up(catalog_id=catalog_id):
        program = row['Program']

        fanart = _get_logo(program['Poster'])

        if program.get('Match'):
            art = row['Program']['Match']['LeagueLogo']
        elif program.get('Competition'):
            art = row['Program']['Competition']['Logo']
        else:
            art = row.get('Headline')

        folder.add_item(
            label=row['Name'],
            art={
                'fanart': fanart,
                'thumb': art
            },
            info={'plot': row['Program']['Description']},
            path=plugin.url_for(play, vod_id=row['Id']),
            playable=True,
        )

    return folder
示例#28
0
def continue_watching(**kwargs):
    folder = plugin.Folder(_.CONTINUE_WATCHING)

    data = api.history()

    for row in data['entries']:
        if row['completed'] or not row['position']:
            continue

        if row['programType'] == 'movie':
            folder.add_item(
                label = row['title'],
                properties = {'ResumeTime': row['position'], 'TotalTime': row['totalDuration']},
                art   = {'thumb': _art(row['images']), 'fanart': _art(row['images'], 'fanart')},
                path = plugin.url_for(play, program_id=row['programId']),
                playable = True,
            )
        elif row['programType'] == 'episode':
            folder.add_item(
                label = row['title'],
                properties = {'ResumeTime': row['position'], 'TotalTime': row['totalDuration']},
                art   = {'thumb': _art(row['images']), 'fanart': _art(row['images'], 'fanart')},
                info = {'tvshowtitle': row['seriesTitle'], 'mediatype': 'episode', 'season': row['tvSeasonNumber'], 'episode': row['tvSeasonEpisodeNumber']},
                context = ((_(_.GOTO_SERIES, series=row['seriesTitle']), 'Container.Update({})'.format(plugin.url_for(series, series_id=row['seriesId']))),),
                path = plugin.url_for(play, program_id=row['programId']),
                playable = True,
            )

    return folder
示例#29
0
def home(**kwargs):
    folder = plugin.Folder(cacheToDisc=False)

    if not api.logged_in:
        folder.add_item(label=_(_.LOGIN, _bold=True),
                        path=plugin.url_for(login))
    else:
        folder.add_item(label=_(_.FEATURED, _bold=True),
                        path=plugin.url_for(page, slug='/', label=_.FEATURED))
        folder.add_item(label=_(_.LIVE, _bold=True),
                        path=plugin.url_for(page, slug='/live'))
        folder.add_item(label=_(_.SEARCH, _bold=True),
                        path=plugin.url_for(search))

        if settings.getBool('bookmarks', True):
            folder.add_item(label=_(_.BOOKMARKS, _bold=True),
                            path=plugin.url_for(plugin.ROUTE_BOOKMARKS),
                            bookmark=False)

        folder.add_item(label=_.LOGOUT,
                        path=plugin.url_for(logout),
                        _kiosk=False,
                        bookmark=False)

    folder.add_item(label=_.SETTINGS,
                    path=plugin.url_for(plugin.ROUTE_SETTINGS),
                    _kiosk=False,
                    bookmark=False)

    return folder
示例#30
0
def playlists(**kwargs):
    folder = plugin.Folder(_.PLAYLISTS)

    playlists = Playlist.select().order_by(Playlist.order)

    for playlist in playlists:
        context = [
            ('Disable Playlist' if playlist.enabled else 'Enable Playlist', "RunPlugin({})".format(plugin.url_for(edit_playlist_value, playlist_id=playlist.id, method=Playlist.toggle_enabled.__name__))),
            (_.DELETE_PLAYLIST, "RunPlugin({})".format(plugin.url_for(delete_playlist, playlist_id=playlist.id))),
            (_.INSERT_PLAYLIST, "RunPlugin({})".format(plugin.url_for(new_playlist, position=playlist.order))),
        ]

        if playlist.source_type == Playlist.TYPE_ADDON:
            context.append((_.ADDON_SETTINGS, "Addon.OpenSettings({})".format(playlist.path)))

        if playlist.order > 1:
            context.append(('Move Up', 'RunPlugin({})'.format(plugin.url_for(shift_playlist, playlist_id=playlist.id, shift=-1))))

        if playlist.order < len(playlists)+1:
            context.append(('Move Down', 'RunPlugin({})'.format(plugin.url_for(shift_playlist, playlist_id=playlist.id, shift=1))))

        folder.add_item(
            label   = playlist.name,
            info    = {'plot': playlist.plot},
            art     = {'thumb': playlist.thumb},
            path    = plugin.url_for(edit_playlist, playlist_id=playlist.id),
            context = context,
        )

    folder.add_item(
        label = _(_.ADD_PLAYLIST, _bold=True),
        path  = plugin.url_for(new_playlist),
    )

    return folder