Skip to content

Commit 52bdb2c

Browse files
committed
add ffmpeg log level alias "warn" for "warning" (fixes #46)
more graceful ffmpeg failures in general version bump v0.9.13
1 parent b40ca3d commit 52bdb2c

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

zotify/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import annotations
2-
__version__ = "0.9.12"
2+
__version__ = "0.9.13"
33

44
from enum import IntEnum
55
from http.server import BaseHTTPRequestHandler, HTTPServer

zotify/config.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,13 @@ def get_lyrics_location(cls) -> PurePath | None:
436436
@classmethod
437437
def get_ffmpeg_log_level(cls) -> str:
438438
level = cls.get(FFMPEG_LOG_LEVEL)
439-
if level not in {"trace", "verbose", "info", "warning", "error", "fatal", "panic", "quiet"}:
440-
raise ValueError()
439+
# see https://ffmpeg.org/ffmpeg.html#Generic-options, -loglevel
440+
valid_levels = {"trace", "debug", "verbose", "info", "warning", "error", "fatal", "panic", "quiet"}
441+
442+
if level == "warn": level += "ing"
443+
if level not in valid_levels:
444+
raise ValueError(f'FFMPEG LOGGING LEVEL "{level}" NOT VALID\n' +\
445+
f'SELECT FROM: {valid_levels}')
441446
return level
442447

443448
@classmethod

zotify/track.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,12 @@ def convert_audio_format(track_path) -> None:
400400
if Path(temp_track_path).exists():
401401
Path(temp_track_path).unlink()
402402

403-
except ffmpy.FFExecutableNotFoundError:
404-
Printer.hashtaged(PrintChannel.WARNING, 'FFMPEG NOT FOUND\n' +\
405-
f'SKIPPING CONVERSION TO {file_codec.upper()}')
403+
except Exception as e:
404+
if isinstance(e, ffmpy.FFExecutableNotFoundError):
405+
reason = 'FFMPEG NOT FOUND\n'
406+
else:
407+
reason = str(e) + "\n"
408+
Printer.hashtaged(PrintChannel.WARNING, reason + f'SKIPPING CONVERSION TO {file_codec.upper()}')
406409

407410
time_ffmpeg_end = time.time()
408411
return fmt_duration(time_ffmpeg_end - time_ffmpeg_start)

0 commit comments

Comments
 (0)