Package: pillar-youtube-upload
PillarGG YouTube UploaderUpload Youtube Videos and more via Python.Getting Startedpip install pillar-youtube-uploadYou can read morebelowand on thedocs.This project uses theYoutube Data API.All implementations of youtube upload needs some form ofauthentication.Client Side youtube uploadTo upload youtube videos as a client, you need to followthis guide.Server Side youtube uploadTo upload youtube videos as a server, you need to followthis guide.Getting a youtube api keyFirst, you need to go tothis website.If prompted, select a project, or create a new one.Use the Library page to find and enable the YouTube Data API v3.Go to thecredentials page.ClickCreate Credentials > OAuth client ID.Select the Web application app type.Fill in the form and click create. For testing redirect URIs that refer to the local machine withhttp://localhost:8080.Download the client_secret.json file from the API Console and securely store the file in a location that only your application can access. By default, the application gets this file from the directory your script is being ran in. The path can also be changed when the classYoutubeUploaderis being initialized.Get yourclient_idandclient_secret.We recommend that youdesign your app's auth endpointsso that your application does not expose authorization codes to other resources on the page.The key must have the scope 'https://www.googleapis.com/auth/youtube.upload'.Usage InfoThe variablesclient_idandclient_secretare how Google identify your application. These are specified in the initialization parameters or in theclient_secrets.jsonfile.
The variablesaccess_tokenandrefresh_tokenare how Google's APIs differentiate between different YouTube channels. These are specified in the authenticate method.This module uploads a given video to a youtube channel, as such there are 2 things this module needs.A videoVideo OptionsTitleDescriptionTagsCategoryStatusDeclaredMadeForKidsA channel to upload to(In the form of a authentication file)The authentication file should contain the following:access_token: token_hererefresh_token: token_herescope: scope_heretoken_type: Bearerexpires_in: 3599This file should be called client_secrets.json and exist in the directory this script is.Usage0. Importing the package# youtube upload apifromyoutube_upload.clientimportYoutubeUploader1. Instantiating an uploaderuploader=YoutubeUploader(client_id,client_secret)oruploader=YoutubeUploader()If a client_secrets.json is present in the current working directory (downloaded from theCredentials Control Panelin the Google Cloud Console when you create the application).oruploader=YoutubeUploader(secrets_file_path=secrets_file_path_here)You can specify the path to the file with thesecrets_file_pathparameter.2. AuthenticationIf you runauthenticatewith no parameters and nooauth.json, it opens a web page locally that you can use to sign into the YouTube Channel you want to upload the video to.uploader.authenticate()oruploader.authenticate(access_token=access_token_here,refresh_token=refresh_token_here)ORuploader.authenticate(oauth_path='oauth.json')3. Uploading the video# Video optionsoptions={"title":"Example title",# The video title"description":"Example description",# The video description"tags":["tag1","tag2","tag3"],"categoryId":"22","privacyStatus":"private",# Video privacy. Can either be "public", "private", or "unlisted""kids":False,# Specifies if the Video if for kids or not. Defaults to False."thumbnailLink":"https://cdn.havecamerawilltravel.com/photographer/files/2020/01/youtube-logo-new-1068x510.jpg"# Optional. Specifies video thumbnail.}# upload videouploader.upload(file_path,options)Parametertagsshould be list of strings only. The parametercategoryIdrefers to YouTube internal categories, more information can be foundhere.4. Closing the uploaderuploader.close()