def highlights(page=1, **kwargs): page = int(page) folder = plugin.Folder(_.HIGHLIGHTS) data = api.highlights(page=page) total_pages = int(data['paging']['totalPages']) if total_pages > 1: folder.title += _(_.PAGE_TITLE, cur_page=page, total_pages=total_pages) for row in data['programs']: try: split = row['runtimeMins'].split(':') duration = int(split[0]) * 60 if len(split) > 1: duration += int(split[1]) except: duration = 0 folder.add_item( label = row['name'], info = {'plot': row.get('description'), 'duration': duration}, art = {'thumb': THUMB_URL.format(row.get('image', ''))}, playable = True, path = plugin.url_for(play, media_id=row['id'], media_type=MEDIA_VIDEO), ) if page < total_pages: folder.add_item( label = _(_.NEXT_PAGE, next_page=page+1), path = plugin.url_for(highlights, page=page+1), ) return folder
def _process_items(rows): items = [] for row in rows: attribs = row['attribs'] if row['typeId'] == 'go-item-video': item = plugin.Item( label=attribs['title'], info={ 'plot': attribs['description'], 'duration': int(attribs['video-duration']) / 1000, }, art={'thumb': attribs['image-background-small']}, path=plugin.url_for(play, id=attribs['assetId']), playable=True, ) elif row['typeId'] == 'go-item-navigation': item = plugin.Item( label=attribs['title'], info={ 'plot': attribs.get('description'), }, art={'thumb': attribs['image-background-small']}, path=plugin.url_for(page, page_id=attribs['pageId']), ) items.append(item) return items
def _parse_movies(rows): items = [] for row in rows: videos = _get_videos(row.get('videos', [])) item = plugin.Item( label=row['title'], info={'plot': row['description']}, art=_get_art(row.get('images', [])), is_folder=False, ) if videos['main']: item.info.update({ 'duration': int(videos['main'][0]['duration']), 'mediatype': 'movie', }) item.video = { 'height': videos['main'][0]['height'], 'width': videos['main'][0]['width'], 'codec': 'h264' } item.path = plugin.url_for(play, asset_id=row['id']) item.playable = True if videos['trailer']: item.info['trailer'] = plugin.url_for(play_trailer, asset_id=row['id']) items.append(item) return items
def epgs(**kwargs): folder = plugin.Folder(_.EPGS) for epg in EPG.select().order_by(EPG.id): context = [ (_.DISABLE_EPG if epg.enabled else _.ENABLE_EPG, 'RunPlugin({})'.format( plugin.url_for(edit_epg_value, epg_id=epg.id, method=EPG.toggle_enabled.__name__))), (_.DELETE_EPG, 'RunPlugin({})'.format(plugin.url_for(delete_epg, epg_id=epg.id))), ] folder.add_item( label=epg.name, info={'plot': epg.plot}, art={'thumb': epg.thumb}, path=plugin.url_for(edit_epg, epg_id=epg.id), context=context, ) folder.add_item( label=_(_.ADD_EPG, _bold=True), path=plugin.url_for(new_epg), ) return folder
def search(query, page, **kwargs): items = [] for row in api.search(query): if row['type'] == 'show': items.append(_process_show(row)) elif row['type'] == 'category': slug = row['page']['href'].split('/')[-1] if slug == 'shows': slug = 'all' items.append( plugin.Item( label=row['title'], info={'plot': row['searchDescription'] or row['synopsis']}, art={'thumb': _get_image(row['tileImage'])}, path=plugin.url_for(category, slug=slug), )) elif row['type'] == 'channel': items.append( plugin.Item( label=row['title'], info={'plot': row['searchDescription'] or row['synopsis']}, art={'thumb': _get_image(row['tileImage'])}, path=plugin.url_for( play, channel=row['page']['href'].split('/')[-1], _is_live=True), playable=True, )) return items, False
def show(slug, **kwargs): _show, sections, embedded = api.show(slug) categories = [] for i in _show['categories']: categories.append(i['label']) fanart = _get_image(_show['coverImage'], '?width=1920&height=548') folder = plugin.Folder(_show['title'], fanart=fanart) count = 0 for row in sections: if row['_embedded']['sectionType'] == 'similarContent': folder.add_item( label=row['label'], art={'thumb': _get_image(_show['tileImage'])}, path=plugin.url_for(similar, href=row['_embedded']['id'], label=_show['title'], fanart=fanart), ) else: for module in row['_embedded']['layout']['slots']['main'][ 'modules']: if module['type'] != 'showVideoCollection': continue for _list in module['lists']: count += 1 if count == 1 and _show[ 'videosAvailable'] == 1 and settings.getBool( 'flatten_single_season', True): # Try to flatten try: data = embedded[embedded[_list['href']]['content'] [0]['href']] item = _process_video(data, _show['title'], categories=categories) folder.add_items(item) continue except: pass item = plugin.Item( label=_list['label'] or module['label'], art={'thumb': _get_image(_show['tileImage'])}, path=plugin.url_for(video_list, href=_list['href'], label=_show['title'], fanart=fanart), ) if 'season' in item.label.lower(): item.info['mediatype'] = 'season' folder.items.insert(0, item) else: folder.items.append(item) return folder
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=_(_.CHANNELS, _bold=True), path=plugin.url_for(editorial, id=LINEAR_ID, title=_.CHANNELS)) _home(folder) 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
def epgs(**kwargs): folder = plugin.Folder(_.EPGS) for epg in EPG.select().order_by(EPG.id): context = [ ('Disable EPG' if epg.enabled else 'Enable EPG', "RunPlugin({})".format(plugin.url_for(edit_epg_value, epg_id=epg.id, method=EPG.toggle_enabled.__name__))), (_.DELETE_EPG, "RunPlugin({})".format(plugin.url_for(delete_epg, epg_id=epg.id))), ] if epg.source_type == EPG.TYPE_ADDON: context.append(('Add-on Settings', "Addon.OpenSettings({})".format(epg.path))) folder.add_item( label = epg.name, info = {'plot': epg.plot}, art = {'thumb': epg.thumb}, path = plugin.url_for(edit_epg, epg_id=epg.id), context = context, ) folder.add_item( label = _(_.ADD_EPG, _bold=True), path = plugin.url_for(new_epg), ) return folder
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
def series(series_id, **kwargs): data = api.series_bundle(series_id, page_size=0) title = _get_text(data['series']['texts'], 'title', 'series') folder = plugin.Folder(title, fanart=_image(data['series']['images'], 'fanart')) for row in data['seasons']['seasons']: item = _parse_season(row, data['series']) folder.add_items(item) if data['extras']['videos']: folder.add_item( label=(_.EXTRAS), art={'thumb': _image(data['series']['images'], 'thumb')}, path=plugin.url_for( extras, family_id=data['series']['family']['encodedFamilyId'], fanart=_image(data['series']['images'], 'fanart')), ) if data['related']['items']: folder.add_item( label=_.SUGGESTED, art={'thumb': _image(data['series']['images'], 'thumb')}, path=plugin.url_for(suggested, series_id=series_id), ) return folder
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
def home(**kwargs): folder = plugin.Folder(cacheToDisc=False) folder.add_item(label=_(_.HOME, _bold=True), path=plugin.url_for(content, slug='home')) folder.add_item(label=_(_.LIVE_TV, _bold=True), path=plugin.url_for(content, slug=LIVE_TV_SLUG, label=_.LIVE_TV, expand_media=1)) folder.add_item(label=_(_.SHOWS, _bold=True), path=plugin.url_for(shows)) folder.add_item(label=_(_.MOVIES, _bold=True), path=plugin.url_for(content, slug='movies')) folder.add_item(label=_(_.SPORT, _bold=True), path=plugin.url_for(content, slug='sport')) folder.add_item(label=_(_.NEWS, _bold=True), path=plugin.url_for(content, slug='news')) folder.add_item(label=_(_.CATEGORIES, _bold=True), path=plugin.url_for(content, slug='all-categories')) 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=_.SETTINGS, path=plugin.url_for(plugin.ROUTE_SETTINGS), _kiosk=False, bookmark=False) return folder
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
def _parse_creators(rows, following=False): items = [] for row in rows: item = plugin.Item( label=row['title'], info={'plot': row['bio']}, art={ 'thumb': row['avatar'], 'fanart': row['banner'] }, path=plugin.url_for(creator_list, slug=row['friendly_title']), ) if following: item.context.append( (_(_.UNFOLLOW_CREATOR, creator=row['title']), 'RunPlugin({})'.format( plugin.url_for(unfollow_creator, slug=row['friendly_title'])))) else: item.context.append( (_(_.FOLLOW_CREATOR, creator=row['title']), 'RunPlugin({})'.format( plugin.url_for(follow_creator, slug=row['friendly_title'])))) items.append(item) return items
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
def my_list(**kwargs): folder = plugin.Folder(_.MY_LIST) data = api.watchlist() for row in data['entries']: if row['programType'] == 'series': folder.add_item( label=row['title'], art={ 'thumb': _art(row['images']), 'fanart': _art(row['images'], 'fanart') }, path=plugin.url_for(series, series_id=row['programId']), ) elif row['programType'] == 'movie': folder.add_item( label=row['title'], art={ 'thumb': _art(row['images']), 'fanart': _art(row['images'], 'fanart') }, path=plugin.url_for(play, program_id=row['programId']), playable=True, ) return folder
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
def search(**kwargs): query = gui.input(_.SEARCH, default=userdata.get('search', '')).strip() if not query: return userdata.set('search', query) folder = plugin.Folder(_(_.SEARCH_FOR, query=query)) for row in api.search(query): item = plugin.Item( label=row['title'], art={'thumb': row['image'].get('LARGE')}, info={}, ) if row['editorialItemType'] == 'Program': item.path = plugin.url_for(list_seasons, id=row['id']) elif row['editorialItemType'] == 'Video': item.path = plugin.url_for(play_video, id=row['id']) item.playable = True else: continue folder.add_items(item) return folder
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
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
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
def _parse_series(rows): items = [] for row in rows: videos = _get_videos(row.get('videos', [])) item = plugin.Item( label=row['title'], info={ 'sorttitle': row['title'], 'plot': row['description'], 'tvshowtitle': row['title'], 'mediatype': 'tvshow', }, art=_get_art(row.get('images', [])), path=plugin.url_for(seasons, series_id=row['id']), ) if videos['trailer']: item.info['trailer'] = plugin.url_for(play_trailer, asset_id=row['id']) items.append(item) return items
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
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
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
def _process_media(row, in_watchlist=False): 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: if in_watchlist: context.append((_.REMOVE_WATCHLIST, "RunPlugin({})".format( plugin.url_for(remove_watchlist, id=row['id'], title=row['title'], series=int(is_collection))))) else: context.append((_.ADD_WATCHLIST, "RunPlugin({})".format( plugin.url_for(add_watchlist, id=row['id'], title=row['title'], series=int(is_collection))))) if is_collection: path = plugin.url_for(series, id=row['id']) else: path = _get_play_path(row['id']) item = 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, ) if settings.getBool('sync_playback', False): try: resume_from = row['user_media']['progress_in_seconds'] except: resume_from = 0 item.properties['ResumeTime'] = resume_from item.properties['TotalTime'] = resume_from return item
def _process_rows(rows): items = [] now = arrow.utcnow() for row in rows: try: thumb = IMG_URL.format( row.get('pictureID') or row['pictures']['16x9']) except: thumb = None start_time = arrow.get(row.get('startTime') or None) end_time = arrow.get(row.get('endTime') or None) now = arrow.utcnow() item = plugin.Item( label=row['name'], info={'plot': row.get('shortDescription')}, art={'thumb': thumb}, path=plugin.url_for(play, id=row['id']), playable=True, is_folder=False, ) if row.get('resourceType') == 'epg/stations': item.path = plugin.url_for(play, id=row['id'], _is_live=True) elif start_time < now and end_time > now: item.label += _(_.LIVE, _bold=True) if row.get('customAttributes', {}).get('isLinearChannelInLiveEvent') != 'true': item.context.append((_.PLAY_FROM_LIVE, "PlayMedia({})".format( plugin.url_for(play, id=row['id'], play_type=PLAY_FROM_LIVE, _is_live=True)))) item.context.append((_.PLAY_FROM_START, "PlayMedia({})".format( plugin.url_for(play, id=row['id'], play_type=PLAY_FROM_START, _is_live=True)))) item.path = plugin.url_for(play, id=row['id'], play_type=settings.getEnum( 'live_play_type', PLAY_FROM_TYPES, PLAY_FROM_ASK), _is_live=True) elif start_time > now.shift(seconds=10): item.label += start_time.to('local').format(_.DATE_FORMAT) items.append(item) return items
def editorial(id, title, **kwargs): folder = plugin.Folder(title) now = arrow.utcnow() live_play_type = settings.getEnum('live_play_type', PLAY_FROM_TYPES, default=PLAY_FROM_ASK) for row in api.editorial(id): is_live = row.get('isLive', False) is_linear = row.get('type') == 'linear-channel' item = plugin.Item( label=row['title'], info={ 'plot': row.get('description'), 'duration': row.get('duration', 0), }, art={'thumb': row.get('imageUrl') or DEFAULT_IMG}, path=plugin.url_for(play, asset=row['id'], _is_live=is_live), playable=True, is_folder=False, ) start_time = arrow.get( row['broadcastStartTime']) if 'broadcastStartTime' in row else None if start_time and start_time > now: item.label += start_time.to('local').format(_.DATE_FORMAT) elif is_linear: item.path = plugin.url_for(play, asset=row['id'], _is_live=is_live) elif is_live: item.label = _(_.LIVE, label=item.label) item.context.append((_.PLAY_FROM_LIVE, "PlayMedia({})".format( plugin.url_for(play, asset=row['id'], play_type=PLAY_FROM_LIVE, _is_live=is_live)))) item.context.append((_.PLAY_FROM_START, "PlayMedia({})".format( plugin.url_for(play, asset=row['id'], play_type=PLAY_FROM_START, _is_live=is_live)))) item.path = plugin.url_for(play, asset=row['id'], play_type=live_play_type, _is_live=is_live) folder.add_items(item) return folder
def home(**kwargs): if not settings.getBool('bookmarks', True): return _stations() folder = plugin.Folder(cacheToDisc=False) folder.add_item(label=_(_.STATIONS, _bold=True), path=plugin.url_for(stations)) folder.add_item(label=_(_.BOOKMARKS, _bold=True), path=plugin.url_for(plugin.ROUTE_BOOKMARKS), bookmark=False) folder.add_item(label=_.SETTINGS, path=plugin.url_for(plugin.ROUTE_SETTINGS), _kiosk=False, bookmark=False) return folder
def _process_items(rows, default_thumb=None): items = [] for row in rows: if row['type'] == 'video': thumb = row['thumbnail']['medium'] if 'default-medium' not in row['thumbnail']['medium'] else default_thumb if row.get('live_video'): label = _(_.LIVE_NOW, label=row['title']) path = plugin.url_for(play, slug=row['url'], _is_live=True) else: label = row['title'] path = plugin.url_for(play, slug=row['url']) info = {'duration': row['duration']['seconds'], 'plot': row['description'], 'mediatype': 'movie'} if row.get('media_type') == 'episode': info.update({ 'mediatype': 'episode', 'season': row['metadata']['season_number'], 'episode': row['metadata']['episode_number'], 'tvshowtitle': row['metadata']['series_name'], }) items.append(plugin.Item( label = label, art = {'thumb': thumb}, info = info, path = path, playable = True, )) elif row['type'] == 'series': collection_id = re.search('collections/(.*?)/', row['_links']['items']['href']).group(1) thumb = row['thumbnail']['medium'] if 'default-medium' not in row['thumbnail']['medium'] else default_thumb items.append(plugin.Item( label = row['name'], art = {'thumb': thumb}, info = {'plot': row['description']}, path = plugin.url_for(collection, id=collection_id, label=row['name'], default_thumb=thumb), )) elif row['type'] == 'season': collection_id = re.search('collections/(.*?)/', row['_links']['items']['href']).group(1) thumb = row['thumbnail']['medium'] if 'default-medium' not in row['thumbnail']['medium'] else default_thumb items.append(plugin.Item( label = 'Season {}'.format(row['season_number']), art = {'thumb': thumb}, info = {'plot': row['description']}, path = plugin.url_for(collection, id=collection_id, label=row['name'], default_thumb=thumb), )) return items