Age restriction gate used also when logging in #5281

Closed
opened 2026-02-21 01:03:27 -05:00 by deekerman · 5 comments
Owner

Originally created by @aldnin on GitHub (Aug 3, 2015).

There is no need for the age restriction gate when logging in, nevertheless it is used in such cases. The age restriction gate can cause issues with embedding rules of videos, therefore it makes it impossible to process a video which is age-restricted, with emedding rules, even when logging in with data which would elminiate the age-restriction.

Originally created by @aldnin on GitHub (Aug 3, 2015). There is no need for the age restriction gate when logging in, nevertheless it is used in such cases. The age restriction gate can cause issues with embedding rules of videos, therefore it makes it impossible to process a video which is age-restricted, with emedding rules, even when logging in with data which would elminiate the age-restriction.
deekerman 2026-02-21 01:03:27 -05:00
Author
Owner

@dstftw commented on GitHub (Aug 3, 2015):

Provide concrete examples.

@dstftw commented on GitHub (Aug 3, 2015): Provide concrete examples.
Author
Owner

@m-porto commented on GitHub (Aug 11, 2015):

aldnin is right

This is related to my problem in https://github.com/rg3/youtube-dl/issues/4627, but thread closed rather than reply (after ask for dumb things like the OS, wich is in the debug info provided or if im using xxxx@gmail.com literally as account)

In youtube.py extractor go here:

    if re.search(r'player-age-gate-content">', video_webpage) is not None:
        age_gate = True
        ...

but in this case (embedded + age restriction) must go to else branch

    else:
        age_gate = False
        ...

Example:

youtube-dl -n -c -v "https://www.youtube.com/watch?v=_ujz8dY7EAE"
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'-n', u'-c', u'-v', u'https://www.youtube.com/watch?v=_ujz8dY7EAE']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2015.08.09
[debug] Python version 2.7.10 - Linux-3.16.0-4-amd64-x86_64-with-debian-stretch-sid
[debug] exe versions: avconv 2.6.2, avprobe 2.6.2, ffmpeg 2.6.2, ffprobe 2.6.2, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] Downloading login page
[youtube] Logging in
[youtube] _ujz8dY7EAE: Downloading webpage
[youtube] _ujz8dY7EAE: Downloading embed webpage
[youtube] _ujz8dY7EAE: Refetching age-gated info webpage
ERROR: _ujz8dY7EAE: YouTube said: Watch this video on YouTube.
Playback on other websites has been disabled by the video owner.
Traceback (most recent call last):
File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 655, in extract_info
ie_result = ie.extract(url)
File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 286, in extract
return self._real_extract(url)
File "/usr/local/bin/youtube-dl/youtube_dl/extractor/youtube.py", line 1063, in _real_extract
expected=True, video_id=video_id)
ExtractorError: _ujz8dY7EAE: YouTube said: Watch this video on YouTube.
Playback on other websites has been disabled by the video owner.

Not sure how to put the condition, but if I put this in youtube.py extractor:

    if False and re.search(r'player-age-gate-content">', video_webpage) is not None:
        age_gate = True
        ...

and I do this:

dl = YoutubeDL()
dl.params['username'] = 'xxxx@gmail.com'
dl.params['password'] = 'xxxx'

ie = YoutubeIE(dl)
resultIE = ie.extract('https://www.youtube.com/watch?v=_ujz8dY7EAE')
resultIE['extractor'] = 'youtube'
dl.process_ie_result(resultIE)

I get the video:

[youtube] Downloading login page
[youtube] Logging in
[youtube] _ujz8dY7EAE: Downloading webpage
[youtube] _ujz8dY7EAE: Downloading video info webpage
[youtube] _ujz8dY7EAE: Extracting video information
[youtube] _ujz8dY7EAE: Downloading DASH manifest
WARNING: Your copy of avconv is outdated and unable to properly mux separate video and audio files, youtube-dl will download single file media. Update avconv to version 10-0 or newer to fix this.
[download] Destination: Effy & Cook - Sex Scene (3x01)-_ujz8dY7EAE.mp4

[download] 0.0% of 3.73MiB at Unknown speed ETA Unknown ETA
[download] 0.1% of 3.73MiB at 206.49KiB/s ETA 00:18
[download] 0.2% of 3.73MiB at 475.92KiB/s ETA 00:08
[download] 0.4% of 3.73MiB at 573.54KiB/s ETA 00:06
[download] 0.8% of 3.73MiB at 1.13MiB/s ETA 00:03
[download] 1.6% of 3.73MiB at 1.23MiB/s ETA 00:02
[download] 3.3% of 3.73MiB at 662.95KiB/s ETA 00:05
[download] 6.7% of 3.73MiB at 1.25MiB/s ETA 00:02
[download] 13.4% of 3.73MiB at 1.22MiB/s ETA 00:02
[download] 26.8% of 3.73MiB at 1.26MiB/s ETA 00:02
[download] 53.5% of 3.73MiB at 1.30MiB/s ETA 00:01
[download] 89.5% of 3.73MiB at 1.32MiB/s ETA 00:00
[download] 100.0% of 3.73MiB at 1.33MiB/s ETA 00:00

