Example #1
0
def retrieveVideoInfo(video_id):
    video_info = Video()
    video_info.set_video_host(getVideoHost())
    video_info.set_id(video_id)
    try:
        video_info_link = 'http://www.videozer.com/player_control/settings.php?v=' + video_id + '&fv=v1.1.45'
        jsonObj = json.load(urllib.urlopen(video_info_link))
                
        key1 = jsonObj["cfg"]["environment"]["rkts"]
        key2 = jsonObj["cfg"]["login"]["pepper"]
        key3 = jsonObj["cfg"]["ads"]["lightbox2"]["time"]
        
        values = binascii.unhexlify(decrypt(jsonObj["cfg"]["login"]["spen"], jsonObj["cfg"]["login"]["salt"], 950569)).split(';')
        spn = http.parse_url_params(values[0])
        outk = http.parse_url_params(values[1])
        ikey = getikey(int(outk["ik"]))
        
        urlKey = ''
        for spnkey in spn:
            spnval = spn[spnkey]
            if spnval == '1':
                cypher = jsonObj["cfg"]["info"]["sece2"]
                urlKey = urlKey + spnkey + '=' + decrypt(cypher, key1, ikey, ln=256) + '&'
            if spnval == '2':
                cypher = jsonObj["cfg"]["ads"]["g_ads"]["url"]
                urlKey = urlKey + spnkey + '=' + decrypt(cypher, key1, ikey) + '&'
            if spnval == '3':
                cypher = jsonObj["cfg"]["ads"]["g_ads"]["type"]
                urlKey = urlKey + spnkey + '=' + decrypt(cypher, key1, ikey, 26, 25431, 56989, 93, 32589, 784152) + '&'
            if spnval == '4':
                cypher = jsonObj["cfg"]["ads"]["g_ads"]["time"]
                urlKey = urlKey + spnkey + '=' + decrypt(cypher, key1, ikey, 82, 84669, 48779, 32, 65598, 115498) + '&'
            if spnval == '5':
                cypher = jsonObj["cfg"]["login"]["euno"]
                urlKey = urlKey + spnkey + '=' + decrypt(cypher, key2, ikey, 10, 12254, 95369, 39, 21544, 545555) + '&'
            if spnval == '6':
                cypher = jsonObj["cfg"]["login"]["sugar"]
                urlKey = urlKey + spnkey + '=' + decrypt(cypher, key3, ikey, 22, 66595, 17447, 52, 66852, 400595) + '&'
        
        urlKey = urlKey + "start=0"
        
        video_link = ""
        for videoStrm in jsonObj["cfg"]["quality"]:
            if videoStrm["d"]:
                video_link = str(base64.b64decode(videoStrm["u"]))
        if video_link == "":
            video_info.set_video_stopped(False)
            raise Exception("VIDEO_STOPPED")
        video_link = video_link + '&' + urlKey
        
        video_info.set_name(jsonObj["cfg"]["info"]["video"]["title"])
        video_info.set_thumb_image(jsonObj["cfg"]["environment"]["thumbnail"])
        video_info.set_stopped(False)
        video_info.add_stream_link(STREAM_QUAL_SD, video_link)
    except:
        video_info.set_video_stopped(True)
    return video_info
