So Amazon has the Sainsmart Coreception for $100 off (I just created a subReddit for it). And since I’ve been looking for a larger CoreXY printer to replace/compliment my Ender 5, I decided to buy it. And while I wait for it to arrive, I wanted to figure out if there was a better way to directly upload my timelapses to YouTube. My old method, stopped working. And since it was a little complicated I figured I would create a better solution that would be more reliable.

Youtube-Upload Python Script

This process is built around the youtube-upload python script by tokland. There is some setup involved, but it is pretty easy and takes about 5 minutes. The readme for the script details it well, and I just had to follow the steps. When I first installed it, I had accidentally missed the dependencies section, so make sure you install those. I installed this on Ubuntu (Linux Mint) running on a PC, but I’m pretty sure this will work on the Pi.

Be sure to test it out and make sure that you are able to upload a video using the command. You do have to specify the title. You can use the command below to test:

youtube-upload –title=inser_title_here /path/to/move/file.mp4

youtube-upload --title=inser_title_here /path/to/move/file.mp4

OctoPrint Events

At first, I was going to make a script that just monitors the timelapse folder for new files, but then I learned about OctoPrint events, which can be used to trigger the youtube-upload script. This was my first time dealing with events, but it was pretty easy. Basically, nearly anytime OctoPrint does something, it triggers an event. One event that is generated is the MovieDone event. That fires when a timelapse has been generated.

Unfortunately, you do have to edit the OctoPrint config file. For me, it is located at /home/username/.octoprint/config.yaml. I used WinSCP via SSH to edit the file, but you can use whatever you feel comfortable with. Inside of the config file, you just need to add the following code. I added between the ‘controls’ and ‘features’ sections since all the sections appear to be in alphabetical order:

events:
    enabled: true
    subscriptions:
    -   command: youtube-upload --title={gcode} {movie}
        event: MovieDone
        type: system

‘enabled: true’ just let’s OctoPrint know that the events are enabled. If you ever want to disable them in the future, just set that here instead of just deleting the section. ‘subscriptions’ sets the ‘event’ you want to monitor (MovieDone), and the ‘command’ you want to run. The ‘type’ just tells it that it is a system command as opposed to a gcode command. As for the actual command, the {gcode} variable tells OctoPrint to insert the name of the gcode file that was printed, and {movie} is the full path to the movie file.

Then save the file and restart OctoPrint. Next time you print, it should automatically upload the video to YouTube. I use the Virtual Printer, Virtual Printer Settings, and DryRun plugins to test things out. This way I can test it without actually having to print something.

 

One Reply to “Automatically Upload Timelapses Directly From OctoPrint”

Leave a Reply