pafy is a Python library to retrieve YouTube content and metadata, such as video titles, descriptions, thumbnails, and download URLs. Current version is 0.5.5, with no set release cadence; the project appears to be in maintenance mode with infrequent updates.
pip install pafyVerified import paths — ran on the pinned version, not inferred.
Fetch metadata from a YouTube video using pafy and print title, views, duration, and best stream URL.
Switch to yt-dlp with pafy: pip install yt-dlp and set pafy.backend = 'youtube-dl' (though yt-dlp is not natively supported). Better to use yt-dlp directly.
Run pafy.new in a thread or use an async-compatible library instead.
Update youtube-dl frequently: pip install --upgrade youtube-dl. Or switch to yt-dlp based forks.