Skip to content

Commit

Permalink
FIX: mypy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dunossauro committed Oct 14, 2023
1 parent 3f42f6d commit bfef5ae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions vmh/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
18 changes: 12 additions & 6 deletions vmh/kdenlive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """ <entry producer="{}" in="00:00:{:.3f}" out="00:00:{:.3f}">
<property name="kdenlive:id">{}</property>
<property name=:id">{}</property>
</entry>
"""

Expand All @@ -36,14 +36,17 @@ 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}"]/..'
).xpath('@id')

logger.debug(f'Playlists: {filename}-{playlists}')
playlist_id = playlists.get()
playlist_id = cast(str, playlist_id)

return _chain, _id, playlist_id

Expand All @@ -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)

Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion vmh/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit bfef5ae

Please sign in to comment.