def main():
    params_str = sys.argv[2]
    params = utils.get_url(params_str)
    addon = xbmcaddon.Addon()
    if (len(params) == 0):
        categories.make_category_list()

    elif 'action' in params:
        action = params.get('action')

        if action in ['program_list', 'livestreams']:
            play.play(params_str)
        elif action in ['series_list']:
            if params.get('type') == 'Series':
                if params.get('dummy') == 'True':
                    return
                else:
                    programs.make_programs_list(params)
            else:
                play.play(params_str)
        elif action == 'collect_list':
            series.make_series_list(params, atoz=False)
        elif action == 'category_list':
            category = params.get('category')
            if category == 'settings':
                addon.openSettings()
            elif category == 'livestreams':
                live.make_livestreams_list()
            elif category == 'search':
                search.make_search_history_list()
            else:
                if addon.getSetting('SHOW_COLLECTIONS') == '1':
                    collect.make_collect_list(params)
                else:
                    series.make_series_list(params)
        elif action == 'searchhistory':
            if params.get('name') == 'New Search':
                search.get_search_input()
            else:
                search.make_search_list(params)
        elif action == 'removesearch':
            search.remove_from_search_history(params.get('name'))
        elif action == 'sendreport':
            utils.user_report()
        elif action == 'open_ia_settings':
            try:
                import drmhelper
                if drmhelper.check_inputstream(drm=False):
                    ia = drmhelper.get_addon()
                    ia.openSettings()
                else:
                    utils.dialog_message(
                        "Can't open inputstream.adaptive settings")
            except Exception:
                utils.dialog_message(
                    "Can't open inputstream.adaptive settings")
 def test_play(self, mock_listitem, mock_token, mock_version):
     mock_version.return_value = 18
     mock_token.return_value = 'foo'
     mock_plugin = fakes.FakePlugin()
     mock_listitem.side_effect = fakes.FakeListItem
     url = re.compile('^https://www.sbs.com.au/api/v3/video_stream')
     responses.add(responses.GET, url, body=self.VIDEO_STREAM_JSON)
     with mock.patch.dict('sys.modules', xbmcplugin=mock_plugin):
         import resources.lib.play as play
         play.play(sys.argv[2][1:])
         expected = 'New Girl - S02 - Re-Launch'
         observed = mock_plugin.resolved[2].getLabel()
         self.assertEqual(expected, observed)
Beispiel #3
0
def main():
    addon = xbmcaddon.Addon()
    if addon.getSetting('firstrun') == 'true':
        utils.dialog_message(
            'Welcome to the new On Demand add-on. An SBS On Demand account '
            'is now required to use this service. Please sign up at '
            'sbs.com.au or in the mobile app, then enter your details in '
            'the add-on settings.')
        comm.get_login_token()
        addon.setSetting('firstrun', 'false')
    params_str = sys.argv[2]
    params = utils.get_url(params_str)
    utils.log(str(params))
    if len(params) == 0:
        index.make_index_list()
    elif params.get('obj_type') == 'Program':
        play.play(params_str)
    elif 'feed_url' in params:
        index.make_entries_list(params)
    elif 'category' in params or params.get('item_type') in [
            'ProgramGenre', 'FilmGenre', 'Channel'
    ]:
        if params.get('category') == 'Search':
            index.make_search_history_list()
        else:
            index.make_category_list(params)
    elif 'action' in params:
        action = params.get('action')
        if action == 'favouritescategories':
            index.make_favourites_categories_list()
        elif action == 'addfavourites':
            comm.add_to_favourites(params)
        elif action == 'removefavourites':
            comm.remove_from_favourites(params)
            xbmc.executebuiltin('Container.Refresh')
        elif action == 'searchhistory':
            if params.get('name') == 'New Search':
                search.get_search_input()
            else:
                index.make_search_list(params)
        elif action == 'removesearch':
            search.remove_from_search_history(params.get('name'))
        elif action == 'sendreport':
            utils.user_report()
        elif action == 'settings':
            xbmcaddon.Addon().openSettings()
        elif action == 'logout':
            comm.clear_login_token()
        elif action == 'login':
            comm.get_login_token()
            xbmc.executebuiltin('Container.Refresh')
