예제 #1
0
 def test_get_entries_hero(self):
     responses.add(responses.GET,
                   'https://foo.bar/hero&range=1-50',
                   body=self.HERO_JSON,
                   status=200)
     params = {
         'item_type': 'hero',
         'obj_type': 'Series',
         'feed_url': 'https://foo.bar/hero',
         'title': 'Hero carousel'
     }
     observed = comm.get_entries(params)
     self.assertEqual(9, len(observed))
     self.assertEqual('362510403921', observed[8].id)
예제 #2
0
 def test_get_entries_collections(self):
     feed_url = 'https://foo.bar/items?q=1'
     params = {
         'item_type': 'title-under',
         'obj_type': 'Series',
         'feed_url': feed_url,
         'title': 'Best Of International Crime '
     }
     responses.add(responses.GET,
                   '{0}{1}'.format(feed_url, '&range=1-50'),
                   body=self.VIDEO_PROGRAM_COLLECTION_JSON,
                   status=200)
     observed = comm.get_entries(params)
     self.assertEqual(27, len(observed))
예제 #3
0
 def test_get_entries_collections_2(self):
     feed_url = 'https://foo.bar/items?q=1'
     params = {
         'addon_version': '1.1.10_matrix',
         'feed_url': feed_url,
         'item_type': 'Collection',
         'obj_type': 'Series',
         'title': 'Fright Night'
     }
     responses.add(responses.GET,
                   '{0}{1}'.format(feed_url, '&range=1-50'),
                   body=self.VIDEO_COLLECTIONS_FFN_JSON,
                   status=200)
     observed = comm.get_entries(params)
     self.assertEqual(16, len(observed))
예제 #4
0
 def test_get_entries_programs(self):
     feed_url = 'https://foo.bar/items?q=1'
     params = {
         'item_type': 'title-under',
         'obj_type': 'Series',
         'sub_category': 'True',
         'feed_url': feed_url,
         'title': 'Latest Content'
     }
     responses.add(responses.GET,
                   '{0}{1}'.format(feed_url, '&range=1-50'),
                   body=self.VIDEO_FEED_JSON,
                   status=200)
     observed = comm.get_entries(params)
     self.assertEqual(18, len(observed))
     self.assertEqual(8, observed[7].get_episode_no())
예제 #5
0
def make_entries_list(params):
    utils.log('Making entries list')
    try:
        programs = comm.get_entries(params)
        ok = True
        items = []
        for p in programs:
            listitem = comm.create_listitem(label=p.get_list_title())

            if isinstance(p, classes.Program):
                listitem.setInfo('video', p.get_kodi_list_item())
                listitem.setProperty('IsPlayable', 'true')
                listitem.addStreamInfo('audio', p.get_kodi_audio_stream_info())
                listitem.addStreamInfo('video', p.get_kodi_video_stream_info())
                # Build the URL for the program, including the list_info
            elif isinstance(p, classes.Series):
                if p.page_begin and p.page_size:
                    listitem.setProperty('SpecialSort', 'bottom')
                else:
                    listitem.setInfo('video', p.get_kodi_list_item())
            thumb = p.get_thumb()
            listitem.setArt({
                'thumb': thumb,
                'icon': thumb,
                'fanart': p.get_fanart()
            })
            url = '{0}?{1}'.format(sys.argv[0], p.make_kodi_url())
            # Add the program item to the list
            isFolder = isinstance(p, classes.Series)
            if p.entry_type in ['TVSeries', 'Movie', 'OneOff']:
                if params.get('favourite'):
                    listitem.addContextMenuItems([
                        ('Remove from SBS favourites',
                         ('RunPlugin(plugin://plugin.video.sbs/?action=remove'
                          'favourites&program_id={0}&entry_type={1})'.format(
                              p.id, p.entry_type)))
                    ])
                else:
                    listitem.addContextMenuItems([
                        ('Add to SBS favourites',
                         ('RunPlugin(plugin://plugin.video.sbs/?action=add'
                          'favourites&program_id={0}&entry_type={1})'.format(
                              p.id, p.entry_type)))
                    ])

            items.append((url, listitem, isFolder))

        xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_NONE)
        xbmcplugin.addSortMethod(int(sys.argv[1]),
                                 xbmcplugin.SORT_METHOD_EPISODE)
        xbmcplugin.addSortMethod(int(sys.argv[1]),
                                 xbmcplugin.SORT_METHOD_TITLE_IGNORE_THE)

        ok = xbmcplugin.addDirectoryItems(handle=int(sys.argv[1]),
                                          items=items,
                                          totalItems=len(items))

        xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
        xbmcplugin.setContent(handle=int(sys.argv[1]), content='episodes')
    except Exception:
        utils.handle_error('Unable to fetch entries list')