def list_newscategories_en(channel_key): xbmcplugin.setPluginCategory(PLUGIN_HANDLE, 'News Categories') xbmcplugin.setContent(PLUGIN_HANDLE, 'videos') parser = NewsCategoryParser categories = parser.parse_categories() for category in categories: list_item = xbmcgui.ListItem(label=category.name, iconImage='DefaultFolder.png') list_item.setInfo('video', { 'title': category.name, 'genre': category.name, 'mediatype': 'video' }) poster_file = "poster_cgtn_{}.png".format( Channel.get_by_key(channel_key)['prefix']) poster = os.path.join(Config.mediaDir, poster_file) list_item.setArt({'poster': poster, 'fanart': Config.fanart}) # plugin://plugin.video.cgtn/?action=listing&newschannel=en& # newscategory=https://www.cgtn.com/nature&hassubs=True url = get_url(action='listing', newschannel=channel_key, newscategory=category.url, hassubs=category.has_subcatagories) xbmcplugin.addDirectoryItem(handle=PLUGIN_HANDLE, url=url, listitem=list_item, isFolder=True) xbmcplugin.addSortMethod(PLUGIN_HANDLE, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE) xbmcplugin.endOfDirectory(PLUGIN_HANDLE)
def list_newssections_other(channel_key): xbmcplugin.setPluginCategory(PLUGIN_HANDLE, 'News Sections') xbmcplugin.setContent(PLUGIN_HANDLE, 'videos') sections = [] if channel_key == "sp": sections = SectionSP.get_all() elif channel_key == "fr": sections = SectionFR.get_all() elif channel_key == "ar": sections = SectionAR.get_all() elif channel_key == "ru": sections = SectionRU.get_all() for section in sections: list_item = xbmcgui.ListItem(label=section['name'], iconImage='DefaultFolder.png') list_item.setInfo( 'video', { 'title': section['name'], 'genre': section['name_en'], 'mediatype': 'video' }) poster_file = "poster_cgtn_{}.png".format( Channel.get_by_key(channel_key)['prefix']) poster = os.path.join(Config.mediaDir, poster_file) list_item.setArt({'poster': poster, 'fanart': Config.fanart}) # plugin://plugin.video.cgtn/?action=listing&newschannel=en|sp|fr|ar|ru url = get_url(action='listing', newschannel=channel_key, section=section['id']) xbmcplugin.addDirectoryItem(handle=PLUGIN_HANDLE, url=url, listitem=list_item, isFolder=True) xbmcplugin.addSortMethod(PLUGIN_HANDLE, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE) xbmcplugin.endOfDirectory(PLUGIN_HANDLE)
def list_channel_videos(channel_key): xbmcplugin.setPluginCategory(PLUGIN_HANDLE, 'Channel Videos') xbmcplugin.setContent(PLUGIN_HANDLE, 'videos') channel = Channel.get_by_key(channel_key) parser = ChannelParser() videos = parser.parse_history_from_now(channel, hours=12) for video in videos: duration = (int(video.end_date) - int(video.start_date)) / 1000 premiered = time.strftime('%Y-%m-%d', time.localtime(int(video.start_date) / 1000)) list_item = xbmcgui.ListItem(label=video.title) list_item.setInfo( 'video', { 'title': video.title, 'genre': 'Channel Program', 'duration': duration, 'premiered': premiered, 'plotoutline': video.title, 'plot': video.title, 'mediatype': 'movie' }) poster_file = "poster_cgtn_{}.png".format(channel['prefix']) poster = os.path.join(Config.mediaDir, poster_file) list_item.setArt({'poster': poster, 'fanart': Config.fanart}) list_item.setProperty('IsPlayable', 'true') # plugin://plugin.video.cgtn/?action=play&video=httpx://example.com/dummy.m3u8 url = get_url(action='play', video=video.video_url) xbmcplugin.addDirectoryItem(handle=PLUGIN_HANDLE, url=url, listitem=list_item, isFolder=False) xbmcplugin.addSortMethod(PLUGIN_HANDLE, xbmcplugin.SORT_METHOD_NONE) xbmcplugin.endOfDirectory(PLUGIN_HANDLE)