Пример #1
0
    def test_play_video(self, mock_listitem, mock_ticket):
        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_XML, status=200)

        escaped_stream_url = re.escape(
            config.STREAM_API_URL).replace('\\{', '{').replace('\\}', '}')
        escaped_stream_url = escaped_stream_url.replace('\\_', '_')
        stream_url = re.compile(escaped_stream_url.format(video_id='.*'))
        responses.add(responses.GET, stream_url,
                      body=self.STREAM_API_JSON, status=200)

        responses.add(responses.GET,
                      config.MEDIA_AUTH_URL.format(embed_code='123456'),
                      body=self.VIDEOTOKEN_JSON)

        mock_ticket.return_value = 'foobar123456'
        mock_listitem.side_effect = fakes.FakeListItem
        params = dict(parse_qsl(sys.argv[2][1:]))
        mock_plugin = fakes.FakePlugin()
        with mock.patch.dict('sys.modules', xbmcplugin=mock_plugin):
            import resources.lib.play as play
            play.play_video(params)
            self.assertEqual(fakes.M3U8_URL.decode(),
                             mock_plugin.resolved[2].getPath())
Пример #2
0
def router(paramstring):
    """
    Router function that calls other functions
    depending on the provided paramstring
    :param paramstring:
    """
    params = dict(parse_qsl(paramstring))
    utils.log('Running with params: {0}'.format(params))
    if params:
        if params['action'] == 'listcategories':
            if params['category'] == 'Live Matches':
                menu.list_matches(params, live=True)
            elif params['category'] == 'Settings':
                addon.openSettings()
            else:
                menu.list_videos(params)
        elif params['action'] in ['listvideos', 'listmatches']:
            play.play_video(params)
        elif params['action'] == 'clearticket':
            stream_auth.clear_ticket()
        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")
    else:
        menu.list_categories()
def router(paramstring):
    """
    Router function that calls other functions
    depending on the provided paramstring
    :param paramstring:
    """
    params = dict(parse_qsl(paramstring))
    if params:
        if params['action'] == 'listcategories':
            if params['category'] == 'settings':
                addon.openSettings()
            else:
                matches.make_matches_list(params)
        elif params['action'] == 'listmatches':
            play.play_video(params)
        elif params['action'] == 'clearticket':
            stream_auth.clear_ticket()
        elif params['action'] == 'sendreport':
            utils.user_report()
        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")
    else:
        categories.list_categories()
Пример #4
0
    def test_play_video_live(self, mock_listitem, mock_ticket):
        params = dict(parse_qsl(sys.argv[2][1:]))
        escaped_bc_url = re.escape(config.BC_URL).replace('\\{', '{').replace(
            '\\}', '}')
        bc_url = re.compile(escaped_bc_url.format('.*', '.*'))
        responses.add(responses.GET,
                      bc_url,
                      body=self.BC_EDGE_JSON,
                      status=200)
        responses.add(responses.GET,
                      config.MEDIA_AUTH_URL.format(video_id='6112170884001'),
                      body=self.VIDEO_TOKEN_JSON,
                      status=200)
        responses.add(responses.GET,
                      config.SIGN_URL.format(
                          quote_plus('https://foo.bar/video.m3u8')),
                      body=self.SIGN_JSON,
                      status=200)
        mock_ticket.return_value = json.dumps({
            'pai': fakes.FAKE_UUID[0],
            'bearer': 'abc123'
        })
        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_video(params)
            self.assertEqual('https://foo.bar/index.m3u8?signed',
                             mock_plugin.resolved[2].getPath())
Пример #5
0
def router(paramstring):
    """
    Router function that calls other functions
    depending on the provided paramstring
    :param paramstring:
    """
    params = dict(parse_qsl(paramstring))
    if params:
        if params['action'] == 'listcategories':
            menu.list_shows(params)
        elif params['action'] == 'listshows':
            menu.list_seasons(params)
        elif params['action'] == 'listseasons':
            menu.list_episodes(params)
        elif params['action'] == 'listepisodes':
            play.play_video(params)
    else:
        menu.list_categories()
def main():
    """
    Router function that calls other functions depending on the
    provided paramstring
    """
    params = dict(parse_qsl(sys.argv[2][1:]))
    utils.log('called with params: {0}'.format(str(params)))
    if (len(params) == 0):
        menu.list_categories()
    else:

        if params['action'] == 'listcategories':
            if params['category'] == 'Live TV':
                menu.make_live_list(params)
            else:
                menu.make_series_list(params)
        elif params['action'] == 'listseries':
            menu.make_episodes_list(params)
        elif params['action'] in ['listepisodes', 'listchannels']:
            play.play_video(params)
        elif params['action'] == 'settings':
            xbmcaddon.Addon().openSettings()
        elif params['action'] == 'sendreport':
            utils.user_report()