{"id":24193,"library":"pafy","title":"pafy","description":"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.","status":"maintenance","version":"0.5.5","language":"python","source_language":"en","source_url":"https://github.com/mps-youtube/pafy","tags":["youtube","video","metadata","downloader"],"install":[{"cmd":"pip install pafy","lang":"bash","label":"Install from PyPI"},{"cmd":"pip install pafy youtube-dl","lang":"bash","label":"Install with youtube-dl backend"}],"dependencies":[{"reason":"Default backend for downloading video streams and metadata","package":"youtube-dl","optional":true}],"imports":[{"note":"","wrong":"","symbol":"pafy","correct":"import pafy"},{"note":"Do not import pafy and try to call pafy.new; use 'from pafy import new' or 'pafy.new' after import pafy","wrong":"import pafy.new","symbol":"new","correct":"from pafy import new"}],"quickstart":{"code":"import pafy\n\nurl = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'\nvideo = pafy.new(url)\nprint(video.title)\nprint(video.viewcount)\nprint(video.duration)\nstream = video.getbest()\nprint(stream.url)","lang":"python","description":"Fetch metadata from a YouTube video using pafy and print title, views, duration, and best stream URL."},"warnings":[{"fix":"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.","message":"pafy uses youtube-dl as its backend, which is no longer actively maintained and may break with YouTube changes. Consider using yt-dlp as a replacement.","severity":"deprecated","affected_versions":"all"},{"fix":"Run pafy.new in a thread or use an async-compatible library instead.","message":"pafy.new blocks on network calls; calling it in a GUI or async context may freeze the application.","severity":"gotcha","affected_versions":"all"},{"fix":"Update youtube-dl frequently: pip install --upgrade youtube-dl. Or switch to yt-dlp based forks.","message":"As of pafy 0.5.5, the default backend relies on youtube-dl, which may frequently break due to YouTube API changes. Ensure youtube-dl is up to date.","severity":"breaking","affected_versions":"0.5.5"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'import pafy' then 'pafy.new(...)' or 'from pafy import new'.","cause":"Importing pafy incorrectly (e.g., 'import pafy.new' instead of 'from pafy import new').","error":"AttributeError: module 'pafy' has no attribute 'new'"},{"fix":"Ensure video is public and not restricted. Set API key via pafy.set_api_key('YOUR_KEY').","cause":"YouTube API key missing or invalid, or videos are age-restricted/private.","error":"pafy.util.GdataError: No data returned"},{"fix":"Install youtube-dl: pip install youtube-dl and ensure it's in PATH.","cause":"youtube-dl executable not installed or not in PATH.","error":"IOError: [Errno 2] No such file or directory: 'youtube-dl'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}