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

56 lines
2.1 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-27 22:08:54 +03:00
def zhanqi_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):
2017-01-26 11:31:56 +03:00
host_name = url.split('/')[2]
2017-01-27 22:08:54 +03:00
first_folder_path = url.split('/')[3].split('?')[0]
2017-01-26 11:31:56 +03:00
2017-01-27 22:08:54 +03:00
if first_folder_path != 'videos': #url = "https://www.zhanqi.tv/huashan?param_s=1_0.2.0"
2017-01-26 11:31:56 +03:00
if first_folder_path == 'topic': #https://www.zhanqi.tv/topic/lyingman
2017-01-27 22:08:54 +03:00
first_folder_path = url.split('/')[4].split('?')[0]
2017-01-26 11:31:56 +03:00
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')
2017-01-27 22:08:54 +03:00
site_info = "www.zhanqi.tv"
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'
2017-01-27 22:08:54 +03:00
video_id = url.split('/')[-1].split('?')[0].split('.')[0]
assert video_id
2017-01-26 11:31:56 +03:00
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
2017-01-27 22:08:54 +03:00
site_info = "www.zhanqi.tv/videos"
2017-01-26 11:31:56 +03:00
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
download = zhanqi_download
2017-01-26 11:31:56 +03:00
download_playlist = playlist_not_supported('zhanqi')