Skip to main content

Access parts of your account unavailable through normal YouTube API access.

Project description

youtube-unofficial

Python versions PyPI - Version GitHub tag (with filter) License GitHub commits since latest release (by SemVer including pre-releases) CodeQL QA Tests Coverage Status Dependabot Documentation Status mypy uv pytest Ruff Downloads Stargazers pre-commit Prettier

@Tatsh Buy Me A Coffee Libera.Chat Mastodon Follow Patreon

Access parts of your account unavailable through normal YouTube API access.

Installation

Poetry

poetry add youtube-unofficial

Pip

pip install youtube-unofficial

Usage

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.
  print-watch-later            Print your Watch Later 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 youtube_unofficial import YouTubeClient, build_youtube_session


async def main() -> None:
    session = await build_youtube_session('chrome', 'Default')
    async with session:
        yt = YouTubeClient(session)

        # Clear watch history
        await yt.clear_watch_history()

        # Remove a single video ID from Watch Later queue
        await yt.remove_video_id_from_playlist('WL', video_id)

        # Clear entire Watch Later queue
        await yt.clear_watch_later()


asyncio.run(main())

Contributing

For a new feature to be accepted, it must be something that cannot be achieved with Google's official API. It also has to be on the youtube.com/youtu.be website or app and not a place like My Activity.

Code must run through yarn qa and have zero issues.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

youtube_unofficial-0.4.0.tar.gz (29.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

youtube_unofficial-0.4.0-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file youtube_unofficial-0.4.0.tar.gz.

File metadata

  • Download URL: youtube_unofficial-0.4.0.tar.gz
  • Upload date:
  • Size: 29.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for youtube_unofficial-0.4.0.tar.gz
Algorithm Hash digest
SHA256 68fe8e7d25ea1e440d32d6879a2939cab8691b3bd781011c2d23367e214fcb17
MD5 58116a7af61ccd97c11c37bca4efce3b
BLAKE2b-256 e3e9ffeb52f6461ecb5e520c30eafa88741c61c5725e1e9971ec3191d274745c

See more details on using hashes here.

Provenance

The following attestation bundles were made for youtube_unofficial-0.4.0.tar.gz:

Publisher: publish.yml on Tatsh/youtube-unofficial

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file youtube_unofficial-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for youtube_unofficial-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 806a917ab6cb559defa36e01b81a2557bdaa1b3c9babadca8b139fd2ae2e192f
MD5 1d78736ad54919bb08f5d776daecfda1
BLAKE2b-256 5709444c20fc992f9e2337b80f4f23e82d4b4c4993c33247956fce76560ad71b

See more details on using hashes here.

Provenance

The following attestation bundles were made for youtube_unofficial-0.4.0-py3-none-any.whl:

Publisher: publish.yml on Tatsh/youtube-unofficial

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page