Commit bd80c0f8 authored by Tanguy Le Carrour's avatar Tanguy Le Carrour
Browse files

Use the Path class from the domain.

parent 45ff3605
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import List, Tuple
from pathlib import Path
from splito.domain.audio_editing.model import Tracks, Interval
from splito.domain.audio_editing.model import Tracks, Interval, Path
......@@ -25,14 +24,11 @@ class ExtractSubTracksInteractor:
def execute(self, request: ExtractSubTracksRequest) -> None:
track = self.__tracks[request.path]
path = Path.from_string(request.path)
intervals = [Interval(start, end) for (start, end) in request.intervals]
for idx, interval in enumerate(intervals):
sub_track = track.extract(interval)
path = self.__sub_path(request.path, idx + 1)
self.__tracks[path] = sub_track
def __sub_path(self, a_path: str, an_index: int) -> str:
path = Path(a_path)
return str(path.with_suffix(f".part-{an_index}{path.suffix}"))
new_path = str(path.with_suffix(f".part-{idx + 1}"))
self.__tracks[new_path] = sub_track
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment