mirror of
https://github.com/soimort/you-get.git
synced 2025-02-11 20:52:31 +03:00
Updated the panda.tv plugin to use api v2
This commit is contained in:
parent
dc6b96f5f6
commit
4578503e5c
@ -5,46 +5,31 @@ __all__ = ['panda_download']
|
|||||||
from ..common import *
|
from ..common import *
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
import urllib.request
|
|
||||||
import urllib.error
|
|
||||||
|
|
||||||
|
|
||||||
def panda_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):
|
def panda_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):
|
||||||
roomid = url[url.rfind('/')+1:]
|
roomid = url[url.rfind('/')+1:]
|
||||||
json_request_url = 'http://www.panda.tv/api_room?roomid={}&pub_key=&_={}'.format(roomid, int(time.time()))
|
json_request_url ="http://www.panda.tv/api_room_v2?roomid={}&__plat=pc_web&_={}".format(roomid, int(time.time()))
|
||||||
content = get_html(json_request_url)
|
content = get_html(json_request_url)
|
||||||
errno = json.loads(content)['errno']
|
api_json = json.loads(content)
|
||||||
errmsg = json.loads(content)['errmsg']
|
|
||||||
|
errno = api_json["errno"]
|
||||||
|
errmsg = api_json["errmsg"]
|
||||||
if errno:
|
if errno:
|
||||||
raise ValueError("Errno : {}, Errmsg : {}".format(errno, errmsg))
|
raise ValueError("Errno : {}, Errmsg : {}".format(errno, errmsg))
|
||||||
|
data = api_json["data"]
|
||||||
data = json.loads(content)['data']
|
title = data["roominfo"]["name"]
|
||||||
title = data.get('roominfo')['name']
|
room_key = data["videoinfo"]["room_key"]
|
||||||
room_key = data.get('videoinfo')['room_key']
|
plflag = data["videoinfo"]["plflag"].split("_")
|
||||||
plflag = data.get('videoinfo')['plflag'].split('_')
|
status = data["videoinfo"]["status"]
|
||||||
status = data.get('videoinfo')['status']
|
|
||||||
if status is not "2":
|
if status is not "2":
|
||||||
raise ValueError("The live stream is not online! (status:%s)" % status)
|
raise ValueError("The live stream is not online! (status:%s)" % status)
|
||||||
real_url = 'http://pl{}.live.panda.tv/live_panda/{}.flv'.format(plflag[1],room_key)
|
|
||||||
counter = 0
|
|
||||||
data2 = json.loads(data['videoinfo']['plflag_list'])
|
|
||||||
pl_code_error = False
|
|
||||||
try:
|
|
||||||
urllib.request.urlopen(real_url)
|
|
||||||
except urllib.error.HTTPError as e:
|
|
||||||
pl_code_error = True
|
|
||||||
|
|
||||||
while (pl_code_error and counter < len(data2["backup"])):
|
data2 = json.loads(data["videoinfo"]["plflag_list"])
|
||||||
plflag = data2["backup"][counter].split('_')
|
rid = data2["auth"]["rid"]
|
||||||
counter = counter + 1
|
sign = data2["auth"]["sign"]
|
||||||
real_url = 'http://pl{}.live.panda.tv/live_panda/{}.flv'.format(plflag[1],room_key)
|
ts = data2["auth"]["time"]
|
||||||
try:
|
real_url = "http://pl{}.live.panda.tv/live_panda/{}.flv?sign={}&ts={}&rid={}".format(plflag[1], room_key, sign, ts, rid)
|
||||||
urllib.request.urlopen(real_url)
|
|
||||||
except urllib.error.HTTPError as e:
|
|
||||||
pl_code_error = True
|
|
||||||
else:
|
|
||||||
pl_code_error = False
|
|
||||||
|
|
||||||
print_info(site_info, title, 'flv', float('inf'))
|
print_info(site_info, title, 'flv', float('inf'))
|
||||||
if not info_only:
|
if not info_only:
|
||||||
download_urls([real_url], title, 'flv', None, output_dir, merge = merge)
|
download_urls([real_url], title, 'flv', None, output_dir, merge = merge)
|
||||||
|
Loading…
Reference in New Issue
Block a user