source: titan/mediathek/localhoster/xvidstage.py @ 40036

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

[tithek] add xvidstage py hoster

File size: 1.4 KB
Line 
1from lib import helpers
2import sys
3from lib.net import Net
4import lib.common as common
5
6class XvidstageResolver(object):
7    name = "xvidstage"
8    domains = ["xvidstage.com"]
9    pattern = '(?://|\.)(xvidstage\.com)/(?:embed-|)?([0-9A-Za-z]+)'
10
11    def __init__(self):
12        self.net = Net()
13        url = str(sys.argv[1])
14        host = self.get_host_and_id(url)[0]
15        media_id = self.get_host_and_id(url)[1]
16
17        return self.get_media_url(host, media_id)
18
19    def get_host_and_id(self, url):
20        r = re.search(self.pattern, url, re.I)
21        if r:
22            return r.groups()
23        else:
24            return False
25
26    def get_media_url(self, host, media_id):
27        web_url = self.get_url(host, media_id)
28        headers = {'User-Agent': common.FF_USER_AGENT}
29        response = self.net.http_GET(web_url, headers=headers)
30        html = response.content
31        data = helpers.get_hidden(html)
32        headers['Cookie'] = response.get_headers(as_dict=True).get('Set-Cookie', '')
33        html = self.net.http_POST(web_url, headers=headers, form_data=data).content
34        sources = helpers.scrape_sources(html, result_blacklist='tmp')
35        print helpers.pick_source(sources) + helpers.append_headers(headers)
36
37    def get_url(self, host, media_id):
38        return 'http://www.xvidstage.com/%s' % media_id
39
40sys.stdout = XvidstageResolver()
Note: See TracBrowser for help on using the repository browser.