Example #2
0
def retrieveVideoInfo(video_id):
    video_info = Video()
    video_info.set_video_host(getVideoHost())
    video_info.set_id(video_id)
    try:
        video_info_link = 'http://www.videobb.com/player_control/settings.php?v=' + video_id + '&fv=v1.2.72'
        jsonObj = json.load(urllib.urlopen(video_info_link))
                
        key1 = jsonObj["settings"]["config"]["rkts"]
        key2 = jsonObj["settings"]["login_status"]["pepper"]
        key3 = jsonObj["settings"]["banner"]["lightbox2"]["time"]
        
        values = binascii.unhexlify(decrypt(jsonObj["settings"]["login_status"]["spen"], jsonObj["settings"]["login_status"]["salt"], 950569)).split(';')
        spn = http.parse_url_params(values[0])
        outk = http.parse_url_params(values[1])
        ikey = getikey(int(outk["ik"]))
        
        urlKey = ''
        for spnkey in spn:
            spnval = spn[spnkey]
            if spnval == '1':
                cypher = jsonObj["settings"]["video_details"]["sece2"]
                urlKey = urlKey + spnkey + '=' + decrypt(cypher, key1, ikey, ln=256) + '&'
            if spnval == '2':
                cypher = jsonObj["settings"]["banner"]["g_ads"]["url"]
                urlKey = urlKey + spnkey + '=' + decrypt(cypher, key1, ikey) + '&'
            if spnval == '3':
                cypher = jsonObj["settings"]["banner"]["g_ads"]["type"]
                urlKey = urlKey + spnkey + '=' + decrypt(cypher, key1, ikey, 26, 25431, 56989, 93, 32589, 784152) + '&'
            if spnval == '4':
                cypher = jsonObj["settings"]["banner"]["g_ads"]["time"]
                urlKey = urlKey + spnkey + '=' + decrypt(cypher, key1, ikey, 82, 84669, 48779, 32, 65598, 115498) + '&'
            if spnval == '5':
                cypher = jsonObj["settings"]["login_status"]["euno"]
                urlKey = urlKey + spnkey + '=' + decrypt(cypher, key2, ikey, 10, 12254, 95369, 39, 21544, 545555) + '&'
            if spnval == '6':
                cypher = jsonObj["settings"]["login_status"]["sugar"]
                urlKey = urlKey + spnkey + '=' + decrypt(cypher, key3, ikey, 22, 66595, 17447, 52, 66852, 400595) + '&'
        
        urlKey = urlKey + "start=0"
        
        video_link = ""
        for videoStrm in jsonObj["settings"]["res"]:
            if videoStrm["d"]:
                video_link = str(base64.b64decode(videoStrm["u"]))
        if video_link == "":
            video_info.set_video_stopped(False)
            raise Exception("VIDEO_STOPPED")
        video_link = video_link + '&' + urlKey
        
        video_info.set_name(jsonObj["settings"]["video_details"]["video"]["title"])
        video_info.set_thumb_image(jsonObj["settings"]["config"]["thumbnail"])
        video_info.set_stopped(False)
        video_info.add_stream_link(STREAM_QUAL_SD, video_link)
    except:
        video_info.set_stopped(True)
    return video_info
Example #3
0
def retrieveVideoInfo(video_id):
    video_info = Video()
    video_info.set_video_host(getVideoHost())
    video_info.set_id(video_id)
    try:
        http.HttpClient().enable_cookies()
        html = http.HttpClient().get_html_content(url='http://www.vplay.ro/watch/' + str(video_id))
        html = http.HttpClient().get_html_content(url='http://www.vplay.ro/play/dinosaur.do', params={'key':str(video_id)})
        params = http.parse_url_params(html)
        video_link = http.get_redirected_url(url=params['nqURL'])
        http.HttpClient().disable_cookies()
        video_info.set_stopped(False)
        video_info.add_stream_link(STREAM_QUAL_SD, video_link)
        video_info.set_thumb_image(params['th'])
    except:
        video_info.set_stopped(True)
    return video_info
Example #4
0
def retrieveVideoInfo(video_id):
    video_info = Video()
    video_info.set_video_host(getVideoHost())
    video_info.set_id(video_id)
    try:
        http.HttpClient().enable_cookies()
        html = http.HttpClient().get_html_content(
            url='http://www.vplay.ro/watch/' + str(video_id))
        html = http.HttpClient().get_html_content(
            url='http://www.vplay.ro/play/dinosaur.do',
            params={'key': str(video_id)})
        params = http.parse_url_params(html)
        video_link = http.get_redirected_url(url=params['nqURL'])
        http.HttpClient().disable_cookies()
        video_info.set_stopped(False)
        video_info.add_stream_link(STREAM_QUAL_SD, video_link)
        video_info.set_thumb_image(params['th'])
    except:
        video_info.set_stopped(True)
    return video_info
