예제 #1
0
def content(label, section='', sortby=None, title=None, channels='', start=0, **kwargs):
    start = int(start)
    folder = plugin.Folder(title=label)

    if not sortby:
        items = [[_.A_Z, 'TITLE'], [_.LATEST, 'LATEST'], [_.LAST_CHANCE, 'LASTCHANCE']]
        for item in items:
            folder.add_item(label=item[0], path=plugin.url_for(content, label=item[0], section=section, sortby=item[1], channels=channels))

    elif sortby == 'TITLE' and title == None:
        items = [[c, c] for c in ascii_uppercase]
        items.insert(0, [_.ALL, ''])
        items.append([_.ZERO_9, '0-9'])
        
        for item in items:
            folder.add_item(label=item[0], path=plugin.url_for(content, label=item[0], section=section, sortby=sortby, title=item[1], channels=channels))

    else:
        data   = api.content(section, sortby=sortby, title=title, 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, sortby=sortby, title=title, channels=channels, start=data['index']),
            )

    return folder
예제 #2
0
def _parse_rows(rows, default_art=None):
    items = []

    for row in rows:
        item = plugin.Item(
            label    = row['title'],
            info     = {'plot': row['description']},
            art      = _get_art(row.get('images', []), default_art),
        )

        if row['type'] in ('movie', 'episode'):
            videos = _get_videos(row.get('videos', []))

            item.info.update({
                'duration': int(videos['main']['duration']),
                'mediatype': row['type'],
            })

            item.video = {'height': videos['main']['height'], 'width': videos['main']['width'], 'codec': 'h264'}
            item.path  = plugin.url_for(play, video_id=videos['main']['id'])
            item.playable = True

            if 'trailer' in videos:
                item.info['trailer'] = plugin.url_for(play, video_id=videos['trailer']['id'])

            if not item.label:
                item.label = _(L_EPISODE_NUMBER, episode_number=row['number'])

        elif row['type'] == 'tv_series':
            item.path      = plugin.url_for(series, series_id=row['id'])
            item.cache_key = cache.key_for(series, series_id=row['id'])

        items.append(item)

    return items
def home(**kwargs):
    folder = plugin.Folder()

    folder.add_item(
        label=_(_.PLAYLISTS, _bold=True),
        path=plugin.url_for(playlists),
    )

    folder.add_item(
        label=_(_.EPGS, _bold=True),
        path=plugin.url_for(epgs),
    )

    folder.add_item(
        label=_(_.CHANNEL_MANAGER, _bold=True),
        path=plugin.url_for(channel_manager),
    )

    folder.add_item(
        label=_.MERGE_NOW,
        path=plugin.url_for(merge),
    )

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

    return folder
예제 #4
0
def home(**kwargs):
    region = get_region()
    channels = get_channels(region)

    folder = plugin.Folder(_(_.REGIONS[region]), cacheToDisc=False)

    for slug in sorted(
            channels,
            key=lambda k:
        (channels[k].get('network', ''), channels[k].get('name', ''))):
        channel = channels[slug]

        folder.add_item(
            label=channel['name'],
            path=plugin.url_for(play, slug=slug, _is_live=True),
            info={'plot': channel.get('description')},
            video=channel.get('video', {}),
            audio=channel.get('audio', {}),
            art={'thumb': channel.get('logo')},
            playable=True,
        )

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

    return folder
