yt-dlp: [PornHub] Unable to extract encoded url

Checklist

  • I’m reporting a broken site
  • I’ve verified that I’m running yt-dlp version 2022.06.29 (update instructions) or later (specify commit)
  • I’ve checked that all provided URLs are playable in a browser with the same IP and same login details
  • I’ve checked that all URLs and arguments with special characters are properly quoted or escaped
  • I’ve searched the bugtracker for similar issues including closed ones. DO NOT post duplicates
  • I’ve read the guidelines for opening an issue
  • I’ve read about sharing account credentials and I’m willing to share it if required

Region

No response

Provide a description that is worded well enough to be understood

[PornHub] Unable to download JSON metadata: HTTP Error 403: Forbidden How to fix it?

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

F:\downloader\pornhub>ytdl-patched https://www.pornhub.com/model/katekuray -F --verbose
[debug] Command-line config: ['https://www.pornhub.com/model/katekuray', '-F', '--verbose']
[debug] User config "D:\OS Files\Users\X\AppData\Roaming\yt-dlp\config": ['--continue', '--http-chunk-size', '1M', '--buffer-size', '16K', '--sub-lang', 'english', '--embed-metadata', '--abort-on-unavailable-fragment', '-o', '%(uploader)s\\%(title)s [%(id)s].%(ext)s', '-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]', '--ffmpeg-location', 'D:\\OS Files\\Program Files\\ffmpeg\\bin', '--no-lock']
[debug] Encodings: locale cp65001, fs utf-8, pref cp65001, out utf-8, error utf-8, screen utf-8
[debug] ytdl-patched version 2022.06.29
[debug] ** The command you are running is not yt-dlp.
[debug] ** Please make bug reports at https://github.com/ytdl-patched/ytdl-patched/issues/new/choose instead.
[debug] Lazy loading extractors is disabled
[debug] Python 3.10.4 (CPython 64bit) - Windows-10-10.0.19043-SP0
[debug] Checking exe version: "D:\OS Files\Program Files\ffmpeg\bin\ffmpeg" -bsfs
[debug] Checking exe version: "D:\OS Files\Program Files\ffmpeg\bin\ffprobe" -bsfs
[debug] exe versions: ffmpeg 5.0.1-essentials_build-www.gyan.dev (setts), ffprobe 5.0.1-essentials_build-www.gyan.dev
[debug] Optional libraries: Cryptodome-3.14.1, WebSocketsWrapper-None, brotli-1.0.9, certifi-2021.10.08, mutagen-1.45.1, sqlite3-2.6.0, websockets-10.2
[debug] Proxy map: {}
[debug] [PornHubUser] Extracting URL: https://www.pornhub.com/model/katekuray
[debug] [PornHubPagedVideoList] Extracting URL: https://www.pornhub.com/model/katekuray/videos
[download] Downloading playlist: model/katekuray/videos
[PornHubPagedVideoList] model/katekuray/videos: Downloading page 1
[PornHubPagedVideoList] [debug] Fetching webpage from https://www.pornhub.com/model/katekuray/videos
[PornHubPagedVideoList] model/katekuray/videos: Downloading page 2
[PornHubPagedVideoList] [debug] Fetching webpage from https://www.pornhub.com/model/katekuray/videos
[PornHubPagedVideoList] Playlist model/katekuray/videos: Downloading 107 videos of 107
[download] Downloading video 11 of 107
[PornHub] ph5f71889303342: Downloading pc webpage
[PornHub] ph5f71889303342: Downloading m3u8 information
[PornHub] ph5f71889303342: Downloading m3u8 information
[PornHub] ph5f71889303342: Downloading m3u8 information
[PornHub] ph5f71889303342: Downloading m3u8 information
[PornHub] ph5f71889303342: Downloading JSON metadata
WARNING: [PornHub] Unable to download JSON metadata: HTTP Error 403: Forbidden
[info] Available formats for ph5f71889303342:
ID         EXT RESOLUTION FPS │  FILESIZE   TBR PROTO │ VCODEC        VBR ACODEC    ABR
───────────────────────────────────────────────────────────────────────────────────────
hls-509-0  mp4 426x240     59 │ ~ 4.48MiB  509k m3u8  │ avc1.64001e  509k mp4a.40.2  0k
hls-509-1  mp4 426x240     59 │ ~ 4.48MiB  509k m3u8  │ avc1.64001e  509k mp4a.40.2  0k
hls-902-0  mp4 854x480     59 │ ~ 7.93MiB  902k m3u8  │ avc1.64001f  902k mp4a.40.2  0k
hls-902-1  mp4 854x480     59 │ ~ 7.93MiB  902k m3u8  │ avc1.64001f  902k mp4a.40.2  0k
hls-1614-0 mp4 1280x720    59 │ ~14.19MiB 1614k m3u8  │ avc1.640020 1614k mp4a.40.2  0k
hls-1614-1 mp4 1280x720    59 │ ~14.19MiB 1614k m3u8  │ avc1.640020 1614k mp4a.40.2  0k
hls-2769   mp4 1920x1080   59 │ ~24.34MiB 2769k m3u8  │ avc1.64002a 2769k mp4a.40.2  0k

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 28 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Per https://github.com/ytdl-org/youtube-dl/pull/31916 it looks like this could be a cookie problem

Does anyone who is affected by this issue (I’m not) want to test this patch? Feel free to PR it if it works

