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
Beispiel #2
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 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
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
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
Beispiel #6
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 collection(id, **kwargs):
    data   = api.collection(id)
    folder = plugin.Folder(title=data['title'], fanart=_image(data, 'background_url'))

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

    return folder
def series(id, **kwargs):
    data   = api.series(id)
    folder = plugin.Folder(title=data['title'], fanart=_image(data, 'image_large'))

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

    return folder
Beispiel #9
0
def season(show_id, season_id, title, **kwargs):
    data = api.show(show_id=show_id, season_id=season_id, profile=userdata.get('profile'))
    folder = plugin.Folder(title=title)

    for row in data:
        if row['title'] == 'Episodes':
            folder.add_items(_parse_contents(row.get('contents', [])))

    return folder
def show(id, title):
    data = api.show(id)

    folder = plugin.Folder(title=title)
    for row in data:
        if row['title'] == 'Episodes':
            folder.add_items(_parse_contents(row.get('contents', [])))

    return folder
Beispiel #11
0
    def get_results(query):
        folder = plugin.Folder(title=_(L_SEARCH_FOR, query=query))
        rows = api.search(query)
        folder.add_items(_parse_rows(rows))

        if not folder.items:
            folder.add_item(
                label     = _(L_NO_RESULTS, label=True),
                is_folder = False,
            )

        return folder
Beispiel #12
0
def live_tv(**kwargs):
    folder = plugin.Folder(title=_.LIVE_TV)

    for row in _get_channels():
        folder.add_item(
            label    = row['label'],
            info     = {'description': row['description']},
            art      = {'thumb': row['image']},
            path     = row['path'],
            playable = True,
        )

    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
Beispiel #14
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=_.SELECT_PROFILE, path=plugin.url_for(select_profile))
        folder.add_item(label=_.LOGOUT, path=plugin.url_for(logout))

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

    return folder
Beispiel #15
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
Beispiel #16
0
def series(series_id):
    data   = api.series(series_id)
    art    = _get_art(data['images'])

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

    for season in data['seasons']:
        folder.add_item(
            label = _(L_SEASON_NUMBER, label=True, season_number=season['number']),
            art   = art,
            is_folder = False,
        )

        rows = season['episodes']
        folder.add_items(_parse_rows(rows, art))

    return folder
Beispiel #17
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 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
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
Beispiel #20
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
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
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
Beispiel #23
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
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
Beispiel #25
0
def series(id, **kwargs):
    data   = api.series(id)

    folder = plugin.Folder(title=data['title'], fanart=IMAGE_URL.format(data['images'].get('PS','')), sort_methods=[xbmcplugin.SORT_METHOD_EPISODE, xbmcplugin.SORT_METHOD_UNSORTED, xbmcplugin.SORT_METHOD_LABEL, xbmcplugin.SORT_METHOD_DATEADDED])

    for row in data.get('subContent', []):
        folder.add_item(
            label = row['episodeTitle'],
            info  = {
                'tvshowtitle': data.get('seriesTitle', data['title']),
                'plot': row.get('episodeSynopsis'),
                'duration': int(row.get('duration', '0 mins').strip(' mins')) * 60,
                'season': int(row.get('seasonNumber', 0)),
                'episode': int(row.get('episodeNumber', 0)),
                'mediatype': 'episode',
            },
            art   = {'thumb': IMAGE_URL.format(data['images'].get('MP',''))},
            path  = plugin.url_for(play, id=row['mediaId']),
            playable = True,
        )

    return folder
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
Beispiel #27
0
def search(query=None, start=0, **kwargs):
    start = int(start)

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

        userdata.set('search', query)

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

    data = api.content(text=query, 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(search, query=query, start=data['index']),
        )

    return folder
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
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
Beispiel #30
0
def channels(**kwargs):
    folder = plugin.Folder(title=_.CHANNELS)

    subscriptions = userdata.get('subscriptions', [])

    for row in sorted(api.channels(), key=lambda row: row['title']):
        label = row['title']

        subscribed = _is_subscribed(subscriptions, row.get('media$categories'))

        if not subscribed:
            label = _(_.LOCKED, label=label)

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

        folder.add_item(
            label    = label,
            info     = {'description': row.get('description')},
            art      = {'thumb': _get_image(row)},
            path     = plugin.url_for(content, label=row['title'], sortby='TITLE', title='', channels=row.get('sky$skyGOChannelID', '')),
        )

    return folder