Automatically upload timelapses to YouTube


Using youtube-upload and the MovieDone event hook it is possible to automatically upload finished timelapses to YouTube.

You'll need to install youtube-upload first. Assuming you are on a Pi, this can accomplished via
sudo apt-get install python-gdata
wget http://youtube-upload.googlecode.com...load-0.7.3.tgz
tar xfz youtube-upload-0.7.3.tgz
cd youtube-upload-0.7.3
sudo python setup.py install


After that, you'll need to add the following event subscription to events > subscriptions in your config.yaml
- command: 'youtube-upload
--email="<yourUser>"
--password="<yourPassword>"
--title="Timelapse: {gcode}"
--description="Timelapse of {gcode}, printed and recorded via OctoPrint"
--category="Tech"
--keywords=OctoPrint "{movie}"'
event: MovieDone
type: system



Substitute <yourUser> and <yourPassword> with your YouTube username and password respectively. If you are using Google's two factor authentication, you'll need to create an application password to use here. If you want to make your movie unlisted, add --unlisted after the keywords, if you want to make it private, add --private.



Send an email incl. a snapshot of the printed object upon print completion

Note: This receipt explains things for a Raspbian/OctoPi-based setup. It also assumes that you've got mjpg-streamer setup as explained here and listening on port 8080.

First you'll need to install a couple of new packages on your system in order to be able to send emails. Open an SSH session into your Pi (or alternatively open a terminal on it if it happens to be connected to monitor, mouse and keyboard). Then:
sudo apt-get install ssmtp mailutils mpack
Modify /etc/ssmtp/ssmtp.conf according to the settings needed to send mail via your mail provider. For Gmail it must look something like this:

AuthMethod=LOGIN
AuthUser=<your gmail address>
AuthPass=<your gmail password>
UseTLS=YES
UseSTARTTLS=YES
mailhub=smtp.gmail.com:587


Add the following line to your event subscriptions in config.yaml, substituting <your mail address> with your email address where you'd like to get the mail sent to.

- event: PrintDone
command: curl -o /tmp/printDone.jpg "http://localhost:8080/?action=snapshot" && mpack -s "Print of {file} finished" /tmp/printDone.jpg <your mail address>
type: system


This will send you an email with a subject of "Print of <printed gcode file> finished" and a webcam snapshot of the webcam attached each time a print finishes.

If you want to have a certain email address as sender (a.e. to send mails to ifttt) you have to specify an alias in /etc/ssmtp/revaliases (for user pi):
pi:email@mydomain.de

In /etc/ssmtp/ssmtp.confyou have to add:

rewriteDomain=mydomain.de
hostname=mydomain.de
FromLineOverride=NO

(not sure about hostname, maybe it's ok just to have rewriteDomain)



Push notifications for Android / iOS via Pushover

Pushover is an application that lets you push notifications to your Android or iOS device via a simple REST endpoint.

You'll need to register for an account and install the app. Then register a new 'application' at https://pushover.net/apps/build (name it 'Octoprint' or something you remember).

The event hook will just do a simple CURL request:

- event: PrintDone
command: curl -s
-F "token=API_TOKEN"
-F "user=USER_TOKEN"
-F "message=Completed {file}"
-F "title=OctoPrint"
https://api.pushover.net/1/messages.json
type: system


The printer will send a notification to all phones logged in to your account. If you've got a Pebble smartwatch, you can enable the app to relay the notification there too.



Push notifications to iOS via Mail

Pushover is nice, but not free.

Set up a iCloud email address and use the following code to get instant email alerts to your iDevice, make sure your account is set to push.

- command: mail -s "3DPrint of {file} DONE!" YOUR_EMAIL@me.com < /dev/null
event: PrintDone
type: system


If you prefer a slightly quicker alert then change 'PrintDone' to 'Alert' and put a M300 command at the start of your end code.
(Make sure there are no tabs in the code)

Make sure you install sstmp and edit the config with your email account information. I use my gmail account. See "Send an email incl. a snapshot of the printed object upon print completion" above for instructions.



Automatically start/stop mjpg_streamer via eventhooks

In config.yaml add the following commands to your subscriptions for PrintStarted and PrintDone to automatically start and stop mjpg-streamer during prints in versions newer than 1.1.0. This way the mjpg-streamer isn't running all the time as in the OctoPi implementation.

Note: This recipe explains things for a scratch Raspbian based setup and does not work directly with OctoPi. It also assumes that you've got mjpg-streamer setup as explained here and listening on port 8080.

events:
enabled: True
- subscriptions:
- event: PrintStarted
command: mjpg_streamer -b -i "/usr/local/lib/input_uvc.so -n" -o "/usr/local/lib/output_http.so -w /usr/local/www"
type: system
- event: PrintDone
command: killall mjpg_streamer
type: system