@m-porto commented on GitHub (Aug 11, 2015): aldnin is right This is related to my problem in https://github.com/rg3/youtube-dl/issues/4627, but thread closed rather than reply (after ask for dumb things like the OS, wich is in the debug info provided or if im using xxxx@gmail.com literally as account) In youtube.py extractor go here: ``` if re.search(r'player-age-gate-content">', video_webpage) is not None: age_gate = True ... ``` but in this case (embedded + age restriction) must go to else branch ``` else: age_gate = False ... ``` Example: youtube-dl -n -c -v "https://www.youtube.com/watch?v=_ujz8dY7EAE" [debug] System config: [] [debug] User config: [] [debug] Command-line args: [u'-n', u'-c', u'-v', u'https://www.youtube.com/watch?v=_ujz8dY7EAE'] [debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8 [debug] youtube-dl version 2015.08.09 [debug] Python version 2.7.10 - Linux-3.16.0-4-amd64-x86_64-with-debian-stretch-sid [debug] exe versions: avconv 2.6.2, avprobe 2.6.2, ffmpeg 2.6.2, ffprobe 2.6.2, rtmpdump 2.4 [debug] Proxy map: {} [youtube] Downloading login page [youtube] Logging in [youtube] _ujz8dY7EAE: Downloading webpage [youtube] _ujz8dY7EAE: Downloading embed webpage [youtube] _ujz8dY7EAE: Refetching age-gated info webpage ERROR: _ujz8dY7EAE: YouTube said: <a href="http://www.youtube.com/watch?v=_ujz8dY7EAE&feature=player_embedded" target="_blank">Watch this video on YouTube.</a><br/>Playback on other websites has been disabled by the video owner. Traceback (most recent call last): File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 655, in extract_info ie_result = ie.extract(url) File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 286, in extract return self._real_extract(url) File "/usr/local/bin/youtube-dl/youtube_dl/extractor/youtube.py", line 1063, in _real_extract expected=True, video_id=video_id) ExtractorError: _ujz8dY7EAE: YouTube said: <a href="http://www.youtube.com/watch?v=_ujz8dY7EAE&feature=player_embedded" target="_blank">Watch this video on YouTube.</a><br/>Playback on other websites has been disabled by the video owner. Not sure how to put the condition, but if I put this in youtube.py extractor: ``` if False and re.search(r'player-age-gate-content">', video_webpage) is not None: age_gate = True ... ``` and I do this: ``` dl = YoutubeDL() dl.params['username'] = 'xxxx@gmail.com' dl.params['password'] = 'xxxx' ie = YoutubeIE(dl) resultIE = ie.extract('https://www.youtube.com/watch?v=_ujz8dY7EAE') resultIE['extractor'] = 'youtube' dl.process_ie_result(resultIE) ``` I get the video: [youtube] Downloading login page [youtube] Logging in [youtube] _ujz8dY7EAE: Downloading webpage [youtube] _ujz8dY7EAE: Downloading video info webpage [youtube] _ujz8dY7EAE: Extracting video information [youtube] _ujz8dY7EAE: Downloading DASH manifest WARNING: Your copy of avconv is outdated and unable to properly mux separate video and audio files, youtube-dl will download single file media. Update avconv to version 10-0 or newer to fix this. [download] Destination: Effy & Cook - Sex Scene (3x01)-_ujz8dY7EAE.mp4 [download] 0.0% of 3.73MiB at Unknown speed ETA Unknown ETA [download] 0.1% of 3.73MiB at 206.49KiB/s ETA 00:18 [download] 0.2% of 3.73MiB at 475.92KiB/s ETA 00:08 [download] 0.4% of 3.73MiB at 573.54KiB/s ETA 00:06 [download] 0.8% of 3.73MiB at 1.13MiB/s ETA 00:03 [download] 1.6% of 3.73MiB at 1.23MiB/s ETA 00:02 [download] 3.3% of 3.73MiB at 662.95KiB/s ETA 00:05 [download] 6.7% of 3.73MiB at 1.25MiB/s ETA 00:02 [download] 13.4% of 3.73MiB at 1.22MiB/s ETA 00:02 [download] 26.8% of 3.73MiB at 1.26MiB/s ETA 00:02 [download] 53.5% of 3.73MiB at 1.30MiB/s ETA 00:01 [download] 89.5% of 3.73MiB at 1.32MiB/s ETA 00:00 [download] 100.0% of 3.73MiB at 1.33MiB/s ETA 00:00
Author
Owner

@dstftw commented on GitHub (Aug 11, 2015):

#4627 has been already closed long before you posted in it. We do not track closed issues. As of going the else branch this is not always the case, e.g. http://www.youtube.com/watch?v=6kLq3WMV1nU does only work with age-gate branch.