diff --git a/yt_dlp/extractor/pornhub.py b/yt_dlp/extractor/pornhub.py
index 5d8d7c100..904094b7e 100644
--- a/yt_dlp/extractor/pornhub.py
+++ b/yt_dlp/extractor/pornhub.py
@@ -269,6 +269,8 @@ def _real_extract(self, url):
         self._login(host)
 
         self._set_cookie(host, 'age_verified', '1')
+        self._set_cookie(host, 'accessAgeDisclaimerPH', '1')
+        self._set_cookie('thumbzilla.com', 'accessAgeDisclaimerTZ', '1')
 
         def dl_webpage(platform):
             self._set_cookie(host, 'platform', platform)

Any news when this will be merged into master?

@hauke96 @Maxwell12347842

That may be the issue, was using the unchanged checkout of the main branch. Will add the changes from PR #6685 and try again.

Edit: Applying the patch works like a charm. Hope this gets merged into master soon.

@Lumpi33 German IP here, too. Have you really added the changes from PR #6685 ? They have not been merged into the main code base yet.

Just tested from germany and can confirm the fix works.

yt-dlp -vU https://www.pornhub.com/model/katekuray
[debug] Command-line config: ['-vU', 'https://www.pornhub.com/model/katekuray']
[debug] User config "/home/nico/.config/yt-dlp/config": ['-o', '/dev/shm/test-dlp/%(title)s.%(ext)s', '-f', 'bestvideo[height<=1080][ext=mp4][vcodec!*=av01]+bestaudio[ext=m4a]/best[ext=mp4]/best', '--no-mtime', '--add-metadata', '--convert-thumbnails', 'jpg', '--embed-thumbnail', '--ppa', 'ThumbnailsConvertor:-q:v 1', '--ppa', 'ffmpeg:-metadata synopsis=""', '--force-ipv4', '--sponsorblock-remove', 'all', '--console-title', '--downloader', 'aria2c', '--downloader-args', 'aria2c:--http-accept-gzip=true -x 10 -s 10 -j 10 -k 1M --log-level=info --file-allocation=none']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version 2022.07.10 [258d88f30] (zip)
[debug] Python 3.8.10 (CPython 64bit) - Linux-5.4.0-121-generic-x86_64-with-glibc2.29 (glibc 2.31)
[debug] Checking exe version: ffmpeg -bsfs
[debug] Checking exe version: ffprobe -bsfs
[debug] exe versions: ffmpeg N-107246-g59a58d1a85-Nico-20220626 (fdk,setts), ffprobe N-107246-g59a58d1a85-Nico-20220626, phantomjs 2.1.1
[debug] Optional libraries: Cryptodome-3.12.0, brotli-1.0.9, certifi-2019.11.28, mutagen-1.45.1, secretstorage-2.3.1, sqlite3-2.6.0, websockets-10.1
[debug] Proxy map: {}
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: 2022.06.29, Current version: 2022.07.10
yt-dlp is up to date (2022.07.10)
[debug] [PornHubUser] Extracting URL: https://www.pornhub.com/model/katekuray
[debug] [PornHubPagedVideoList] Extracting URL: https://www.pornhub.com/model/katekuray/videos
[download] Downloading playlist: model/katekuray/videos
[PornHubPagedVideoList] model/katekuray/videos: Downloading page 1
[PornHubPagedVideoList] model/katekuray/videos: Downloading page 2
[PornHubPagedVideoList] Playlist model/katekuray/videos: Downloading 107 videos of 107
[download] Downloading video 1 of 107
[debug] [PornHub] Extracting URL: http://www.pornhub.com/view_video.php?viewkey=ph5fd3531b21ace
[PornHub] ph5fd3531b21ace: Downloading pc webpage
[PornHub] ph5fd3531b21ace: Downloading tv webpage
ERROR: [PornHub] ph5fd3531b21ace: Unable to extract encoded url; please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
  File "/usr/local/bin/yt-dlp/yt_dlp/extractor/common.py", line 640, in extract
    ie_result = self._real_extract(url)
  File "/usr/local/bin/yt-dlp/yt_dlp/extractor/pornhub.py", line 408, in _real_extract
    js_vars = extract_js_vars(
  File "/usr/local/bin/yt-dlp/yt_dlp/extractor/pornhub.py", line 345, in extract_js_vars
    assignments = self._search_regex(
  File "/usr/local/bin/yt-dlp/yt_dlp/extractor/common.py", line 1192, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)

[download] Downloading video 2 of 107
[debug] [PornHub] Extracting URL: http://www.pornhub.com/view_video.php?viewkey=ph5fcf2135b4d02
[PornHub] ph5fcf2135b4d02: Downloading pc webpage
[PornHub] ph5fcf2135b4d02: Downloading tv webpage
ERROR: [PornHub] ph5fcf2135b4d02: Unable to extract encoded url; please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
  File "/usr/local/bin/yt-dlp/yt_dlp/extractor/common.py", line 640, in extract
    ie_result = self._real_extract(url)
  File "/usr/local/bin/yt-dlp/yt_dlp/extractor/pornhub.py", line 408, in _real_extract
    js_vars = extract_js_vars(
  File "/usr/local/bin/yt-dlp/yt_dlp/extractor/pornhub.py", line 345, in extract_js_vars
    assignments = self._search_regex(
  File "/usr/local/bin/yt-dlp/yt_dlp/extractor/common.py", line 1192, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)

[download] Downloading video 3 of 107
[debug] [PornHub] Extracting URL: http://www.pornhub.com/view_video.php?viewkey=ph5fcdd1ca2d34c
[PornHub] ph5fcdd1ca2d34c: Downloading pc webpage
[PornHub] ph5fcdd1ca2d34c: Downloading tv webpage
^C
ERROR: Interrupted by user