NokiMo
FormerLurker
FormerLurker

patreon


Dropbox Timelapse Plugin Compatibility and Enhancements

A few days ago I got a request from a Patron to take a look at a github issue regarding the excellent OctoPrint Dropbox Timelapse plugin by Justin Slay. Some changes I made to Octolapse had apparently broken the timelapse upload provided by this plugin.  Prior to v0.4.0rc1.dev3, Octolapse used the OctoPrint Movie Done event to create a popup and add the timelapse file to the file browser on the timelapse tab.  Now that Octolapse has its own timelapse browser, I needed to create a new event to accomplish the same thing without causing unnecessary side effects, like an extra popup notification.

However, adding this custom event had an unintended side effect:  Plugins that were taking advantage of the MovieDone event no longer got triggered after a timelapse was produced.  Since I have been mostly waiting around for feedback regarding the latest development release candidates, I figured I might as well help out with this issue I created.

At first I just offered some advice regarding how I would handle the situation.  The solution seemed obvious at first, but like most things software related, there were many ways to tackle the problem, each with their own pros and cons.  One other solution I strongly considered was re-adding the original MovieDone event back to Octolapse.  This had some disadvantages, and in the end I decided not to do this, even though Justin submitted a pull request for this feature.  Testing revealed the same issues that had prompted me to remove the event in the first place.  

After a lot of contemplation, I decided to implement what I thought would be a good general solution, building off of a previous branch created by Sam Kemp. Sam's branch seemed to work just fine, but I thought it could be enhanced by generalizing the solution and giving users the ability to handle other types of files that one might want to upload to Dropbox.

At first, I just added the new Octolapse Movie Done event to a default settings with some extra error handling and a slightly more efficient method of detecting the event, but this wasn't very satisfying to me.  Without modifying the GUI so users could add their own custom events, it seemed limiting (even though they could theoretically be added directly to the config.yaml file, but that is a pain).  Adding new settings is rarely fun, but because my wife had fallen asleep and I was bored, I decided to roll up my sleeves and dug in.  Eventually I got them all added and working as expected.  Here is what the new settings tab looks like:

To test the new system, I decided to add another new event to Octolapse:  Snapshot Archive Done.  This event gets fired if a snapshot archive (a new feature in v0.4.0rc1.dev3) is generated.  It was quite trivial to add (thanks, Gina, for the great features!), so I figured what the heck.  All I had to do after that was manually enter the new event name as well as the key to extract the archive path:

After this I fired up a print, generated a timelapse, and it uploaded just as expected!  I added the new archive event to the default settings (one advantage of adding a feature yourself, lol) since even if Octolapse is not installed, no errors will be generated.  I did add a warning in the plugin log file that will show up if any custom event doesn't exist, but a warning will only be generated if you are logging warnings for the Dropbox Timelapse plugin.  Also, performance will not be impacted at all by adding events that don't exist, since only events that actually exist are watched for.

At this point, the Dropbox Timelapse plugin issue seemed to be solved.  I was very happy with the changes so far but noticed one other missing feature:  there were no notifications that the upload had started or that it was complete.  Not a huge deal, but after looking through the issues on the Dropbox Timelapse plugin github page, I noticed another issue asking for the very same popups that I also wanted to see.  Interestingly, there was also a help wanted tag next to that issue.  I figured while I was already monkeying around with the code, I might as well add those, too.  I had a few useful snippets from Octolapse lying around, which made it pretty trivial to add the popups.  I also added popups for file upload/delete errors (it's good to know when things fail).

If you are interested in uploading your OctoLapse timelapse videos or image archives to Dropbox, please check out the branch I created.  You can install it through the OctoPrint plugin manager by clicking Get More... and entering this url in the From Url... text box:

https://github.com/jslay88/OctoPrint-Dropbox-Timelapse/archive/octolapse-hooks-v2.zip

If you want to leave any feedback regarding the custom events, please see this issue.  To leave feedback regarding the popup messages, please see this issue.  I appreciate your comments, and I'm sure Justin does as well!

I'm not sure if this branch will ever make it into the master version, and there still could be some bugs lurking in the new code, but it was fun to help someone else with their plugin, and it gave me something to do while waiting for feedback on the latest Octolapse pre-release.

Would you like to see me make more contributions to existing open-source OctoPrint plugins, or perhaps to OctoPrint itself, or would you rather I continue to focus mostly on Octolapse?  I'd love to hear your thoughts!


Related Creators