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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve documentation and usage of release_year #8524
Conversation
- Update docs to better reflect actual usage of release_year - Auto generate release year if not present - Fix HarpodeonIE which reported an incorrect release date when only the year was known
yt_dlp/YoutubeDL.py
Outdated
if info_dict.get('release_year') is None and info_dict.get('release_date') is not None: | ||
info_dict['release_year'] = int_or_none(info_dict['release_date'][:4]) |
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 thing that gives me pause about this is that it will make so many otherwise-passing download tests now fail
Also could probably just use int()
here, but either way is fine
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.
We can make an exception in the tester similar to
Lines 221 to 223 in 21dc069
# display_id may be generated from id | |
if test_info_dict.get('display_id') == test_info_dict.get('id'): | |
test_info_dict.pop('display_id') |
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.
if info_dict.get('release_year') is None and info_dict.get('release_date') is not None: | |
info_dict['release_year'] = int_or_none(info_dict['release_date'][:4]) | |
if not info_dict.get('release_year'): | |
info_dict['release_year'] = traverse_obj(info_dict, ('release_date', lambda x: int(x[:4]))) |
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.
Okay, so should this be used as an exception in sanitize_got_info_dict
?
# release_year may be generated from release_date
if test_info_dict.get('release_year') and test_info_dict.get('release_date'):
test_info_dict.pop('release_year')
There shouldn't be that many IE's that return both a release_date
and release_year
.
I could find: ArchiveOrgIE
, MonstercatIE
, TrueIDIE
(inconstant), and YoutubeIE
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.
There can be situations in theory where the year doesn't match the date. I think this'd be better:
if try_call(lambda: test_info_dict['release_year'] == int(test_info_dict['release_date'][:4])):
test_info_dict.pop('release_year')
That way only the auto-generated value will be excluded
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.
and
YoutubeIE
release_year is currently broken for Youtube if I remember right
Co-authored-by: pukkandan <pukkandan.ytdlp@gmail.com>
Closes yt-dlp#7263 Authored by: seproDev
IMPORTANT: PRs without the template will be CLOSED
Description of your pull request and other information
HarpodeonIE
, which reported an incorrect release date when only the year was knownCloses #7263
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 all of the following options that apply:
What is the purpose of your pull request?
Copilot Summary
馃 Generated by Copilot at cfea45e
Summary
馃搮馃帪锔忦煕狅笍
This pull request adds a new
release_year
field to the common metadata fields for extracted videos, and updates the Harpodeon extractor to use it. It also adds a logic to infer therelease_year
from therelease_date
if possible.Walkthrough
release_year
to theInfoExtractor
class and document its meaning and usage (link)release_year
as an album-specific field (link)release_year
field instead of therelease_date
field and convert the year to an integer or None (link, link)release_date
torelease_year
and use integers instead of strings (link, link, link)YoutubeDL
class to calculate therelease_year
field from therelease_date
field if not explicitly set by the extractor (link)