[45111] | 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']
|
---|
| 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 |
|
---|
| 73 | sys.stdout = StreamTapeResolver()
|
---|