Automating the Hummingbird Video Upload to YouTube or How I finally got Cron to do what I needed it to do but in the ugliest way possible

Several weeks ago in Cronjob Redux I wrote that I had finally gotten Cron to automate the entire process of compiling the h264 files into an mp4 and uploading it to YouTube.

I hadn’t. And it took the better part of the last 2 weeks to figure out what the heck was going on.

Part of what I wrote before was correct. I wasn’t able to read the client_secrets.json file and that was leading to an error.

I was not correct on the creation of the though.

The reason I got it to run automatically that night was because I had, in my testing, created the and when cron ran my it was able to use what was already there.

The next night when it ran, the was already there, but the h264 files that were referenced in it weren’t. This lead to no video being uploaded and me being confused.

The issue was that cron was unable to run the part of the script that generates the script to create the mp4 file.

I’m close to having a fix for that, but for now I did the most inelegant thing possible. I broke up the script in cron so it looks like this:

00 06 * * * /home/pi/Documents/python_projects/
10 19 * * * /home/pi/Documents/python_projects/
11 19 * * * /home/pi/Documents/python_projects/ >> $HOME/Documents/python_projects/ 2>&1
12 19 * * * /home/pi/Documents/python_projects/
13 19 * * * /home/pi/Documents/python_projects/

At 6am every morning the runs and removes the h264 files, the mp4 file and the script

At 7:10pm the ‘header’ for the runs. At 7:11pm the ‘body’ for runs. At 7:12pm the ‘footer’ for runs.

Finally at 7:13pm the compiles the h264 files into an mp4 and uploads it to YouTube.

Last night while I was at a School Board meeting the whole process ran on it’s own. I was super pumped when I checked my YouTube channel and saw that the May 1 hummingbird video was there and I didn’t have to do anything.