source: titan/mediathek/localhoster/upstream.py

Last change on this file was 45114, checked in by obi, 16 months ago

fix typo

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