source: titan/mediathek/localhoster/abcvideo.py

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

[tithek] add hoster abcvideo

File size: 3.0 KB
Line 
1"""
2    Plugin for URLResolver
3    Copyright (C) 2021 gujal
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8    This program is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11    GNU General Public License for more details.
12    You should have received a copy of the GNU General Public License
13    along with this program.  If not, see <http://www.gnu.org/licenses/>.
14"""
15
16#from six.moves import urllib_parse
17#from urlresolver.plugins.lib import helpers
18#from urlresolver import common
19#from urlresolver.resolver import UrlResolver, ResolverError
20
21import lib.six
22from lib.six.moves import urllib_parse, urllib_request
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 ABCVideoResolver(object):
33    name = "abcvideo"
34    domains = ['abcvideo.cc']
35    pattern = r'(?://|\.)(abcvideo\.cc)/(?:embed-)?([0-9a-zA-Z]+)'
36
37    def __init__(self):
38        self.net = Net()
39        url = str(sys.argv[1])
40        host = self.get_host_and_id(url)[0]
41        media_id = self.get_host_and_id(url)[1]
42
43        return self.get_media_url(host, media_id)
44
45    def get_host_and_id(self, url):
46        r = re.search(self.pattern, url, re.I)
47        if r:
48            return r.groups()
49        else:
50            return False
51
52    def get_media_url(self, host, media_id):
53        surl = 'https://abcvideo.cc/dl'
54        domain = 'aHR0cHM6Ly9hYmN2aWRlby5jYzo0NDM.'
55        web_url = self.get_url(host, media_id)
56        rurl = 'https://{0}/'.format(host)
57        headers = {'User-Agent': common.FF_USER_AGENT,
58                   'Referer': rurl}
59        html = self.net.http_GET(web_url, headers).content
60        token = helpers.girc(html, rurl, domain)
61        if token:
62            data = {'op': 'video_src',
63                    'file_code': media_id,
64                    'g-recaptcha-response': token}
65            headers.update({'X-Requested-With': 'XMLHttpRequest'})
66            shtml = self.net.http_GET('{0}?{1}'.format(surl, urllib_parse.urlencode(data)), headers=headers).content
67            sources = helpers.scrape_sources(shtml)
68
69            if sources:
70                headers.pop('X-Requested-With')
71                print helpers.pick_source(sources) + helpers.append_headers(headers)
72            else:
73                print 'errormsg=File Not Found or removed'
74        else:
75             print 'errormsg=Token Not Found or removed'
76#        raise ResolverError('File Not Found or removed')
77
78#    def get_url(self, host, media_id):
79#        return self._default_get_url(host, media_id, template='https://{host}/embed-{media_id}.html')
80
81    def get_url(self, host, media_id):
82        return 'https://%s/embed-%s.html' % (host, media_id)
83
84sys.stdout = ABCVideoResolver()
Note: See TracBrowser for help on using the repository browser.