In order to keep things moving quickly, I’ve decided to take a shortcut when it comes to uploading timelapse videos to youtube. I’ve decided to basically create a function that passes data to youtube-upload, a command line utility for linux that can upload videos very simply.
Here’s the function:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
def UploadVideo(video,email,password): humantime = str(datetime.now().strftime("%m/%d/%Y")) title = 'Time Lapse of Tomato Plants of the Three Days Prior To ' + str(humantime) description = 'Confused? https://esologic.com/?page_id=1042' category = 'Tech' keywords = 'piplanter' uploadcommand = 'youtube-upload --email=' + email + ' --password=' + password + ' --title="' + title +'"'+ ' --description="' + description + '"' + ' --category=' + category + ' --keywords=' + keywords + ' ' + os.path.normpath(video) ConsoleDebug('Upload Command: ' + uploadcommand) for i in range(10): try: ConsoleDebug('Attempt [' + str(i) + '] To Upload: ' + str(video)) proc = subprocess.Popen(uploadcommand, shell=True, stdout=subprocess.PIPE) output = proc.stdout.read() break except: ConsoleDebug('Upload Failed, Retrying') ConsoleDebug('Upload Error: ' + str(output)) i = i + 1 time.sleep(15) if i < 10: ConsoleDebug('Uploaded After ' + str(i) + ' Attempts, Details: URL [ ' + str(output) + ']' ) return output if i == 10: ConsoleDebug('Upload Was a Failure') return 'Upload was a Failure' |
It should remind you a lot of “TryTweet” from the main version of the PiPlanter.