mikf / gallery-dl

Command-line program to download image galleries and collections from several image hosting sites
GNU General Public License v2.0
11.84k stars 974 forks source link

ytdl extractor apply to certain websites only #4394

Open ghbook opened 1 year ago

ghbook commented 1 year ago

If I enable ytdl extractor, it handles all the URLs/websites which are not supported by gallery-dl. How to restrict it to certain websites, for ex youtube, pornhub only, something similar to whitelist option.

"extractor":
 {
    "ytdl":
      {
          "enabled": true,
          "module": "yt_dlp",
          "cmdline-args": "--write-thumbnail --write-info-json --match-filter 'duration < 12000'",
      }
}
mikf commented 1 year ago

The ytdl extractor sets its subcategory (instead of the main category) to the site name used by the ytdl module, and the blacklist and whitelist options actually work as long as it's a URL coming from another extractor.

    "whitelist": ["ytdl:Youtube", "ytdl:PornHub"]
    # or just
    "whitelist": [":Youtube", ":PornHub"]

You can check the (sub)caategory names with -E:

$ gallery-dl -E ytdl:https://www.youtube.com/watch?v=BaW_jenozKc
Category / Subcategory
  "ytdl" / "Youtube"
ghbook commented 1 year ago

The ytdl extractor sets its subcategory (instead of the main category) to the site name used by the ytdl module, and the blacklist and whitelist options actually work as long as it's a URL coming from another extractor.

whitelist option is not working, I tried both "whitelist": ["ytdl:Youtube", "ytdl:PornHub"], "whitelist": [":Youtube", ":PornHub"] here is my config:

"ytdl":
        {
        "enabled": true,
        "module": "yt_dlp",

    "directory": ["{subcategory}"],
    "filename": "{subcategory}_{id}{num:?_//}.{extension}",
    "format": "bestvideo[height<=480]+bestaudio/[height<=480]",
        "cmdline-args": "--no-overwrites --write-thumbnail --write-info-json --match-filter 'duration < 1200'",
    "whitelist": [":Youtube"]
        }

then i used gallery-dl -v https://www.pornhub.com/view_video.php?viewkey=ph5e3c83096dcba and it started downloading.

D:\>gallery-dl -v https://www.pornhub.com/view_video.php?viewkey=ph5e3c83096dcba
[gallery-dl][debug] Version 1.25.7
[gallery-dl][debug] Python 3.11.4 - Windows-10-10.0.19045-SP0
[gallery-dl][debug] requests 2.29.0 - urllib3 1.26.16
[gallery-dl][debug] Configuration Files ['%APPDATA%\\gallery-dl\\config.json']
[gallery-dl][debug] Starting DownloadJob for 'https://www.pornhub.com/view_video.php?viewkey=ph5e3c83096dcba'
[ytdl][debug] Using YoutubeDLExtractor for 'https://www.pornhub.com/view_video.php?viewkey=ph5e3c83096dcba'
[ytdl][debug] Using <module 'yt_dlp' from 'C:\\Python3\\Lib\\site-packages\\yt_dlp\\__init__.py'>
[ytdl][debug] [PornHub] Extracting URL: https://www.pornhub.com/view_video.php?viewkey=ph5e3c83096dcba
[ytdl][debug] [PornHub] ph5e3c83096dcba: Downloading pc webpage
[ytdl][debug] [PornHub] ph5e3c83096dcba: Downloading m3u8 information
[ytdl][debug] [PornHub] ph5e3c83096dcba: Downloading m3u8 information
[ytdl][debug] [PornHub] ph5e3c83096dcba: Downloading m3u8 information
[ytdl][debug] [PornHub] ph5e3c83096dcba: Downloading m3u8 information
[ytdl][debug] [PornHub] ph5e3c83096dcba: Downloading JSON metadata
  F:\\dled-gallery-dl\PornHub\PornHub_ph5e3c83096dcba.mp4[ytdl][debug] [info] Downloading video thumbnail 0 ...
[ytdl][debug] [info] Writing video thumbnail 0 to: \\?\F:\dled-gallery-dl\PornHub\PornHub_ph5e3c83096dcba.jpg
[ytdl][debug] [info] Writing video metadata as JSON to: \\?\F:\dled-gallery-dl\PornHub\PornHub_ph5e3c83096dcba.info.json
[ytdl][debug] [download] Destination: \\?\F:\dled-gallery-dl\PornHub\PornHub_ph5e3c83096dcba.mp4
[ytdl][debug] [download] Download completed
* F:\\dled-gallery-dl\PornHub\PornHub_ph5e3c83096dcba.mp4