-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
[extractor/youtube] Add the first 3 characters of client name in format_note
#6254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
That would be nice |
|
yt_dlp/extractor/youtube.py
Outdated
@@ -3736,6 +3740,8 @@ def _extract_formats_and_subtitles(self, streaming_data, video_id, player_url, l | |||
if is_damaged: | |||
self.report_warning( | |||
f'{video_id}: Some formats are possibly damaged. They will be deprioritized', only_once=True) | |||
|
|||
client_name = (traverse_obj(query, ('c', 0, {str})) or fmt.get(STRAMING_DATA_CLIENT_NAME) or '')[0:3].upper() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With 3 chars, we can't tell web_embedded
etc apart. Maybe use thw whole string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason behind 3 characters is that it's narrow enough not to cause break lines in my console and it's long enough to identify which device is problematic, at first glance
And if we need the whole string, it should be done by editing code as needed
Co-authored-by: pukkandan <pukkandan.ytdlp@gmail.com>
What do you think about this? diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py
index cfad8b325..397e68137 100644
--- a/yt_dlp/extractor/youtube.py
+++ b/yt_dlp/extractor/youtube.py
@@ -250,6 +250,11 @@ def _split_innertube_client(client_name):
return client_name, base, variant[0] if variant else None
+def short_client_name(client_name):
+ parts = _split_innertube_client(client_name)[0].replace('embedscreen', 'e_s').split('_')
+ return ''.join(x[0] for x in parts).upper()
+
+
def build_innertube_clients():
THIRD_PARTY = {
'embedUrl': 'https://www.youtube.com/', # Can be any valid URL
@@ -3620,8 +3625,9 @@ def append_client(*client_names):
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())
else:
- # set the client name in streamingData so that we can show it on -F
- (traverse_obj(pr, ('streamingData', {dict})) or {})[STREAMING_DATA_CLIENT_NAME] = client
+ # Save client name for introspection later
+ for f in traverse_obj(pr, ('streamingData', ('formats', 'adaptiveFormats'), ..., {dict})):
+ f[STREAMING_DATA_CLIENT_NAME] = short_client_name(client)
prs.append(pr)
# creator clients can bypass AGE_VERIFICATION_REQUIRED if logged in
@@ -3741,7 +3747,7 @@ def _extract_formats_and_subtitles(self, streaming_data, video_id, player_url, l
self.report_warning(
f'{video_id}: Some formats are possibly damaged. They will be deprioritized', only_once=True)
- client_name = (traverse_obj(query, ('c', 0, {str})) or fmt.get(STREAMING_DATA_CLIENT_NAME) or '')[0:3].upper()
+ client_name = fmt.get(STREAMING_DATA_CLIENT_NAME)
dct = {
'asr': int_or_none(fmt.get('audioSampleRate')),
'filesize': int_or_none(fmt.get('contentLength')),
@@ -3754,7 +3760,6 @@ def _extract_formats_and_subtitles(self, streaming_data, video_id, player_url, l
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',
- # for convenience of seeing client name in -F without debugging
client_name,
delim=', '),
# Format 22 is likely to be damaged. See https://github.com/yt-dlp/yt-dlp/issues/3372
@@ -3833,7 +3838,7 @@ def process_manifest_format(f, proto, client_name, itag):
subtitles = {}
for sd in streaming_data:
- client_name = (sd.get(STREAMING_DATA_CLIENT_NAME) or '')[0:3].upper()
+ client_name = sd.get(STREAMING_DATA_CLIENT_NAME)
hls_manifest_url = 'hls' not in skip_manifests and sd.get('hlsManifestUrl')
if hls_manifest_url: It's compact and gives more info. Issue is that it's harder to read for those unfamilar with code
Also, maybe we could add it only with - client_name,
+ client_name if self.get_param('verbose') else None, cc @coletdjnz |
You never replied, @Lesmiscore |
That's fine to me, but you don't like it?
Use the YouTube's client name as always? |
You could use the client integer number instead if it needs to be compact, though it's a bit less clear. |
This comment was marked as off-topic.
This comment was marked as off-topic.
The code in #6254 (comment) can be tweaked to pass any data about the client into where formats are built. We just need to decide how we want it to be displayed.
Using numeric code is worse than abbreviation (my code) imo |
…p#6254) Authored by: Lesmiscore, pukkandan
* [utils] Add hackish 'now' support for --download-sections * [utils] Add microseconds to unified_timestamp * [common] Extract start and end keys for Dash fragments * [utils] Allow using local timezone for 'now' timestamps * Use local timezone for download sections * Add fixme in modified parse_chapters function A range like '*(now-1hour)-(now-30minutes)' doesn't work * [youtube] Support --download-sections for YT Livestream from start * Create last_segment_url only if necessary * Improve parse_chapters comments * Fix linter * [extractor/iq] Set more language codes (yt-dlp#6476) Authored by: D0LLYNH0 * [extractor/opencast] Add ltitools to `_VALID_URL` (yt-dlp#6371) Authored by: C0D3D3V * [downloader/curl] Fix progress reporting Bug in 8c53322 Closes yt-dlp#6490 * [extractor/youtube] Bypass throttling for `-f17` and related cleanup Thanks @AudricV for the finding * [extractor/twitch] Fix `is_live` (yt-dlp#6500) Closes yt-dlp#6494 Authored by: elyse0 * [extractor/cbc:gem] Update `_VALID_URL` (yt-dlp#6499) Authored by: makeworld-the-better-one Closes yt-dlp#6395 * Support loading info.json with a list at it's root * [extractor/hidive] Fix login Fixes yt-dlp#6493 (comment) * [extractor/opencast] Fix format bug (yt-dlp#6512) Authored by: C0D3D3V * [extractor/rokfin] Re-construct manifest url (yt-dlp#6507) Authored by: vampirefrog * [extractor/youtube] Add client name to `format_note` when `-v` (yt-dlp#6254) Authored by: Lesmiscore, pukkandan * [extractor/youtube] Add extractor-arg `include_duplicate_formats` * [extractor/youtube] Construct fragment list lazily Building fragment list for all formats take significant time for large videos * Support negative durations * Revert "[utils] Allow using local timezone for 'now' timestamps" This reverts commit 1799a6a. * Add fragment count * Fix unified_timestamp * Remove tz_aware date code * Add debug for selected section * Add initial documentation * Fix linter * Fix linter * Allow days in parse_duration * Improve option documentation * Add some documentation * Lock less agressively This gives a speed performance of about 30% * Fix return values of _extract_sequence_from_mpd * Always compute last_seq * Support for epoch timestamps * Update options docs * Restore README.md I think this is auto-generated by some script * Add warning about --download-sections without --live-from-start * Fix bug after merge * Update yt_dlp/options.py * Cleanup --------- Co-authored-by: Elyse <26639800+elyse0@users.noreply.github.com> Co-authored-by: Sophire <115919609+sophie0x@users.noreply.github.com> Co-authored-by: D0LLYNH0 <67797325+D0LLYNH0@users.noreply.github.com> Co-authored-by: Daniel Vogt <daniel-vogt@mail.de> Co-authored-by: pukkandan <pukkandan.ytdlp@gmail.com> Co-authored-by: makeworld <25111343+makeworld-the-better-one@users.noreply.github.com> Co-authored-by: Daniel Vogt <c0d3d3v@mag-keinen-spam.de> Co-authored-by: vampirefrog <vampirefrog@users.noreply.github.com> Co-authored-by: Lesmiscore <nao20010128@gmail.com> Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com> Co-authored-by: bashonly <bashonly@bashonly.com>
…p#6254) Authored by: Lesmiscore, pukkandan
IMPORTANT: PRs without the template will be CLOSED
Description of your pull request and other information
This PR adds the client names to
format_note
returned by the Youtube extractor for convenienceIf you wish to enforce this to all the formats (MPD and HLS), a little rewrite would be required
p.s. make a release before reviewing this
Template
Before submitting a pull request make sure you have:
In order to be accepted and merged into yt-dlp each piece of code must be in public domain or released under Unlicense. Check one of the following options:
What is the purpose of your pull request?