Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_get_resource_basenames(self):
tu = TubeUp(dir_path=os.path.join(current_path,
'test_tubeup_rootdir'),
# HACK: A hack to make the test in Travis successful,
# We need to investigate more about this, it doesn't
# make sense that the verbose flag affect the
# youtubedl extract_info() process.
# See:
# https://travis-ci.org/bibanon/tubeup/builds/299091640
verbose=True)
copy_testfiles_to_tubeup_rootdir_test()
result = tu.get_resource_basenames(
['https://www.youtube.com/watch?v=6iRV8liah8A'])
expected_result = {os.path.join(
current_path, 'test_tubeup_rootdir', 'downloads',
def test_archive_urls(self):
tu = TubeUp(dir_path=os.path.join(current_path,
'test_tubeup_rootdir'),
ia_config_path=get_testfile_path('ia_config_for_test.ini'),
# HACK: A hack to make the test in Travis successful,
# We need to investigate more about this, it doesn't
# make sense that the verbose flag affect the
# youtubedl extract_info() process.
# See:
# https://travis-ci.org/bibanon/tubeup/builds/299091640
verbose=True)
videobasename = os.path.join(
current_path, 'test_tubeup_rootdir', 'downloads',
'Mountain_3_-_Video_Background_HD_1080p-6iRV8liah8A')
copy_testfiles_to_tubeup_rootdir_test()
def test_upload_ia(self):
tu = TubeUp(dir_path=os.path.join(current_path,
'test_tubeup_rootdir'),
# Use custom ia configuration file so we don't need
# to login with username and password.
ia_config_path=get_testfile_path('ia_config_for_test.ini'))
videobasename = os.path.join(
current_path, 'test_tubeup_rootdir', 'downloads',
'Mountain_3_-_Video_Background_HD_1080p-6iRV8liah8A')
copy_testfiles_to_tubeup_rootdir_test()
with requests_mock.Mocker() as m:
# Mock the request to s3.us.archive.org, so it will responds
# a custom json. `internetarchive` library sends GET request to
# that url to check that we don't violate the upload limit.
m.get('https://s3.us.archive.org',
def test_generate_ydl_options_with_verbose_mode(self):
tu = TubeUp(verbose=True)
result = tu.generate_ydl_options(
mocked_ydl_progress_hook, ydl_username='testUsername',
ydl_password='testPassword')
expected_result = {
'outtmpl': os.path.join(
self.tu.dir_path['downloads'], '%(title)s-%(id)s.%(ext)s'),
'restrictfilenames': True,
'verbose': True,
'quiet': False,
'progress_with_newline': True,
'forcetitle': True,
'continuedl': True,
'retries': 9001,
'fragment_retries': 9001,
'forcejson': True,
def test_tubeup_attribute_logger_when_verbose_mode(self):
tu = TubeUp(verbose=True)
self.assertIsInstance(tu.logger, Logger)
def setUp(self):
self.tu = TubeUp()
self.maxDiff = 999999999
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 '
'https://github.com/bibanon/tubeup/issues')
traceback.print_exc()