So you’re making lots of movies and you want things to upload to youtube automatically without you having to do any heavy lifting? If you are comfortable with a little bit of terminal and command line stuff, no problem.
A few things you will need:
Gmail account and Youtube account. These will be linked. You can use one gmail account as the developer for multiple youtube accounts but each youtube account needs it’s own independent email address, and for multiple gmail accounts you might need to get some dummy address at yahoo.com or mail.com as an alternative email. Then get yourself a developer key while logged into your developer gmail account.
Python 2.6 is probably already installed. But if not, install that too.
We’ve gotten this working for MacOSX and Linux (ubuntu 9.10 and fedora 11 anyway).
It’s probably not too hard to get it working with Windows but we’ve never tried.
Files you need:
uploader2.py at http://gist.github.com/319734
edit login information for youtube and gmail accounts.
edit developer key. edit the keywords and description to fit your project.
videochecker.sh at https://gist.github.com/e2569bca9313b1056c0e
check the path.
Thanks to Sean Levin for writing these.
Gdata and Atom directories. They are zipped and downloadable here: http://www.divshare.com/download/11521457-3da Unzip and place into same directory as uploader2.py.
Copy these files into whatever directory you will be uploading videos from.
You will now need to edit both of these files as noted above. Do you have a favorite text editor for simple code? We like smultron on mac and gedit or emacs on linux but any will do. Whatever music you like.
make sure both files are executable.
chmod 755 uploader2.py
chmod 755 videochecker.sh
then try it out manually. from the video directory prompt try running the videochecker.
yourvideodirectory$ ./videochecker.sh
Got Upload directory
You have a save directory
Not running
just before loop start
inside for loop
Uploading OMPD-20100301-20100302.mp4
uploader-log: running doit with the_time=2010-03-02T00:00:53 and the_filename=OMPD-20100301-20100302.mp4
uploader-log: created media_group
uploader-log: created youtube entry
uploader-log: created YouTubeService
uploader-log: attempting to find previous login token in token file
uploader-log: token file found
uploader-log: set login token to DQAAAHUAAA ...
uploader-log: trying login with captcha_token=None and captcha_response=None
uploader-log: login succeeded continuing on to upload
uploader-log: saving token (DQAAAHYAAABXiMigRrgi5 ... ) to token file (youtube_login_token.txt)
uploader-log: starting to upload video entry
uploader-log: completed upload of video entry
uploader-log: OMPD-20100301-20100302.mp4 uploaded to service successfully. Returning success to calling script (0)
yourvideodirectory$
if you’re getting an error with videochecker, try changing the first line to
#! /bin/bash -ex
and it will output lots of extra info as it runs.
Ok. So you made it that far and now you want to set it up so it runs automatically each day or week or hour. Time for crontab. What is a crontab you ask? It’s sort of like asking your alarm clock to run a program instead of make a loud sound. It’s just a simple text file that you add some instructions to. The only problem is that you usually edit it in vi (a text editor). vi is nice and all but it’s rather confusing if you haven’t used it before. With vi, there are 2 modes, insert-text mode and command mode. 3 most useful key sequences are:
i
– enter insert mode,
esc
– exit insert mode
ZZ
– save file and exit program.
Want to learn more: http://heather.cs.ucdavis.edu/~matloff/UnixAndC/Editors/ViIntro.html
In the terminal window (here your current path matters not), enter
crontab -e
type i
to put the editor in INSERT mode. (see text in bottom left of editor)
– then make your crontab look like:
# m h dom mon dow command
*/10 * * * * /home/yourlinuxboxname/Videos/Webcam/videochecker.sh
(which runs that script every 10 minutes.)
or
# m h dom mon dow command
* 3 * * * /home/yourmac/Movies/AUTOUPLOAD/videochecker.sh
(which runs that script at 3am each evening. But only when the computer is awake.)
– hit the ‘esc’ key to get out of insert mode.
– then type ZZ to save and exit.
Let us know how this works for you and we will try to keep an updated version of these instructions.
Tags: broadcaster, python, script, twvee, uploader, video, videobooth, youtube
March 3, 2010 at 9:13 pm |
[…] Want automatic uploading to YOUTUBE? Follow the instructions here: https://broadcasterproject.wordpress.com/2010/03/03/howto-youtube-auto-upload-script/ […]
May 28, 2010 at 11:15 pm |
I’m running ubuntu 10.04, and am having serious issues with the videochecker.sh script: It gave me a ton of error messages until I removed quotes from some of the string variables like SEARCH_DIR.
This is what I have so far:
lhaeh@ubuntu:~/youtube$ ./videochecker.sh
“Got Videos directory”
“You have a save directory”
“Not running”
./videochecker.sh: line 105: syntax error near unexpected token `done’
./videochecker.sh: line 105: `done’
Maybe it is not picking up where my videos are? Thanks for making this, it looks like it will be very useful.
May 29, 2010 at 1:26 am |
lars,
mac and linux handle shell differently and i think you need to delete the ” ” around any variable name. or better yet, just regrab the gist. i just deleted them all from it.
for those who want the mac version, it’s this version https://gist.github.com/e2569bca9313b1056c0e/7730b56f15f47f18e3f74600eb34d3410d4ebb86
one other thing, i forgot to include atom and gdata directories which you need as well: http://www.divshare.com/download/11521457-3da
download and unzip this and there will be 2 directories (gdata and atom) and place these into same folder as uploader2.py
July 14, 2010 at 5:45 pm |
[…] If you’d like the movies to upload to a youtube channel automatically every night, you can do that as well. Instructions here. […]
July 16, 2010 at 5:13 pm |
[…] python uploading scripts for youtube By t he ans weri saque stion? UPDATE: condiser skipping this post and going right to this newer one: https://broadcasterproject.wordpress.com/2010/03/03/howto-youtube-auto-upload-script/ […]
September 24, 2010 at 12:46 pm |
Hello Guys, I love th elook of this. Two questions though.
Can it be adapted to PHP?
And does it still work in these days of YouTube API?
thanks
September 24, 2010 at 2:42 pm |
yes this still works. we use it all the time.
it probably can be adapted to php if someone takes the time to do the work.
January 12, 2011 at 7:34 pm |
Hey, the uploader2.py is your script, right? Can you update it to support the ability to specify video name, category and description?
January 14, 2011 at 9:15 pm |
yes you can edit the python file to change the name, category, and description. just edit uploader2.py in a text editor that will keep the spaces as they are. python is space and tab sensitive.
February 18, 2011 at 7:32 pm |
[…] The machine also uses the youtube uploader stuff described in this post. […]
February 19, 2011 at 2:54 am |
Ready made python uploader here:
http://code.google.com/p/youtube-upload/
June 16, 2011 at 11:32 am |
youtube uploader
I have followed the instructions as listed. When I run manually the video checker I get
You have new mail.
ojokr:~ robert$ cd /Users/robert/Desktop/YOUTUBEROBERT
ojokr:YOUTUBEROBERT robert$ ./videochecker.sh+ SEARCH_DIR=/Users/robert/Desktop/YOUTUBEROBERT/MyVideos/MyVideos
+ COPY_DIR=/Users/robert/Desktop/YOUTUBEROBERT/MyVideos/MyVideos/copies
+ ‘[‘ -d /Users/robert/Desktop/YOUTUBEROBERT/MyVideos/MyVideos ‘]’
+ echo $’?\200\234Got’ Videos $’directory?\200\235′
“Got Videos directory”
+ cd /Users/robert/Desktop/YOUTUBEROBERT/MyVideos/MyVideos
+ ‘[‘ -d /Users/robert/Desktop/YOUTUBEROBERT/MyVideos/MyVideos/copies ‘]’
+ echo $’?\200\234You’ have a save $’directory?\200\235′
“You have a save directory”
++ basename ./videochecker.sh
+ PDIR=./
++ basename ./videochecker.sh
+ LCK_FILE=videochecker.sh.lck
+ ‘[‘ -f videochecker.sh.lck ‘]’
++ head -n 1 videochecker.sh.lck
+ MYPID=2048
++ ps -p 2048
++ grep 2048
+ TEST_RUNNING=
ojokr:YOUTUBEROBERT robert$
When i run the upload in terminal Mac I get the following error
robert$ /Users/robert/Desktop/YOUTUBEROBERT/uploader2.py
from: can’t read /var/mail/gdata.youtube
from: can’t read /var/mail/gdata.youtube.service
/Users/robert/Desktop/YOUTUBEROBERT/uploader2.py: line 3: import: command not found
from: can’t read /var/mail/gdata.service
from: can’t read /var/mail/optparse
/Users/robert/Desktop/YOUTUBEROBERT/uploader2.py: line 8: import: command not found
/Users/robert/Desktop/YOUTUBEROBERT/uploader2.py: line 9: import: command not found
/Users/robert/Desktop/YOUTUBEROBERT/uploader2.py: line 10: import: command not found
/Users/robert/Desktop/YOUTUBEROBERT/uploader2.py: line 13: debug: command not found
/Users/robert/Desktop/YOUTUBEROBERT/uploader2.py: line 15: syntax error near unexpected token `(‘
/Users/robert/Desktop/YOUTUBEROBERT/uploader2.py: line 15: `def log(line):’
ojokr:YOUTUBEROBERT robert$
Any suggestions?
June 17, 2011 at 11:59 pm |
do you have the gdata and atom directories installed? i think that is the error. check the divshare link above and make sure those directories are in the same directory as the .py script.
also, you should consider using this program instead, i think it is better. works well on linux, but i haven’t tried it on mac.
Ready made python uploader here:
http://code.google.com/p/youtube-upload/
June 20, 2011 at 8:29 am
Thanks for the python however it appears that I cannot auto upload as in the one above. Both the atom gdata are in the same folder as the videochecker.sh and upload2.py. I removed them from the folder Atom-Gdata and placed them both at top level of the folder.
When I run the uploader2.py I get the following report. There must be more that needs modifying than the above instructions provide?
Thanks anyway for the help
/Users/robertojok/Desktop/YouTubeupload/uploader2.py
from: can’t read /var/mail/gdata.youtube
from: can’t read /var/mail/gdata.youtube.service
/Users/robertojok/Desktop/YouTubeupload/uploader2.py: line 3: import: command not found
from: can’t read /var/mail/gdata.service
from: can’t read /var/mail/optparse
/Users/robertojok/Desktop/YouTubeupload/uploader2.py: line 8: import: command not found
/Users/robertojok/Desktop/YouTubeupload/uploader2.py: line 9: import: command not found
/Users/robertojok/Desktop/YouTubeupload/uploader2.py: line 10: import: command not found
/Users/robertojok/Desktop/YouTubeupload/uploader2.py: line 13: debug: command not found
/Users/robertojok/Desktop/YouTubeupload/uploader2.py: line 15: syntax error near unexpected token `(‘
/Users/robertojok/Desktop/YouTubeupload/uploader2.py: line 15: `def log(line):’
June 20, 2011 at 8:37 am
I forgot to mention that the line 3: import: command not found
When I checked the uploader2.py line 3 it has
import gdata
Is that correct or should it be modified?
June 20, 2011 at 4:30 pm |
robert do you have developer tools installed?
xcode?
try this at the command line to see if you have python 2.6
robert$which python
June 21, 2011 at 7:57 am
I have installed Python Version 3.1.1
running $which python
returns
/usr/bin/python
June 21, 2011 at 8:00 am
developer tools is installed xcode available too. Thanks for the reply
June 21, 2011 at 2:28 pm
python is indent sensitive.
did you copy and paste the file
or did you just unzip and run it
that could be an issue
June 27, 2011 at 8:38 am |
I edited the files that I am required to edit in Text wrangler. the Files are already available from the download
July 4, 2011 at 5:12 pm |
The script is great but I am having the problem below.
“Got Videos directory”
“You have a save directory”
“Not running”
“Uploading ./0050.flv”
/usr/local/bin/gdata/tlslite/utils/cryptomath.py:9: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
import sha
uploader-log: running doit with the_time=20110704171025 and the_filename=./0050.flv
uploader-log: created media_group
uploader-log: created youtube entry
uploader-log: created YouTubeService
uploader-log: attempting to find previous login token in token file
uploader-log: unable to set previous login token, continuing with default login settings
uploader-log: trying login with captcha_token=None and captcha_response=None
uploader-log: Some Error ocurred, returning failure to calling script (1)
global name ‘Error’ is not defined
any help will be appreciated…
July 5, 2011 at 4:40 pm |
not sure what you error is. could be a lot of things.
consider using this uploader instead:
http://code.google.com/p/youtube-upload/
July 5, 2011 at 8:40 pm |
I gave up. I do not think that the script works. If it does then there is considerably more that needs to be done to it for it to work.
This one
“http://code.google.com/p/youtube-upload/”
seems better BUT means you would have to keep modifying it each time to get a file uploaded.
I thought I could use podcast producer workflow to post files to a folder then have the above script run from that folder and upload to youtube; BUT cannot get it to work.
February 9, 2012 at 5:04 am |
Hi – I am running a Joomla site with lots of users uploading video into JomSocial stream – I want to be able to cron load user videos to our YT channel automatically. does anyone know of a Joomla plugin or component that can handle this task? Anyone who can do this – i can pay for DEV. Please let me know.
Peace
November 21, 2012 at 1:07 am |
Is this GPL? What license is this under?
November 21, 2012 at 1:21 am |
all code here is public domain.
April 8, 2013 at 9:00 am |
Should this work with Python 2.4? For some reason I have it on my VPS – no other reason to upgrade. But if necessary, I will. I’m also getting error
uploader-log: trying login with captcha_token=None and captcha_response=None
uploader-log: Some Error ocurred, returning failure to calling script (1)
Could it be Python or it’s something else?
April 9, 2013 at 1:04 pm |
i apologize, it’s been a while since i ran this script.
but i’m guessing it’s youtube login not successful rather than python version.
i will try to run again sometime in next couple weeks and report back…
April 9, 2013 at 4:07 pm
Hello. No need for apologizes. Your response wa quite fast for private blog. However, I need to report to you and any other interested parties that it was Python version. Script is still functional and already running on my CentOS box 🙂
May 3, 2013 at 12:13 pm
great! thanks!
May 3, 2013 at 10:17 am |
Can you please post for windows os?
May 3, 2013 at 12:12 pm |
if you install cygwin it most of the rest of the instructions should be useable.
i don’t own a windows machine so i can’t do it but if you try it out, i can post it here or link to you.
April 26, 2014 at 10:20 am |
Hi !
I’m trying to use the script on a Synology running ash instead of bash. So I replaced /bash by /ash in the first line and ran it.
Script launched before telling there is an unknown operand error. I isolated this line :
“if [[ ‘*’ != ${f:2:1} ]]; then”
Totally unfamiliar with ash / bash prog, could you tell me what’s wrong ?
Thank you.
January 28, 2015 at 2:47 pm |
i’m not sure. try http://www.linuxquestions.org/ for knowledgable people in shell scripts.