# -*- coding: utf-8 -*- # @Author : ChenZhaoyuchen # @Time : 2024/9/13 15:02 # @File : GetVideoInfo.py import json import re from .GetResponse import GetResponse from .setting import url def GetVideoInfo() -> str: response = GetResponse(url = url) html_audio = response.text info = re.findall('', html_audio)[0] json_data = json.loads(info) audio_url = json_data['data']['dash']['audio'][0]['baseUrl'] video_url = json_data['data']['dash']['video'][0]['baseUrl'] title = re.findall('(.*?)', html_audio) title = title[0] if title: illegal_chars = fr'<|>\/:"*?' def remove_illegal_chars(title_ill): for char in illegal_chars: title_ill = title_ill.replace(char, "") return title_ill else: return None title = remove_illegal_chars(title) print("title:",title) return (title, audio_url, video_url)