Compare commits

..

No commits in common. "321d8a4862d61034d02cd32a83e30b293e65a8e3" and "9679654fe91af86887a84335d84efd5ae3e30328" have entirely different histories.

View File

@ -4,10 +4,11 @@ import re
class TudouIE(InfoExtractor): class TudouIE(InfoExtractor):
_VALID_URL = r'https?://(?:play\.)?tudou\.com/v_show/(?P<id>id_[\w=]+).html[\w\W]+' _VALID_URL = r'https?://(?:play\.)?tudou\.com/v_show/(?P<id>id_[\w=.]+)'
_TESTS = [{ _TESTS = [{
'url': 'https://play.tudou.com/v_show/id_XNjAxNjI2OTU3Ng.html?', 'url': 'https://play.tudou.com/v_show/id_XNjAxNjI2OTU3Ng',
'md5': 'to be updated', 'md5': 'to be updated',
'info_dict': { 'info_dict': {
'id': 'XNjAxNjI2OTU3Ng==', 'id': 'XNjAxNjI2OTU3Ng==',
'ext': 'mp4', 'ext': 'mp4',
@ -34,19 +35,23 @@ class TudouIE(InfoExtractor):
cna = re.findall(re_cna, urlh.headers['set-cookie'])[0].replace("; expires", "") cna = re.findall(re_cna, urlh.headers['set-cookie'])[0].replace("; expires", "")
ts1 = time.time() * 1000 ts1 = time.time() * 1000
# About params1{} (sometimes they call it querystring?)
# IS there a way to know which value is essential to make the request work?
params1 = { params1 = {
'vid': video_id, "vid": video_id,
'ccode': '050F', "ccode": "050F",
'client_ip': '192.168.1.1', "client_ip": "192.168.1.1",
'utid': cna, "utid": cna,
'client_ts': ts1, "client_ts": ts1,
'ckey': '140#XvSoigEEzzPw6zo2K5XTwpN8s9xI9h7FQeSkq6lrpeQ3Qm8xyFnPG9Uxtq6aSBxXVXwkqv6L4/GKvKzgD5oqlbzxhQfIlJgkzFnb0OK7lpTzzPzbVXlqlbrofJH+V3hqabzi228++bP0EHmiuZsHofFc74upoC6MkpscNHvXzJK+//Wna4Zt+dTHiQWqckfMQdZWTBs1ZpU/wadIq8nYxy5uZ+cRepqZMra+XLkaqMgGBcF/Ie/igRJDCcHl4d28aId7B+XOW/V6+gNOtDc+y6piEy1V51R4rYd41m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HQ9wYa3lQS3MjIjWejRlGzQdt0fxqEhcHuu10zfo4lhobcXARy7rDT2fb6wJrCHf98c0l8iGiOTSXVZVvWiQMM1est+EACvaMFB/baJm1BjCMKeS2zQEgUkRmulz00icM/W0BS8sEOR1RpOP4WXpji1HjEDpt2MTVHGqUwo223u03IGTHK3Z+Ki1ujWXKKUP+E1VESmBF0rzBkR/dyP20hRbGSpfX7eRVABF6npnWgdgjzQB4FOxAjHPn5CupypFZDYIdKyfQyC45mGS5WI6Wz9JmoFjxO7ikUKKP6p0KP3nj+5YTtbwUNpciVhD+mOZZKq6+dT6G7cfBhOzZQFXs66gZ3174KWt6sLTcvLzEezfoA0mO0NIx0mZZlL1lYonycOtcByLpKmSW5Xd96FWP5fuenIBUUJZCectNPgB/nFNGpeZuhruYbBbG843gwtfiXaRp2r4ssDM07/pPsEfk6MzcmtAxIimwdRjv6lSx+QSEANWRazykZneHEpH1R0uB0BjJdozYDKK84KMsNd+jjg6XTz9Ai0KZYMUJXN1Vz=",
'vip': '0', "vip": "0",
# "callback": "", # youkuPlayer_call_1695807088862
# "_t": "08847696931775378"
} }
headers1 = { headers1 = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0', "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0",
'Referer': 'https://play.tudou.com/' "Referer": "https://play.tudou.com/"
} }
# About video_url # About video_url
@ -54,27 +59,28 @@ class TudouIE(InfoExtractor):
# This get.json file contains 4 cdn_url and 4 m3u8_url # This get.json file contains 4 cdn_url and 4 m3u8_url
# I'm not sure what cdn_url stands for, but it also delivers the full video # I'm not sure what cdn_url stands for, but it also delivers the full video
# I'll put the cdn_url here for now, if needed I can replace it with m3u8_url # I'll put the cdn_url here for now, if needed I can replace it with m3u8_url
# I probably need to do a bit more on stuff like cookies, to pass the authentication, I wonder how those values are calculated
data_m3u8 = self._download_json( data_m3u8 = self._download_json(
'https://ups.youku.com/ups/get.json', video_id, 'https://ups.youku.com/ups/get.json', video_id,
'Downloading JSON metadata', 'Downloading JSON metadata',
query=params1, headers=headers1) query=params1, headers=headers1)
list_of_video_data = [] list_of_url = []
for item in data_m3u8['data']['stream']: for item in data_m3u8['data']['stream']:
item_of_video_data = { item_of_url = {
'url': item['segs'][0]['cdn_url'].replace('http://', 'https://'),
'ext': 'mp4',
'filesize': item['size'],
'width': item['width'], 'width': item['width'],
'height': item['height'], 'height': item['height'],
'size': item['size'],
'cdn_url': item['segs'][0]['cdn_url'].replace('http://', 'https://'),
} }
list_of_video_data.append(item_of_video_data) list_of_url.append(item_of_url)
sorted_list_of_video_data = sorted(list_of_video_data, key=lambda d: d['filesize'], reverse=False) # Sort urls in descending order, according to size, so the first one in the list will always be the best quality one
sorted_list_of_url = sorted(list_of_url, key=lambda d: d['size'], reverse=True)
return { return {
'id': video_id, 'id': video_id,
'title': title, 'title': title,
'show_name': show_name,
'ext': 'mp4', 'ext': 'mp4',
'formats': sorted_list_of_video_data, 'url': sorted_list_of_url[0]['cdn_url'],
'show_name': show_name,
} }