Beispiel #1
0
    def get_episode_url(start_timestamp, duration, force_login=False):
        if not vars.cookies or force_login:
            common.login()
        if not vars.cookies:
            return None

        url = vars.config['publish_endpoint']
        headers = {
            'Cookie':
            vars.cookies,
            'Content-Type':
            'application/x-www-form-urlencoded',
            'User-Agent':
            'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36',
        }
        body = {
            'type': 'channel',
            'id': 1,
            'drmtoken': True,
            'deviceid': xbmc.getInfoLabel('Network.MacAddress'),
            'st': start_timestamp,
            'dur': duration,
            'pcid': vars.player_id,
            'format': 'xml',
        }

        body = urllib.urlencode(body)
        utils.log('the body of publishpoint request is: %s' % body,
                  xbmc.LOGDEBUG)

        try:
            request = urllib2.Request(url, body, headers)
            response = urllib2.urlopen(request)
            content = response.read()
        except urllib2.HTTPError as err:
            utils.logHttpException(err, url)
            utils.littleErrorPopup(xbmcaddon.Addon().getLocalizedString(50020))
            return None

        xml = parseString(str(content))
        url = xml.getElementsByTagName('path')[0].childNodes[0].nodeValue
        utils.log('response URL from publishpoint: %s' % url, xbmc.LOGDEBUG)
        drm = xml.getElementsByTagName('drmToken')[0].childNodes[0].nodeValue
        utils.log(drm, xbmc.LOGDEBUG)

        return {'url': url, 'drm': drm}
Beispiel #2
0
 def get_serie_episode():
     video_id = vars.params.get("url")
     if not common.authenticate():
         return None
     url = vars.config['publish_endpoint']
     headers = {
         'Cookie': vars.cookies,
         'Content-Type': 'application/x-www-form-urlencoded',
         'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36',
     }
     body = {
         'type': 'video',
         'id': video_id,
         'drmtoken': True,
         'token': vars.access_token,
         'deviceid': 'web-%s' % vars.player_id,
         'pcid': vars.player_id,
         'format': 'json',
     }
     body = urlencode(body).encode()
     utils.log('the body of publishpoint request is: %s' % body, xbmc.LOGDEBUG)
     try:
         request = urllib2.Request(url, body, headers)
         response = urllib2.urlopen(request, timeout=30)
         content = response.read()
     except urllib2.HTTPError as err:
         utils.logHttpException(err, url)
         utils.littleErrorPopup(xbmcaddon.Addon().getLocalizedString(50020))
         return None
     content_json = json.loads(content)
     url = content_json['path']
     drm = content_json['drmToken']
     utils.log('response URL from publishpoint: %s' % url, xbmc.LOGDEBUG)
     utils.log(drm, xbmc.LOGDEBUG)
     
     return {'url': url, 'drm': drm}
