This commit is contained in:
Valdemar Erk 2017-01-10 22:23:33 +01:00
parent 69a54bfd2c
commit 7b4114dac4

View File

@ -5,6 +5,7 @@ __all__ = ['panda_download']
from ..common import * from ..common import *
import json import json
import time import time
import requests
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:]
@ -20,12 +21,15 @@ def panda_download(url, output_dir = '.', merge = True, info_only = False, **kwa
room_key = data.get('videoinfo')['room_key'] room_key = data.get('videoinfo')['room_key']
plflag = data.get('videoinfo')['plflag'].split('_') plflag = data.get('videoinfo')['plflag'].split('_')
status = data.get('videoinfo')['status'] status = data.get('videoinfo')['status']
if data.get("roominfo")["banned_reason"]:
data2 = json.loads(data['videoinfo']['plflag_list'])
plflag = data2["backup"][0].split('_')
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) real_url = 'http://pl{}.live.panda.tv/live_panda/{}.flv'.format(plflag[1],room_key)
counter = 0
while (requests.head(real_url, allow_redirects=True).status_code == 403):
data2 = json.loads(data['videoinfo']['plflag_list'])
plflag = data2["backup"][counter].split('_')
counter = counter + 1
real_url = 'http://pl{}.live.panda.tv/live_panda/{}.flv'.format(plflag[1],room_key)
print_info(site_info, title, 'flv', float('inf')) print_info(site_info, title, 'flv', float('inf'))
if not info_only: if not info_only: