Esempio n. 1
0
 def team_channel_to_listitem(self, team_channel):
     images = team_channel.get(Keys.IMAGE)
     image = Images.ICON
     if images:
         image = images.get(Keys.SIZE600) if images.get(
             Keys.SIZE600) else Images.ICON
     channel_name = team_channel[Keys.NAME]
     title_values = self.extract_channel_title_values(team_channel)
     title = self.title_builder.format_title(title_values)
     context_menu = list()
     context_menu.extend(menu_items.refresh())
     context_menu.extend(
         menu_items.run_plugin(
             i18n('play_choose_quality'), {
                 'mode': MODES.PLAY,
                 'name': channel_name,
                 'ask': True,
                 'use_player': True
             }))
     return {
         'label': title,
         'path': kodi.get_plugin_url({
             'mode': MODES.PLAY,
             'name': channel_name
         }),
         'context_menu': context_menu,
         'is_playable': True,
         'art': the_art({
             'poster': image,
             'thumb': image,
             'icon': image
         })
     }
Esempio n. 2
0
    def convert_to_kodi_playlist(input_playlist, title='', image=''):
        # Create playlist in Kodi, return dict {'initial_item': {listitem dict}, 'playlist': playlist}
        playlist = kodi.PlayList(kodi.PLAYLIST_VIDEO)
        playlist.clear()
        initial_item = None
        for (url, details) in input_playlist:
            if url:
                if details != ():
                    (title, image) = details
                playback_item = kodi.ListItem(label=title, path=url)
                playback_item.setArt(
                    the_art({
                        'poster': image,
                        'thumb': image,
                        'icon': image
                    }))
                playback_item.setProperty('IsPlayable', 'true')
                playlist.add(url, playback_item)
                if not initial_item and url:
                    initial_item = {
                        'label': title,
                        'thumbnail': image,
                        'path': url,
                        'is_playable': True
                    }

        if playlist and initial_item:

            return {'initial_item': initial_item, 'playlist': playlist}
        else:
            return {'initial_item': None, 'playlist': None}
Esempio n. 3
0
 def collection_to_listitem(self, collection):
     title = collection[Keys.TITLE].encode('utf-8')
     _id = collection[Keys._ID]
     image = collection[Keys.THUMBNAILS].get(Keys.MEDIUM, Images.THUMB)
     owner = collection[Keys.OWNER]
     context_menu = list()
     context_menu.extend(menu_items.refresh())
     name = owner.get(Keys.DISPLAY_NAME) if owner.get(
         Keys.DISPLAY_NAME) else owner.get(Keys.NAME)
     if self.has_token:
         context_menu.extend(menu_items.edit_follow(owner[Keys._ID], name))
         # context_menu.extend(menu_items.edit_block(owner[Keys._ID], name))
     context_menu.extend(menu_items.add_blacklist(owner[Keys._ID], name))
     return {
         'label':
         title,
         'path':
         kodi.get_plugin_url({
             'mode': MODES.COLLECTIONVIDEOLIST,
             'collection_id': _id
         }),
         'art':
         the_art({
             'poster': image,
             'thumb': image,
             'icon': image
         }),
         'context_menu':
         context_menu,
         'info':
         self.get_plot_for_collection(collection)
     }
Esempio n. 4
0
 def team_to_listitem(team):
     name = team[Keys.NAME]
     background = team.get(Keys.BACKGROUND) if team.get(
         Keys.BACKGROUND) else Images.FANART
     image = team.get(Keys.LOGO) if team.get(Keys.LOGO) else Images.ICON
     context_menu = list()
     context_menu.extend(menu_items.refresh())
     context_menu.extend(menu_items.clear_previews())
     return {
         'label':
         name,
         'path':
         kodi.get_plugin_url({
             'mode': MODES.TEAMSTREAMS,
             'team': name
         }),
         'art':
         the_art({
             'fanart': background,
             'poster': image,
             'thumb': image,
             'icon': image
         }),
         'context_menu':
         context_menu
     }
