Compare commits

...

5 Commits

Author SHA1 Message Date
naginatana
321d8a4862
Update tudou.py 2023-10-01 22:34:08 +08:00
naginatana
7c149a1027
Update tudou.py 2023-10-01 22:12:19 +08:00
naginatana
41c6cc6748
Update tudou.py 2023-10-01 22:08:06 +08:00
naginatana
3665483dc7
Update tudou.py 2023-10-01 22:04:47 +08:00
naginatana
9728d5bcd5
Update tudou.py 2023-10-01 22:01:13 +08:00

View File

@ -4,11 +4,10 @@ import re
class TudouIE(InfoExtractor):
_VALID_URL = r'https?://(?:play\.)?tudou\.com/v_show/(?P<id>id_[\w=.]+)'
_VALID_URL = r'https?://(?:play\.)?tudou\.com/v_show/(?P<id>id_[\w=]+).html[\w\W]+'
_TESTS = [{
'url': 'https://play.tudou.com/v_show/id_XNjAxNjI2OTU3Ng',
'url': 'https://play.tudou.com/v_show/id_XNjAxNjI2OTU3Ng.html?',
'md5': 'to be updated',
'info_dict': {
'id': 'XNjAxNjI2OTU3Ng==',
'ext': 'mp4',
@ -35,23 +34,19 @@ class TudouIE(InfoExtractor):
cna = re.findall(re_cna, urlh.headers['set-cookie'])[0].replace("; expires", "")
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 = {
"vid": video_id,
"ccode": "050F",
"client_ip": "192.168.1.1",
"utid": cna,
"client_ts": ts1,
"ckey": "140#XvSoigEEzzPw6zo2K5XTwpN8s9xI9h7FQeSkq6lrpeQ3Qm8xyFnPG9Uxtq6aSBxXVXwkqv6L4/GKvKzgD5oqlbzxhQfIlJgkzFnb0OK7lpTzzPzbVXlqlbrofJH+V3hqabzi228++bP0EHmiuZsHofFc74upoC6MkpscNHvXzJK+//Wna4Zt+dTHiQWqckfMQdZWTBs1ZpU/wadIq8nYxy5uZ+cRepqZMra+XLkaqMgGBcF/Ie/igRJDCcHl4d28aId7B+XOW/V6+gNOtDc+y6piEy1V51R4rYd41m6FkoEE4ix4eQE3VY7wvREVNJfR54V4qc3aqV4zzx+dkH8STo4ABYgr27bP9Vi0NBwse6wOOAJfYbnYZQdqQ4rlte/TfegJDmiufcPHd7sUG/A0RYx3pHQ9wYa3lQS3MjIjWejRlGzQdt0fxqEhcHuu10zfo4lhobcXARy7rDT2fb6wJrCHf98c0l8iGiOTSXVZVvWiQMM1est+EACvaMFB/baJm1BjCMKeS2zQEgUkRmulz00icM/W0BS8sEOR1RpOP4WXpji1HjEDpt2MTVHGqUwo223u03IGTHK3Z+Ki1ujWXKKUP+E1VESmBF0rzBkR/dyP20hRbGSpfX7eRVABF6npnWgdgjzQB4FOxAjHPn5CupypFZDYIdKyfQyC45mGS5WI6Wz9JmoFjxO7ikUKKP6p0KP3nj+5YTtbwUNpciVhD+mOZZKq6+dT6G7cfBhOzZQFXs66gZ3174KWt6sLTcvLzEezfoA0mO0NIx0mZZlL1lYonycOtcByLpKmSW5Xd96FWP5fuenIBUUJZCectNPgB/nFNGpeZuhruYbBbG843gwtfiXaRp2r4ssDM07/pPsEfk6MzcmtAxIimwdRjv6lSx+QSEANWRazykZneHEpH1R0uB0BjJdozYDKK84KMsNd+jjg6XTz9Ai0KZYMUJXN1Vz=",
"vip": "0",
# "callback": "", # youkuPlayer_call_1695807088862
# "_t": "08847696931775378"
'vid': video_id,
'ccode': '050F',
'client_ip': '192.168.1.1',
'utid': cna,
'client_ts': ts1,
'ckey': '140#XvSoigEEzzPw6zo2K5XTwpN8s9xI9h7FQeSkq6lrpeQ3Qm8xyFnPG9Uxtq6aSBxXVXwkqv6L4/GKvKzgD5oqlbzxhQfIlJgkzFnb0OK7lpTzzPzbVXlqlbrofJH+V3hqabzi228++bP0EHmiuZsHofFc74upoC6MkpscNHvXzJK+//Wna4Zt+dTHiQWqckfMQdZWTBs1ZpU/wadIq8nYxy5uZ+cRepqZMra+XLkaqMgGBcF/Ie/igRJDCcHl4d28aId7B+XOW/V6+gNOtDc+y6piEy1V51R4rYd41m6FkoEE4ix4eQE3VY7wvREVNJfR54V4qc3aqV4zzx+dkH8STo4ABYgr27bP9Vi0NBwse6wOOAJfYbnYZQdqQ4rlte/TfegJDmiufcPHd7sUG/A0RYx3pHQ9wYa3lQS3MjIjWejRlGzQdt0fxqEhcHuu10zfo4lhobcXARy7rDT2fb6wJrCHf98c0l8iGiOTSXVZVvWiQMM1est+EACvaMFB/baJm1BjCMKeS2zQEgUkRmulz00icM/W0BS8sEOR1RpOP4WXpji1HjEDpt2MTVHGqUwo223u03IGTHK3Z+Ki1ujWXKKUP+E1VESmBF0rzBkR/dyP20hRbGSpfX7eRVABF6npnWgdgjzQB4FOxAjHPn5CupypFZDYIdKyfQyC45mGS5WI6Wz9JmoFjxO7ikUKKP6p0KP3nj+5YTtbwUNpciVhD+mOZZKq6+dT6G7cfBhOzZQFXs66gZ3174KWt6sLTcvLzEezfoA0mO0NIx0mZZlL1lYonycOtcByLpKmSW5Xd96FWP5fuenIBUUJZCectNPgB/nFNGpeZuhruYbBbG843gwtfiXaRp2r4ssDM07/pPsEfk6MzcmtAxIimwdRjv6lSx+QSEANWRazykZneHEpH1R0uB0BjJdozYDKK84KMsNd+jjg6XTz9Ai0KZYMUJXN1Vz=',
'vip': '0',
}
headers1 = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0",
"Referer": "https://play.tudou.com/"
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/117.0',
'Referer': 'https://play.tudou.com/'
}
# About video_url
@ -59,28 +54,27 @@ class TudouIE(InfoExtractor):
# 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'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(
'https://ups.youku.com/ups/get.json', video_id,
'Downloading JSON metadata',
query=params1, headers=headers1)
list_of_url = []
list_of_video_data = []
for item in data_m3u8['data']['stream']:
item_of_url = {
item_of_video_data = {
'url': item['segs'][0]['cdn_url'].replace('http://', 'https://'),
'ext': 'mp4',
'filesize': item['size'],
'width': item['width'],
'height': item['height'],
'size': item['size'],
'cdn_url': item['segs'][0]['cdn_url'].replace('http://', 'https://'),
}
list_of_url.append(item_of_url)
# 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)
list_of_video_data.append(item_of_video_data)
sorted_list_of_video_data = sorted(list_of_video_data, key=lambda d: d['filesize'], reverse=False)
return {
'id': video_id,
'title': title,
'ext': 'mp4',
'url': sorted_list_of_url[0]['cdn_url'],
'show_name': show_name,
'ext': 'mp4',
'formats': sorted_list_of_video_data,
}