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

Last change on this file since 40039 was 40039, checked in by obi, 5 years ago

fix

File size: 1.4 KB
Line 
1from lib import helpers
2import sys
3import re
4from lib.net import Net
5import lib.common as common
6
7class XvidstageResolver(object):
8    name = "xvidstage"
9    domains = ["xvidstage.com"]
10    pattern = '(?://|\.)(xvidstage\.com)/(?:embed-|)?([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        headers = {'User-Agent': common.FF_USER_AGENT}
30        response = self.net.http_GET(web_url, headers=headers)
31        html = response.content
32        data = helpers.get_hidden(html)
33        headers['Cookie'] = response.get_headers(as_dict=True).get('Set-Cookie', '')
34        html = self.net.http_POST(web_url, headers=headers, form_data=data).content
35        sources = helpers.scrape_sources(html, result_blacklist='tmp')
36        print helpers.pick_source(sources) + helpers.append_headers(headers)
37
38    def get_url(self, host, media_id):
39        return 'http://www.xvidstage.com/%s' % media_id
40
41sys.stdout = XvidstageResolver()
Note: See TracBrowser for help on using the repository browser.