Пример #1
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})}
Пример #2
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})}
Пример #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)
     }
Пример #4
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)
     }
Пример #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}}
Пример #6
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
         }
     }
Пример #7
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})}
Пример #8
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)}