Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
use_download_archive = args['--use-download-archive']
if debug_mode:
# Display log messages.
root = logging.getLogger()
root.setLevel(logging.DEBUG)
ch = logging.StreamHandler(sys.stdout)
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter(
'\033[92m[DEBUG]\033[0m %(asctime)s - %(name)s - %(levelname)s - '
'%(message)s')
ch.setFormatter(formatter)
root.addHandler(ch)
metadata = internetarchive.cli.argparser.get_args_dict(args['--metadata'])
tu = TubeUp(verbose=not quiet_mode,
output_template=args['--output'])
try:
for identifier, meta in tu.archive_urls(URLs, metadata, proxy_url,
username, password,
use_download_archive):
print('\n:: Upload Finished. Item information:')
print('Title: %s' % meta['title'])
print('Upload URL: https://archive.org/details/%s\n' % identifier)
except Exception:
print('\n\033[91m' # Start red color text
'An exception just occured, if you found this '
"exception isn't related with any of your connection problem, "
'please report this issue to '
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
root.addHandler(ch)
# parse arguments from file docstring
args = docopt.docopt(__doc__)
# test url: https://www.youtube.com/watch?v=LE2v3sUzTH4
URLs = args['']
proxy_url = args['--proxy']
# download all URLs with youtube-dl
download(URLs, proxy_url)
# parse supplemental metadata.
md = internetarchive.cli.argparser.get_args_dict(args['--metadata'])
# while downloading, if the download hook returns status "finished", myhook() will append the basename to the `to_upload` array.
# upload all URLs with metadata to the Internet Archive
global to_upload
for video in to_upload:
print(":: Uploading %s..." % video)
identifier, meta = upload_ia(video, custom_meta=md)
print("\n:: Upload Finished. Item information:")
print("Title: %s" % meta['title'])
print("Upload URL: http://archive.org/details/%s" % identifier)