you-get/src/you_get/extractors/zhanqi.py

54 lines
2.0 KiB
Python
Raw Normal View History

2014-11-16 17:54:57 +03:00
#!/usr/bin/env python
__all__ = ['zhanqi_download']
from ..common import *
2016-03-19 07:28:26 +03:00
import json
2014-11-16 17:54:57 +03:00
2017-01-26 11:31:56 +03:00
def zhanqi_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):#the programmers of zhanqi are noobs
host_name = url.split('/')[2]
first_folder_path = url.split('/')[3]
if first_folder_path != 'videos': #url = "https://www.zhanqi.tv/huashan"
if first_folder_path == 'topic': #https://www.zhanqi.tv/topic/lyingman
first_folder_path = url.split('/')[4]
api_url = "https://www.zhanqi.tv/api/static/v2.1/room/domain/" + first_folder_path + ".json"
api_json = json.loads(get_html(api_url))
data = api_json['data']
status = data['status']
if status != '4':
raise ValueError ("The live stream is not online!")
nickname = data['nickname']
title = nickname + ": " + data['title']
roomid = data['id']
videoId = data['videoId']
jump_url = "http://wshdl.load.cdn.zhanqi.tv/zqlive/" + videoId + ".flv?get_url=1"
jump_url = jump_url.strip('\r\n')
real_url = get_html(jump_url)
real_url = real_url.strip('\r\n')
print_info(site_info, title, 'flv', float('inf'))
if not info_only:
2017-01-26 11:31:56 +03:00
download_url_ffmpeg(real_url, title, 'flv', {}, output_dir = output_dir, merge = merge)
2017-01-26 11:31:56 +03:00
else: #url = 'https://www.zhanqi.tv/videos/Lyingman/2017/01/182308.html'
video_id = url.split('/')[-1].split('.')[0]
api_url = "https://www.zhanqi.tv/api/static/v2.1/video/" + video_id + ".json"
api_json = json.loads(get_html(api_url))
data = api_json['data']
title = data['title']
video_url_id = data['flashvars']['VideoID']
real_url = "http://dlvod.cdn.zhanqi.tv/" + video_url_id
print_info(site_info, title, 'flv', float('inf'))
if not info_only:
2017-01-26 11:31:56 +03:00
download_url_ffmpeg(real_url, title, 'flv', {}, output_dir = output_dir, merge = merge)
2016-03-19 07:28:26 +03:00
2014-11-16 17:54:57 +03:00
site_info = "zhanqi.tv"
download = zhanqi_download
2017-01-26 11:31:56 +03:00
download_playlist = playlist_not_supported('zhanqi')