Reputation: 41
Can (and perhaps should) I be able to delete a youtube video with the youtube data api using only an ad hoc generated access token for authorization in a "no user interaction" solution.
I am attempting to use the google youtube data api for the relatively simple task of deleting one of my existing youtube videos then uploading a new one to replace it.
Edited this to original I've looked again at the shoogle https://pypi.python.org/pypi/shoogle/0.1.0 package which:
- Exposes agnostically all the services in the API.
- Provides infrastructure for the Oauth2 authentication (console or QT/GTK browser).
- Shows info so you can build the JSON requests.
- Credentials for scopes (separated by profiles) are stored for later use.
It may be worth a closer look. It operates as a shell command requires python 3. But before I install python 3 and try to figure it out it would be great to learn more about it but I can find nothing on SO and not much besides the git-hub and python package site. If there is anyone using it or can provide direction it would be great to hear.
Original Post Continued
Most of the scopes are to "Manage your YouTube videos/account" but it is unclear how the api would know from my google client id (which I used to generate a re-usable refresh token) which youtube channel(s) I own. Could I delete any video regardless of ownership, doesn't seem like I could. So my concern is that I will expend a lot of effort on a solution I ultimately can't use. This project is for my weather station website to be able to link to a high resolution time lapse video of the last hours weather hosted on youtube, basically a hobbyist project.
The use of the api requires: a sign up to the Google Cloud Platform, quotas which may have some cost, using oauth2 which I am slowly figuring out. None of these are necessarily show stoppers but but seems like a heavy handed solution. Still it is, at this time, the only method I've found to accomplish the delete portion of the task.
I could probably accomplish something acceptable using Dropbox but youtube is the de facto standard for video sharing and I'd like to make it part of my solution if I can.
Upvotes: 0
Views: 184
Reputation: 41
The answer is yes. Or at least one viable solution.
Using the youtube data api python samples https://developers.google.com/youtube/v3/code_samples/python and the delete example in this post Deleting a video from youtube YouTube Data API v3 and python I was able to both delete and upload youtube videos after running the scripts once to generate and store an authorization code. The first run returns a url to your google account and after "Allowing" access to the application a code is returned which the application stores for later use.
I had mistakenly canceled the apps when I received the the "Allow" message thinking this was required for each run. After several re-readings of many posts and examining the samples I realized the authorization code could and was being saved for later use.
There are other solutions which seem to wrap api functionality into command line solutions which are also viable but after resolving my confusion about how the youtube api and oauth2 work they are also useful solutions.
Upvotes: 1