def parseIqiyiUrl(url, headers = {}): data = json.loads(tools.getText(url, headers)) program = data['data']['program'] if type(program) == list: print('服务器返回错误,可能原因:愛奇藝台灣站需要使用代理下载(http_proxy/https_proxy)') exit() subtitles = [] filterVideos = list(filter(lambda each: each.get('m3u8'), program['video'])) if len(filterVideos): content = filterVideos[0]['m3u8'] if content.startswith('#EXTM3U'): videoType = 'hls' audioUrls, videoUrls = [], tools.filterHlsUrls(content) else: videoType = 'dash' audioUrls, videoUrls = parseIqiyiMpd(content, headers) else: filterVideos = list(filter(lambda each: each.get('fs'), program['video'])) fsList = filterVideos[0]['fs'] basePath = data['data']['dd'] infoUrls = list(map(lambda each: basePath + each['l'], fsList)) videoType = 'partial' audioUrls, videoUrls = [], parseIqiyiInfoUrls(infoUrls, headers) if 'stl' in program: defaultSrts = list(filter(lambda x: x.get('_selected'), program['stl'])) srts = defaultSrts + list(filter(lambda x: not x.get('_selected'), program['stl'])) basePath = data['data']['dstl'] subtitles = [ (srt.get('_name', 'default'), basePath + srt['srt']) for srt in srts ] return videoType, audioUrls, videoUrls, subtitles
def parseIqiyiUrl(url, headers={}): data = json.loads(tools.getText(url, headers)) program = data['data']['program'] if type(program) == list: print('服务器返回错误,可能原因:愛奇藝台灣站需要使用代理下载(http_proxy/https_proxy)') exit() videos = program['video'] filterVideos = list(filter(lambda each: each.get('m3u8'), videos)) if len(filterVideos): content = filterVideos[0]['m3u8'] if content.startswith('#EXTM3U'): videoType = 'hls' audioUrls, videoUrls = [], tools.filterHlsUrls(content) else: videoType = 'dash' audioUrls, videoUrls = parseIqiyiMpd(content, headers) else: filterVideos = list(filter(lambda each: each.get('fs'), videos)) fsList = filterVideos[0]['fs'] basePath = data['data']['dd'] infoUrls = list(map(lambda each: basePath + each['l'], fsList)) videoType = 'partial' audioUrls, videoUrls = [], parseIqiyiInfoUrls(infoUrls, headers) return videoType, audioUrls, videoUrls
def parseIqiyiUrl(url, headers={}): data = json.loads(tools.getText(url, headers)) videos = data['data']['program']['video'] videos = list(filter(lambda each: each.get('m3u8'), videos)) content = videos[0]['m3u8'] if content.startswith('#EXTM3U'): videoType = 'hls' audioUrls, videoUrls = [], tools.filterHlsUrls(content) else: videoType = 'dash' audioUrls, videoUrls = parseIqiyiMpd(content, headers) return videoType, audioUrls, videoUrls
def parseHls(url, headers = {}): content = tools.getText(url, headers) return tools.filterHlsUrls(content, url)