Changeset 42919 for titan/mediathek/localhoster/thevideo.py
- Timestamp:
- Oct 17, 2018, 10:50:07 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
titan/mediathek/localhoster/thevideo.py
r41171 r42919 9 9 import lib.common as common 10 10 from lib import jsunpack 11 import re, urllib, json 11 12 12 13 INTERVALS = 5 … … 15 16 name = "thevideo" 16 17 domains = ["thevideo.me"] 17 pattern = '(?://|\.)(thevideo\.me )/(?:embed-|download/)?([0-9a-zA-Z]+)'18 pattern = '(?://|\.)(thevideo\.me|thevideo\.cc|vev\.io|tvad./me)/(?:embed-|download/)?([0-9a-zA-Z]+)' 18 19 19 20 def __init__(self): 20 self.net = Net() 21 # self.net = Net() 22 self.net = Net(cookie_file='/mnt/network/cookies', http_debug = False) 21 23 self.headers = {'User-Agent': common.ANDROID_USER_AGENT} 22 24 url = str(sys.argv[1]) … … 35 37 def get_media_url(self, host, media_id): 36 38 web_url = self.get_url(host, media_id) 39 37 40 headers = { 38 41 'Referer': web_url 39 42 } 40 43 headers.update(self.headers) 41 html = self.net.http_GET(web_url, headers=headers).content42 44 43 r = re.search('sources:\s*(\[.*?\])', html, re.DOTALL) 45 response = self.net.http_GET(web_url, headers=headers).content 46 ret = self.net.save_cookies('/mnt/network/cookies') 47 videoCode = self.getSearchGroups(response, r'''['"]video_code['"]\s*:\s*['"]([^'^"]+?)['"]''')[0] 48 print videoCode 44 49 45 if r: 46 sources = json.loads(r.group(1)) 47 max_label = 0 48 stream_url = '' 49 for source in sources: 50 if 'label' in source and int(re.sub('[^0-9]', '', source['label'])) > max_label: 51 stream_url = source['file'] 52 max_label = int(re.sub('[^0-9]', '', source['label'])) 50 def getSearchGroups(self, data, pattern, grupsNum=1, ignoreCase=False): 51 tab = [] 52 if ignoreCase: 53 match = re.search(pattern, data, re.IGNORECASE) 54 else: 55 match = re.search(pattern, data) 56 57 for idx in range(grupsNum): 58 try: value = match.group(idx + 1) 59 except Exception: value = '' 60 tab.append(value) 61 return tab 53 62 54 if re.search('File was deleted.', html): 55 print 'errormsg=File was deleted.' 56 57 varname = re.search('''concat\(\s*['"]/["']\s*\+([^\+]+?)\+''', html).group(1) 58 59 # authkey = re.search('''var lets_play_a_game=\'(.*)\'''', html).group(1) 60 # print "authkey2", authkey 61 62 authkey = re.search(r"=\'(.*)\'", html).group(1) 63 64 # my_regex = r"var " + re.escape(varname) + r"""\s*=\s*['"]([^'^"]+?)['"]""" 65 # my_regex = re.escape(varname) + r"""\s*=\s*['"]([^'^"]+?)['"]""" 66 # 67 # test = re.search(my_regex, html, re.IGNORECASE) 68 # print "test", test 69 70 web_url = "https://thevideo.me/vsign/player/" + authkey 71 html = self.net.http_GET(web_url, headers=headers).content 72 73 js_data = jsunpack.unpack(html) 74 for match in re.finditer('(eval\(function.*?)\{\}\)\)', html, re.DOTALL): 75 js_data = jsunpack.unpack(match.group(1)) 76 ua = re.search('"ua=(.*?)"', js_data).group(1) 77 vt = re.search('"vt=(.*?)"', js_data).group(1) 78 print '%s?direct=false&ua=%s&vt=%s' % (stream_url, ua, vt) 79 63 def getPage(self, url, addParams = {}, post_data = None): 64 ''' wraps getURLRequestData ''' 65 try: 66 addParams['url'] = url 67 if 'return_data' not in addParams: 68 addParams['return_data'] = True 69 response = self.getURLRequestData(addParams, post_data) 70 status = True 71 except urllib2.HTTPError, e: 72 # printExc() 73 response = e 74 status = False 75 except Exception: 76 # printExc() 77 response = None 78 status = False 80 79 80 if addParams['return_data'] and status and not isinstance(response, basestring): 81 status = False 82 83 return (status, response) 84 81 85 def get_url(self, host, media_id): 82 86 return 'http://%s/embed-%s-640x360.html' % (host, media_id)
Note: See TracChangeset
for help on using the changeset viewer.