Skip to content

Commit

Permalink
execute rule func
Browse files Browse the repository at this point in the history
  • Loading branch information
azuline committed Oct 31, 2023
1 parent ac8a288 commit 75a89f6
Show file tree
Hide file tree
Showing 3 changed files with 381 additions and 20 deletions.
10 changes: 5 additions & 5 deletions rose/audiotags.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class AudioTags:

duration_sec: int

_m: Any
path: Path

@classmethod
def from_file(cls, p: Path) -> AudioTags:
Expand Down Expand Up @@ -136,7 +136,7 @@ def _get_paired_frame(x: str) -> str | None:
dj=_get_paired_frame("DJ-mix"),
),
duration_sec=round(m.info.length),
_m=m,
path=p,
)
if isinstance(m, mutagen.mp4.MP4):
return AudioTags(
Expand All @@ -162,7 +162,7 @@ def _get_paired_frame(x: str) -> str | None:
dj=_get_tag(m.tags, ["----:com.apple.iTunes:DJMIXER"], split=True),
),
duration_sec=round(m.info.length), # type: ignore
_m=m,
path=p,
)
if isinstance(m, (mutagen.flac.FLAC, mutagen.oggvorbis.OggVorbis, mutagen.oggopus.OggOpus)):
return AudioTags(
Expand Down Expand Up @@ -190,14 +190,14 @@ def _get_paired_frame(x: str) -> str | None:
dj=_get_tag(m.tags, ["djmixer"], split=True),
),
duration_sec=round(m.info.length), # type: ignore
_m=m,
path=p,
)
raise UnsupportedFiletypeError(f"{p} is not a supported audio file")

@no_type_check
def flush(self, *, validate: bool = True) -> None:
"""Flush the current tags to the file on disk."""
m = self._m
m = mutagen.File(self.path)
if not validate and "pytest" not in sys.modules:
raise Exception("Validate can only be turned off by tests.")

Expand Down
5 changes: 5 additions & 0 deletions rose/cache.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ CREATE TABLE releases (
);
CREATE INDEX releases_source_path ON releases(source_path);
CREATE INDEX releases_release_year ON releases(release_year);
CREATE INDEX releases_title ON releases(release_title);
CREATE INDEX releases_type ON releases(release_type);

CREATE TABLE releases_genres (
release_id TEXT REFERENCES releases(id) ON DELETE CASCADE,
Expand Down Expand Up @@ -81,6 +83,9 @@ CREATE TABLE tracks (
CREATE INDEX tracks_source_path ON tracks(source_path);
CREATE INDEX tracks_release_id ON tracks(release_id);
CREATE INDEX tracks_ordering ON tracks(release_id, disc_number, track_number);
CREATE INDEX tracks_title ON tracks(title);
CREATE INDEX tracks_track_number ON tracks(track_number);
CREATE INDEX tracks_disc_number ON tracks(disc_number);

CREATE TABLE artist_role_enum (value TEXT PRIMARY KEY);
INSERT INTO artist_role_enum (value) VALUES
Expand Down
Loading

0 comments on commit 75a89f6

Please sign in to comment.