source: titan/mediathek/localhoster/briskfile.py @ 40097

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

tithek add Briskfile hoster

File size: 1.8 KB
Line 
1
2import re
3import json
4import urllib2
5from lib import helpers
6import sys
7from lib.net import Net
8import lib.common as common
9
10class BriskfileResolver(object):
11    name = "briskfile"
12    domains = ["briskfile.com"]
13    pattern = '(?://|\.)(briskfile\.com)/(?:l|e)/([0-9A-Za-z\-]+)'
14
15    def __init__(self):
16        self.net = Net()
17        url = str(sys.argv[1])
18        host = self.get_host_and_id(url)[0]
19        media_id = self.get_host_and_id(url)[1]
20
21        return self.get_media_url(host, media_id)
22
23    def get_host_and_id(self, url):
24        r = re.search(self.pattern, url, re.I)
25        if r:
26            return r.groups()
27        else:
28            return False
29
30    def get_media_url(self, host, media_id):
31        web_url = self.get_url(host, media_id)
32        headers = {'User-Agent': common.FF_USER_AGENT}
33        html = self.net.http_GET(web_url, headers=headers).content
34        match = re.search('''val\(\)\s*\+\s*['"]([^"']+)''', html)
35        suffix = match.group(1) if match else ''
36        data = helpers.get_hidden(html)
37        for name in data:
38            data[name] = data[name] + suffix
39       
40        headers['Referer'] = web_url
41        html = self.net.http_POST(web_url, form_data=data, headers=headers).content
42        html = re.compile(r'clip\s*:\s*\{.*?(?:url|src)\s*:\s*[\"\'](.+?)[\"\']', re.DOTALL).search(html)
43        if not html:
44            print 'File Not Found or removed'
45        stream_url = html.group(1)
46        req = urllib2.Request(stream_url)
47        for key in headers:
48            req.add_header(key, headers[key])
49        stream_url = urllib2.urlopen(req).geturl()
50        print stream_url + '|User-Agent=%s&Referer=%s' % (common.FF_USER_AGENT, web_url)
51
52    def get_url(self, host, media_id):
53        return 'http://www.briskfile.com/l/%s' % (media_id)
54
55sys.stdout = BriskfileResolver()
Note: See TracBrowser for help on using the repository browser.