source: titan/mediathek/localhoster/vidcloud.py @ 42562

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

tithek add vidcloud|loadvid support

File size: 2.2 KB
Line 
1"""
2    urlresolver XBMC Addon
3    Copyright (C) 2016 jsergio
4
5This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 3 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program. If not, see <http://www.gnu.org/licenses/>.
17"""
18import re, urllib, json
19from lib import helpers
20import lib.common as common
21
22class VidCloudResolver(object):
23    name = 'vidcloud'
24    domains = ['vidcloud.co', 'loadvid.online']
25    pattern = '(?://|\.)((?:vidcloud.co|loadvid.online))/(?:embed|v)/([0-9a-zA-Z]+)'
26
27    def __init__(self):
28        self.net = common.Net()
29
30    def __init__(self):
31        self.net = Net()
32        url = str(sys.argv[1])
33        host = self.get_host_and_id(url)[0]
34        media_id = self.get_host_and_id(url)[1]
35
36        return self.get_media_url(host, media_id)
37
38    def get_host_and_id(self, url):
39        r = re.search(self.pattern, url, re.I)
40        if r:
41            return r.groups()
42        else:
43            return False
44
45    def get_media_url(self, host, media_id):
46        web_url = self.get_url(host, media_id)
47        headers = {'User-Agent': common.CHROME_USER_AGENT, 'Referer': 'https://vidcloud.co/embed/%s' % media_id}
48        html = self.net.http_GET(web_url, headers=headers).content
49
50        if html:
51            sources = helpers.scrape_sources(html.replace("\\n", "").replace("\\", ""), patterns=[
52                '''src":\s*"(?P<url>[^"]+)(?:[^}>\]]+)label":\s*"(?P<label>[^"]+)'''], generic_patterns=False)
53            if sources:
54                return helpers.pick_source(sources) + helpers.append_headers(headers)
55
56        raise ResolverError("Unable to locate video")
57
58    def get_url(self, host, media_id):
59        return 'https://vidcloud.co/player?fid=%s&page=embed' % media_id
60
61sys.stdout = VideoweedResolver()
Note: See TracBrowser for help on using the repository browser.