def main():
    params_str = sys.argv[2]
    params = utils.get_url(params_str)
    utils.log('Loading with params: {0}'.format(params))

    if len(params) == 0:
        index.make_list()
    elif 'category' in params:
        if params['category'] == 'Settings':
            xbmcaddon.Addon().openSettings()
        elif params['category'] == 'Team Video':
            teams.make_list()
        elif params['category'] == 'All Match Replays':
            index.make_seasons_list()
        else:
            videos.make_list(params)
    elif 'season' in params:
        rounds.make_rounds(params)
    elif 'team' in params:
        videos.make_list(params)
    elif 'round_id' in params:
        videos.make_list(params)
    elif 'title' in params:
        play.play(params_str)
    elif 'action' in params:
        if params['action'] == 'cleartoken':
            stream_auth.clear_token()
        elif params['action'] == 'sendreport':
            utils.user_report()
        elif params['action'] == 'iap_help':
            stream_auth.iap_help()
        elif params['action'] == 'open_ia_settings':
            try:
                import drmhelper
                if drmhelper.check_inputstream(drm=False):
                    ia = drmhelper.get_addon()
                    ia.openSettings()
                else:
                    utils.dialog_message(
                        "Can't open inputstream.adaptive settings")
            except Exception:
                utils.dialog_message(
                    "Can't open inputstream.adaptive settings")
Beispiel #5
0
 def test_play_video_bc(self, mock_listitem, mock_drm):
     mock_drm.return_value = True
     responses.add(responses.POST,
                   config.TOKEN_URL,
                   body=json.dumps({'token': 'abcdef'}),
                   status=200)
     edge_url = config.BC_EDGE_URL.format(account_id='foo', video_id='bar')
     responses.add(responses.GET,
                   edge_url,
                   body=self.BC_EDGE_JSON,
                   status=200)
     responses.add(responses.GET,
                   config.CONFIG_URL,
                   body=self.CONFIG_JSON,
                   status=200)
     mock_listitem.side_effect = fakes.FakeListItem
     mock_plugin = fakes.FakePlugin()
     with mock.patch.dict('sys.modules', xbmcplugin=mock_plugin):
         import resources.lib.play as play
         play.play(sys.argv[2][1:])
         self.assertEqual(fakes.M3U8_URL_BC.get('stream_url'),
                          mock_plugin.resolved[2].getPath())
Beispiel #6
0
    def test_play_video_live(self, mock_listitem, mock_ticket, mock_drm,
                             mock_sub_type):
        escaped_auth_url = re.escape(config.AUTH_URL).replace('\\{',
                                                              '{').replace(
                                                                  '\\}', '}')
        auth_url = re.compile(escaped_auth_url.format('.*', '.*', '.*'))
        responses.add(responses.GET, auth_url, body=self.AUTH_JSON, status=200)

        escaped_embed_url = re.escape(config.EMBED_TOKEN_URL).replace(
            '\\{', '{').replace('\\}', '}')
        embed_url = re.compile(escaped_embed_url.format('.*', '.*'))
        responses.add(responses.GET,
                      embed_url,
                      body=self.EMBED_TOKEN_JSON,
                      status=200)
        responses.add(responses.POST,
                      config.TOKEN_URL,
                      body=json.dumps({'token': 'abcdef'}),
                      status=200)
        responses.add(responses.GET,
                      config.CONFIG_URL,
                      body=self.CONFIG_JSON,
                      status=200)
        edge_url = config.BC_EDGE_URL.format(account_id='foo', video_id='bar')
        responses.add(responses.GET,
                      edge_url,
                      body=self.BC_EDGE_JSON,
                      status=200)
        mock_ticket.return_value = 'foobar123456'
        mock_listitem.side_effect = fakes.FakeListItem
        mock_drm.return_value = False
        mock_sub_type.return_value = '0'
        mock_plugin = fakes.FakePlugin()
        with mock.patch.dict('sys.modules', xbmcplugin=mock_plugin):
            import resources.lib.play as play
            play.play(sys.argv[2][1:])
            self.assertEqual(fakes.M3U8_URL_BC.get('stream_url'),
                             mock_plugin.resolved[2].getPath())