Skip to main content

Upload videos to YouTube using the internal YouTube API. Does not require an API key.

Project description

youtube-up

Upload videos to YouTube using the internal YouTube API. Does not require an API key.

Installation

From PyPI:

pip install youtube-up

Installing certificates

On your first run you may get an error which says Was not able to load https://youtube.com. Have you installed the certificate at {cert_path} ?. If this happens you should follow the instructions at https://docs.mitmproxy.org/stable/concepts-certificates/#installing-the-mitmproxy-ca-certificate-manually to install the certificate at the given path.

Documentation

https://7x11x13.xyz/youtube-up/youtube_up

Examples

Upload a video

from youtube_up import AllowCommentsEnum, Metadata, PrivacyEnum, YTUploaderSession

uploader = YTUploaderSession.from_cookies_txt("cookies/cookies.txt")
metadata = Metadata(
    title="Video title",
    description="Video description",
    privacy=PrivacyEnum.PUBLIC,
    made_for_kids=False,
    allow_comments_mode=AllowCommentsEnum.HOLD_ALL,
)
uploader.upload("video.webm", metadata)

Note that for Enum-type parameters we can either pass the Enum itself (as shown above), or the Enum value, or the Enum key, as a string. For example, instead of writing

allow_comments_mode=AllowCommentsEnum.HOLD_ALL

we could instead write allow_comments_mode="HOLD_ALL" or allow_comments_mode="APPROVED_COMMENTS"

Note about cookies.txt format

The cookies file must be in Netscape cookies.txt format. See the following browser extensions for exporting cookies in the correct format:

Upload multiple videos

from youtube_up import Metadata, YTUploaderSession

uploader = YTUploaderSession.from_cookies_txt("cookies/cookies.txt")
metadata_1 = Metadata(
    title="Video 1",
)
metadata_2 = Metadata(
    title="Video 2",
)
uploader.upload("video1.webm", metadata_1)
uploader.upload("video2.webm", metadata_2)

Upload to a new or existing playlist

from youtube_up import Metadata, YTUploaderSession, Playlist

uploader = YTUploaderSession.from_cookies_txt("cookies/cookies.txt")
metadata = Metadata(
    title="Video 1",
    playlists=[
        Playlist(
            "Songs by me",
            description="Playlist that will only be created if "
            "no playlist exists with the title 'Songs by me'",
            create_if_title_doesnt_exist=True,
            create_if_title_exists=False,
        ),
        Playlist(
            "test playlist",
            description="Playlist that video will be added to "
            "only if it exists already. This description does "
            "nothing.",
            create_if_title_doesnt_exist=False,
            create_if_title_exists=False,
        ),
        Playlist(
            "Album",
            description="Playlist will be created even if there"
            " is already a playlist with the name 'Album'"
            create_if_title_doesnt_exist=True,
            create_if_title_exists=True,
        ),
    ],
)
uploader.upload("video.webm", metadata)

CLI

youtube-up comes with a CLI app for uploading videos. For example, if we wanted to create a public video with the title "Video title", we would execute the following command: youtube-up video video.webm --title="Video title" --cookies_file="cookies/cookies.txt" --privacy="PUBLIC"

The app can also take a JSON file as input. For example, the following JSON file would upload one video to a new or existing playlist called "Music" and one video which is set to premiere on December 25th, 2023 at 5 PM (local time).

[
    {
        "file": "song.webm",
        "metadata": {
            "title": "New song",
            "privacy": "PUBLIC",
            "playlists": [
                {
                    "title": "Music"
                }
            ]
        }
    },
    {
        "file": "premiere.webm",
        "metadata": {
            "title": "Special Announcement",
            "scheduled_upload": "2023-12-25T17:00:00",
            "premiere_countdown_duration": "ONE_MIN",
            "premiere_theme": "BRIGHT"
        }
    }
]

If we wanted the video to premiere at 5 PM GMT, would could have written "2023-12-25T17:00:00+00:00" instead. We then run

youtube-up json metadata.json --cookies_file="cookies/cookies.txt"

to upload these videos.

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_up-0.5.4.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

youtube_up-0.5.4-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file youtube_up-0.5.4.tar.gz.

File metadata

  • Download URL: youtube_up-0.5.4.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.0 Linux/6.5.0-1023-azure

File hashes

Hashes for youtube_up-0.5.4.tar.gz
Algorithm Hash digest
SHA256 bd25ab3bcbfefeefa75ee5584f99fcc9dca6fa17fc7c996e18a242ab530c6bef
MD5 5ce33c5940f02b840da6d6c57176bcb6
BLAKE2b-256 c8e0caa6e84b098b9ee6198604cf5f6e32059402437871f594cd77ad0dd22734

See more details on using hashes here.

File details

Details for the file youtube_up-0.5.4-py3-none-any.whl.

File metadata

  • Download URL: youtube_up-0.5.4-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.0 Linux/6.5.0-1023-azure

File hashes

Hashes for youtube_up-0.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5ea5a3a7d2ecfa489a1b62de86b73574bb27a825d2f74aab19c432a6b3f18a5f
MD5 4fb61081b6a54068b71efcfc651c13b7
BLAKE2b-256 c824b7be3189ea19b93637c0f2671334ba9b29961b5db05b17387d0d42f026cd

See more details on using hashes here.

Supported by

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