Beispiel #3
0
def getGameUrl(video_id, video_type, video_ishomefeed, start_time, duration):
    utils.log("cookies: %s %s" % (video_type, vars.cookies), xbmc.LOGDEBUG)

    # video_type could be archive, live, condensed or oldseason
    if video_type not in ["live", "archive", "condensed"]:
        video_type = "archive"
    gt = 1
    if not video_ishomefeed:
        gt = 4
    if video_type == "condensed":
        gt = 8

    url = vars.config['publish_endpoint']
    headers = {
        'Cookie': vars.cookies,
        'Content-Type': 'application/x-www-form-urlencoded',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36',
    }
    body = {
        'type': 'game',
        'extid': str(video_id),
        'drmtoken': True,
        'deviceid': xbmc.getInfoLabel('Network.MacAddress'),
        'gt': gt,
        'gs': vars.params.get('game_state', 3),
        'pcid': vars.player_id,
        'format': 'xml',
    }

    if video_type == "live":
        line1 = "Start from Beginning"
        line2 = "Go LIVE"
        ret = xbmcgui.Dialog().select("Game Options", [line1, line2])
        if ret == -1:
            return
        elif ret == 0:
            if start_time:
                body['st'] = str(start_time)
                if duration:
                    body['dur'] = str(duration)
                else:
                    utils.log("No end time, can't start from beginning", xbmc.LOGERROR)
            else:
                utils.log("No start time can't start from beginning", xbmc.LOGERROR)
    else:
        if start_time:
            body['st'] = str(start_time)
            utils.log("start_time: %s" % start_time, xbmc.LOGDEBUG)

            if duration:
                body['dur'] = str(duration)
                utils.log("Duration: %s"% str(duration), xbmc.LOGDEBUG)
            else:
                utils.log("No end time for game", xbmc.LOGDEBUG)
        else:
            utils.log("No start time, can't start from beginning", xbmc.LOGERROR)

    if vars.params.get("camera_number"):
        body['cam'] = vars.params.get("camera_number")

    body = urllib.urlencode(body)
    utils.log("the body of publishpoint request is: %s" % body, xbmc.LOGDEBUG)

    try:
        request = urllib2.Request(url, body, headers)
        response = urllib2.urlopen(request)
        content = response.read()
    except urllib2.HTTPError as err:
        utils.logHttpException(err, url)
        utils.littleErrorPopup(xbmcaddon.Addon().getLocalizedString(50020))
        return ''

    xml = parseString(str(content))
    url = xml.getElementsByTagName("path")[0].childNodes[0].nodeValue
    utils.log("response URL from publishpoint: %s" % url, xbmc.LOGDEBUG)
    drm = xml.getElementsByTagName("drmToken")[0].childNodes[0].nodeValue
    utils.log(drm, xbmc.LOGDEBUG)

    selected_video_url = ''
    if video_type == "live":
        if '.mpd' in url:
            selected_video_url = url
        else:
            # transform the url
            match = re.search('(https?)://([^:]+)/([^?]+?)\?(.+)$', url)
            protocol = match.group(1)
            domain = match.group(2)
            arguments = match.group(3)
            querystring = match.group(4)

            livecookies = "nlqptid=%s" % (querystring)
            livecookiesencoded = urllib.quote(livecookies)

            utils.log("live cookie: %s %s" % (querystring, livecookies), xbmc.LOGDEBUG)

            url = "%s://%s/%s?%s" % (protocol, domain, arguments, querystring)

            selected_video_url = "%s&Cookie=%s" % (url, livecookiesencoded)
    else:
        # Archive and condensed flow: We now work with HLS.
        # The cookies are already in the URL and the server will supply them to ffmpeg later.
        selected_video_url = url

    if selected_video_url:
        utils.log("the url of video %s is %s" % (video_id, selected_video_url), xbmc.LOGDEBUG)

    return {'url': selected_video_url, 'drm': drm}
def getGameUrl(video_id, video_type, video_ishomefeed, start_time, duration):
    utils.log("cookies: %s %s" % (video_type, vars.cookies), xbmc.LOGDEBUG)

    # video_type could be archive, live, condensed or oldseason
    if video_type not in ["live", "archive", "condensed"]:
        video_type = "archive"
    gt = 1
    if not video_ishomefeed:
        gt = 4
    if video_type == "condensed":
        gt = 8

    url = vars.config['publish_endpoint']
    headers = {
        'Cookie': vars.cookies,
        'Content-Type': 'application/x-www-form-urlencoded',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; Xbox; Xbox One) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10553',
    }
    body = {
        'extid': str(video_id),
        'format': "xml",
        'gt': gt,
        'gs': vars.params.get("game_state", "3"),
        'type': 'game',
        'plid': vars.player_id,
        'drmtoken': 'true',
        'deviceid': xbmc.getInfoLabel('Network.MacAddress')
    }

    if video_type == "live":
        line1 = "Start from Beginning"
        line2 = "Go LIVE"
        ret = xbmcgui.Dialog().select("Game Options", [line1, line2])
        if ret == -1:
            return
        elif ret == 0:
            if start_time:
                body['st'] = str(start_time)
                if duration:
                    body['dur'] = str(duration)
                else:
                    utils.log("No end time, can't start from beginning", xbmc.LOGERROR)
            else:
                utils.log("No start time can't start from beginning", xbmc.LOGERROR)
    else:
        if start_time:
            body['st'] = str(start_time)
            utils.log("start_time: %s" % start_time, xbmc.LOGDEBUG)

            if duration:
                body['dur'] = str(duration)
                utils.log("Duration: %s"% str(duration), xbmc.LOGDEBUG)
            else:
                utils.log("No end time for game", xbmc.LOGDEBUG)
        else:
            utils.log("No start time, can't start from beginning", xbmc.LOGERROR)

    if vars.params.get("camera_number"):
        body['cam'] = vars.params.get("camera_number")
    if video_type != "live":
        body['format'] = 'xml'
    body = urllib.urlencode(body)

    utils.log("the body of publishpoint request is: %s" % body, xbmc.LOGDEBUG)

    try:
        request = urllib2.Request(url, body, headers)
        response = urllib2.urlopen(request)
        content = response.read()
    except urllib2.HTTPError as e:
        utils.logHttpException(e, url)
        utils.littleErrorPopup( xbmcaddon.Addon().getLocalizedString(50020) )
        return ''

    xml = parseString(str(content))
    url = xml.getElementsByTagName("path")[0].childNodes[0].nodeValue
    utils.log("response URL from publishpoint: %s" % url, xbmc.LOGDEBUG)
    drm = xml.getElementsByTagName("drmToken")[0].childNodes[0].nodeValue
    utils.log(drm, xbmc.LOGDEBUG)

    selected_video_url = ''
    if video_type == "live":
        if '.mpd' in url:
            selected_video_url = url
        else:
            # transform the url
            match = re.search('(https?)://([^:]+)/([^?]+?)\?(.+)$', url)
            protocol = match.group(1)
            domain = match.group(2)
            arguments = match.group(3)
            querystring = match.group(4)

            livecookies = "nlqptid=%s" % (querystring)
            livecookiesencoded = urllib.quote(livecookies)

            utils.log("live cookie: %s %s" % (querystring, livecookies), xbmc.LOGDEBUG)

            url = "%s://%s/%s?%s" % (protocol, domain, arguments, querystring)
            url = common.getGameUrlWithBitrate(url, video_type)

            selected_video_url = "%s&Cookie=%s" % (url, livecookiesencoded)
    else:
        # Archive and condensed flow: We now work with HLS.
        # The cookies are already in the URL and the server will supply them to ffmpeg later.
        if '.mpd' in url:
            selected_video_url = url
        else:
            selected_video_url = common.getGameUrlWithBitrate(url, video_type)
        
        
    if selected_video_url:
        utils.log("the url of video %s is %s" % (video_id, selected_video_url), xbmc.LOGDEBUG)

    return {'url':selected_video_url, 'drm':drm}
