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

Last change on this file since 42600 was 41177, checked in by obi, 22 months ago

tithek add vidlox

File size: 1.5 KB
Line 
1
2import sys
3from lib.net import Net
4
5import re, urllib, json
6from lib import helpers
7import lib.common as common
8
9class VidloxResolver(object):
10    name = "vidlox"
11    domains = ['vidlox.tv']
12    pattern = '(?://|\.)(vidlox\.tv)/(?:embed-)?([0-9a-zA-Z]+)'
13
14    def __init__(self):
15#        self.net = Net()
16#        self.net = Net(cookie_file='/mnt/network/cookies', http_debug = True)
17        self.net = Net(cookie_file='/mnt/network/cookies', http_debug = False)
18 
19        url = str(sys.argv[1])
20        host = self.get_host_and_id(url)[0]
21        media_id = self.get_host_and_id(url)[1]
22 
23        return self.get_media_url(host, media_id)
24
25    def get_host_and_id(self, url):
26        r = re.search(self.pattern, url, re.I)
27        if r:
28            return r.groups()
29        else:
30            return False
31
32    def get_media_url(self, host, media_id):
33        web_url = self.get_url(host, media_id)
34        headers = {'User-Agent': common.IE_USER_AGENT, 'Referer': web_url}
35        html = self.net.http_GET(web_url, headers=headers).content
36        try: sources = re.search(r'sources\s*:\s*\[(.+?)\]', html).groups()[0]
37        except: print 'errormsg=Unable to locate link'
38
39        if sources:
40            sources = helpers.scrape_sources(sources, patterns=['''["'](?P<url>http[^"']+)'''])
41            if sources: print helpers.pick_source(sources) + helpers.append_headers(headers)
42           
43#        raise ResolverError('Unable to locate link')
44
45    def get_url(self, host, media_id):
46        return 'http://%s/embed-%s.html' % (host, media_id)
47
48sys.stdout = VidloxResolver()
Note: See TracBrowser for help on using the repository browser.