From bfef5ae7c4b12c3559cf00ed63377bdf26242f86 Mon Sep 17 00:00:00 2001 From: dunossauro Date: Sat, 14 Oct 2023 04:23:54 -0300 Subject: [PATCH] FIX: mypy issues --- vmh/audio.py | 4 ++-- vmh/kdenlive.py | 18 ++++++++++++------ vmh/video.py | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/vmh/audio.py b/vmh/audio.py index 01376f5..696a867 100644 --- a/vmh/audio.py +++ b/vmh/audio.py @@ -7,8 +7,8 @@ from pydub import AudioSegment, silence from tinydb import TinyDB, where -from .equalize import process_audio -from .settings import cache_db_path +from vmh.equalize import process_audio +from vmh.settings import cache_db_path db = TinyDB(str(cache_db_path)) diff --git a/vmh/kdenlive.py b/vmh/kdenlive.py index 7b78a8f..9a4c411 100644 --- a/vmh/kdenlive.py +++ b/vmh/kdenlive.py @@ -2,15 +2,15 @@ from itertools import islice, pairwise from os import getcwd from pathlib import Path -from typing import Literal +from typing import Literal, cast from loguru import logger from parsel.selector import Selector -from .audio import detect_silences +from vmh.audio import detect_silences xml_template = """ - {} + {} """ @@ -36,7 +36,9 @@ def check_chain( el = s.xpath(f'//chain/property[text() = "{filename.name}"]/..') _chain = el.css('chain::attr("id")').get() + _chain = cast(str, _chain) _id = el.css('property[name="kdenlive:id"]::text').get() + _id = cast(str, _id) playlists = s.xpath( f'//playlist/entry[@producer="{_chain}"]/..' @@ -44,6 +46,7 @@ def check_chain( logger.debug(f'Playlists: {filename}-{playlists}') playlist_id = playlists.get() + playlist_id = cast(str, playlist_id) return _chain, _id, playlist_id @@ -62,7 +65,9 @@ def kdenlive_xml( tree = ET.parse(path) root = tree.getroot() - playlist: ET.Element = root.find(f'./playlist[@id="{playlist_id}"]') + playlist = root.find(f'./playlist[@id="{playlist_id}"]') + playlist = cast(ET.Element, playlist) + playlist.clear() playlist.attrib.update(id=playlist_id) @@ -75,8 +80,8 @@ def kdenlive_xml( entry = ET.SubElement(playlist, 'entry', attrib=entry_attribs) ET.SubElement( - entry, 'property', attrib={'name': 'kdenlive:id'}, text=property_id - ) + entry, 'property', attrib={'name': 'kdenlive:id'} + ).text=property_id if overwrite: tree.write(path) @@ -108,6 +113,7 @@ def cut( ) chain_id, file_id, playlist = check_chain(video_file, input_file, 0) + _output_path: str = kdenlive_xml( str(input_file), playlist_id=playlist, diff --git a/vmh/video.py b/vmh/video.py index f144148..561996c 100644 --- a/vmh/video.py +++ b/vmh/video.py @@ -5,7 +5,7 @@ from loguru import logger from moviepy.editor import AudioFileClip, VideoFileClip, concatenate_videoclips -from .audio import detect_silences +from vmh.audio import detect_silences class Preset(str, Enum):