1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-24 19:52:32 +01:00
Commit Graph

49 Commits

Author SHA1 Message Date
Mike Fährmann
76f855d87b
[output] use ANSI colors only when stream is a TTY 2024-10-28 19:36:42 +01:00
Mike Fährmann
ee61256054
[output] define and use global TTY_STD... values 2024-10-28 14:59:14 +01:00
Mike Fährmann
e93b8efe7b
[output] make it easier to disable output to stdout
allow 'output.mode' to be set to any falsy value
instead of requiring it to be the string "null"
2024-10-28 14:49:52 +01:00
Mike Fährmann
f7a6401031
[actions] move LoggerAdapter from 'output' to 'actions' 2024-06-30 20:41:51 +02:00
Mike Fährmann
9671bd6d40
[actions] fix exception when 'msg' is not a string (#5683) 2024-06-18 16:49:45 +02:00
Mike Fährmann
dc9d83e64b
[output] support 'NO_COLOR' environment variable 2024-05-03 12:25:41 +02:00
Mike Fährmann
20e2c0042b
[output] enable colors by default 2024-04-20 20:51:20 +02:00
Mike Fährmann
14b38264e0
[output] extend 'output.colors' (#2566)
allow specifying ANSI colors for all loglevels
(debug, info, warning, error)
2024-04-20 20:50:58 +02:00
Mike Fährmann
d921d860f1
automatically create directory path for logging files (#5249) 2024-02-28 02:11:20 +01:00
Mike Fährmann
75697dfb26
implement -e/--error-file as a logging handler
similar to --write-unsupported
2023-12-10 00:06:39 +01:00
Mike Fährmann
e46efbd5b5
prevent crash when 'stdout.line_buffering' is not defined (#642) 2023-10-29 15:32:11 +01:00
Mike Fährmann
f7ce33c85c
[output] set 'errors=replace' for output streams (#3765)
fixes regression from e480a933
2023-03-14 13:30:04 +01:00
Mike Fährmann
4235d412c4
implement 'actions'
continuation of d37e7f48
but more versatile and extendable

Example:

"actions": [
    # change debug messages to info
    ["debug", "level ~info"],

    # change exit status to a non-zero value
    ["info:^No results for", "status |= 1"],

    # exit with status 2 on 429
    ["warning:429", "exit 2"],

    # restart extractor when no cookies found
    ["warning:^[Nn]o .*cookies", "restart"]
]
2023-03-10 22:08:10 +01:00
Mike Fährmann
e480a93337
add 'output.stdout', '.stdin', and '.stderr' options
(#1621, #2152, #2529)

Allow setting custom input/output encodings and options
without having to rely on Python's defaults.
2023-02-26 14:56:19 +01:00
Mike Fährmann
d37e7f4898
add 'hooks' option
Very much a work in progress.

At the moment, it allows to
- wait and restart an extractor (#3338)
- change the exit code (#3630)
- change the log level of a logging message
based on the contents of a logging message
2023-02-13 13:33:42 +01:00
Mike Fährmann
7d1a95ada6
implement 'path-metadata' option (#2734) 2022-07-30 12:31:45 +02:00
Mike Fährmann
7990fe84f1
support user-defined 'output.mode' settings (#2529)
work in progress

the same output as produced by "mode": "color" can be achieved with

"output": {
    "mode": {
        "start"  : "{}",
        "success": "\r\u001b[1;32m{}\u001b[0m\n",
        "skip"   : "\u001b[2m{}\u001b[0m\n",
        "progress"      : "\r{0:>7}B {1:>7}B/s ",
        "progress-total": "\r{3:>3}% {0:>7}B {1:>7}B/s "
    }
}

to make 'output.shorten' work correctly, it is necessary to manually
specify the number of extra characters:

        "start"  : [12, "Downloading {}"]
2022-05-27 15:03:54 +02:00
Mike Fährmann
44ffc017ea
remove useless 'tries' argument from out.success 2022-05-24 10:45:09 +02:00
Mike Fährmann
cf16f9a407
[output] introduce 'stdout_write()' etc (#2529) 2022-05-18 18:29:07 +02:00
Mike Fährmann
eeef9ccdc1
explicitly flush all writes to stdout (#2529) 2022-05-17 13:26:53 +02:00
Mike Fährmann
61887c895b
implement 'output.colors' options (#2532) 2022-05-02 12:41:14 +02:00
Mike Fährmann
0054ad434e
[output] write directly to sys.stdout 2021-11-29 04:41:29 +01:00
Mike Fährmann
da14b3fe9f
[output] write download progress indicator to stderr 2021-11-29 04:41:17 +01:00
Mike Fährmann
28f1c36da2
simplify and adjust download progress indicator (#1519) 2021-09-29 18:40:36 +02:00
Mike Fährmann
c22ff97743
remove 'unit' argument from 'util.format_value()' 2021-09-28 23:07:55 +02:00
Mike Fährmann
d0761454b1
implement a download progress indicator (#1519) 2021-09-28 22:48:58 +02:00
Mike Fährmann
74145467dd
move 'util.Formatter' into its own 'formatter' module 2021-09-27 02:37:04 +02:00
Mike Fährmann
bd845303ad
implement a way to shorten filenames with east-asian characters
(#1377)

Setting 'output.shorten' to "eaw" (East-Asian Width) uses a slower
algorithm that also considers characters with a width > 1.
2021-09-13 21:38:33 +02:00
Mike Fährmann
e300da1424
add 'output.skip' option 2021-05-04 19:27:18 +02:00
Mike Fährmann
c8787647ed
add global WINDOWS bool 2020-05-19 22:32:53 +02:00
Mike Fährmann
ece73b5b2a
make 'path' and 'keywords' available in logging messages
Wrap all loggers used by job, extractor, downloader, and postprocessor
objects into a (custom) LoggerAdapter that provides access to the
underlying job, extractor, pathfmt, and kwdict objects and their
properties.

__init__() signatures for all downloader and postprocessor classes have
been changed to take the current Job object as their first argument,
instead of the current extractor or pathfmt.

(#574, #575)
2020-05-18 19:04:51 +02:00
Mike Fährmann
11d3247c85
use 'util.Formatter' when formatting logging output 2020-05-10 00:09:06 +02:00
Mike Fährmann
4bc161ca0f
prevent crash when sys.stdout and co. are None (#653) 2020-03-23 23:38:55 +01:00
Mike Fährmann
5cdf1b1319
fix --verbose/--quiet
caused by 383795b
2020-02-17 22:29:51 +01:00
Mike Fährmann
383795b550
prevent superfluous calls to Logger.makeRecord()
… by setting an appropriate minimal logging level for the root Logger.
2020-01-30 15:19:06 +01:00
Mike Fährmann
f5604492c3
update interface of config functions 2019-11-24 00:42:28 +01:00
Mike Fährmann
15e4ddf46d
implement custom logging formatter
supports custom log message formats for each loglevel and, by
extension, custom ANSI codes and colors for errors and warnings

(#304)
2019-06-21 20:17:58 +02:00
Mike Fährmann
ae353ed3b0
provide "extractor" and "job" keys for logging output
This allows for stuff like "{extractor.url}" and "{extractor.category}"
in logging format strings.
Accessing 'extractor' and 'job' in any way will return "None" if those
fields aren't defined, i.e. in general logging messages.
2019-02-14 11:09:58 +01:00
Mike Fährmann
4810d446bb
remove the obsolete safeprint() and error() functions
- safeprint() was used to print values which might have caused a
  UnicodeEncodeError, but that is no longer necessary (0381ae5)
- errors are now handled via logging output (f94e370)
2018-04-05 13:10:33 +02:00
Mike Fährmann
79bcaa8726
improve downloader retry behavior
- only retry download on 5xx and 429 status codes
- immediately fail on 4xx status codes
2017-11-10 21:46:18 +01:00
Mike Fährmann
701c016b97
add '-q/--quiet' option 2017-04-26 11:33:19 +02:00
Mike Fährmann
8d5f26d530
small fixes to the output module 2017-04-07 13:24:36 +02:00
Mike Fährmann
4f123b8513
code adjustments according to pep8 2017-01-30 19:40:15 +01:00
Mike Fährmann
91c446805b
replace platform.system() with os.name 2016-10-25 15:44:36 +02:00
Mike Fährmann
810aa4e146
add a space after status indicators 2015-12-02 18:49:49 +01:00
Mike Fährmann
b2401542eb
implement output.mode and .shorten options 2015-12-02 18:47:42 +01:00
Mike Fährmann
8d257510d0
rework output module 2015-12-02 16:48:23 +01:00
Mike Fährmann
d26eec8470
workarounds for windows console 2015-12-01 23:54:57 +01:00
Mike Fährmann
c786843a6f
add output-module 2015-12-01 21:21:39 +01:00