Beispiel #5
0
def get_game(video_id, video_type, video_ishomefeed, start_time, duration):
    utils.log("cookies: %s %s" % (video_type, vars.cookies), xbmc.LOGDEBUG)

    # video_type could be archive, live, condensed or oldseason
    if video_type not in ["live", "archive", "condensed"]:
        video_type = "archive"
    gt = 1
    if not video_ishomefeed:
        gt = 4
    if video_type == "condensed":
        gt = 8

    url = vars.config['publish_endpoint']
    headers = {
        'Cookie':
        vars.cookies,
        'Content-Type':
        'application/x-www-form-urlencoded',
        'User-Agent':
        'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36',
    }
    body = {
        'type': 'game',
        'extid': str(video_id),
        'drmtoken': True,
        'token': vars.access_token,
        'deviceid': xbmc.getInfoLabel('Network.MacAddress'),  # TODO
        'gt': gt,
        'gs': vars.params.get('game_state', 3),
        'pcid': vars.player_id,
        'format': 'xml',
    }

    if video_type == "live":
        line1 = "Start from Beginning"
        line2 = "Go LIVE"
        ret = xbmcgui.Dialog().select("Game Options", [line1, line2])
        if ret == -1:
            return None
        elif ret == 0:
            if start_time:
                body['st'] = str(start_time)
                if duration:
                    body['dur'] = str(duration)
                else:
                    utils.log("No end time, can't start from beginning",
                              xbmc.LOGERROR)
            else:
                utils.log("No start time can't start from beginning",
                          xbmc.LOGERROR)
    else:
        if start_time:
            body['st'] = str(start_time)
            utils.log("start_time: %s" % start_time, xbmc.LOGDEBUG)

            if duration:
                body['dur'] = str(duration)
                utils.log("Duration: %s" % str(duration), xbmc.LOGDEBUG)
            else:
                utils.log("No end time for game", xbmc.LOGDEBUG)
        else:
            utils.log("No start time, can't start from beginning",
                      xbmc.LOGERROR)

    if vars.params.get("camera_number"):
        body['cam'] = vars.params.get("camera_number")

    body = urllib.urlencode(body)
    utils.log("the body of publishpoint request is: %s" % body, xbmc.LOGDEBUG)

    try:
        request = urllib2.Request(url, body, headers)
        response = urllib2.urlopen(request)
        content = response.read()
    except urllib2.HTTPError as err:
        utils.logHttpException(err, url)
        utils.littleErrorPopup(xbmcaddon.Addon().getLocalizedString(50020))
        return None

    xml = parseString(str(content))
    url = xml.getElementsByTagName("path")[0].childNodes[0].nodeValue
    utils.log("URL: %s" % url, xbmc.LOGDEBUG)
    drm = xml.getElementsByTagName("drmToken")[0].childNodes[0].nodeValue
    utils.log("DRM: %s" % drm, xbmc.LOGDEBUG)

    return {'url': url, 'drm': drm}