def _process_media(row):
    if settings.getBool('child_friendly', False) and not row.get('is_child_friendly', False):
        #maybe just block playback and add label, so pagination still correct
        return None

    is_published   = row.get('is_published', True)
    is_collection  = row.get('is_collection', False)
    is_free        = row.get('is_free', False) 
    is_series      = row.get('is_numbered_series', False)
    duration       = row.get('duration', 0) if plugin.logged_in or is_free else PREVIEW_LENGTH

    context = []

    if plugin.logged_in and not is_collection:
        user_media   = row.get('user_media') or {}
        in_watchlist = user_media.get('is_bookmarked', False)

        if in_watchlist:
            context.append((_.REMOVE_WATCHLIST, "XBMC.RunPlugin({})".format(plugin.url_for(remove_watchlist, id=row['id'], title=row['title']))))
        else:
            context.append((_.ADD_WATCHLIST, "XBMC.RunPlugin({})".format(plugin.url_for(add_watchlist, id=row['id'], title=row['title']))))

    if is_collection:
        path = plugin.url_for(series, id=row['id'])
    else:
        path = plugin.url_for(play, id=row['id'])

    return plugin.Item(
        label = row.get('title'),
        info  = {'plot': row['description'], 'duration': duration, 'year': row.get('year_produced')},
        art   = {'thumb': _image(row, 'image_medium')},
        path  = path,
        context = context,
        playable = not is_collection,
    )
