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

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

fix vidcloud

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 lib.common as common
19import re
20import sys
21from lib.net import Net
22from lib import helpers
23
24class VidCloudResolver(object):
25    name = 'vidcloud'
26    domains = ['vidcloud.co', 'loadvid.online']
27    pattern = '(?://|\.)((?:vidcloud.co|loadvid.online))/(?:embed|v)/([0-9a-zA-Z]+)'
28
29    def __init__(self):
30        self.net = Net()
31        url = str(sys.argv[1])
32        host = self.get_host_and_id(url)[0]
33        media_id = self.get_host_and_id(url)[1]
34
35        return self.get_media_url(host, media_id)
36
37    def get_host_and_id(self, url):
38        r = re.search(self.pattern, url, re.I)
39        if r:
40            return r.groups()
41        else:
42            return False
43
44    def get_media_url(self, host, media_id):
45        web_url = self.get_url(host, media_id)
46        headers = {'User-Agent': common.CHROME_USER_AGENT, 'Referer': 'https://vidcloud.co/embed/%s' % media_id}
47        html = self.net.http_GET(web_url, headers=headers).content
48
49        if html:
50            sources = helpers.scrape_sources(html.replace("\\n", "").replace("\\", ""), patterns=[
51                '''src":\s*"(?P<url>[^"]+)(?:[^}>\]]+)label":\s*"(?P<label>[^"]+)'''], generic_patterns=False)
52            if sources:
53                print helpers.pick_source(sources) + helpers.append_headers(headers)
54
55        raise ResolverError("Unable to locate video")
56
57    def get_url(self, host, media_id):
58        return 'https://vidcloud.co/player?fid=%s&page=embed' % media_id
59
60sys.stdout = VidCloudResolver()
Note: See TracBrowser for help on using the repository browser.