Wall's Corners Wall's Corners Author
Title: PiPlanter 2 | Adding Youtube Upload Functionality
Author: Wall's Corners
Rating 5 of 5 Des:
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...

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 that can upload videos very simply.

Here’s the function:

def UploadVideo(video,email,password):
humantime = str(datetime.now().strftime(“%m/%d/%Y”))
title = ‘Time Lapse of Tomato of the Three Days Prior To ‘ + str(humantime)
description = ‘Confused? http://ift.tt/22fLKk7;
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 .

 

Share This:

View more at: http://yoursmart.mobi

About Author

Advertisement

Post a Comment

 
Top