source: titan/mediathek/localhoster/flashx.py @ 38996

Last change on this file since 38996 was 38996, checked in by obi, 6 years ago

[tithek] add local python hoster openload / allmyvideos / nosvideo / vidup

File size: 2.3 KB
Line 
1
2import re, time
3from lib import jsunpack
4import sys
5from lib.net import Net
6
7class FlashxResolver(object):
8    name = "flashx"
9    domains = ["flashx.tv"]
10    pattern = '(?://|\.)(flashx\.tv)/(?:embed-|dl\?|embed.php\?c=)?([0-9a-zA-Z/-]+)'
11
12    def __init__(self):
13        self.net = Net()
14        url = str(sys.argv[1])
15        host = self.get_host_and_id(url)[0]
16        media_id = self.get_host_and_id(url)[1]
17
18        return self.get_media_url(host, media_id)
19
20    def get_host_and_id(self, url):
21        r = re.search(self.pattern, url, re.I)
22        if r:
23            return r.groups()
24        else:
25            return False
26
27    def get_media_url(self, host, media_id):
28        web_url = self.get_url(host, media_id)
29        resp = self.net.http_GET(web_url)
30        html = resp.content
31        cfdcookie = resp._response.info()['set-cookie']
32        cfduid = re.search('cfduid=(.*?);', cfdcookie).group(1)
33        file_id = re.search("'file_id', '(.*?)'", html).group(1)
34        aff = re.search("'aff', '(.*?)'", html).group(1)
35        headers = { 'Referer': web_url,
36                    'Cookie': '__cfduid=' + cfduid + '; lang=1'}
37        surl = re.search('src="(.*?' + file_id + ')',html).group(1)
38        dummy = self.net.http_GET(url=surl, headers=headers).content
39        headers = { 'Referer': web_url,
40                    'Cookie': '__cfduid=' + cfduid + '; lang=1; file_id=' + file_id + '; aff=' + aff }
41        html = self.net.http_GET(url=web_url, headers=headers).content
42        fname = re.search('name="fname" value="(.*?)"', html).group(1)
43        hash = re.search('name="hash" value="(.*?)"', html).group(1)
44        fdata = { 'op': 'download1',
45                  'usr_login': '',
46                  'id': media_id,
47                  'fname': fname,
48                  'referer': '',
49                  'hash': hash,
50                  'imhuman': 'Proceed to video' }
51        furl = 'http://www.flashx.tv/dl?' + media_id
52        time.sleep(5)
53        html = self.net.http_POST(url=furl, form_data=fdata, headers=headers).content
54        strhtml = jsunpack.unpack(re.search('(eval\(function.*?)</script>', html, re.DOTALL).group(1))
55        stream = re.search('file:"([^"]*)",label', strhtml).group(1)
56
57        if stream:
58            print stream
59
60    def get_url(self, host, media_id):
61        return 'http://www.flashx.tv/%s.html' % media_id
62 
63sys.stdout = FlashxResolver()
Note: See TracBrowser for help on using the repository browser.