source: titan/mediathek/localhoster/openload.py @ 41385

Last change on this file since 41385 was 41359, checked in by obi, 4 years ago

openload add errormsg

File size: 28.8 KB
Line 
1# -*- coding: utf-8 -*-
2# Based on (root)/trunk/xbmc-addons/src/plugin.video.polishtv.live/hosts/ @ 419 - Wersja 636
3# encoding=utf8 
4import sys 
5
6reload(sys) 
7sys.setdefaultencoding('utf8')
8
9import os
10import hashlib
11import sys
12from lib.net import Net
13import re
14import lib.ol_gmu as ol_gmu
15import lib.common as common
16import json
17from lib import jsunpack
18
19###################################################
20import re
21import time
22import urllib
23import socket
24import string
25import base64
26import math
27import lib.jjdecode as JJDecoder
28
29#OL_SOURCE = 'https://offshoregit.com/tvaresolvers/ol_gmu.py'
30OL_PATH = ''
31
32API_BASE_URL = 'https://api.openload.co/1'
33INFO_URL = API_BASE_URL + '/streaming/info'
34GET_URL = API_BASE_URL + '/streaming/get?file={media_id}'
35#OL_PATH = os.path.join(common.plugins_path, 'ol_gmu.py')
36
37
38import urllib
39import urllib2
40try: import ssl
41except Exception: pass
42import re
43import string
44import time
45import htmlentitydefs
46import cookielib
47import unicodedata
48#import urllib2_ssl
49#try:    import json
50#except Exception: import simplejson as json
51#try:
52#    try: from cStringIO import StringIO
53#    except Exception: from StringIO import StringIO
54#    import gzip
55
56class OpenLoadResolver(object):
57    name = "openload"
58#    domains = ["openload.io", "openload.co"]
59#    pattern = '(?://|\.)(openload\.(?:io|co))/(?:embed|f)/([0-9a-zA-Z-_]+)'
60    domains = ["openload.io", "openload.co", "oload.tv", "oload.stream"]
61    pattern = '(?://|\.)(o(?:pen)??load\.(?:io|co|tv|stream))/(?:embed|f)/([0-9a-zA-Z-_]+)'
62
63    def __init__(self):
64        self.net = Net(cookie_file='/mnt/network/cookies', cloudflare=True)
65        self.headers = {'User-Agent': common.ANDROID_USER_AGENT}
66        url = str(sys.argv[1])
67        host = self.get_host_and_id(url)[0]
68        media_id = self.get_host_and_id(url)[1]
69
70        return self.get_media_url(host, media_id)
71
72    def get_host_and_id(self, url):
73        r = re.search(self.pattern, url, re.I)
74        if r:
75            return r.groups()
76        else:
77            return False
78
79    def i18n(string_id):
80        try:
81            return addon.getLocalizedString(strings.STRINGS[string_id]).encode('utf-8', 'ignore')
82        except Exception as e:
83#            log_utils.log('Failed String Lookup: %s (%s)' % (string_id, e))
84            return string_id
85
86    def get_ol_code(self):
87        try:
88            new_py = self.net.http_GET(OL_SOURCE).content
89#            common.log_utils.log('new_py: %s' % (new_pya))
90
91            if new_py:
92                with open(OL_PATH, 'w') as f:
93                    f.write(new_py)
94        except Exception as e:
95             print 'errormsg=Exception during openload code retrieve:'
96#            common.log_utils.log_warning('Exception during openload code retrieve: %s' % e)
97
98        def decode1(self, encoded):
99            tab = encoded.split('\\')
100            ret = ''
101            for item in tab:
102                try: ret += chr(int(item, 8))
103                except Exception:
104                    ret += item
105            return ret
106       
107        def base10toN(self, num,n):
108            num_rep={10:'a', 11:'b',12:'c',13:'d',14:'e',15:'f',16:'g',17:'h',18:'i',19:'j',20:'k',21:'l',22:'m',23:'n',24:'o',25:'p',26:'q',27:'r',28:'s',29:'t',30:'u',31:'v',32:'w',33:'x',34:'y',35:'z'}
109            new_num_string=''
110            current=num
111            while current!=0:
112                remainder=current%n
113                if 36>remainder>9:
114                    remainder_string=num_rep[remainder]
115                elif remainder>=36:
116                    remainder_string='('+str(remainder)+')'
117                else:
118                    remainder_string=str(remainder)
119                new_num_string=remainder_string+new_num_string
120                current=current/n
121            return new_num_string
122
123    def decodeOpenLoad(self, aastring):
124       # decodeOpenLoad made by mortael, please leave this line for proper credit :)
125    #aastring = re.search(r"<video(?:.|\s)*?<script\s[^>]*?>((?:.|\s)*?)</script", html, re.DOTALL | re.IGNORECASE).group(1)
126
127        aastring = aastring.replace("(゚Д゚)[゚ε゚]+(o゚ー゚o)+ ((c^_^o)-(c^_^o))+ (-~0)+ (゚Д゚) ['c']+ (-~-~1)+","")
128        aastring = aastring.replace("((゚ー゚) + (゚ー゚) + (゚Θ゚))", "9")
129        aastring = aastring.replace("((゚ー゚) + (゚ー゚))","8")
130        aastring = aastring.replace("((゚ー゚) + (o^_^o))","7")
131        aastring = aastring.replace("((c^_^o)-(c^_^o))","0")
132        aastring = aastring.replace("((゚ー゚) + (゚Θ゚))","5")
133        aastring = aastring.replace("(゚ー゚)","4")
134        aastring = aastring.replace("((o^_^o) - (゚Θ゚))","2")
135        aastring = aastring.replace("(o^_^o)","3")
136        aastring = aastring.replace("(゚Θ゚)","1")
137        aastring = aastring.replace("(+!+[])","1")
138        aastring = aastring.replace("(c^_^o)","0")
139        aastring = aastring.replace("(0+0)","0")
140        aastring = aastring.replace("(゚Д゚)[゚ε゚]","\\") 
141        aastring = aastring.replace("(3 +3 +0)","6")
142        aastring = aastring.replace("(3 - 1 +0)","2")
143        aastring = aastring.replace("(!+[]+!+[])","2")
144        aastring = aastring.replace("(-~-~2)","4")
145        aastring = aastring.replace("(-~-~1)","3")
146        aastring = aastring.replace("(-~0)","1")
147        aastring = aastring.replace("(-~1)","2")
148        aastring = aastring.replace("(-~3)","4")
149        aastring = aastring.replace("(0-0)","0")
150   
151        aastring = aastring.replace("(゚Д゚).゚ω゚ノ","10")
152        aastring = aastring.replace("(゚Д゚).゚Θ゚ノ","11")
153        aastring = aastring.replace("(゚Д゚)[\'c\']","12")
154        aastring = aastring.replace("(゚Д゚).゚ー゚ノ","13")
155        aastring = aastring.replace("(゚Д゚).゚Д゚ノ","14")
156        aastring = aastring.replace("(゚Д゚)[゚Θ゚]","15")
157#        print "aastring", aastring
158        decodestring = re.search(r"\\\+([^(]+)", aastring, re.DOTALL | re.IGNORECASE).group(1)
159#        decodestring = re.search(r"\\\+([^(]+)", aastring, re.DOTALL | re.IGNORECASE)
160        decodestring = "\\+"+ decodestring
161        decodestring = decodestring.replace("+","")
162        decodestring = decodestring.replace(" ","")
163
164        decodestring = self.decode1(decodestring)
165        decodestring = decodestring.replace("\\/","/")
166   
167        if 'toString' in decodestring:
168            base = re.compile(r"toString\(a\+(\d+)", re.DOTALL | re.IGNORECASE).findall(decodestring)[0]
169            base = int(base)
170            match = re.compile(r"(\(\d[^)]+\))", re.DOTALL | re.IGNORECASE).findall(decodestring)
171            for repl in match:
172                match1 = re.compile(r"(\d+),(\d+)", re.DOTALL | re.IGNORECASE).findall(repl)
173                base2 = base + int(match1[0][0])
174                repl2 = self.base10toN(int(match1[0][1]),base2)
175                decodestring = decodestring.replace(repl,repl2)
176            decodestring = decodestring.replace("+","")
177            decodestring = decodestring.replace("\"","")
178        print "decodestring", decodestring
179        return decodestring
180
181#    def OPENLOADIO_decryptPlayerParams(p, a, c, k, e, d):
182    def decryptPlayerParams(self, p, a, c, k, e, d):
183        def e1(c):
184            return c
185        def e2(t=None):
186            return '\\w+'
187        def k1(matchobj):
188            return d[int(matchobj.group(0))]
189        e = e1
190        if True:
191            while c != 0:
192                c -= 1
193                d[c] = k[c]
194                if c < len(k):
195                    d[c] = k[c]
196                else:
197                    d[c] = c
198            c = 1
199            k = [k1]
200            e = e2
201        while c != 0:
202            c -= 1
203            if k[c]:
204                reg = '\\b' + e(c) + '\\b'
205                p = re.sub(reg, k[c], p)
206        return p
207
208    def getAllItemsBeetwenMarkers(self, data, marker1, marker2, withMarkers=True, caseSensitive=True):
209        itemsTab = []
210        if caseSensitive:
211            sData = data
212        else:
213            sData = data.lower()
214            marker1 = marker1.lower()
215            marker2 = marker2.lower()
216        idx1 = 0
217        while True:
218            idx1 = sData.find(marker1, idx1)
219            if -1 == idx1: return itemsTab
220            idx2 = sData.find(marker2, idx1 + len(marker1))
221            if -1 == idx2: return itemsTab
222            tmpIdx2 = idx2 + len(marker2)
223            if withMarkers:
224                idx2 = tmpIdx2
225            else:
226                idx1 = idx1 + len(marker1)
227            itemsTab.append(data[idx1:idx2])
228            idx1 = tmpIdx2
229        return itemsTab
230
231    def getSearchGroups(self, data, pattern, grupsNum=1, ignoreCase=False):
232        tab = []
233        if ignoreCase:
234            match = re.search(pattern, data, re.IGNORECASE)
235        else:
236            match = re.search(pattern, data)
237       
238        for idx in range(grupsNum):
239            try:    value = match.group(idx + 1)
240            except Exception: value = ''
241            tab.append(value)
242        return tab
243       
244    def getPage(self, url, addParams = {}, post_data = None):
245        ''' wraps getURLRequestData '''
246        try:
247            addParams['url'] = url
248            if 'return_data' not in addParams:
249                addParams['return_data'] = True
250            response = self.getURLRequestData(addParams, post_data)
251            status = True
252        except urllib2.HTTPError, e:
253#            printExc()
254            response = e
255            status = False
256        except Exception:
257#            printExc()
258            response = None
259            status = False
260       
261        if addParams['return_data'] and status and not isinstance(response, basestring):
262            status = False
263           
264        return (status, response)
265
266    def GetTmpDir(self, file = ''):
267        path = "/tmp/"
268        path = path.replace('//', '/')
269        self.mkdirs(path)
270        return path + '/' + file
271
272    def GetDukPath(self):
273#        return "/tmp/localhoster/bin/duk.arm"
274        arch = self.command("cat /etc/.arch")
275#        print "arch", arch
276        return "/tmp/localhoster/bin/duk.%s" % (arch)
277 #       return "/tmp/localhoster/bin/duk.sh4"
278
279#        return config.plugins.iptvplayer.dukpath.value
280
281    def iptv_js_execute(self, jscode):
282        sts, tmpPath = self.CreateTmpFile('.iptv_js.js', jscode)
283        if sts:
284            cmd =  self.GetDukPath() + ' ' + tmpPath + ' 2> /dev/null'
285 #           printDBG("iptv_js_execute cmd[%s]" % cmd)
286 #           print "iptv_js_execute cmd[%s]" % cmd
287 #           test = self.command(cmd);
288 #           print "test", test
289
290            ret = self.command(cmd);
291#            print "test3", os.system(cmd);
292
293 #           ret = iptv_execute()( cmd )
294#            ret = {'sts':False, 'code':-12, 'data':''}
295            # leave last script for debug purpose
296 #           if getDebugMode() == '':
297 #               rm(tmpPath)
298        else:
299            ret = {'sts':False, 'code':-12, 'data':''}
300#        printDBG('iptv_js_execute cmd ret[%s]' % ret)
301#        print 'iptv_js_execute cmd ret[%s]' % ret
302
303        return ret
304
305    def mkdirs(self, newdir):
306        """ Create a directory and all parent folders.
307            Features:
308            - parent directories will be created
309            - if directory already exists, then do nothing
310            - if there is another filsystem object with the same name, raise an exception
311        """
312#        printDBG('mkdirs: "%s"' % newdir)
313 #       print 'mkdirs: "%s"' % newdir
314        try:
315            if os.path.isdir(newdir):
316                pass
317            elif os.path.isfile(newdir):
318#                raise OSError("cannot create directory, file already exists: '%s'" % newdir)
319                raise #print "cannot create directory, file already exists: '%s'" % newdir
320            else:
321                head, tail = os.path.split(newdir)
322                if head and not os.path.isdir(head) and not os.path.ismount(head) and not os.path.islink(head):
323                   mkdirs(head)
324                if tail:
325                    os.mkdir(newdir)
326            return True
327        except Exception:
328#            printExc('!!!!!!!!!! EXCEPTION mkdirs["%s"]' % newdir)
329            print '!!!!!!!!!! EXCEPTION mkdirs["%s"]' % newdir
330            return False
331
332    def CreateTmpFile(self, filename, data=''):
333        sts = False
334        filePath = self.GetTmpDir(filename)
335        try:
336            with open(filePath, 'w') as f:
337                f.write(data)
338                sts = True
339        except Exception:
340            printExc()
341        return sts, filePath
342
343    def getDataBeetwenMarkers(self, data, marker1, marker2, withMarkers=True, caseSensitive=True):
344        if caseSensitive:
345            idx1 = data.find(marker1)
346        else:
347            idx1 = data.lower().find(marker1.lower())
348        if -1 == idx1: return False, ''
349        if caseSensitive:
350            idx2 = data.find(marker2, idx1 + len(marker1))
351        else:
352            idx2 = data.lower().find(marker2.lower(), idx1 + len(marker1))
353        if -1 == idx2: return False, ''
354       
355        if withMarkers:
356            idx2 = idx2 + len(marker2)
357        else:
358            idx1 = idx1 + len(marker1)
359
360        return True, data[idx1:idx2]
361
362        # edit bb , touch commands.getouput with this def #
363    def command(self, comandline, strip=1):
364        comandline = comandline + " >/tmp/command.txt"
365        os.system(comandline)
366        text = ""
367        if os.path.exists("/tmp/command.txt") is True:
368            file = open("/tmp/command.txt", "r")
369            if strip == 1:
370                for line in file:
371                    text = text + line.strip() + '\n'
372            else:
373                for line in file:
374                    text = text + line
375                    if text[-1:] != '\n': text = text + "\n"
376            file.close
377        # if one or last line then remove linefeed
378        if text[-1:] == '\n': text = text[:-1]
379        comandline = text
380        os.system("rm /tmp/command.txt")
381        return comandline
382
383    def get_media_url(self, host, media_id):
384        web_url = self.get_url(host, media_id)
385#        web_url = "https://openload.co/embed/SVMiyZR_yM4/Game_of_Thrones_S07E07_Der_Drache_und_der_Wolf_German_AC3_Dubbed_AmazonHD.mkv"
386#        web_url = "https://openload.co/embed/8ATYb_yCakU/pso-atomic_ts.sd.mkv"
387        headers = {
388            'Referer': web_url
389        }
390        headers.update(self.headers)
391        data = self.net.http_GET(web_url, headers=headers).content
392        ret = self.net.save_cookies('/mnt/network/cookies')
393
394#        print "data", data
395        baseUrl = web_url
396 #       baseUrl = "https://openload.co/embed/SVMiyZR_yM4/Game_of_Thrones_S07E07_Der_Drache_und_der_Wolf_German_AC3_Dubbed_AmazonHD.mkv"
397        HTTP_HEADER= { 'User-Agent':"Mozilla/5.0", 'Referer':baseUrl}
398        HTTP_HEADER = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
399               'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
400               'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
401               'Accept-Encoding': 'none',
402               'Accept-Language': 'en-US,en;q=0.8',
403               'Referer':baseUrl} #'Connection': 'keep-alive'
404
405#        sts, data = self.getPage(baseUrl, {'header':HTTP_HEADER})
406 #       data = self.net.http_GET(web_url, headers=headers).content
407
408        orgData = data
409 #       print "data", data
410
411#        print "222222222222222222222222"
412        if re.search('Sorry!</h3>', data):
413            print 'errormsg=%s %s' % (str(re.compile('<h3>(.*)</h3>').findall(data)[0]), str(re.compile('<h6>(.*)</h6>').findall(data)[0]))
414
415        subTracksData = self.getAllItemsBeetwenMarkers(data, '<track ', '>', False, False)
416        subTracks = []
417        for track in subTracksData:
418            if 'kind="captions"' not in track: continue
419            subUrl = self.getSearchGroups(track, 'src="([^"]+?)"')[0]
420#            print "suburl", subUrl
421            if subUrl.startswith('/'):
422                subUrl = 'http://openload.co' + subUrl
423            if subUrl.startswith('http'):
424                subLang = self.getSearchGroups(track, 'srclang="([^"]+?)"')[0]
425                subLabel = self.getSearchGroups(track, 'label="([^"]+?)"')[0]
426                subTracks.append({'title':subLabel + '_' + subLang, 'url':subUrl, 'lang':subLang, 'format':'srt'})
427       
428#        print "33333333333333333333333"
429 
430        preDataTab = self.getAllItemsBeetwenMarkers(data, 'a="0%', '{}', withMarkers=True, caseSensitive=False)
431#        print "preDataTab", preDataTab
432 
433        for item in preDataTab:
434#            print "item", item
435            try:
436                dat = self.getSearchGroups(item, 'a\s*?=\s*?"([^"]+?)"', ignoreCase=True)[0]
437#                print "dat1", dat
438                z = self.getSearchGroups(item, '\}\(([0-9]+?)\)', ignoreCase=True)[0]
439#                print "z1", z
440                z = int(z)
441#                print "z2", z
442                def checkA(c):
443                    code = ord(c.group(1))
444                    if code <= ord('Z'):
445                        tmp = 90
446                    else:
447                        tmp = 122
448                    c = code + z
449                    if tmp < c:
450                        c -= 26
451                    return chr(c)
452                   
453                dat = urllib.unquote( re.sub('([a-zA-Z])', checkA, dat) )
454#                print "dat2", dat
455                dat = self.decryptPlayerParams(dat, 4, 4, ['j', '_', '__', '___'], 0, {})
456#                pageData = unpackJS(data[idx1:-3], VIDUPME_decryptPlayerParams)
457#               dat = jsunpack.unpack(dat)
458
459#                print "dat3", dat
460                data += dat
461            except Exception:
462                 print "preDataTab error"
463#                printExc()
464
465
466
467
468
469        videoUrl = ''
470        tmp = ''
471
472        encodedData = self.getAllItemsBeetwenMarkers(data, '゚ω゚', '</script>', withMarkers=False, caseSensitive=False)
473#        encodedData = re.sub('゚ω゚', '</script>', data)
474   #     encodedData = re.search(r'゚ω゚\.*?</script>', data, re.DOTALL)
475  #      encodedData = re.search('''゚ω゚\(\s*)</script>''', data).group(1)
476
477#        print "encodedData1", encodedData
478
479        for item in encodedData:
480#            print "item1", item
481            tmpEncodedData = item.split('┻━┻')
482#            print "tmpEncodedData1", tmpEncodedData
483            for tmpItem in tmpEncodedData:
484#                print "tmpItem", tmpItem
485                try:
486                    tmp += self.decodeOpenLoad(tmpItem)
487#                    print "tmpItem1", tmpItem
488                except Exception:
489                    skip = 1
490#                    printExc()
491#                    print "encodedData1 error"
492
493        tmp2 = ''
494        encodedData = self.getAllItemsBeetwenMarkers(data, "j=~[];", "())();", withMarkers=True, caseSensitive=False)
495#        print "encodedData2", encodedData
496        for item in encodedData:
497#            print "item2", item
498            try:
499                if '' != item:
500                    tmp2 += JJDecoder(item).decode()
501#                    print "tmp2", tmp2
502            except Exception:
503                    skip = 1
504#                printExc()
505#                    print "encodedData2 error"
506
507       
508#        printDBG('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')
509#        printDBG(tmp)
510#        printDBG('BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB')
511#        printDBG(tmp2)
512#        printDBG('CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC')
513#        print 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
514#        print "tmp1:", tmp
515#        print 'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'
516#        print "tmp2:", tmp2
517#        print 'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC'
518
519        ##########################################################
520        # new algo 2016-12-04 ;)
521        ##########################################################
522        varName = self.getSearchGroups(tmp, '''window.r=['"]([^'^"]+?)['"]''', ignoreCase=True)[0]
523        encTab = re.compile('''<span[^>]+?id="%s[^"]*?"[^>]*?>([^<]+?)<\/span>''' % varName).findall(data)
524#        printDBG(">>>>>>>>>>>> varName[%s] encTab[%s]" % (varName, encTab) )
525#        print ">>>>>>>>>>>> varName[%s] encTab[%s]" % (varName, encTab)
526
527
528        if varName == '':
529            for e in encTab:
530                if len(e) > 40:
531                    encTab.insert(0, e)
532                    break
533       
534        def __decode_k(enc, jscode):
535            decoded = ''
536            tmpPath = ''
537            try:
538                jscode = base64.b64decode('''ICAgICAgICAgICAgICAgICAgICB2YXIgaWQgPSAiJXMiDQogICAgICAgICAgICAgICAgICAgICAgLCBkZWNvZGVkDQogICAgICAgICAgICAgICAgICAgICAgLCBkb2N1bWVudCA9IHt9DQogICAgICAgICAgICAgICAgICAgICAgLCB3aW5kb3cgPSB0aGlzDQogICAgICAgICAgICAgICAgICAgICAgLCAkID0gZnVuY3Rpb24oKXsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0OiBmdW5jdGlvbihhKXsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmKGEpDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlY29kZWQgPSBhOw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaWQ7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkeTogZnVuY3Rpb24oYSl7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhKCkNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgIH07DQogICAgICAgICAgICAgICAgICAgIChmdW5jdGlvbihkLCB3KXsNCiAgICAgICAgICAgICAgICAgICAgICB2YXIgZiA9IGZ1bmN0aW9uKCl7fTsNCiAgICAgICAgICAgICAgICAgICAgICB2YXIgcyA9ICcnOw0KICAgICAgICAgICAgICAgICAgICAgIHZhciBvID0gbnVsbDsNCiAgICAgICAgICAgICAgICAgICAgICB2YXIgYiA9IGZhbHNlOw0KICAgICAgICAgIC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ywnY29udGVudFR5cGUnLCdjb29raWUnLCdkZXNpZ25Nb2RlJywnZG9tYWluJywnbGFzdE1vZGlmaWVkJywncmVmZXJyZXInLCd0aXRsZSddOw0KICAgICAgICAgICAgICAgICAgICAgIGRzLmZvckVhY2goZnVuY3Rpb24oZSl7ZFtlXT1zO30pOw0KICAgICAgICAgICAgICAgICAgICAgIHZhciB3YiA9IFsnY2xvc2VkJywnaXNTZWN1cmVDb250ZXh0J107DQogICAgICAgICAgICAgICAgICAgICAgd2IuZm9yRWFjaChmdW5jdGlvbihlKXt3W2VdPWI7fSk7DQogICAgICAgICAgICAgICAgICAgICAgdmFyIHdmID0gWydhZGRFdmVudExpc3RlbmVyJywnYWxlcnQnLCdhdG9iJywnYmx1cicsJ2J0b2EnLCdjYW5jZWxBbmltYXRpb25GcmFtZScsJ2NhcHR1cmVFdmVudHMnLCdjbGVhckludGVydmFsJywnY2xlYXJUaW1lb3V0JywnY2xvc2UnLCdjb25maXJtJywnY3JlYXRlSW1hZ2VCaXRtYXAnLCdkaXNwYXRjaEV2ZW50JywnZmV0Y2gnLCdmaW5kJywnZm9jdXMnLCdnZXRDb21wdXRlZFN0eWxlJywnZ2V0U2VsZWN0aW9uJywnbWF0Y2hNZWRpYScsJ21vdmVCeScsJ21vdmVUbycsJ29wZW4nLCdwb3N0TWVzc2FnZScsJ3Byb21wdCcsJ3JlbGVhc2VFdmVudHMnLCdyZW1vdmVFdmVudExpc3RlbmVyJywncmVxdWVzdEFuaW1hdGlvbkZyYW1lJywncmVzaXplQnknLCdyZXNpemVUbycsJ3Njcm9sbCcsJ3Njcm9sbEJ5Jywnc2Nyb2xsVG8nLCdzZXRJbnRlcnZhbCcsJ3NldFRpbWVvdXQnLCdzdG9wJ107DQogICAgICAgICAgICAgICAgICAgICAgd2YuZm9yRWFjaChmdW5jdGlvbihlKXt3W2VdPWY7fSk7DQogICAgICAgICAgICAgICAgICAgICAgdmFyIHduID0gWydkZXZpY2VQaXhlbFJhdGlvJywnaW5u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ICAgICAgICAgIHZhciB3cyA9IFsnbmFtZSddOw0KICAgICAgICAgICAgICAgICAgICAgIHdzLmZvckVhY2goZnVuY3Rpb24oZSl7d1tlXT1zO30pOw0KICAgICAgICAgICAgICAgICAgICB9KShkb2N1bWVudCwgd2luZG93KTsNCiAgICAgICAgICAgICAgICAgICAgJXM7DQogICAgICAgICAgICAgICAgICAgIHByaW50KGRlY29kZWQpOw==''') % (enc, jscode)                     
539#                printDBG("+++++++++++++++++++++++  CODE  ++++++++++++++++++++++++")
540#                printDBG(jscode)
541#                printDBG("+++++++++++++++++++++++++++++++++++++++++++++++++++++++")
542#                print "+++++++++++++++++++++++  CODE  ++++++++++++++++++++++++"
543#                print jscode
544#                print "+++++++++++++++++++++++++++++++++++++++++++++++++++++++"
545#                return self.iptv_js_execute( jscode )
546                return self.iptv_js_execute( jscode )
547
548#                ret = self.iptv_js_execute( jscode )
549#                if ret['sts'] and 0 == ret['code']:
550#                    decoded = ret['data'].strip()
551#                    printDBG('DECODED DATA -> [%s]' % decoded)
552            except Exception:
553#                printExc()
554                print "__decode_k error"
555
556            #rm(tmpPath)
557            return decoded
558
559#        marker = '゚ω゚ノ= /`m´)ノ'
560        marker = '゚ω゚ノ= /`m'
561
562#        marker = '゚ω゚'
563
564        orgData = marker + self.getDataBeetwenMarkers(orgData, marker, marker, False)[1]
565        orgData = re.sub('''if\s*\([^\}]+?typeof[^\}]+?\}''', '', orgData)
566        orgData = re.sub('''if\s*\([^\}]+?document[^\}]+?\}''', '', orgData)
567#        dec = self.__decode_k(encTab[0], orgData)
568        dec = __decode_k(encTab[0], orgData)
569       
570        videoUrl = 'https://openload.co/stream/{0}?mime=true'.format(dec)
571        params = dict(HTTP_HEADER)
572        params['external_sub_tracks'] = subTracks
573        print videoUrl
574#        print "params:", params
575
576    def get_url(self, host, media_id):
577        return 'https://openload.co/embed/%s' % (media_id)
578
579    def __auth_ip(self, media_id):
580        js_data = self.__get_json(INFO_URL)
581        pair_url = js_data.get('result', {}).get('auth_url', '')
582        if pair_url:
583            pair_url = pair_url.replace('\/', '/')
584            header = i18n('ol_auth_header')
585            line1 = i18n('auth_required')
586            line2 = i18n('visit_link')
587            line3 = i18n('click_pair') % (pair_url)
588            with common.kodi.CountdownDialog(header, line1, line2, line3) as cd:
589                return cd.start(self.__check_auth, [media_id])
590       
591    def __check_auth(self, media_id):
592        try:
593            js_data = self.__get_json(GET_URL.format(media_id=media_id))
594        except ResolverError as e:
595#        except Exception as e:
596            status, mscommandg = e
597            if status == 403:
598                print "errormsg=%s" % (e)
599                return
600            else:
601                print "errormsg=%s" % (msg)
602#                raise ResolverError(msg)
603       
604        return js_data.get('result', {}).get('url')
605   
606    def __get_json(self, url):
607        result = self.net.http_GET(url).content
608        js_result = json.loads(result)
609#        common.log_utils.log_debug(js_result)
610#        if js_result['status'] != 200:
611#            raise ResolverError(js_result['status'], js_result['msg'])
612        return js_result
613
614
615sys.stdout = OpenLoadResolver()
Note: See TracBrowser for help on using the repository browser.