def categories(id=None, **kwargs):
    folder = plugin.Folder(title=_.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
예제 #7
0
def playlist(output, **kwargs):
    EPG_MAP = {
        68330: 'RACING',
        53208: 'FSCRICHD',
        53210: 'FSLEAGUEHD',
        53211: 'FS3HD',
        53212: 'FSFOOTYHD',
        53214: 'FS5HD',
        53215: 'FS6HD',
        53216: 'FSMHD',
        53217: 'FSNHD2',
        53169: 'ESPNHD',
        53207: 'ESPN2HD',
        53153: 'BEIN1HD',
        53154: 'BEIN2HD',
        53167: 'BEIN3HD',
    }

    data = api.panel(CHANNELS_PANEL)

    with open(output, 'wb') as f:
        f.write('#EXTM3U\n')

        for row in data.get('contents', []):
            asset = row['data']['asset']

            if row['contentType'] != 'video':
                continue

            f.write('#EXTINF:-1 tvg-id="{id}" tvg-logo="{logo}",{name}\n{path}\n'.format(
                id=EPG_MAP.get(int(asset['id']), asset['id']), logo=_get_image(asset, 'video', 'thumb').encode('utf8'),
                    name=asset['title'].encode('utf8'), path=plugin.url_for(play, id=asset['id'], _is_live=True)))
예제 #8
0
def show(show_id, title, **kwargs):
    data = api.show(show_id=show_id, profile=userdata.get('profile'))

    folder = plugin.Folder(title=title)

    for row in data:
        if row['title'] == 'Seasons':
            for row2 in row.get('contents', []):
                asset = row2['data']['asset']

                folder.add_item(
                    label=asset['title'],
                    art={
                        'thumb': _get_image(asset, 'show', 'thumb'),
                        'fanart': _get_image(asset, 'show', 'fanart'),
                    },
                    info={
                        'plot': asset.get('description-short'),
                    },
                    path=plugin.url_for(season,
                                        show_id=show_id,
                                        season_id=asset['id'],
                                        title=asset['title']),
                )

    return folder
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(title=_(_.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
예제 #10
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=_(_.SHOWS, _bold=True),
                        path=plugin.url_for(shows))
        folder.add_item(label=_(_.SPORTS, _bold=True),
                        path=plugin.url_for(sports))
        folder.add_items(_landing('home'))

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

    return folder
예제 #11
0
def home(**kwargs):
    folder = plugin.Folder()

    if not api.logged_in:
        folder.add_item(label=_(_.LOGIN, _bold=True), path=plugin.url_for(login))
    else:
        folder.add_item(label=_(_.LIVE_TV, _bold=True),  path=plugin.url_for(live_tv))
        folder.add_item(label=_(_.TV_SHOWS, _bold=True), path=plugin.url_for(content, label=_.TV_SHOWS, section='tvshows'))
        folder.add_item(label=_(_.MOVIES, _bold=True),   path=plugin.url_for(content, label=_.MOVIES, section='movies'))
        folder.add_item(label=_(_.SPORTS, _bold=True),   path=plugin.url_for(content, label=_.SPORTS, section='sport'))
        folder.add_item(label=_(_.BOX_SETS, _bold=True), path=plugin.url_for(content, label=_.BOX_SETS, section='boxsets'))
        folder.add_item(label=_(_.CHANNELS, _bold=True), path=plugin.url_for(channels))
        folder.add_item(label=_(_.SEARCH, _bold=True),   path=plugin.url_for(search))

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

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

    return folder
예제 #12
0
def home():
    folder = plugin.Folder()

    folder.add_item(
        label = _(_.PLAYLISTS, _bold=True), 
        path  = plugin.url_for(playlists),
    )

    folder.add_item(
        label = _(_.EPGS, _bold=True), 
        path  = plugin.url_for(epgs),
    )

    folder.add_item(
        label = _.MERGE_NOW, 
        path  = plugin.url_for(merge),
    )

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

    return folder
예제 #13
0
def _parse_show(asset):
    return plugin.Item(
        label=asset['title'],
        art={
            'thumb': _get_image(asset, 'show', 'thumb'),
            'fanart': _get_image(asset, 'show', 'fanart'),
        },
        info={
            'plot': asset.get('description-short'),
        },
        path=plugin.url_for(show, id=asset['id'], title=asset['title']),
    )
예제 #14
0
def _parse_panel(row):
    art = {}

    items = _parse_contents(row.get('contents', []))
    if items:
        art = items[0].art

    return plugin.Item(
        label=row['title'],
        path=plugin.url_for(panel, id=row['id']),
        art=art,
    )
def index(**kwargs):
    folder = plugin.Folder()

    folder.add_item(label=_.CATEGORIES, path=plugin.url_for(categories))
    folder.add_item(label=_.COLLECTIONS, path=plugin.url_for(collections))
    folder.add_item(label=_.FEATURED, path=plugin.url_for(featured))
    folder.add_item(label=_.SEARCH, path=plugin.url_for(search))

    if not api.logged_in:
        folder.add_item(label=_(_.LOGIN, _bold=True), path=plugin.url_for(login), _position=0)
    else:
        folder.add_item(label=_.WATCHLIST, path=plugin.url_for(watchlist))
        folder.add_item(label=_.WATCHING, path=plugin.url_for(watching))
        folder.add_item(label=_.LOGOUT, path=plugin.url_for(logout))

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

    return folder
예제 #16
0
def home(**kwargs):
    folder = plugin.Folder(cacheToDisc=False)

    if not userdata.get('dns4me_key'):
        folder.add_item(
            label='dns4me Login',
            path=plugin.url_for(dns4me_login),
        )
    else:
        folder.add_item(
            label='dns4me Logout',
            path=plugin.url_for(dns4me_logout),
        )

    folder.add_item(
        label='Install Widevine CDM',
        path=plugin.url_for(ia_install),
    )

    #folder.add_item(label=_.SETTINGS, path=plugin.url_for(plugin.ROUTE_SETTINGS))

    return folder
예제 #17
0
def epgs():
    folder = plugin.Folder(title=_.EPGS)
    sources = list(Source.select().where(Source.item_type == Source.EPG))

    for source in sources:
        item = plugin.Item(
            label = source.label(),
            path = plugin.url_for(edit_source, id=source.id),
            is_folder = False,
            playable = False,
        )

        item.context.append((_.DELETE_SOURCE, 'XBMC.RunPlugin({})'.format(plugin.url_for(delete_source, id=source.id))))

        folder.add_items([item])

    folder.add_item(
        label = _(_.ADD_EPG, _bold=len(sources) == 0), 
        path  = plugin.url_for(edit_source, type=Source.EPG),
    )

    return folder
예제 #18
0
def _parse_show(asset):
    return plugin.Item(
        label=asset['title'],
        art={
            'thumb': _get_image(asset, 'carousel-item'),
            'fanart': _get_image(asset, 'hero-default'),
        },
        info={
            'plot': asset.get('description-short'),
            'mediatype': 'tvshow',
        },
        path=plugin.url_for(show, id=asset['id'], title=asset['title']),
    )
def featured(id=None, **kwargs):
    folder = plugin.Folder(title=_.FEATURED)

    rows = api.sections(7)

    if id:
        for row in rows:
            if str(row['id']) == str(id):
                folder.title = row['label']
                folder.fanart = _image(row, 'background_url')

                for subrow in row.get('media', []):
                    item = _process_media(subrow)
                    folder.add_items([item])

                break

    else:
        for row in rows:
            if row['type'] == 'custom':
                path = plugin.url_for(featured, id=row['id'])
            elif row['type'] == 'playlist':
                path = plugin.url_for(collection, id=row['model_id'])
            else:
                path = plugin.url_for(media, title=row['label'], filterby=row['type'], term=row['name'])

            thumb = _image(row, 'image_url')
            if not thumb and row.get('media', []):
                thumb = _image(row['media'][0], 'image_medium')

            folder.add_item(
                label = row['label'],
                info  = {'plot': row.get('description')},
                art   = {'thumb': thumb},
                path  = path,
            )

    return folder
def epgs(**kwargs):
    folder = plugin.Folder(title=_.EPGS)
    sources = Source.select().where(Source.item_type == Source.EPG).order_by(
        Source.order.asc())

    items = _process_sources(sources)
    folder.add_items(items)

    folder.add_item(
        label=_(_.ADD_EPG, _bold=len(items) == 0),
        path=plugin.url_for(edit_source, type=Source.EPG, order=len(items)),
    )

    return folder
예제 #21
0
def home(**kwargs):
    folder = plugin.Folder()

    channels = get_channels()
    for slug in sorted(
            channels,
            key=lambda k: channels[k].get('channel', channels[k]['name'])):
        channel = channels[slug]

        folder.add_item(
            label=channel['name'],
            path=plugin.url_for(play, slug=slug, _is_live=True),
            info={'plot': channel.get('description')},
            video=channel.get('video', {}),
            audio=channel.get('audio', {}),
            art={'thumb': channel.get('logo')},
            playable=True,
        )

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

    return folder
예제 #22
0
def _landing(name, sport=None):
    items = []

    for row in api.landing(name, sport=sport, profile=userdata.get('profile')):
        if row['panelType'] == 'hero-carousel' and row.get('contents') and settings.getBool('show_hero_contents', True):
            items.extend(_parse_contents(row['contents']))

        elif row['panelType'] != 'hero-carousel' and 'id' in row:
            items.append(plugin.Item(
                label = row['title'],
                path  = plugin.url_for(panel, id=row['id'], sport=sport),
            ))

    return items
def collections(page=1, **kwargs):
    page = int(page)

    data = api.collections(page=page)
    total_pages = int(data['paginator']['total_pages'])

    folder = plugin.Folder(title=_.COLLECTIONS)

    for row in data['data']:
        folder.add_item(
            label = row['title'],
            info  = {'plot': row['description']},
            art   = {'thumb': _image(row, 'image_url')},
            path  = plugin.url_for(collection, id=row['id']),
        )

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

    return folder
예제 #24
0
def _process_content(rows):
    items = []
    subscriptions = userdata.get('subscriptions', [])

    for row in rows:
        if row['suspended']:
            continue

        label = row['title']

        if 'subCode' in row and subscriptions and row['subCode'] not in subscriptions:
            label = _(_.LOCKED, label=label)

            if settings.getBool('hide_unplayable', False):
                continue

        if row['type'] == 'movie':
            items.append(plugin.Item(
                label = label,
                info = {
                    'plot': row.get('synopsis'),
                    'duration': int(row.get('duration', '0 mins').strip(' mins')) * 60,
                    'mediatype': 'movie',
                },
                art  = {'thumb': IMAGE_URL.format(row['images'].get('MP',''))},
                path = plugin.url_for(play, id=row['mediaId']),
                playable = True,
            ))

        elif row['type'] == 'season':
            items.append(plugin.Item(
                label = label,
                art   = {'thumb': IMAGE_URL.format(row['images'].get('MP',''))},
                path  = plugin.url_for(series, id=row['id']),
            ))

    return items
예제 #25
0
def sports(**kwargs):
    folder = plugin.Folder(title=_.SPORTS)

    for row in api.sport_menu():
        slug = row['url'].split('sport!')[1]

        folder.add_item(
            label = row['name'],
            path  = plugin.url_for(sport, slug=slug, title=row['name']),
            art   = {
                'thumb': SPORT_LOGO.format(row['sport']),
            },
        )

    folder.add_items(_landing('sports'))

    return folder
예제 #26
0
def playlist(output, **kwargs):
    channels = get_channels()

    with open(output, 'wb') as f:
        f.write('#EXTM3U\n')

        for slug in sorted(
                channels,
                key=lambda k: channels[k].get('channel', channels[k]['name'])):
            channel = channels[slug]

            f.write(
                '#EXTINF:-1 tvg-id="{id}" tvg-chno="{chno}" tvg-logo="{logo}",{name}\n{path}\n'
                .format(id=slug,
                        logo=channel.get('logo', '').encode('utf8'),
                        name=channel['name'].encode('utf8'),
                        chno=channel.get('channel', ''),
                        path=plugin.url_for(play, slug=slug, _is_live=True)))
def watching(page=1, **kwargs):
    page = int(page)

    folder = plugin.Folder(title=_.WATCHING)
    data   = api.filter_media('watching', page=page)
    total_pages = int(data['paginator']['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(watchlist, page=page+1),
        )

    return folder
예제 #28
0
def home():
    folder = plugin.Folder()

    if not plugin.logged_in:
        folder.add_item(label=_(L_LOGIN, bold=True), path=plugin.url_for(login))

    folder.add_item(label=_(L_SERIES, bold=plugin.logged_in),  path=plugin.url_for(all_series), cache_key=cache.key_for(all_series))
    folder.add_item(label=_(L_MOVIES, bold=plugin.logged_in),  path=plugin.url_for(movies),     cache_key=cache.key_for(movies))
    folder.add_item(label=_(L_KIDS,   bold=plugin.logged_in),  path=plugin.url_for(kids),       cache_key=cache.key_for(kids))
    folder.add_item(label=_(L_SEARCH, bold=plugin.logged_in),  path=plugin.url_for(search),     cache_key=cache.key_for(search))

    if plugin.logged_in:
        folder.add_item(label=_(L_LOGOUT), path=plugin.url_for(logout))

    folder.add_item(label=_(L_SETTINGS), path=plugin.url_for(plugin.ROUTE_SETTINGS))

    return folder
def media(title, filterby, term, page=1, **kwargs):
    page = int(page)

    data = api.filter_media(filterby, term, page=page)
    total_pages = int(data['paginator']['total_pages'])

    folder = plugin.Folder(title=title)

    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(media, title=title, filterby=filterby, term=term, page=page+1),
        )

    return folder
예제 #30
0
def _sport(sport):
    items = []

    #https://vccapi.kayosports.com.au/content/types/landing/names/sport?sport=tennis&evaluate=3&profile=d3bf57f6ce9bbadf05488e7fd82972e899e857be

    for row in api.sport_menu(sport):
        item = plugin.Item(
            label=row['name'],
            path=plugin.url_for(sport_list,
                                sport=row['sport'],
                                name=row['name']),
            art={
                'thumb':
                'https://resources.kayosports.com.au/production/sport-logos/1x1/{}.png?imwidth=320'
                .format(row['sport'])
            },
        )
        items.append(item)

    return items