source: titan/mediathek/localhoster/streamtape.py @ 45111

Last change on this file since 45111 was 45111, checked in by obi, 3 years ago

tithek add streamtape

File size: 2.5 KB
RevLine 
[45111]1"""
2Plugin for ResolveUrl
3Copyright (C) 2020 gujal
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"""
18
19#import re
20#from resolveurl.plugins.lib import helpers
21#from resolveurl import common
22#from resolveurl.resolver import ResolveUrl, ResolverError
23
24import re
25import sys
26import time
27from lib.net import Net
28import re, urllib, json
29from lib import helpers
30import lib.common as common
31
32class StreamTapeResolver(object):
33    name = "streamtape"
34    domains = ['streamtape.com']
35    pattern = r'(?://|\.)(streamtape\.com)/(?:e|v)/([0-9a-zA-Z]+)'
36    print "1111111111111"
37
38#    def __init__(self):
39#        self.net = common.Net()
40
41    def __init__(self):
42        self.net = Net()
43        url = str(sys.argv[1])
44        host = self.get_host_and_id(url)[0]
45        media_id = self.get_host_and_id(url)[1]
46
47        return self.get_media_url(host, media_id)
48
49    def get_host_and_id(self, url):
50        r = re.search(self.pattern, url, re.I)
51        if r:
52            return r.groups()
53        else:
54            return False
55
56    def get_media_url(self, host, media_id):
57        web_url = self.get_url(host, media_id)
58        headers = {'User-Agent': common.FF_USER_AGENT,
59                   'Referer': 'https://{0}/'.format(host)}
60        r = self.net.http_GET(web_url, headers=headers)
61        src = re.search(r'''ById\('vi.+?=\s*["']([^"']+)['"].+?["']([^"']+)''', r.content)
62        if src:
63            src_url = 'https:{0}{1}&stream=1'.format(src.group(1), src.group(2))
64            print helpers.get_redirect_url(src_url, headers) + helpers.append_headers(headers)
65#        raise ResolverError('Video cannot be located.')
66
67#    def get_url(self, host, media_id):
68#        return self._default_get_url(host, media_id, template='https://{host}/e/{media_id}')
69
70    def get_url(self, host, media_id):
71        return 'https://%s/e/%s' % (host, media_id)
72               
73sys.stdout = StreamTapeResolver()
Note: See TracBrowser for help on using the repository browser.