Example #5
0
def retrieveVideoInfo(video_id):

    video_info = Video()
    video_info.set_video_host(getVideoHost())
    video_info.set_id(video_id)
    try:

        http.HttpClient().enable_cookies()
        video_info.set_thumb_image('http://i.ytimg.com/vi/' + video_id +
                                   '/default.jpg')
        html = http.HttpClient().get_html_content(
            url='http://www.youtube.com/get_video_info?video_id=' + video_id +
            '&asv=3&el=detailpage&hl=en_US')
        stream_map = None

        html = html.decode('utf8')
        html = html.replace('\n', '')
        html = html.replace('\r', '')
        html = unicode(html + '&').encode('utf-8')
        if re.search('status=fail', html):
            # XBMCInterfaceUtils.displayDialogMessage('Video info retrieval failed', 'Reason: ' + ((re.compile('reason\=(.+?)\.').findall(html))[0]).replace('+', ' ') + '.')
            logging.getLogger().info('YouTube video is removed for Id = ' +
                                     video_id + ' reason = ' + html)
            video_info.set_stopped(True)
            return video_info

        title = urllib.unquote_plus(
            re.compile('title=(.+?)&').findall(html)[0]).replace('/\+/g', ' ')
        video_info.set_name(title)
        stream_info = None
        if not re.search('url_encoded_fmt_stream_map=&', html):
            stream_info = re.compile(
                'url_encoded_fmt_stream_map=(.+?)&').findall(html)
        stream_map = None
        if (stream_info is None or len(stream_info) == 0) and re.search(
                'fmt_stream_map": "', html):
            stream_map = re.compile('fmt_stream_map": "(.+?)"').findall(
                html)[0].replace("\\/", "/")
        elif stream_info is not None:
            stream_map = stream_info[0]

        if stream_map is None:
            params = http.parse_url_params(html)
            logging.getLogger().debug('ENTERING live video scenario...')
            for key in params:
                logging.getLogger().debug(key + " : " +
                                          urllib.unquote_plus(params[key]))
            hlsvp = urllib.unquote_plus(params['hlsvp'])
            playlistItems = http.HttpClient().get_html_content(
                url=hlsvp).splitlines()
            qualityIdentified = None
            for item in playlistItems:
                logging.getLogger().debug(item)
                if item.startswith('#EXT-X-STREAM-INF'):
                    if item.endswith('1280x720'):
                        qualityIdentified = STREAM_QUAL_HD_720
                    elif item.endswith('1080'):
                        qualityIdentified = STREAM_QUAL_HD_1080
                    elif item.endswith('854x480'):
                        qualityIdentified = STREAM_QUAL_SD
                    elif item.endswith('640x360'):
                        qualityIdentified = STREAM_QUAL_LOW
                elif item.startswith('http') and qualityIdentified is not None:
                    videoUrl = http.HttpClient().add_http_cookies_to_url(
                        item,
                        extraExtraHeaders={
                            'Referer':
                            'https://www.youtube.com/watch?v=' + video_id
                        })
                    video_info.add_stream_link(qualityIdentified, videoUrl)
                    qualityIdentified = None
            video_info.set_stopped(False)
            return video_info

        stream_map = urllib.unquote_plus(stream_map)
        logging.getLogger().debug(stream_map)
        formatArray = stream_map.split(',')
        streams = {}
        for formatContent in formatArray:
            if formatContent == '':
                continue
            formatUrl = ''
            try:
                formatUrl = urllib.unquote(
                    re.compile("url=([^&]+)").findall(formatContent)
                    [0]) + "&title=" + urllib.quote_plus(title)
            except Exception, e:
                logging.getLogger().error(e)
            if re.search("rtmpe", stream_map):
                try:
                    conn = urllib.unquote(
                        re.compile("conn=([^&]+)").findall(formatContent)[0])
                    host = re.compile("rtmpe:\/\/([^\/]+)").findall(conn)[0]
                    stream = re.compile("stream=([^&]+)").findall(
                        formatContent)[0]
                    path = 'videoplayback'

                    formatUrl = "-r %22rtmpe:\/\/" + host + "\/" + path + "%22 -V -a %22" + path + "%22 -f %22WIN 11,3,300,268%22 -W %22http:\/\/s.ytimg.com\/yt\/swfbin\/watch_as3-vfl7aCF1A.swf%22 -p %22http:\/\/www.youtube.com\/watch?v=" + video_id + "%22 -y %22" + urllib.unquote(
                        stream) + "%22"
                except Exception, e:
                    logging.getLogger().error(e)
            if formatUrl == '':
                continue
            logging.getLogger().debug('************************')
            logging.getLogger().debug(formatContent)
            if (formatUrl[0:4] == "http" or formatUrl[0:2] == "-r"):
                formatQual = re.compile("itag=([^&]+)").findall(
                    formatContent)[0]
                if not re.search("signature=", formatUrl):
                    sig = re.compile("sig=([^&]+)").findall(formatContent)
                    if sig is not None and len(sig) == 1:
                        formatUrl += "&signature=" + sig[0]
                    else:
                        sig = re.compile("s=([^&]+)").findall(formatContent)
                        if sig is not None and len(sig) == 1:
                            formatUrl += "&signature=" + parseSignature(sig[0])

            qual = formatQual
            url = http.HttpClient().add_http_cookies_to_url(
                formatUrl,
                addHeaders=False,
                addCookies=False,
                extraExtraHeaders={
                    'Referer': 'https://www.youtube.com/watch?v=' + video_id
                })
            streams[int(qual)] = url
