Based on your requirements, it seems you're looking for a way to use the YouTube API for personal use without going through the extensive review process required for public applications. Unfortunately, there isn't a built-in way to restrict API access to local use only in the YouTube API.
However there is be a workaround for your needs:
- You can use the YouTube Data API v3 with OAuth 2.0 authentication for your personal Google account.
- This method allows you to create a project in the Google Developers Console and use the API without going through the verification process, as long as you're the only user.
Here's how you can set this up:
- Go to the Google Developers Console.
- Create a new project.
- Enable the YouTube Data API v3 for your project.
- Create OAuth 2.0 credentials (Client ID and Client Secret) for a desktop application.
- Use these credentials in your application.
First of all you need a method to handle OAuth 2.0 authentication then you just need to add a method for uploading videos.
Here's a example how you can implement a YouTubeAPI class in python to include a video upload method:
from googleapiclient.http import MediaFileUpload
class YouTubeAPI:
def upload_video(self, file_path, title, description, category_id, privacy_status='private'):
body = {
'snippet': {
'title': title,
'description': description,
'categoryId': category_id
},
'status': {
'privacyStatus': privacy_status
}
}
media = MediaFileUpload(file_path, resumable=True)
request = self.youtube.videos().insert(
part='snippet,status',
body=body,
media_body=media
)
response = request.execute()
return response
Then you can add a new endpoint to handle video uploads. This setup allows you to use the YouTube API for personal use without going through the extensive review process. However, keep in mind:
- The API quota is limited for unverified apps.
- This should only be used for personal projects where you're the only user.
- You'll need to handle the OAuth flow manually
Include the necessary packages:
google-api-python-client
google-auth-oauthlib
google-auth-httplib2
as long as you're the only user of the application this solution can allow you to upload videos programmatically while avoiding the extensive review process. Good luck :)
Answer from MariO on Stack Overflow