mirror of
https://github.com/soimort/you-get.git
synced 2025-02-03 00:33:58 +03:00
common.py: Print URL of get_content call when --debug is enabled
Use logging, and raise the root logger level from WARNING (default) to DEBUG when --debug is enabled. This logging facility can be extended to other functions.
This commit is contained in:
parent
ebdc27bce5
commit
d02b5bb9ad
@ -91,6 +91,7 @@ SITES = {
|
||||
import getopt
|
||||
import json
|
||||
import locale
|
||||
import logging
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
@ -298,6 +299,8 @@ def get_content(url, headers={}, decoded=True):
|
||||
The content as a string.
|
||||
"""
|
||||
|
||||
logging.debug('get_content: %s' % url)
|
||||
|
||||
req = request.Request(url, headers=headers)
|
||||
if cookies:
|
||||
cookies.add_cookie_header(req)
|
||||
@ -1032,6 +1035,8 @@ def script_main(script_name, download, download_playlist, **kwargs):
|
||||
% get_version(kwargs['repo_path']
|
||||
if 'repo_path' in kwargs else __version__))
|
||||
|
||||
logging.basicConfig(format='[%(levelname)s] %(message)s')
|
||||
|
||||
help = 'Usage: %s [OPTION]... [URL]...\n\n' % script_name
|
||||
help += '''Startup options:
|
||||
-V | --version Print version and exit.
|
||||
@ -1055,7 +1060,7 @@ def script_main(script_name, download, download_playlist, **kwargs):
|
||||
-x | --http-proxy <HOST:PORT> Use an HTTP proxy for downloading.
|
||||
-y | --extractor-proxy <HOST:PORT> Use an HTTP proxy for extracting only.
|
||||
--no-proxy Never use a proxy.
|
||||
-d | --debug Show traceback for debugging.
|
||||
-d | --debug Show traceback and other debug info.
|
||||
'''
|
||||
|
||||
short_opts = 'Vhfiuc:ndF:O:o:p:x:y:'
|
||||
@ -1145,6 +1150,8 @@ def script_main(script_name, download, download_playlist, **kwargs):
|
||||
proxy = ''
|
||||
elif o in ('-d', '--debug'):
|
||||
traceback = True
|
||||
# Set level of root logger to DEBUG
|
||||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
elif o in ('-F', '--format', '--stream', '--itag'):
|
||||
stream_id = a
|
||||
elif o in ('-O', '--output-filename'):
|
||||
|
Loading…
Reference in New Issue
Block a user