Example #1
0
    def on_channel_format(self, context, re_match):
        channel_id = re_match.group('channel_id')
        format_id = re_match.group('format_id')
        channel_config = Client.CHANNELS[channel_id]
        client = self.get_client(context)

        # try to process tabs
        seo_url = context.get_param('seoUrl', '')
        if not seo_url:
            raise KodionException('seoUrl missing')

        format_tabs = client.get_format_tabs(channel_config, seo_url)

        # only on season tab -> show the content directly
        if len(format_tabs) == 1 and format_tabs[0]['type'] == 'tab':
            format_tab = format_tabs[0]
            return self._on_channel_format_list(context, channel_config,
                                                format_tab['id'])

        # show the tabs/sections
        tabs = []
        for format_tab in format_tabs:
            if format_tab['type'] == 'tab':
                tab_item = DirectoryItem(
                    format_tab['title'],
                    # /[CHANNEL_ID]/format/[FORMAT_ID]/list/[FORMAT_LIST_ID]/
                    context.create_uri([
                        channel_id, 'format', format_id, 'list',
                        str(format_tab['id'])
                    ]))
                tab_item.set_image(format_tab['images']['thumb'])
                tab_item.set_fanart(format_tab['images']['fanart'])
                tabs.append(tab_item)
                pass
            elif format_tab['type'] == 'date-span':
                tab_title = format_tab['title']
                image = format_tab['images']['thumb']
                fanart = format_tab['images']['fanart']
                tab_item = DirectoryItem(
                    tab_title,
                    # /[CHANNEL_ID]/format/[FORMAT_ID]/year/[YEAR]/
                    context.create_uri(
                        [channel_id, 'format', format_id, 'year', tab_title], {
                            'start': format_tab['start'],
                            'end': format_tab['end'],
                            'image': image,
                            'fanart': fanart
                        }))
                tab_item.set_image(image)
                tab_item.set_fanart(fanart)
                tabs.append(tab_item)
                pass
            else:
                raise KodionException('Unknown type "%s" for tab' %
                                      format_tab['type'])
            pass

        return tabs
Example #2
0
    def on_favorites(self, context, re_match):
        method = re_match.group('method')
        if not method in ['list', 'delete', 'add']:
            raise KodionException('Unknown method "%s" for favorites')

        client = self.get_client(context)
        format_id = context.get_param('format_id', '')

        if method == 'list':
            context.add_sort_method(kodion.sort_method.LABEL)
            json_formats = client.get_favorites()
            return self._do_formats(context, json_formats)
        elif method == 'delete':
            client.remove_favorite_format(format_id=format_id)
            context.get_ui().refresh_container()
            pass
        elif method == 'add':
            client.add_favorite_format(format_id=format_id)
            pass

        return True
Example #3
0
    def _on_watch_later(self, context, re_match):
        method = re_match.group('method')
        if not method in ['list', 'delete', 'add']:
            raise KodionException('Unknown method "%s" for watch later')

        client = self.get_client(context)
        video_id = context.get_param('video_id', '')

        if method == 'list':
            context.set_content_type(kodion.content_type.EPISODES)
            json_videos = client.get_watch_later().get('items', [])
            return self._videos_to_items(context, json_videos, prepend_format_title=True)
        elif method == 'delete':
            client.remove_watch_later_video(video_id=video_id)
            context.get_ui().refresh_container()
            pass
        elif method == 'add':
            client.add_watch_later_video(video_id=video_id)
            pass

        return True
Example #4
0
 def __init__(self):
     KodionException.__init__(self, 'DRM Protected stream not supported')
     pass
 def __init__(self):
     KodionException.__init__(self, 'DRM Protected stream not supported')
     pass