Open hseg opened 6 days ago
Out of the 4 suggestions, only conditional formatting in output templates would be both useful and feasible, but it would only be feasible after output template refactoring; see #8511
In the meantime, maybe you could hack a workaround with --parse-metadata
like this:
--parse-meta "%(playlist_id)s %(playlist_index)s:PL[A-Za-z0-9_-]{32} (?P<playlist_index>[0-9]+)"
--parse-meta "%(playlist_id)s %(playlist_title)s:PL[A-Za-z0-9_-]{32} (?P<playlist_title>.+)"
-o "%(playlist_title,upload_date>%Y-%m-%d&{} - |)s%(playlist_index&{} - |)s.%(ext)s"
I was hoping you'd pick that option, but it didn't seem fair to push for it.
Testing that command, though, it doesn't seem to work on parse failures, see the log below. I tried fixing this, by appending eg |.*(?P<playlist_title>)
, but re (unlike regex) doesn't support branch reset, and in particular can't use the same capture group across two alternatives. I tried using the "has matched" predicate, but
((?P<isPL>PL[A-Za-z0-9_-]{32})|[A-Za-z0-9_-]{24}) (?(isPL)(?P<playlist_index>[0-9]+)|.*)
unexpectedly always parsed as a playlist.
I'm a little lost, but then again it's late and I'm afk. Don't know if I'll have time to test this tomorrow.
The log:
[youtube:tab] Extracting URL: ***@***.***
[youtube:tab] @PracticalEngineeringChannel: Downloading webpage
[youtube:tab] Downloading all uploads of the channel. To download only the videos in a specific tab, pass the tab's URL
[youtube:tab] @PracticalEngineeringChannel/shorts: Downloading webpage
[youtube:tab] Downloading as multiple playlists, separated by tabs. To download as a single playlist instead, pass https://www.youtube.com/playlist?list=UUMOqf8ab-42UUQIdVoKwjlQ
[download] Downloading playlist: Practical Engineering
[youtube:tab] Playlist Practical Engineering: Downloading 2 items of 2
[download] Downloading item 1 of 2
[download] Downloading playlist: Practical Engineering - Videos
[youtube:tab] UCMOqf8ab-42UUQIdVoKwjlQ page 1: Downloading API JSON
[youtube:tab] UCMOqf8ab-42UUQIdVoKwjlQ page 2: Downloading API JSON
[youtube:tab] UCMOqf8ab-42UUQIdVoKwjlQ page 3: Downloading API JSON
[youtube:tab] UCMOqf8ab-42UUQIdVoKwjlQ page 4: Downloading API JSON
[youtube:tab] UCMOqf8ab-42UUQIdVoKwjlQ page 5: Downloading API JSON
[youtube:tab] UCMOqf8ab-42UUQIdVoKwjlQ page 6: Downloading API JSON
[youtube:tab] Playlist Practical Engineering - Videos: Downloading 189 items of 189
[download] Downloading item 1 of 189
[youtube] Extracting URL: https://www.youtube.com/watch?v=sH1PVVJuBtE
[youtube] sH1PVVJuBtE: Downloading webpage
[youtube] sH1PVVJuBtE: Downloading ios player API JSON
[youtube] sH1PVVJuBtE: Downloading mweb player API JSON
[youtube] sH1PVVJuBtE: Downloading player a8476471
[youtube] sH1PVVJuBtE: Downloading m3u8 information
[MetadataParser] Could not interpret '%(playlist_id)s %(playlist_index)s' as 'PL[A-Za-z0-9_-]{32} (?P<playlist_index>[0-9]+)'
[MetadataParser] Could not interpret '%(playlist_id)s %(playlist_title)s' as 'PL[A-Za-z0-9_-]{32} (?P<playlist_title>.+)'
[info] sH1PVVJuBtE: Downloading 1 format(s): 401+251
[download] Destination: /storage/emulated/0/Download/Seal/Practical_Engineering - Practical_Engineering_-_Videos1Which_Power_Plant_Does_My_Electricity_Come_From [sH1PVVJuBtE].f401.mp4
Canceled by user
El 22 de noviembre de 2024 00:03:49 GMT+02:00, bashonly @.***> escribió:
Out of the 4 suggestions, only conditional formatting in output templates would be both useful and feasible, but it would only be feasible after output template refactoring; see #8511
In the meantime, maybe you could hack a workaround with
--parse-metadata
like this:--parse-meta "%(playlist_id)s %(playlist_index)s:PL[A-Za-z0-9_-]{32} (?P<playlist_index>[0-9]+)" --parse-meta "%(playlist_id)s %(playlist_title)s:PL[A-Za-z0-9_-]{32} (?P<playlist_title>.+)" -o "%(playlist_title,upload_date>%Y-%m-%d&{} - |)s%(playlist_index&{} - |)s.%(ext)s"
-- Reply to this email directly or view it on GitHub: https://github.com/yt-dlp/yt-dlp/issues/11583#issuecomment-2492429941 You are receiving this because you authored the thread.
Message ID: @.***>
But thanks for the help, regardless!
DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE
Checklist
Provide a description that is worded well enough to be understood
I would like to format videos in playlists differently from videos out of playlists (specifically, I'm using
%(playlist_title,upload_date>%Y-%m-%d&{} - |)s%(playlist_index&{} - |)s
).However, since the
youtube:tab
extractor presents videos from eg/@user/videos
as a playlist, this means that unless I either manually list all the videos I want to download, or download channel updates and playlists separately, the above output template will have the wrong behaviour on channel tabs. A way to distinguish the two is desirable. For the remainder of the discussion, note that in this caseplaylist_id=channel_id
.Additional relevant context: On one of my devices, I'm using https://github.com/JunkFood02/Seal to wrap
yt-dlp
. While I have prodded them (https://github.com/JunkFood02/Seal/issues/1873) to support multiple output templates, at the moment they only support a single custom output template.Four ways suggest themselves:
yt-dlp --print | xargs yt-dlp
on desktop which is less than ideal)youtube:tab
's behaviour, perhaps by adding a new metadata field (backwards incompatible)%(playlist_title?(playlist_id & playlist_id != channel_id),upload_date)s
or %(playlist_title[playlist_id][playlist_id != channel_id,upload_date)s), or allow arbitrary python conditionals (
{playlist_title if playlist_id != "NA" and playlist_id != channel_id else upload_date}`)Provide verbose output that clearly demonstrates the problem
yt-dlp -vU <your command line>
)'verbose': True
toYoutubeDL
params instead[debug] Command-line config
) and insert it belowComplete Verbose Output