Metadata-Version: 2.4
Name: ytb-gears
Version: 0.5.1
Summary: A Python package to interact with YouTube Data API v3.
Author-email: Hao Guan <10684225+hguandl@users.noreply.github.com>
Requires-Python: >=3.9
Requires-Dist: google-api-python-client>=2.158.0
Requires-Dist: google-auth-oauthlib>=1.2.1
Provides-Extra: test
Requires-Dist: tqdm>=4.67.1; extra == 'test'
Description-Content-Type: text/markdown

# YouTube Gears

A Python package for uploading videos to YouTube.

## Service Setup

- <https://console.cloud.google.com/apis/library>
  - YouTube Data API v3
- <https://console.cloud.google.com/apis/credentials>
  - OAuth 2.0 Client ID
    - Application type: Desktop App
    - Download the client secret file (JSON)

## Example

```python
import logging

import tqdm

from ytb_gears import uploader


def main():
    logging.basicConfig(level=logging.WARNING)
    logging.getLogger("ytb_gears").setLevel(logging.INFO)

    credentials_file = "credentials.json"
    video_path = "test.mp4"
    thumbnail_path = "thumbnail.jpg"

    if uploader.today_already_uploaded(credentials_file):
        return

    print(f"即将上传视频: {video_path}")

    with tqdm.tqdm(total=100) as pbar:

        def update_progress(progress: float):
            pbar.update(int(progress * 100) - pbar.n)

        uploader.upload(
            video_path,
            credentials_file,
            "YouTube Gears Test Video",
            thumbnail_path,
            "Uploaded by YouTube Gears",
            ["ytb-gears", "test"],
            "22",
            "unlisted",
            progress_callback=update_progress,
        )


main()
```

## Proxy

```python
import os

os.environ["HTTP_PROXY"] = "http://127.0.0.1:7890"
os.environ["HTTPS_PROXY"] = "http://127.0.0.1:7890"
```
