Ejemplo n.º 1
0
def getStream(url):
    adobe = ADOBE(SERVICE_VARS)
    if adobe.checkAuthN():
        if adobe.authorize():
            media_token = adobe.mediaToken()
            url = url + "&auth=" + urllib.quote(base64.b64decode(media_token))

            headers = {
                "Connection": "keep-alive",
                "Accept": "*/*",
                "Accept-Encoding": "deflate",
                "Accept-Language": "en-us",
                "Connection": "keep-alive",
                "User-Agent": UA_FX,
            }

            r = requests.get(url, headers=headers, verify=VERIFY)

            stream_url = r.url
            stream_url = stream_url + '|User-Agent=okhttp/3.4.1'
            listitem = xbmcgui.ListItem(path=stream_url)
            xbmcplugin.setResolvedUrl(addon_handle, True, listitem)
        else:
            sys.exit()
    else:
        #msg = 'Your device\'s is not currently authorized to view the selected content.\n Would you like to authorize this device now?'
        dialog = xbmcgui.Dialog()
        answer = dialog.yesno(LOCAL_STRING(30911), LOCAL_STRING(30910))
        if answer:
            adobe.registerDevice()
            getStream(url)
        else:
            sys.exit()
def sign_stream(stream_url, stream_name, stream_icon, pid, drm_type,
                drm_asset_id):
    SERVICE_VARS['requestor_id'] = 'nbcsports'
    resource_id = get_resource_id()
    SERVICE_VARS['resource_id'] = urllib.quote(resource_id)
    adobe = ADOBE(SERVICE_VARS)
    if adobe.check_authn():
        if adobe.authorize():
            media_token = adobe.media_token()
            stream_vars = {
                'drm_asset_id': drm_asset_id,
                'drm_type': drm_type,
                'manifest_url': stream_url,
                'media_token': media_token,
                'resource_id': resource_id,
                'pid': pid
            }
            stream = Stream(stream_vars)
            xbmcplugin.setResolvedUrl(ADDON_HANDLE, True,
                                      stream.create_listitem())
        else:
            sys.exit()
    else:
        dialog = xbmcgui.Dialog()
        answer = dialog.yesno(LOCAL_STRING(30010), LOCAL_STRING(30011))
        if answer:
            adobe.register_device()
            sign_stream(stream_url, stream_name, stream_icon, pid)
        else:
            sys.exit()
Ejemplo n.º 3
0
def sign_stream(stream_url, stream_name, stream_icon, requestor_id, channel):
    SERVICE_VARS['requestor_id'] = requestor_id
    resource_id = "<rss version='2.0'><channel><title>" + channel + "</title></channel></rss>"
    SERVICE_VARS['resource_id'] = urllib.quote(resource_id)
    adobe = ADOBE(SERVICE_VARS)
    if adobe.check_authn():
        if adobe.authorize():
            # resource_id = get_resource_id()
            media_token = adobe.media_token()
            stream_url = tv_sign(media_token, resource_id, stream_url)
            stream_url = set_stream_quality(stream_url)
            listitem = xbmcgui.ListItem(path=stream_url)
            xbmcplugin.setResolvedUrl(ADDON_HANDLE, True, listitem)
        else:
            sys.exit()
    else:
        msg = 'You must authenticate this device to view the selected content.\n Would you like to do that now?'
        dialog = xbmcgui.Dialog()
        answer = dialog.yesno("Authorize", msg)
        if answer:
            adobe.register_device()
            sign_stream(stream_url, stream_name, stream_icon, requestor_id,
                        channel)
        else:
            sys.exit()
Ejemplo n.º 4
0
def getStream(url):
    adobe = ADOBE(SERVICE_VARS)
    if adobe.checkAuthN():
        if adobe.authorize():
            media_token = adobe.mediaToken()
            url = url + "&auth=" + urllib.quote(base64.b64decode(media_token))
            req = urllib2.Request(url)
            req.add_header("Accept", "*/*")
            req.add_header("Accept-Encoding", "deflate")
            req.add_header("Accept-Language", "en-us")
            req.add_header("Connection", "keep-alive")
            req.add_header("User-Agent", UA_FX)
            response = urllib2.urlopen(req)
            response.close()

            #get the last url forwarded to
            stream_url = response.geturl()
            stream_url = stream_url + '|User-Agent=okhttp/3.4.1'
            listitem = xbmcgui.ListItem(path=stream_url)
            xbmcplugin.setResolvedUrl(addon_handle, True, listitem)
        else:
            sys.exit()
    else:
        #msg = 'Your device\'s is not currently authorized to view the selected content.\n Would you like to authorize this device now?'
        dialog = xbmcgui.Dialog()
        answer = dialog.yesno(LOCAL_STRING(30911), LOCAL_STRING(30910))
        if answer:
            adobe.registerDevice()
            getStream(url)
        else:
            sys.exit()
