|
|
@ -299,30 +299,30 @@ def upload_video(oauth, secret, options): |
|
|
|
headers = { |
|
|
|
'Content-Type': multipart_data.content_type |
|
|
|
} |
|
|
|
# response = oauth.post(url + "/api/v1/videos/upload", |
|
|
|
# data=multipart_data, |
|
|
|
# headers=headers) |
|
|
|
# if response is not None: |
|
|
|
# if response.status_code == 200: |
|
|
|
# jresponse = response.json() |
|
|
|
# jresponse = jresponse['video'] |
|
|
|
# uuid = jresponse['uuid'] |
|
|
|
# video_id = str(jresponse['id']) |
|
|
|
# logger.info('Peertube: Video was successfully uploaded.') |
|
|
|
# template = 'Peertube: Watch it at %s/videos/watch/%s.' |
|
|
|
# logger.info(template % (url, uuid)) |
|
|
|
# template_stdout = '%s/videos/watch/%s' |
|
|
|
# if options.get('--url-only'): |
|
|
|
# logger_stdout.info(template_stdout % (url, uuid)) |
|
|
|
# elif options.get('--batch'): |
|
|
|
# logger_stdout.info("Peertube: " + template_stdout % (url, uuid)) |
|
|
|
# # Upload is successful we may set playlist |
|
|
|
# if options.get('--playlist'): |
|
|
|
# set_playlist(oauth, url, video_id, playlist_id) |
|
|
|
# else: |
|
|
|
# logger.critical(('Peertube: The upload failed with an unexpected response: ' |
|
|
|
# '%s') % response) |
|
|
|
# exit(1) |
|
|
|
response = oauth.post(url + "/api/v1/videos/upload", |
|
|
|
data=multipart_data, |
|
|
|
headers=headers) |
|
|
|
if response is not None: |
|
|
|
if response.status_code == 200: |
|
|
|
jresponse = response.json() |
|
|
|
jresponse = jresponse['video'] |
|
|
|
uuid = jresponse['uuid'] |
|
|
|
video_id = str(jresponse['id']) |
|
|
|
logger.info('Peertube: Video was successfully uploaded.') |
|
|
|
template = 'Peertube: Watch it at %s/videos/watch/%s.' |
|
|
|
logger.info(template % (url, uuid)) |
|
|
|
template_stdout = '%s/videos/watch/%s' |
|
|
|
if options.get('--url-only'): |
|
|
|
logger_stdout.info(template_stdout % (url, uuid)) |
|
|
|
elif options.get('--batch'): |
|
|
|
logger_stdout.info("Peertube: " + template_stdout % (url, uuid)) |
|
|
|
# Upload is successful we may set playlist |
|
|
|
if options.get('--playlist'): |
|
|
|
set_playlist(oauth, url, video_id, playlist_id) |
|
|
|
else: |
|
|
|
logger.critical(('Peertube: The upload failed with an unexpected response: ' |
|
|
|
'%s') % response) |
|
|
|
exit(1) |
|
|
|
|
|
|
|
|
|
|
|
def run(options): |
|
|
|