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

Add age-limit option on dailymotion to download explicit #18437

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions youtube_dl/extractor/dailymotion.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,18 @@ def _real_extract(self, url):
if metadata_url:
metadata_url = metadata_url.replace(':videoId', video_id)
else:
metadata_url = update_url_query(
'https://www.dailymotion.com/player/metadata/video/%s'
% video_id, {
'embedder': url,
'integration': 'inline',
'GK_PV5_NEON': '1',
})
if (17 < age_limit) :
Copy link

Choose a reason for hiding this comment

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

Please continue to make the code PEP8 compliant, which the extra space between the condition and the : violate, as does the extra space between your else and : below

The parens around the test are also unnecessary, but I don't believe they're strictly speaking wrong

metadata_url = update_url_query(
'https://www.dailymotion.com/player/metadata/video/%s'
% video_id, {})
Copy link

Choose a reason for hiding this comment

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

By far the better solution is to pull the extra dict out into a variable guarded by this if rather than duplicating the "meat" of that call; something like:

                    if 17 < age_limit:
                        metadata_extra = {}
                    else:
                        metadata_extra = {
                                'embedder': url,
                                'integration': 'inline',
                                'GK_PV5_NEON': '1',
                        }
                    metadata_url = update_url_query(
                            'https://www.dailymotion.com/player/metadata/video/%s'
                            % video_id, metadata_extra)

else :
metadata_url = update_url_query(
'https://www.dailymotion.com/player/metadata/video/%s'
% video_id, {
'embedder': url,
'integration': 'inline',
'GK_PV5_NEON': '1',
})
metadata = self._download_json(
metadata_url, video_id, 'Downloading metadata JSON')

Expand Down