Example #6
0
'''
Created on Nov 24, 2013

@author: ajju
'''
from xoze.lib.jsonrpclib.jsonrpc import Server
import logging
import sys

try:
    if len(sys.argv) >= 3:
        from xoze.utils import http
        sysParams = str(sys.argv[2])
        logging.getLogger().debug('Found params %s' % sysParams)
        params = http.parse_url_params(sysParams)
        videoLink = params['videoLink']
        logging.getLogger().debug(videoLink)
        client = Server('http://localhost:%d/TVonDESIZONE' % 11421)
        response = client.resolveStream(videoLink=videoLink)
        logging.getLogger().debug(response)
        if response['status'] == 'success':
            logging.getLogger().debug(response['streamLink'])
            import xbmcgui, xbmcplugin  # @UnresolvedImport
            xbmcplugin.setResolvedUrl(
                int(sys.argv[1]), True,
                xbmcgui.ListItem(path=response['streamLink']))
        elif response['status'] == 'exception':
            logging.getLogger().error(response['message'])

    else:
        from xoze.context import AddonContext
Example #7
0
def retrieveVideoInfo(video_id):
    
    video_info = Video()
    video_info.set_video_host(getVideoHost())
    video_info.set_id(video_id)
    try:
        
        http.HttpClient().enable_cookies()
        video_info.set_thumb_image('http://i.ytimg.com/vi/' + video_id + '/default.jpg')
        html = http.HttpClient().get_html_content(url='http://www.youtube.com/get_video_info?video_id=' + video_id + '&asv=3&el=detailpage&hl=en_US')
        stream_map = None
        
        html = html.decode('utf8')
        html = html.replace('\n', '')
        html = html.replace('\r', '')
        html = unicode(html + '&').encode('utf-8')
        if re.search('status=fail', html):
            # XBMCInterfaceUtils.displayDialogMessage('Video info retrieval failed', 'Reason: ' + ((re.compile('reason\=(.+?)\.').findall(html))[0]).replace('+', ' ') + '.')
            logging.getLogger().info('YouTube video is removed for Id = ' + video_id + ' reason = ' + html)
            video_info.set_stopped(True)
            return video_info
        
        title = urllib.unquote_plus(re.compile('title=(.+?)&').findall(html)[0]).replace('/\+/g', ' ')
        video_info.set_name(title)
        stream_info = None
        if not re.search('url_encoded_fmt_stream_map=&', html):
            stream_info = re.compile('url_encoded_fmt_stream_map=(.+?)&').findall(html)
        stream_map = None
        if (stream_info is None or len(stream_info) == 0) and re.search('fmt_stream_map": "', html):
            stream_map = re.compile('fmt_stream_map": "(.+?)"').findall(html)[0].replace("\\/", "/")
        elif stream_info is not None:
            stream_map = stream_info[0]
            
        if stream_map is None:
            params = http.parse_url_params(html)
            logging.getLogger().debug('ENTERING live video scenario...')
            for key in params:
                logging.getLogger().debug(key + " : " + urllib.unquote_plus(params[key]))
            hlsvp = urllib.unquote_plus(params['hlsvp'])
            playlistItems = http.HttpClient().get_html_content(url=hlsvp).splitlines()
            qualityIdentified = None
            for item in playlistItems:
                logging.getLogger().debug(item)
                if item.startswith('#EXT-X-STREAM-INF'):
                    if item.endswith('1280x720'):
                        qualityIdentified = STREAM_QUAL_HD_720
                    elif item.endswith('1080'):
                        qualityIdentified = STREAM_QUAL_HD_1080
                    elif item.endswith('854x480'):
                        qualityIdentified = STREAM_QUAL_SD
                    elif item.endswith('640x360'):
                        qualityIdentified = STREAM_QUAL_LOW
                elif item.startswith('http') and qualityIdentified is not None:
                    videoUrl = http.HttpClient().add_http_cookies_to_url(item, extraExtraHeaders={'Referer':'https://www.youtube.com/watch?v=' + video_id})
                    video_info.add_stream_link(qualityIdentified, videoUrl)
                    qualityIdentified = None
            video_info.set_stopped(False)
            return video_info
        
        stream_map = urllib.unquote_plus(stream_map)
        logging.getLogger().debug(stream_map)
        formatArray = stream_map.split(',')
        streams = {}
        for formatContent in formatArray:
            if formatContent == '':
                continue
            formatUrl = ''
            try:
                formatUrl = urllib.unquote(re.compile("url=([^&]+)").findall(formatContent)[0]) + "&title=" + urllib.quote_plus(title)   
            except Exception, e:
                logging.getLogger().error(e)     
            if re.search("rtmpe", stream_map):
                try:
                    conn = urllib.unquote(re.compile("conn=([^&]+)").findall(formatContent)[0]);
                    host = re.compile("rtmpe:\/\/([^\/]+)").findall(conn)[0];
                    stream = re.compile("stream=([^&]+)").findall(formatContent)[0];
                    path = 'videoplayback';
                    
                    formatUrl = "-r %22rtmpe:\/\/" + host + "\/" + path + "%22 -V -a %22" + path + "%22 -f %22WIN 11,3,300,268%22 -W %22http:\/\/s.ytimg.com\/yt\/swfbin\/watch_as3-vfl7aCF1A.swf%22 -p %22http:\/\/www.youtube.com\/watch?v=" + video_id + "%22 -y %22" + urllib.unquote(stream) + "%22"
                except Exception, e:
                    logging.getLogger().error(e)
            if formatUrl == '':
                continue
            logging.getLogger().debug('************************')
            logging.getLogger().debug(formatContent)
            if(formatUrl[0: 4] == "http" or formatUrl[0: 2] == "-r"):
                formatQual = re.compile("itag=([^&]+)").findall(formatContent)[0]
                if not re.search("signature=", formatUrl):
                    sig = re.compile("sig=([^&]+)").findall(formatContent)
                    if sig is not None and len(sig) == 1:
                        formatUrl += "&signature=" + sig[0]
                    else:
                        sig = re.compile("s=([^&]+)").findall(formatContent)
                        if sig is not None and len(sig) == 1:
                            formatUrl += "&signature=" + parseSignature(sig[0])
        
            qual = formatQual
            url = http.HttpClient().add_http_cookies_to_url(formatUrl, addHeaders=False,addCookies=False, extraExtraHeaders={'Referer':'https://www.youtube.com/watch?v=' + video_id})
            streams[int(qual)] = url
