youtube-unofficial
Access parts of your account unavailable through normal YouTube API access.
Installation
Poetry
poetry add youtube-unofficialPip
pip install youtube-unofficialUsage
This uses a browser cookie storage to be able to access authorised endpoints. There is no feature to log in. You must be logged on in a supported browser. This supports any browser that yt-dlp supports.
Command line
Usage: youtube [OPTIONS] COMMAND [ARGS]...
Unofficial YouTube CLI.
Options:
-h, --help Show this message and exit.
Commands:
clear-watch-history Clear watch history.
clear-watch-later Clear watch later queue.
print-history Print your watch history.
print-playlist Print a playlist.remove-history-entries Remove videos from Watch History. remove-video-id Remove videos from a playlist. remove-watch-later-video-id Remove videos from your Watch Later queue. toggle-watch-history Disable or enable watch history
Every command takes a `--debug` or `-d` argument to show very verbose logs.
Some commands accept a `-j`/`--json` argument to print machine-readable output as JSON lines.
### In Python
import asyncio
from youtubeunofficial import YouTubeClient, buildyoutubesession
async def main() - None: session = await buildyoutubesession('chrome', 'Default') async with session: yt = YouTubeClient(session)
Clear watch history
await yt.clearwatchhistory()