@dstftw commented on GitHub (Aug 11, 2015): #4627 has been already closed long before you posted in it. We do not track closed issues. As of going the else branch this is not always the case, e.g. http://www.youtube.com/watch?v=6kLq3WMV1nU does only work with age-gate branch.
Author
Owner

@m-porto commented on GitHub (Aug 11, 2015):

Ok, this works for me:

    # Get video info

    embed_webpage = None
    is_live = None

    retry_embedded = False
    player_age_gate_content = re.search(r'player-age-gate-content">', video_webpage) 

    if  player_age_gate_content is not None:
        age_gate = True

        # We simulate the access to the video from www.youtube.com/v/{video_id}
        # this can be viewed without login into Youtube
        url = proto + '://www.youtube.com/embed/%s' % video_id
        embed_webpage = self._download_webpage(url, video_id, 'Downloading embed webpage')
        data = compat_urllib_parse.urlencode({
            'video_id': video_id,
            'eurl': 'https://youtube.googleapis.com/v/' + video_id,
            'sts': self._search_regex(
                r'"sts"\s*:\s*(\d+)', embed_webpage, 'sts', default=''),
        })
        video_info_url = proto + '://www.youtube.com/get_video_info?' + data
        video_info_webpage = self._download_webpage(
            video_info_url, video_id,
            note='Refetching age-gated info webpage',
            errnote='unable to download video info webpage')
        video_info = compat_parse_qs(video_info_webpage)
        add_dash_mpd(video_info)

        if 'token' not in video_info and 'reason' in video_info and len(video_info['reason']) and 'Playback on other websites has been disabled by the video owner.' in video_info['reason'][0]:
            retry_embedded = True

    if player_age_gate_content is None or retry_embedded:
        age_gate = False
        ...

(Sorry for the edit)

@m-porto commented on GitHub (Aug 11, 2015): Ok, this works for me: ``` # Get video info embed_webpage = None is_live = None retry_embedded = False player_age_gate_content = re.search(r'player-age-gate-content">', video_webpage) if player_age_gate_content is not None: age_gate = True # We simulate the access to the video from www.youtube.com/v/{video_id} # this can be viewed without login into Youtube url = proto + '://www.youtube.com/embed/%s' % video_id embed_webpage = self._download_webpage(url, video_id, 'Downloading embed webpage') data = compat_urllib_parse.urlencode({ 'video_id': video_id, 'eurl': 'https://youtube.googleapis.com/v/' + video_id, 'sts': self._search_regex( r'"sts"\s*:\s*(\d+)', embed_webpage, 'sts', default=''), }) video_info_url = proto + '://www.youtube.com/get_video_info?' + data video_info_webpage = self._download_webpage( video_info_url, video_id, note='Refetching age-gated info webpage', errnote='unable to download video info webpage') video_info = compat_parse_qs(video_info_webpage) add_dash_mpd(video_info) if 'token' not in video_info and 'reason' in video_info and len(video_info['reason']) and 'Playback on other websites has been disabled by the video owner.' in video_info['reason'][0]: retry_embedded = True if player_age_gate_content is None or retry_embedded: age_gate = False ... ``` (Sorry for the edit)
Author
Owner

@gnaag commented on GitHub (Jan 19, 2016):

I have problems downloading this video: https://www.youtube.com/watch?v=UNDIrIyvQFk even though I succesfully logged in through CLI.

youtube-dl -n https://www.youtube.com/watch?v=UNDIrIyvQFk
[youtube] Downloading login page
[youtube] Logging in
Type 2-step verification code and press [Return]: 
[youtube] Submitting TFA code
[youtube] UNDIrIyvQFk: Downloading webpage
[youtube] UNDIrIyvQFk: Downloading embed webpage
[youtube] UNDIrIyvQFk: Refetching age-gated info webpage
ERROR: UNDIrIyvQFk: YouTube said: Watch this video on YouTube.
Playback on other websites has been disabled by the video owner.
@gnaag commented on GitHub (Jan 19, 2016): I have problems downloading this video: https://www.youtube.com/watch?v=UNDIrIyvQFk even though I succesfully logged in through CLI. <pre> youtube-dl -n https://www.youtube.com/watch?v=UNDIrIyvQFk [youtube] Downloading login page [youtube] Logging in Type 2-step verification code and press [Return]: [youtube] Submitting TFA code [youtube] UNDIrIyvQFk: Downloading webpage [youtube] UNDIrIyvQFk: Downloading embed webpage [youtube] UNDIrIyvQFk: Refetching age-gated info webpage ERROR: UNDIrIyvQFk: YouTube said: <a href="http://www.youtube.com/watch?v=UNDIrIyvQFk&feature=player_embedded" target="_blank">Watch this video on YouTube.</a><br/>Playback on other websites has been disabled by the video owner. </pre>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/youtube-dl#5281
No description provided.