Skip to content

Commit

Permalink
Changed the log level of aria2 (#481)
Browse files Browse the repository at this point in the history
* Changed the log level of aria2

made aria2 more quiet so it only prints out the download progress and any error, so no useless bloat on your terminal

Co-authored-by: Blatzar <46196380+Blatzar@users.noreply.github.com>
  • Loading branch information
ArjixWasTaken and Blatzar committed Oct 10, 2020
1 parent bb7613d commit d950dd6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions anime_downloader/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
'provider': 'twist.moe',
'external_downloader': '',
'aria2c_for_torrents': False,
'aria2c_log_level': 'error',
'selescrape_browser': None,
'selescrape_browser_executable_path': None,
'selescrape_driver_binary_path': None,
Expand Down
17 changes: 14 additions & 3 deletions anime_downloader/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,20 @@ def format_command(cmd, episode, file_format, speed_limit, path):
if not Config._CONFIG['dl']['aria2c_for_torrents'] and episode.url.startswith('magnet:?xt=urn:btih:'):
return ['open', episode.url]

# For aria2c.
log_levels = ['debug', 'info', 'notice', 'warn', 'error']
log_level = Config['dl']['aria2c_log_level'].lower()
if log_level not in log_levels:
logger.warn('Invalid logging level "{}", defaulting to "error".'.format(log_level))
logger.debug('Possible levels: {}.'.format(log_levels))
log_level = 'error'

cmd_dict = {
'{aria2}': 'aria2c {stream_url} -x 12 -s 12 -j 12 -k 10M -o '
'{file_format}.mp4 --continue=true --dir={download_dir}'
' --stream-piece-selector=inorder --min-split-size=5M --referer={referer} --check-certificate=false --user-agent={useragent} --max-overall-download-limit={speed_limit}',
'{file_format}.mp4 --continue=true --dir={download_dir} '
'--stream-piece-selector=inorder --min-split-size=5M --referer={referer} '
'--check-certificate=false --user-agent={useragent} --max-overall-download-limit={speed_limit} '
'--console-log-level={log_level}',
'{idm}': 'idman.exe /n /d {stream_url} /p {download_dir} /f {file_format}.mp4'
}

Expand All @@ -284,7 +294,8 @@ def format_command(cmd, episode, file_format, speed_limit, path):
'download_dir': os.path.abspath(path),
'referer': episode.source().referer,
'useragent': useragent,
'speed_limit': speed_limit
'speed_limit': speed_limit,
'log_level': log_level
}

if cmd == "{idm}":
Expand Down

0 comments on commit d950dd6

Please sign in to comment.