source: titan/mediathek/localhoster/streamango.py

Last change on this file was 42560, checked in by obi, 4 years ago

tithek hoster fix streammago streamcherry

File size: 4.0 KB
Line 
1
2import sys
3from lib.net import Net
4
5import re, urllib, json
6from lib import helpers
7import lib.common as common
8
9class StreamangoResolver(object):
10    name = "streamango"
11    domains = ['streamango.com', "streamcherry.com"]
12    pattern = '(?://|\.)(stream(?:ango|cherry)\.com)/(?:v/d|f|embed)/([0-9a-zA-Z]+)'
13
14    def __init__(self):
15#        self.net = Net()
16#        self.net = Net(cookie_file='/mnt/network/cookies', http_debug = True)
17        self.net = Net(cookie_file='/mnt/network/cookies', http_debug = False)
18 
19        url = str(sys.argv[1])
20        host = self.get_host_and_id(url)[0]
21        media_id = self.get_host_and_id(url)[1]
22 
23        return self.get_media_url(host, media_id)
24
25    def get_host_and_id(self, url):
26        r = re.search(self.pattern, url, re.I)
27        if r:
28            return r.groups()
29        else:
30            return False
31
32    def get_media_url1(self, host, media_id):
33        web_url = self.get_url(host, media_id)
34        link = self.net.http_GET(web_url).content
35        if 'FILE WAS DELETED' in link:
36            print 'File deleted.'
37        else:
38            video_link = str(re.compile('file[: ]*"(.+?)"').findall(link)[0])
39
40            if len(video_link) > 0:
41                print video_link
42            else:
43                print 'errormsg=No playable video found.'
44
45    def get_media_url(self, host, media_id):
46        web_url = self.get_url(host, media_id)
47        headers = {'User-Agent': common.RAND_UA}
48#        headers = {'User-Agent': common.FF_USER_AGENT}
49        html = self.net.http_GET(web_url, headers=headers).content
50
51        if html:
52#           srces.push( {type:"video/mp4",src:d('keDN2p3bx6LdzqrO1JcSxaDTkZoRyuDbzaLN0KzR2qHQza7NyJ/U4N8Lld4IltoMlN3Cn98Sl90JkN=SlpHQ/K3YnqnW3uENltwA',93),height:360,bitrate:576});
53            encoded = re.search('''srces\.push\({type:"video/mp4",src:\w+\('([^']+)',(\d+)''', html)
54            if not encoded:
55                encoded = re.search('''srces\.push\( {type:"video/mp4",src:\w+\('([^']+)',(\d+)''', html)
56
57            if encoded:
58                source = self.decode(encoded.group(1), int(encoded.group(2)))
59                if source:
60                    source = "http:%s" % source if source.startswith("//") else source
61                    source = source.split("/")
62                    if not source[-1].isdigit():
63                      source[-1] = re.sub('[^\d]', '', source[-1])
64                    source = "/".join(source)
65
66                    headers.update({'Referer': web_url})
67                    print source + helpers.append_headers(headers)
68
69#<h1 style="text-align: center !important;">Sorry!</h1>
70#<p class="lead">We are unable to find the video you're looking for. There could be several reasons for this, for example it got removed by the owner.</p>
71#</div>
72#</div>
73
74    def decode(self, encoded, code):
75        _0x59b81a = ""
76        k = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
77        k = k[::-1]
78
79        count = 0
80
81        for index in range(0, len(encoded) - 1):
82            while count <= len(encoded) - 1:
83                _0x4a2f3a = k.index(encoded[count])
84                count += 1
85                _0x29d5bf = k.index(encoded[count])
86                count += 1
87                _0x3b6833 = k.index(encoded[count])
88                count += 1
89                _0x426d70 = k.index(encoded[count])
90                count += 1
91
92                _0x2e4782 = ((_0x4a2f3a << 2) | (_0x29d5bf >> 4))
93                _0x2c0540 = (((_0x29d5bf & 15) << 4) | (_0x3b6833 >> 2))
94                _0x5a46ef = ((_0x3b6833 & 3) << 6) | _0x426d70
95                _0x2e4782 = _0x2e4782 ^ code
96
97                _0x59b81a = str(_0x59b81a) + chr(_0x2e4782)
98
99                if _0x3b6833 != 64:
100                    _0x59b81a = str(_0x59b81a) + chr(_0x2c0540)
101                if _0x3b6833 != 64:
102                    _0x59b81a = str(_0x59b81a) + chr(_0x5a46ef)
103
104        return _0x59b81a
105
106    def get_url(self, host, media_id):
107        if host.lower() == 'streamango.com':
108            host = 'fruitstreams.com'
109        return 'http://%s/embed/%s' % (host, media_id)
110
111sys.stdout = StreamangoResolver()
Note: See TracBrowser for help on using the repository browser.