Mhodgy
Posts: 1
Joined: Sun Apr 23, 2017 12:59 pm

youtube API help needed

Wed Apr 26, 2017 12:53 am

hey guys, i'm an absolute novice to raspberry pi's and the last week has been a bit of a rollercoaster for me. i'm doing a project in which ive set up the camera module to record 10 second videos when someone clicks the button and then it saves them to be MP4's. mind numbingly simple for most i assume but its been a lot of learning for myself.

my next step is that i want these videos to be automatically uploaded to youtube as soon as this has happened. Now ive had a look into this a bit and have started trying to use googles youtube data api. https://developers.google.com/youtube/v ... ng_a_video

ive tried to follow these steps but my understanding of code is a bit too basic to really understand what i'm doing.
this gentleman here gave a bit more detail and ive looked at both of the links he refers to and sort of get what is supposed to happen. http://www.nicksuch.com/2016/08/31/rasp ... -uploader/

my question now is: in as simple terms as possible what do i need to do now?

i have set up my project and api on google and have made the client_secrets.json folder and run the sample script and i receive this.

usage: api sample.py [--auth_host_name AUTH_HOST_NAME] [--noauth_local_webserver] [--auth_host_port [AUTH_HOST_PORT [AUTH_HOST_PORT ...]]] [--logging_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}] --file FILE [--title TITLE] [--description DESCRIPTION] [--category CATEGORY] [--keywords KEYWORDS] [--privacyStatus {public,private,unlisted}] api sample.py: error: argument --file is required

sorry if this is a stupid question or needs more info
thanks in advance!

User avatar
topguy
Posts: 6466
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: youtube API help needed

Wed Apr 26, 2017 12:21 pm

How do you call the script ? The error says quite clearly "error: argument --file is required" so its saying that you have not supplied the correct arguments.

The example ("python python/upload_video.py --file test_20160831.mov --privacyStatus unlisted" ) clearly uses "--file" to specify which file to upload.

ghostinthepi
Posts: 9
Joined: Fri Feb 24, 2017 6:25 am

Re: youtube API help needed

Thu Apr 27, 2017 6:37 am

Yes, sometimes commands require multiple arguments.

If you become too dependent on other's programs that you don't understand, you can always start smaller in whatever way you define that. :roll:

User avatar
Rbert
Posts: 39
Joined: Mon May 01, 2017 8:57 pm
Location: Amsterdam
Contact: Website YouTube

Re: youtube API help needed

Mon May 01, 2017 9:27 pm

Hi Mhodgy,
I noticed you're request and I am more or less dealing with the same question.

It's great that everyone provide examples of code. As a newbee I managed to get a laser distance detector and video recording working based on examples code in Raspberry python.
Now I want to upload the recorded short (10s) movies to youtube (or a good alternative)

My plan is to get existing sample python code working and then merge it into my existing python code of the project I'm working on.
I thought to follow these examples:
https://developers.google.com/youtube/v ... ng_a_video
http://www.nicksuch.com/2016/08/31/rasp ... -uploader/

Before I continue I though it was a good idea to see if you've it running and if you have any additional tips/tricks.
If not, I'll proceed and (if successful) I keep this post updated.

User avatar
Rbert
Posts: 39
Joined: Mon May 01, 2017 8:57 pm
Location: Amsterdam
Contact: Website YouTube

Re: youtube API help needed

Tue May 02, 2017 10:15 pm

I got it working!
I'm still on the "hello world" level, but by reading the tips&tricks from others I got the youtube api working.
The problem is that posts (like this one also) will be available and once you start to use the tips&tricks, screens, names and referrals are changed.
Credits to the google team, they have outstanding step-by-step process to make it easy for you.
I used the following instructions:
https://developers.google.com/youtube/v ... art/python
http://www.cnx-software.com/2014/02/09/ ... -in-linux/

by following the proces you can simply download your own file "client_secrets.json"
please bear in mind that i had to copy it into another file "client_secret.json"
I created a directory "youtube" in the Pi and put both files there.

After that i simply started the webbrowser on the Pi and logged in into google.
After that i created a directory on the pi containing:
client_secret.json
client_secrets.json (exactly the same file but with the additional 's' in the file name)
upload_video.py (unmodified sample code )
test.h264 (this is a short test video file recorded with the pi camera)
I opened the terminal and entered the command which looks like this:

pi@raspberrypi:~/youtube $ python upload_video.py --file="test.h264" --title="test3" --description="test3" --keywords="test" --category="22" --privacyStatus="private"

After enter it confirmed a successful upload and i looked on my youtube page which showed the video.
Easy!

If I can do it, I'm sure anybody can do it!

Return to “General discussion”