Example #8
0
File: main.py Project: msports/mw
'''
Created on Nov 24, 2013

@author: ajju
'''
from xoze.lib.jsonrpclib.jsonrpc import Server
import logging
import sys

try:
    if len(sys.argv) >= 3:
        from xoze.utils import http
        sysParams = str(sys.argv[2])
        logging.getLogger().debug('Found params %s' % sysParams)
        params = http.parse_url_params(sysParams)
        videoLink = params['videoLink']
        logging.getLogger().debug(videoLink)
        client = Server('http://localhost:%d/TVonDESIZONE' % 11421)
        response = client.resolveStream(videoLink=videoLink)
        logging.getLogger().debug(response)
        if response['status'] == 'success':
            logging.getLogger().debug(response['streamLink'])
            import xbmcgui, xbmcplugin  # @UnresolvedImport
            xbmcplugin.setResolvedUrl(int(sys.argv[ 1 ]), True, xbmcgui.ListItem(path=response['streamLink']))
        elif response['status'] == 'exception':
            logging.getLogger().error(response['message'])
        
    else:
        from xoze.context import AddonContext
        addon_context = AddonContext(addon_id='plugin.video.tvondesizonexl', conf={'contextFiles':['actions.xml', 'dr_actions.xml', 'dtb_actions.xml'], 'webServiceEnabled':True, 'webServicePath':'/TVonDESIZONE', 'webServicePort':11421})
        addon_context.get_current_addon().get_action_controller().do_action('start')