Compare commits

..

No commits in common. "c7dcf0b31e57bb98472da7cf293f523caa81c4a7" and "1f6b90ed8db7006e2f2d539c41c8f3e59058dd00" have entirely different histories.

6 changed files with 22 additions and 65 deletions

View File

@ -1276,7 +1276,6 @@ The available fields are:
- `vbr` (numeric): Average video bitrate in KBit/s
- `fps` (numeric): Frame rate
- `dynamic_range` (string): The dynamic range of the video
- `audio_channels` (numeric): The number of audio channels
- `stretched_ratio` (float): `width:height` of the video's pixels, if not square
- `vcodec` (string): Name of the video codec in use
- `container` (string): Name of the container format
@ -1530,7 +1529,6 @@ The available fields are:
- `res`: Video resolution, calculated as the smallest dimension.
- `fps`: Framerate of video
- `hdr`: The dynamic range of the video (`DV` > `HDR12` > `HDR10+` > `HDR10` > `HLG` > `SDR`)
- `channels`: The number of audio channels
- `tbr`: Total average bitrate in KBit/s
- `vbr`: Average video bitrate in KBit/s
- `abr`: Average audio bitrate in KBit/s

View File

@ -527,8 +527,7 @@ class YoutubeDL:
"""
_NUMERIC_FIELDS = {
'width', 'height', 'asr', 'audio_channels', 'fps',
'tbr', 'abr', 'vbr', 'filesize', 'filesize_approx',
'width', 'height', 'tbr', 'abr', 'asr', 'vbr', 'fps', 'filesize', 'filesize_approx',
'timestamp', 'release_timestamp',
'duration', 'view_count', 'like_count', 'dislike_count', 'repost_count',
'average_rating', 'comment_count', 'age_limit',
@ -540,7 +539,7 @@ class YoutubeDL:
_format_fields = {
# NB: Keep in sync with the docstring of extractor/common.py
'url', 'manifest_url', 'manifest_stream_number', 'ext', 'format', 'format_id', 'format_note',
'width', 'height', 'resolution', 'dynamic_range', 'tbr', 'abr', 'acodec', 'asr', 'audio_channels',
'width', 'height', 'resolution', 'dynamic_range', 'tbr', 'abr', 'acodec', 'asr',
'vbr', 'fps', 'vcodec', 'container', 'filesize', 'filesize_approx',
'player_url', 'protocol', 'fragment_base_url', 'fragments', 'is_from_start',
'preference', 'language', 'language_preference', 'quality', 'source_preference',
@ -2130,7 +2129,6 @@ class YoutubeDL:
'acodec': the_only_audio.get('acodec'),
'abr': the_only_audio.get('abr'),
'asr': the_only_audio.get('asr'),
'audio_channels': the_only_audio.get('audio_channels')
})
return new_dict
@ -3571,7 +3569,6 @@ class YoutubeDL:
format_field(f, func=self.format_resolution, ignore=('audio only', 'images')),
format_field(f, 'fps', '\t%d', func=round),
format_field(f, 'dynamic_range', '%s', ignore=(None, 'SDR')).replace('HDR', ''),
format_field(f, 'audio_channels', '\t%s'),
delim,
format_field(f, 'filesize', ' \t%s', func=format_bytes) + format_field(f, 'filesize_approx', '~\t%s', func=format_bytes),
format_field(f, 'tbr', '\t%dk', func=round),
@ -3591,7 +3588,7 @@ class YoutubeDL:
delim=' '),
] for f in formats if f.get('preference') is None or f['preference'] >= -1000]
header_line = self._list_format_headers(
'ID', 'EXT', 'RESOLUTION', '\tFPS', 'HDR', 'CH', delim, '\tFILESIZE', '\tTBR', 'PROTO',
'ID', 'EXT', 'RESOLUTION', '\tFPS', 'HDR', delim, '\tFILESIZE', '\tTBR', 'PROTO',
delim, 'VCODEC', '\tVBR', 'ACODEC', '\tABR', '\tASR', 'MORE INFO')
return render_table(

View File

@ -154,7 +154,6 @@ class InfoExtractor:
* abr Average audio bitrate in KBit/s
* acodec Name of the audio codec in use
* asr Audio sampling rate in Hertz
* audio_channels Number of audio channels
* vbr Average video bitrate in KBit/s
* fps Frame rate
* vcodec Name of the video codec in use
@ -1669,7 +1668,7 @@ class InfoExtractor:
regex = r' *((?P<reverse>\+)?(?P<field>[a-zA-Z0-9_]+)((?P<separator>[~:])(?P<limit>.*?))?)? *$'
default = ('hidden', 'aud_or_vid', 'hasvid', 'ie_pref', 'lang', 'quality',
'res', 'fps', 'hdr:12', 'channels', 'codec:vp9.2', 'size', 'br', 'asr',
'res', 'fps', 'hdr:12', 'codec:vp9.2', 'size', 'br', 'asr',
'proto', 'ext', 'hasaud', 'source', 'id') # These must not be aliases
ytdl_default = ('hasaud', 'lang', 'quality', 'tbr', 'filesize', 'vbr',
'height', 'width', 'proto', 'vext', 'abr', 'aext',
@ -1705,7 +1704,6 @@ class InfoExtractor:
'height': {'convert': 'float_none'},
'width': {'convert': 'float_none'},
'fps': {'convert': 'float_none'},
'channels': {'convert': 'float_none', 'field': 'audio_channels'},
'tbr': {'convert': 'float_none'},
'vbr': {'convert': 'float_none'},
'abr': {'convert': 'float_none'},
@ -1719,14 +1717,13 @@ class InfoExtractor:
'res': {'type': 'multiple', 'field': ('height', 'width'),
'function': lambda it: (lambda l: min(l) if l else 0)(tuple(filter(None, it)))},
# Actual field names
# For compatibility with youtube-dl
'format_id': {'type': 'alias', 'field': 'id'},
'preference': {'type': 'alias', 'field': 'ie_pref'},
'language_preference': {'type': 'alias', 'field': 'lang'},
'source_preference': {'type': 'alias', 'field': 'source'},
'protocol': {'type': 'alias', 'field': 'proto'},
'filesize_approx': {'type': 'alias', 'field': 'fs_approx'},
'audio_channels': {'type': 'alias', 'field': 'channels'},
# Deprecated
'dimension': {'type': 'alias', 'field': 'res', 'deprecated': True},

View File

@ -3,7 +3,7 @@ from ..utils import (
ExtractorError,
determine_ext,
int_or_none,
traverse_obj,
try_get,
unescapeHTML,
url_or_none,
)
@ -11,20 +11,18 @@ from ..utils import (
class NineGagIE(InfoExtractor):
IE_NAME = '9gag'
IE_DESC = '9GAG'
_VALID_URL = r'https?://(?:www\.)?9gag\.com/gag/(?P<id>[^/?&#]+)'
_TESTS = [{
'url': 'https://9gag.com/gag/ae5Ag7B',
'info_dict': {
'id': 'ae5Ag7B',
'ext': 'webm',
'ext': 'mp4',
'title': 'Capybara Agility Training',
'upload_date': '20191108',
'timestamp': 1573237208,
'thumbnail': 'https://img-9gag-fun.9cache.com/photo/ae5Ag7B_460s.jpg',
'categories': ['Awesome'],
'tags': ['Awesome'],
'tags': ['Weimaraner', 'American Pit Bull Terrier'],
'duration': 44,
'like_count': int,
'dislike_count': int,
@ -34,26 +32,6 @@ class NineGagIE(InfoExtractor):
# HTML escaped title
'url': 'https://9gag.com/gag/av5nvyb',
'only_matching': True,
}, {
# Non Anonymous Uploader
'url': 'https://9gag.com/gag/ajgp66G',
'info_dict': {
'id': 'ajgp66G',
'ext': 'webm',
'title': 'Master Shifu! Or Splinter! You decide:',
'upload_date': '20220806',
'timestamp': 1659803411,
'thumbnail': 'https://img-9gag-fun.9cache.com/photo/ajgp66G_460s.jpg',
'categories': ['Funny'],
'tags': ['Funny'],
'duration': 26,
'like_count': int,
'dislike_count': int,
'comment_count': int,
'uploader': 'Peter Klaus',
'uploader_id': 'peterklaus12',
'uploader_url': 'https://9gag.com/u/peterklaus12',
}
}]
def _real_extract(self, url):
@ -68,6 +46,8 @@ class NineGagIE(InfoExtractor):
'The given url does not contain a video',
expected=True)
title = unescapeHTML(post['title'])
duration = None
formats = []
thumbnails = []
@ -118,7 +98,7 @@ class NineGagIE(InfoExtractor):
formats.append(common)
self._sort_formats(formats)
section = traverse_obj(post, ('postSection', 'name'))
section = try_get(post, lambda x: x['postSection']['name'])
tags = None
post_tags = post.get('tags')
@ -130,19 +110,18 @@ class NineGagIE(InfoExtractor):
continue
tags.append(tag_key)
get_count = lambda x: int_or_none(post.get(x + 'Count'))
return {
'id': post_id,
'title': unescapeHTML(post.get('title')),
'title': title,
'timestamp': int_or_none(post.get('creationTs')),
'duration': duration,
'uploader': traverse_obj(post, ('creator', 'fullName')),
'uploader_id': traverse_obj(post, ('creator', 'username')),
'uploader_url': url_or_none(traverse_obj(post, ('creator', 'profileUrl'))),
'formats': formats,
'thumbnails': thumbnails,
'like_count': int_or_none(post.get('upVoteCount')),
'dislike_count': int_or_none(post.get('downVoteCount')),
'comment_count': int_or_none(post.get('commentsCount')),
'like_count': get_count('upVote'),
'dislike_count': get_count('downVote'),
'comment_count': get_count('comments'),
'age_limit': 18 if post.get('nsfw') == 1 else None,
'categories': [section] if section else None,
'tags': tags,

View File

@ -95,7 +95,7 @@ class WASDTVStreamIE(WASDTVBaseIE):
class WASDTVRecordIE(WASDTVBaseIE):
IE_NAME = 'wasdtv:record'
_VALID_URL = r'https?://wasd\.tv/[^/#?]+(?:/videos)?\?record=(?P<id>\d+)$'
_VALID_URL = r'https?://wasd\.tv/[^/#?]+/videos\?record=(?P<id>\d+)$'
_TESTS = [{
'url': 'https://wasd.tv/spacemita/videos?record=907755',
'md5': 'c9899dd85be4cc997816ff9f9ca516ce',
@ -110,9 +110,6 @@ class WASDTVRecordIE(WASDTVBaseIE):
'is_live': False,
'view_count': int,
},
}, {
'url': 'https://wasd.tv/spacemita?record=907755',
'only_matching': True,
}]
def _get_container(self, url):

View File

@ -109,8 +109,7 @@ INNERTUBE_CLIENTS = {
'INNERTUBE_CONTEXT': {
'client': {
'clientName': 'ANDROID',
'clientVersion': '17.29.34',
'androidSdkVersion': 30
'clientVersion': '17.28.34',
}
},
'INNERTUBE_CONTEXT_CLIENT_NAME': 3,
@ -121,8 +120,7 @@ INNERTUBE_CLIENTS = {
'INNERTUBE_CONTEXT': {
'client': {
'clientName': 'ANDROID_EMBEDDED_PLAYER',
'clientVersion': '17.29.34',
'androidSdkVersion': 30
'clientVersion': '17.28.34',
},
},
'INNERTUBE_CONTEXT_CLIENT_NAME': 55,
@ -134,7 +132,6 @@ INNERTUBE_CLIENTS = {
'client': {
'clientName': 'ANDROID_MUSIC',
'clientVersion': '5.16.51',
'androidSdkVersion': 30
}
},
'INNERTUBE_CONTEXT_CLIENT_NAME': 21,
@ -146,7 +143,6 @@ INNERTUBE_CLIENTS = {
'client': {
'clientName': 'ANDROID_CREATOR',
'clientVersion': '22.28.100',
'androidSdkVersion': 30
},
},
'INNERTUBE_CONTEXT_CLIENT_NAME': 14,
@ -2258,10 +2254,6 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'tags': [],
'uploader_url': 'http://www.youtube.com/user/nao20010128nao',
}
}, {
'note': '6 channel audio',
'url': 'https://www.youtube.com/watch?v=zgdo7-RRjgo',
'only_matching': True,
}
]
@ -3146,7 +3138,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
pr_video_id = traverse_obj(pr, ('videoDetails', 'videoId'))
if pr_video_id and pr_video_id != video_id:
self.report_warning(
f'Skipping player response from {client} client (got player response for video "{pr_video_id}" instead of "{video_id}")' + bug_reports_message())
f'{client} client returned a player response for "{pr_video_id}" instead of "{video_id}"' + bug_reports_message())
else:
prs.append(pr)
@ -3261,13 +3253,10 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'%s%s' % (audio_track.get('displayName') or '',
' (default)' if language_preference > 0 else ''),
fmt.get('qualityLabel') or quality.replace('audio_quality_', ''),
try_get(fmt, lambda x: x['projectionType'].replace('RECTANGULAR', '').lower()),
try_get(fmt, lambda x: x['spatialAudioType'].replace('SPATIAL_AUDIO_TYPE_', '').lower()),
throttled and 'THROTTLED', is_damaged and 'DAMAGED', delim=', '),
# Format 22 is likely to be damaged. See https://github.com/yt-dlp/yt-dlp/issues/3372
'source_preference': -10 if throttled else -5 if itag == '22' else -1,
'fps': int_or_none(fmt.get('fps')) or None,
'audio_channels': fmt.get('audioChannels'),
'height': height,
'quality': q(quality),
'has_drm': bool(fmt.get('drmFamilies')),
@ -3588,7 +3577,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
formats.extend(self._extract_storyboard(player_responses, duration))
# source_preference is lower for throttled/potentially damaged formats
self._sort_formats(formats, ('quality', 'res', 'fps', 'hdr:12', 'channels', 'source', 'codec:vp9.2', 'lang', 'proto'))
self._sort_formats(formats, ('quality', 'res', 'fps', 'hdr:12', 'source', 'codec:vp9.2', 'lang', 'proto'))
info = {
'id': video_id,