Skip to content
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

[ie/adn] require subscriptions in German #9068

Merged
merged 7 commits into from Jan 28, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion yt_dlp/extractor/adn.py
Expand Up @@ -182,10 +182,15 @@ def _real_extract(self, url):
'Downloading player config JSON metadata',
headers=self._HEADERS)['player']
options = player['options']
video = options['video']
startDate = video.get('startDate')
currentDate = video.get('currentDate')
if startDate and currentDate and startDate > currentDate:
raise ExtractorError(f'This video is not available yet. Release date: {startDate}', expected=True)
Copy link
Member

@bashonly bashonly Jan 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these values unix timestamps? And if so, should we rely on currentDate instead of time.time()? IMO we should do this a bit more safely (and use snake_case):

Suggested change
video = options['video']
startDate = video.get('startDate')
currentDate = video.get('currentDate')
if startDate and currentDate and startDate > currentDate:
raise ExtractorError(f'This video is not available yet. Release date: {startDate}', expected=True)
start_date = traverse_obj(options, ('video', 'startDate', {int}))
current_date = traverse_obj(options, ('video', 'currentDate', {int}))
if start_date and current_date and start_date > current_date:
raise ExtractorError(f'This video is not available yet. Release date: {start_date}', expected=True)

and if these are unix timestamps, Release date: {start_date} is not useful IMO

Perhaps we should even check this after the if not formats: statement below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are ISO 8601 UTC timestamps. Do I need to convert that to unix timestamps or datetime for comparison?
If this is a future video we won't reach the formats section, because user.get('hasAccess') will be false.
Thanks for pointing out snake case, that's what you get for relying on Copilot too much 🤦
I'll push a fix tomorrow.

Copy link
Member

@bashonly bashonly Jan 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok. I'd import parse_iso8601 from utils and import time and do this then:

Suggested change
video = options['video']
startDate = video.get('startDate')
currentDate = video.get('currentDate')
if startDate and currentDate and startDate > currentDate:
raise ExtractorError(f'This video is not available yet. Release date: {startDate}', expected=True)
start_date = traverse_obj(options, ('video', 'startDate', {str}))
if (parse_iso8601(start_date) or 0) > time.time():
raise ExtractorError(f'This video is not available yet. Release date: {start_date}', expected=True)


user = options['user']
if not user.get('hasAccess'):
self.raise_login_required()
self.raise_login_required(msg='This video requires a subscription', method='password')
bashonly marked this conversation as resolved.
Show resolved Hide resolved
bashonly marked this conversation as resolved.
Show resolved Hide resolved

token = self._download_json(
user.get('refreshTokenUrl') or (self._PLAYER_BASE_URL + 'refresh/token'),
Expand Down Expand Up @@ -267,6 +272,9 @@ def _real_extract(self, url):
f['language'] = 'de'
formats.extend(m3u8_formats)

if not formats:
self.raise_login_required(msg='This video requires a subscription', method='password')
bashonly marked this conversation as resolved.
Show resolved Hide resolved

video = (self._download_json(
self._API_BASE_URL + 'video/%s' % video_id, video_id,
'Downloading additional video metadata', fatal=False) or {}).get('video') or {}
Expand Down