Esempio n. 5
0
 def game_to_listitem(game):
     channel_count = i18n('unknown')
     if Keys.CHANNELS in game:
         channel_count = str(game[Keys.CHANNELS])
     viewer_count = i18n('unknown')
     if Keys.VIEWERS in game:
         viewer_count = str(game[Keys.VIEWERS])
     if Keys.GAME in game:
         game = game[Keys.GAME]
     name = game[Keys.NAME].encode('utf-8')
     if not name:
         name = i18n('unknown_game')
     image = Images.BOXART
     if game.get(Keys.BOX):
         image = game[Keys.BOX].get(Keys.LARGE) if game[Keys.BOX].get(Keys.LARGE) else image
     context_menu = list()
     context_menu.extend(menu_items.refresh())
     context_menu.extend(menu_items.edit_follow_game(name))
     context_menu.extend(menu_items.add_blacklist(game[Keys._ID], name, list_type='game'))
     plot = '{name}\r\n{channels}:{channel_count} {viewers}:{viewer_count}' \
         .format(name=name, channels=i18n('channels'), channel_count=channel_count, viewers=i18n('viewers'), viewer_count=viewer_count)
     return {'label': name,
             'path': kodi.get_plugin_url({'mode': MODES.GAMELISTS, 'game': name}),
             'art': the_art({'poster': image, 'thumb': image, 'icon': image}),
             'context_menu': context_menu,
             'info': {u'plot': plot, u'plotoutline': plot, u'tagline': plot}}
Esempio n. 6
0
 def community_to_listitem(self, community):
     name = community[Keys.NAME].encode('utf-8')
     display_name = community.get(Keys.DISPLAY_NAME)
     display_name = display_name.encode('utf-8') if display_name else name
     _id = community[Keys._ID]
     image = community.get(Keys.AVATAR_IMAGE, Images.THUMB)
     context_menu = list()
     context_menu.extend(menu_items.refresh())
     context_menu.extend(menu_items.clear_previews())
     context_menu.extend(
         menu_items.add_blacklist(_id, display_name, list_type='community'))
     return {
         'label':
         display_name,
         'path':
         kodi.get_plugin_url({
             'mode': MODES.COMMUNITYSTREAMS,
             'community_id': _id
         }),
         'art':
         the_art({
             'poster': image,
             'thumb': image,
             'icon': image
         }),
         'context_menu':
         context_menu,
         'info':
         self.get_plot_for_community(community)
     }
Esempio n. 7
0
 def video_list_to_listitem(self, video):
     duration = video.get(Keys.LENGTH)
     date = video.get(Keys.CREATED_AT)[:10] if video.get(Keys.CREATED_AT) else ''
     year = video.get(Keys.CREATED_AT)[:4] if video.get(Keys.CREATED_AT) else ''
     image = video.get(Keys.PREVIEW) if video.get(Keys.PREVIEW) else Images.VIDEOTHUMB
     if Keys.MEDIUM in image:
         image = image.get(Keys.MEDIUM)
     channel = video[Keys.CHANNEL]
     context_menu = list()
     context_menu.extend(menu_items.refresh())
     name = channel.get(Keys.DISPLAY_NAME) if channel.get(Keys.DISPLAY_NAME) else channel.get(Keys.NAME)
     if self.has_token:
         context_menu.extend(menu_items.edit_follow(channel[Keys._ID], name))
         # context_menu.extend(menu_items.edit_block(channel[Keys._ID], name))
     context_menu.extend(menu_items.channel_videos(channel[Keys._ID], channel[Keys.NAME], name))
     if video[Keys.GAME]:
         context_menu.extend(menu_items.go_to_game(video[Keys.GAME]))
     context_menu.extend(menu_items.add_blacklist(channel[Keys._ID], name))
     context_menu.extend(menu_items.add_blacklist(b64encode(video[Keys.GAME].encode('utf-8', 'ignore')), video[Keys.GAME], list_type='game'))
     context_menu.extend(menu_items.set_default_quality('video', channel[Keys._ID], channel[Keys.NAME], video[Keys._ID]))
     context_menu.extend(menu_items.run_plugin(i18n('play_choose_quality'),
                                               {'mode': MODES.PLAY, 'video_id': video[Keys._ID], 'ask': True, 'use_player': True}))
     info = self.get_plot_for_video(video)
     info.update({'duration': str(duration), 'year': year, 'date': date, 'premiered': date, 'mediatype': 'video'})
     return {'label': self.get_title_for_video(video),
             'path': kodi.get_plugin_url({'mode': MODES.PLAY, 'video_id': video[Keys._ID]}),
             'context_menu': context_menu,
             'is_playable': True,
             'info': info,
             'content_type': 'video',
             'art': the_art({'poster': image, 'thumb': image, 'icon': image})}