Ejemplo n.º 5
0
def getStream(url):
    adobe = ADOBE(SERVICE_VARS)            
    if adobe.checkAuthN():
        if adobe.authorize():
            media_token = adobe.mediaToken()       
            url = url + "&auth="+urllib.quote(base64.b64decode(media_token))

            headers = {
                "Connection": "keep-alive",
                "Accept": "*/*",
                "Accept-Encoding": "deflate",
                "Accept-Language": "en-us",
                "Connection": "keep-alive",
                "User-Agent": UA_FX,
            }

            r = requests.get(url, headers=headers, verify=VERIFY)

            stream_url = r.url
            stream_url = stream_url + '|User-Agent=okhttp/3.4.1'            
            listitem = xbmcgui.ListItem(path=stream_url)
            xbmcplugin.setResolvedUrl(addon_handle, True, listitem)
        else:
            sys.exit()
    else:
        #msg = 'Your device\'s is not currently authorized to view the selected content.\n Would you like to authorize this device now?'
        dialog = xbmcgui.Dialog() 
        answer = dialog.yesno(LOCAL_STRING(30911), LOCAL_STRING(30910))
        if answer:
            adobe.registerDevice()
            getStream(url)
        else:
            sys.exit()
Ejemplo n.º 6
0
def get_stream(url, INFO=None):
    adobe = ADOBE(SERVICE_VARS)
    if adobe.check_authn():
        if adobe.authorize():
            media_token = adobe.media_token()
            url = url + "&auth=" + urllib.quote(base64.b64decode(media_token))

            headers = {
                "Accept": "*/*",
                "Accept-Encoding": "deflate",
                "Accept-Language": "en-us",
                "Connection": "keep-alive",
                "User-Agent": UA_FX,
            }

            r = requests.get(url, headers=headers, verify=VERIFY)

            stream_url = r.url
            stream_url = stream_url + '|User-Agent=okhttp/3.4.1'

            if xbmc.getCondVisibility('System.HasAddon(inputstream.adaptive)'
                                      ) and INPUTSTREAM_ENABLED == 'true':
                listitem = xbmcgui.ListItem(path=stream_url.split("|")[0])
                listitem.setProperty('inputstreamaddon',
                                     'inputstream.adaptive')
                listitem.setProperty('inputstream.adaptive.manifest_type',
                                     'hls')
                listitem.setProperty('inputstream.adaptive.stream_headers',
                                     stream_url.split("|")[1])
                listitem.setProperty('inputstream.adaptive.license_key',
                                     "|" + stream_url.split("|")[1])
            else:
                listitem = xbmcgui.ListItem(path=stream_url)
                listitem.setMimeType("application/x-mpegURL")

            if INFO is not None:
                listitem.setInfo(type='Video', infoLabels=INFO)

            xbmcplugin.setResolvedUrl(addon_handle, True, listitem)
        else:
            sys.exit()
    else:
        dialog = xbmcgui.Dialog()
        answer = dialog.yesno(LOCAL_STRING(30911), LOCAL_STRING(30910))
        if answer:
            adobe.register_device()
            get_stream(url, INFO)
        else:
            sys.exit()
Ejemplo n.º 7
0
def deauthorize():
    adobe = ADOBE(SERVICE_VARS)
    adobe.deauthorizeDevice()
    dialog = xbmcgui.Dialog()
    dialog.notification(LOCAL_STRING(30900), LOCAL_STRING(30901), '', 5000,
                        False)
def logout():
    adobe = ADOBE(SERVICE_VARS)
    adobe.logout()
Ejemplo n.º 9
0
def deauthorize():
    adobe = ADOBE(SERVICE_VARS)
    adobe.deauthorizeDevice()
    dialog = xbmcgui.Dialog()      
    dialog.notification(LOCAL_STRING(30900), LOCAL_STRING(30901), '', 5000, False)