source: titan/mediathek/localhoster/doodstream.py

Last change on this file was 45652, checked in by obi, 6 months ago

tithek add doodstream hoster

File size: 2.9 KB
Line 
1"""
2    plugin for URLResolver
3    Copyright (C) 2020 gujal
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"""
18import re
19import random
20import string
21import time
22#from urlresolver.plugins.lib import helpers
23#from urlresolver import common
24#from urlresolver.resolver import UrlResolver, ResolverError
25
26import sys
27from lib.net import Net
28import re, urllib, json
29from lib import helpers
30import lib.common as common
31
32
33class DoodStreamResolver(object):
34    name = "doodstream"
35    domains = ['dood.watch', 'doodstream.com', 'dood.to', 'dood.so', 'dood.cx', 'dood.la', 'dood.ws']
36    pattern = r'(?://|\.)(dood(?:stream)?\.(?:com|watch|to|so|cx|la|ws))/(?:d|e)/([0-9a-zA-Z]+)'
37
38    def __init__(self):
39        self.net = Net()
40        url = str(sys.argv[1])
41        host = self.get_host_and_id(url)[0]
42        media_id = self.get_host_and_id(url)[1]
43
44        return self.get_media_url(host, media_id)
45
46    def get_host_and_id(self, url):
47        r = re.search(self.pattern, url, re.I)
48        if r:
49            return r.groups()
50        else:
51            return False
52
53    def get_media_url(self, host, media_id):
54        web_url = self.get_url(host, media_id)
55        headers = {'User-Agent': common.RAND_UA,
56                   'Referer': 'https://{0}/'.format(host)}
57
58        r = self.net.http_GET(web_url, headers=headers)
59        if r.get_url() != web_url:
60            host = re.findall(r'(?://|\.)([^/]+)', r.get_url())[0]
61            web_url = self.get_url(host, media_id)
62        headers.update({'Referer': web_url})
63
64        html = r.content
65        match = re.search(r'''dsplayer\.hotkeys[^']+'([^']+).+?function\s*makePlay.+?return[^?]+([^"]+)''', html, re.DOTALL)
66        if match:
67            token = match.group(2)
68            url = 'https://{0}{1}'.format(host, match.group(1))
69            html = self.net.http_GET(url, headers=headers).content
70            print self.dood_decode(html) + token + str(int(time.time() * 1000)) + helpers.append_headers(headers)
71
72        #raise ResolverError('Video Link Not Found')
73        else:
74            print 'errormsg=Video Link Not Found'
75
76    def dood_decode(self, data):
77        t = string.ascii_letters + string.digits
78        return data + ''.join([random.choice(t) for _ in range(10)])
79
80    def get_url(self, host, media_id):
81        return 'https://%s/e/%s' % (host, media_id)
82
83sys.stdout = DoodStreamResolver()
Note: See TracBrowser for help on using the repository browser.