Esempio n. 8
0
    def clip_to_listitem(self, clip):
        duration = clip.get(Keys.DURATION)
        plot = clip.get(Keys.DESCRIPTION)
        date = clip.get(Keys.CREATED_AT)[:10] if clip.get(Keys.CREATED_AT) else ''
        year = clip.get(Keys.CREATED_AT)[:4] if clip.get(Keys.CREATED_AT) else ''

        image = clip.get(Keys.THUMBNAILS) if clip.get(Keys.THUMBNAILS) else Images.VIDEOTHUMB
        if Keys.MEDIUM in image:
            image = image.get(Keys.MEDIUM)
        broadcaster = clip[Keys.BROADCASTER]
        context_menu = list()
        context_menu.extend(menu_items.refresh())
        name = broadcaster.get(Keys.DISPLAY_NAME) if broadcaster.get(Keys.DISPLAY_NAME) else broadcaster.get(Keys.NAME)
        if self.has_token:
            context_menu.extend(menu_items.edit_follow(broadcaster[Keys.ID], name))
            # context_menu.extend(menu_items.edit_block(broadcaster[Keys.ID], name))
        context_menu.extend(menu_items.channel_videos(broadcaster[Keys.ID], broadcaster[Keys.NAME], name))
        if clip[Keys.GAME]:
            context_menu.extend(menu_items.go_to_game(clip[Keys.GAME]))
        context_menu.extend(menu_items.add_blacklist(broadcaster[Keys.ID], name))
        context_menu.extend(menu_items.add_blacklist(b64encode(clip[Keys.GAME].encode('utf-8', 'ignore')), clip[Keys.GAME], list_type='game'))
        context_menu.extend(menu_items.set_default_quality('clip', broadcaster[Keys.ID], broadcaster[Keys.NAME], clip_id=clip[Keys.SLUG]))
        context_menu.extend(menu_items.run_plugin(i18n('play_choose_quality'),
                                                  {'mode': MODES.PLAY, 'slug': clip[Keys.SLUG], 'ask': True, 'use_player': True}))
        info = self.get_plot_for_clip(clip)
        info.update({'duration': str(duration), 'year': year, 'date': date, 'premiered': date, 'mediatype': 'video'})

        return {'label': self.get_title_for_clip(clip),
                'path': kodi.get_plugin_url({'mode': MODES.PLAY, 'slug': clip[Keys.SLUG]}),
                'context_menu': context_menu,
                'is_playable': True,
                'info': info,
                'content_type': 'video',
                'art': the_art({'poster': image, 'thumb': image, 'icon': image})}
Esempio n. 9
0
 def game_to_listitem(game):
     name = game[Keys.NAME].encode('utf-8')
     if not name:
         name = i18n('unknown_game')
     image = Images.BOXART
     if game.get(Keys.BOX):
         image = game[Keys.BOX].get(Keys.LARGE) if game[Keys.BOX].get(
             Keys.LARGE) else image
     context_menu = list()
     context_menu.extend(menu_items.refresh())
     context_menu.extend(menu_items.edit_follow_game(name))
     context_menu.extend(
         menu_items.add_blacklist(game[Keys._ID], name, list_type='game'))
     return {
         'label': name,
         'path': kodi.get_plugin_url({
             'mode': MODES.GAMELISTS,
             'game': name
         }),
         'art': the_art({
             'poster': image,
             'thumb': image,
             'icon': image
         }),
         'context_menu': context_menu,
         'info': {
             u'plot': name,
             u'plotoutline': name,
             u'tagline': name
         }
     }
Esempio n. 10
0
 def stream_to_playitem(self, stream):
     # path is returned '' and must be set after
     channel = stream[Keys.CHANNEL]
     preview = stream.get(Keys.PREVIEW)
     if preview:
         preview = preview.get(Keys.MEDIUM)
     logo = channel.get(Keys.LOGO) if channel.get(Keys.LOGO) else Images.VIDEOTHUMB
     image = preview if preview else logo
     title = self.get_title_for_stream(stream)
     info = self.get_plot_for_stream(stream, include_title=False)
     info.update({'mediatype': 'video'})
     return {'label': title,
             'path': '',
             'art': the_art({'poster': image, 'thumb': image, 'icon': image}),
             'info': info,
             'content_type': 'video',
             'is_playable': True}
