1 | """
|
---|
2 | Plugin for ResolveUrl
|
---|
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 | """
|
---|
18 |
|
---|
19 | #import re
|
---|
20 | #from resolveurl.plugins.lib import helpers
|
---|
21 | #from resolveurl import common
|
---|
22 | #from resolveurl.resolver import ResolveUrl, ResolverError
|
---|
23 |
|
---|
24 | import re
|
---|
25 | import sys
|
---|
26 | import time
|
---|
27 | from lib.net import Net
|
---|
28 | import re, urllib, json
|
---|
29 | from lib import helpers
|
---|
30 | import lib.common as common
|
---|
31 |
|
---|
32 | class StreamTapeResolver(object):
|
---|
33 | name = "streamtape"
|
---|
34 | domains = ['streamtape.com', 'strtape.cloud', 'streamtape.net', 'streamta.pe', 'streamtape.site', 'strcloud.link']
|
---|
35 | pattern = r'(?://|\.)(str(?:eam)?(?:tap?e?|cloud)\.(?:com|cloud|net|pe|site|link))/(?:e|v)/([0-9a-zA-Z]+)'
|
---|
36 |
|
---|
37 | # def __init__(self):
|
---|
38 | # self.net = common.Net()
|
---|
39 |
|
---|
40 | def __init__(self):
|
---|
41 | self.net = Net()
|
---|
42 | url = str(sys.argv[1])
|
---|
43 | host = self.get_host_and_id(url)[0]
|
---|
44 | media_id = self.get_host_and_id(url)[1]
|
---|
45 |
|
---|
46 | return self.get_media_url(host, media_id)
|
---|
47 |
|
---|
48 | def get_host_and_id(self, url):
|
---|
49 | r = re.search(self.pattern, url, re.I)
|
---|
50 | if r:
|
---|
51 | return r.groups()
|
---|
52 | else:
|
---|
53 | return False
|
---|
54 |
|
---|
55 | def get_media_url(self, host, media_id):
|
---|
56 | web_url = self.get_url(host, media_id)
|
---|
57 | headers = {'User-Agent': common.FF_USER_AGENT,
|
---|
58 | 'Referer': 'https://{0}/'.format(host)}
|
---|
59 | try:
|
---|
60 | r = self.net.http_GET(web_url, headers=headers).content
|
---|
61 | except urllib_error.HTTPError:
|
---|
62 | # raise ResolverError('Video deleted or removed.')
|
---|
63 | print 'errormsg=Video deleted or removed.'
|
---|
64 | return
|
---|
65 | src = re.findall(r'''ById\('.+?=\s*(["']//[^;<]+)''', r)
|
---|
66 | if src:
|
---|
67 | src_url = ''
|
---|
68 | parts = src[-1].replace("'", '"').split('+')
|
---|
69 | for part in parts:
|
---|
70 | p1 = re.findall(r'"([^"]*)', part)[0]
|
---|
71 | p2 = 0
|
---|
72 | if 'substring' in part:
|
---|
73 | subs = re.findall(r'substring\((\d+)', part)
|
---|
74 | for sub in subs:
|
---|
75 | p2 += int(sub)
|
---|
76 | src_url += p1[p2:]
|
---|
77 | src_url += '&stream=1'
|
---|
78 | src_url = 'https:' + src_url if src_url.startswith('//') else src_url
|
---|
79 | print helpers.get_redirect_url(src_url, headers) + helpers.append_headers(headers)
|
---|
80 | # raise ResolverError('Video cannot be located.')
|
---|
81 | else
|
---|
82 | print 'errormsg=Video cannot be located.'
|
---|
83 |
|
---|
84 | def get_url(self, host, media_id):
|
---|
85 | return 'https://%s/e/%s' % (host, media_id)
|
---|
86 |
|
---|
87 | sys.stdout = StreamTapeResolver()
|
---|