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

Last change on this file since 42600 was 40041, checked in by obi, 3 years ago

fix

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