Esempio n. 11
0
 def clip_to_playitem(self, clip):
     # path is returned '' and must be set after
     broadcaster = clip[Keys.BROADCASTER]
     image = clip.get(Keys.THUMBNAILS)
     if Keys.MEDIUM in image:
         image = image.get(Keys.MEDIUM)
     logo = broadcaster.get(Keys.LOGO) if broadcaster.get(Keys.LOGO) else Images.VIDEOTHUMB
     image = image if image else logo
     title = self.get_title_for_clip(clip)
     info = self.get_plot_for_clip(clip, include_title=False)
     info.update({'mediatype': 'video'})
     return {'label': title,
             'path': '',
             'art': the_art({'poster': image, 'thumb': image, 'icon': image}),
             'info': info,
             'content_type': 'video',
             'is_playable': True}
Esempio n. 12
0
 def channel_to_listitem(self, channel):
     image = channel.get(Keys.LOGO) if channel.get(Keys.LOGO) else Images.ICON
     video_banner = channel.get(Keys.VIDEO_BANNER)
     if not video_banner:
         video_banner = channel.get(Keys.PROFILE_BANNER) if channel.get(Keys.PROFILE_BANNER) else Images.FANART
     context_menu = list()
     context_menu.extend(menu_items.refresh())
     context_menu.extend(menu_items.clear_previews())
     name = channel.get(Keys.DISPLAY_NAME) if channel.get(Keys.DISPLAY_NAME) else channel.get(Keys.NAME)
     if self.has_token:
         context_menu.extend(menu_items.edit_follow(channel[Keys._ID], name))
         # context_menu.extend(menu_items.edit_block(channel[Keys._ID], name))
     context_menu.extend(menu_items.add_blacklist(channel[Keys._ID], name))
     return {'label': name,
             'path': kodi.get_plugin_url({'mode': MODES.CHANNELVIDEOS, 'channel_id': channel[Keys._ID],
                                          'channel_name': channel[Keys.NAME], 'display_name': name}),
             'art': the_art({'fanart': video_banner, 'poster': image, 'thumb': image}),
             'context_menu': context_menu,
             'info': self.get_plot_for_channel(channel)}
Esempio n. 13
0
 def stream_to_listitem(self, stream):
     channel = stream[Keys.CHANNEL]
     video_banner = channel.get(Keys.PROFILE_BANNER)
     if not video_banner:
         video_banner = channel.get(Keys.VIDEO_BANNER) if channel.get(Keys.VIDEO_BANNER) else Images.FANART
     preview = stream.get(Keys.PREVIEW)
     if Keys.MEDIUM in preview:
         preview = preview.get(Keys.MEDIUM)
     logo = channel.get(Keys.LOGO) if channel.get(Keys.LOGO) else Images.VIDEOTHUMB
     image = preview if preview else logo
     title = self.get_title_for_stream(stream)
     if stream.get(Keys.STREAM_TYPE) == 'watch_party':
         color = get_vodcast_color()
         title = u'[COLOR={color}]{title}[/COLOR]'.format(title=title, color=color)
     info = self.get_plot_for_stream(stream)
     info.update({'mediatype': 'video'})
     context_menu = list()
     context_menu.extend(menu_items.refresh())
     name = channel.get(Keys.DISPLAY_NAME) if channel.get(Keys.DISPLAY_NAME) else channel.get(Keys.NAME)
     if self.has_token:
         context_menu.extend(menu_items.edit_follow(channel[Keys._ID], name))
         # context_menu.extend(menu_items.edit_block(channel[Keys._ID], name))
     context_menu.extend(menu_items.channel_videos(channel[Keys._ID], channel[Keys.NAME], name))
     if channel[Keys.GAME]:
         context_menu.extend(menu_items.go_to_game(channel[Keys.GAME]))
     context_menu.extend(menu_items.add_blacklist(channel[Keys._ID], name))
     context_menu.extend(menu_items.add_blacklist(b64encode(channel[Keys.GAME].encode('utf-8', 'ignore')), channel[Keys.GAME], list_type='game'))
     context_menu.extend(menu_items.set_default_quality('stream', channel[Keys._ID], channel[Keys.NAME]))
     context_menu.extend(menu_items.run_plugin(i18n('play_choose_quality'),
                                               {'mode': MODES.PLAY, 'channel_id': channel[Keys._ID], 'ask': True, 'use_player': True}))
     return {'label': title,
             'path': kodi.get_plugin_url({'mode': MODES.PLAY, 'channel_id': channel[Keys._ID]}),
             'context_menu': context_menu,
             'is_playable': True,
             'info': info,
             'content_type': 'video',
             'art': the_art({'fanart': video_banner, 'poster': image, 'thumb': image, 'icon': image})}