mirror of
https://github.com/soimort/you-get.git
synced 2025-02-11 20:52:31 +03:00
fix:[zhanqi.tv]recode all
This commit is contained in:
parent
8bc0ec7a71
commit
23f9803482
@ -3,73 +3,50 @@
|
|||||||
__all__ = ['zhanqi_download']
|
__all__ = ['zhanqi_download']
|
||||||
|
|
||||||
from ..common import *
|
from ..common import *
|
||||||
import re
|
|
||||||
import base64
|
|
||||||
import json
|
import json
|
||||||
import time
|
|
||||||
import hashlib
|
|
||||||
|
|
||||||
def zhanqi_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):
|
def zhanqi_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):#the programmers of zhanqi are noobs
|
||||||
html = get_content(url)
|
host_name = url.split('/')[2]
|
||||||
video_type_patt = r'VideoType":"([^"]+)"'
|
first_folder_path = url.split('/')[3]
|
||||||
video_type = match1(html, video_type_patt)
|
|
||||||
|
if first_folder_path != 'videos': #url = "https://www.zhanqi.tv/huashan"
|
||||||
|
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')
|
||||||
|
|
||||||
#rtmp_base_patt = r'VideoUrl":"([^"]+)"'
|
|
||||||
rtmp_id_patt = r'videoId":"([^"]+)"'
|
|
||||||
vod_m3u8_id_patt = r'VideoID":"([^"]+)"'
|
|
||||||
title_patt = r'<p class="title-name" title="[^"]+">([^<]+)</p>'
|
|
||||||
title_patt_backup = r'<title>([^<]{1,9999})</title>'
|
|
||||||
title = match1(html, title_patt) or match1(html, title_patt_backup)
|
|
||||||
title = unescape_html(title)
|
|
||||||
rtmp_base = "http://wshdl.load.cdn.zhanqi.tv/zqlive"
|
|
||||||
vod_base = "http://dlvod.cdn.zhanqi.tv"
|
|
||||||
rtmp_real_base = "rtmp://dlrtmp.cdn.zhanqi.tv/zqlive/"
|
|
||||||
room_info = "http://www.zhanqi.tv/api/static/live.roomid/"
|
|
||||||
KEY_MASK = "#{&..?!("
|
|
||||||
ak2_pattern = r'ak2":"\d-([^|]+)'
|
|
||||||
|
|
||||||
if video_type == "LIVE":
|
|
||||||
rtmp_id = match1(html, rtmp_id_patt).replace('\\/','/')
|
|
||||||
#request_url = rtmp_base+'/'+rtmp_id+'.flv?get_url=1'
|
|
||||||
#real_url = get_html(request_url)
|
|
||||||
html2 = get_content(room_info + rtmp_id.split("_")[0] + ".json")
|
|
||||||
json_data = json.loads(html2)
|
|
||||||
cdns = json_data["data"]["flashvars"]["cdns"]
|
|
||||||
cdns = base64.b64decode(cdns).decode("utf-8")
|
|
||||||
cdn = match1(cdns, ak2_pattern)
|
|
||||||
cdn = base64.b64decode(cdn).decode("utf-8")
|
|
||||||
key = ''
|
|
||||||
i = 0
|
|
||||||
while(i < len(cdn)):
|
|
||||||
key = key + chr(ord(cdn[i]) ^ ord(KEY_MASK[i % 8]))
|
|
||||||
i = i + 1
|
|
||||||
time_hex = hex(int(time.time()))[2:]
|
|
||||||
key = hashlib.md5(bytes(key + "/zqlive/" + rtmp_id + time_hex, "utf-8")).hexdigest()
|
|
||||||
real_url = rtmp_real_base + '/' + rtmp_id + "?k=" + key + "&t=" + time_hex
|
|
||||||
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_rtmp_url(real_url, title, 'flv', {}, output_dir, merge = merge)
|
download_url_ffmpeg(real_url, title, 'flv', {}, output_dir = output_dir, merge = merge)
|
||||||
#download_urls([real_url], title, 'flv', None, output_dir, merge = merge)
|
|
||||||
elif video_type == "VOD":
|
|
||||||
vod_m3u8_request = vod_base + match1(html, vod_m3u8_id_patt).replace('\\/','/')
|
|
||||||
vod_m3u8 = get_html(vod_m3u8_request)
|
|
||||||
part_url = re.findall(r'(/[^#]+)\.ts',vod_m3u8)
|
|
||||||
real_url = []
|
|
||||||
for i in part_url:
|
|
||||||
i = vod_base + i + ".ts"
|
|
||||||
real_url.append(i)
|
|
||||||
type_ = ''
|
|
||||||
size = 0
|
|
||||||
for url in real_url:
|
|
||||||
_, type_, temp = url_info(url)
|
|
||||||
size += temp or 0
|
|
||||||
|
|
||||||
print_info(site_info, title, type_ or 'ts', size)
|
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:
|
if not info_only:
|
||||||
download_urls(real_url, title, type_ or 'ts', size, output_dir, merge = merge)
|
download_url_ffmpeg(real_url, title, 'flv', {}, output_dir = output_dir, merge = merge)
|
||||||
else:
|
|
||||||
NotImplementedError('Unknown_video_type')
|
|
||||||
|
|
||||||
site_info = "zhanqi.tv"
|
site_info = "www.zhanqi.tv"
|
||||||
download = zhanqi_download
|
download = zhanqi_download
|
||||||
download_playlist = playlist_not_supported('zhanqi')
|
download_playlist = playlist_not_supported('zhanqi')
|
Loading…
Reference in New Issue
Block a user