首页 > 解决方案 > Youtube上传api

问题描述

这里有人有使用 YouTube API 的经验吗?我目前正在尝试通过使用 OAuth 应用程序来自动上传我的视频,但是,由于它没有经过验证,我的视频会立即被锁定并设置为私有。由于没有网站,我无法验证我的 OAuth 应用程序。

有没有其他方法可以在不使用 OAuth 应用程序的情况下做到这一点?

def uploadClip(clip):
# Disable OAuthlib's HTTPS verification when running locally.
# *DO NOT* leave this option enabled in production.
os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"

api_service_name = "youtube"
api_version = "v3"
client_secrets_file = "client_secrets.json"

# Get credentials and create an API client
flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(client_secrets_file, scopes)
credentials = flow.run_console()
youtube = googleapiclient.discovery.build(api_service_name, api_version, credentials=credentials)

request = youtube.videos().insert(
    part="snippet,status",
    body={
        "snippet": {
            "categoryId": "22",
            "description": ".",
            "title": "H "
        },
        "status": {
            "privacyStatus": "public"
        }
    },

    # TODO: For this request to work, you must replace "YOUR_FILE"
    #       with a pointer to the actual file you are uploading.
    media_body=clip
)
response = request.execute()

标签: pythonyoutubeyoutube-data-api

解决方案


推荐阅读