Use Ruff and fix all its warnings

This commit is contained in:
2023-11-02 00:08:42 +01:00
parent df59c33f9b
commit 2165dd5b7b
19 changed files with 347 additions and 203 deletions

View File

@ -1,3 +1,6 @@
from __future__ import annotations
import logging
import sys
from dataclasses import dataclass
@ -5,6 +8,8 @@ import ffmpeg
from discord_embed import settings
logger: logging.Logger = logging.getLogger(__name__)
@dataclass
class Resolution:
@ -28,9 +33,12 @@ def video_resolution(path_to_video: str) -> Resolution:
Returns height and width.
"""
probe = ffmpeg.probe(path_to_video)
video_stream = next((stream for stream in probe["streams"] if stream["codec_type"] == "video"), None)
video_stream = next(
(stream for stream in probe["streams"] if stream["codec_type"] == "video"),
None,
)
if video_stream is None:
print("No video stream found", file=sys.stderr)
logger.critical("No video stream found")
sys.exit(1)
width: int = int(video_stream["width"])