diff --git a/.idea/JuicySerato.iml b/.idea/JuicySerato.iml
index 07ec6a9..445c8e7 100644
--- a/.idea/JuicySerato.iml
+++ b/.idea/JuicySerato.iml
@@ -5,6 +5,7 @@
+
diff --git a/juicy_serato.spec b/juicy_serato.spec
index a7a681b..1c0a0b2 100644
--- a/juicy_serato.spec
+++ b/juicy_serato.spec
@@ -2,7 +2,7 @@
a = Analysis(
- ['juicy_serato\\__main__.py'],
+ ['juicy_serato/__main__.py'],
pathex=[],
binaries=[],
datas=[],
diff --git a/juicy_serato/_juicer.py b/juicy_serato/_juicer.py
index 158fc5d..3553bb6 100644
--- a/juicy_serato/_juicer.py
+++ b/juicy_serato/_juicer.py
@@ -1,7 +1,11 @@
import os
import tqdm
+import click
+import struct
import shutil
+from mutagen import MutagenError
+
from juicy_serato.djuced.djuced_db_parser import DJucedDBParser
from juicy_serato.serato.serato_db_parser import SeratoDBParser
from juicy_serato.serato.serato_structs import CueEntry
@@ -24,18 +28,23 @@ def inject(self, use_tqdm: bool = True):
continue
markers = list()
- skipped_first = False
- for i, cue in enumerate(track.cues):
- if i == 0 and track.cues[0].cuepos == track.cues[1].cuepos:
- skipped_first = True
- continue
+ cues = filter(lambda c: c.cuename.startswith("Cue") and c.cuenumber <= 8, track.cues)
+ for i, cue in enumerate(cues):
+ cue_number = cue.cuenumber - 1 if cue.cuenumber - 1 >= 0 else 0
marker = CueEntry(field1=b"\x00", field4=b"\x00", field6=b"\x00\x00",
color=get_serato_color(cue.cueColor), position=int(cue.cuepos*1000),
- name=cue.cuename, index=i if not skipped_first else i - 1)
+ name=cue.cuename, index=cue_number)
markers.append(marker)
- with SeratoDBParser(file) as parser:
- parser.set_markers(markers)
+ try:
+ with SeratoDBParser(file) as parser:
+ parser.set_markers(markers)
+ except MutagenError:
+ click.echo(click.style(f"Failed to read '{track.filename}'", fg="red"))
+ except ValueError:
+ click.echo(click.style(f"Failed to save metadata to '{track.filename}'", fg="red"))
+ except struct.error:
+ click.echo(click.style(f"Failed to parse '{track.filename}'", fg="red"))
def copy(self, location, use_tqdm: bool = True):
if not os.path.exists(location):
diff --git a/juicy_serato/serato/serato_db_parser.py b/juicy_serato/serato/serato_db_parser.py
index aa47c52..a6b6f5a 100644
--- a/juicy_serato/serato/serato_db_parser.py
+++ b/juicy_serato/serato/serato_db_parser.py
@@ -4,7 +4,7 @@
import struct
from mutagen import File
-from mutagen.id3 import GEOB, error
+from mutagen.id3 import GEOB
from .serato_utils import get_entry_type, read_bytes
@@ -105,6 +105,7 @@ def get_markers(self):
def set_markers(self, markers: list):
data = self._dump_markers(markers)
+
frame = GEOB(
encoding=3,
mime="application/octet-stream",
@@ -112,15 +113,15 @@ def set_markers(self, markers: list):
data=data
)
- if "GEOB:Serato Markers_" in self.audio.tags:
- self.audio.tags.pop("GEOB:Serato Markers_")
- if "GEOB:Serato Markers2" in self.audio.tags:
- self.audio.tags.pop("GEOB:Serato Markers2")
+ if hasattr(self.audio, "tags") and self.audio.tags:
+ if "GEOB:Serato Markers_" in self.audio.tags:
+ self.audio.tags.pop("GEOB:Serato Markers_")
+ if "GEOB:Serato Markers2" in self.audio.tags:
+ self.audio.tags.pop("GEOB:Serato Markers2")
- try:
- self.audio.tags["GEOB:Serato Markers2"] = frame
- except error:
+ if not hasattr(self.audio, "tags") or not self.audio.tags:
self.audio.add_tags()
- self.audio.tags["GEOB:Serato Markers2"] = frame
+
+ self.audio.tags["GEOB:Serato Markers2"] = frame
self._changes_made = True
diff --git a/pyproject.toml b/pyproject.toml
index 5963e59..1dcd797 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "juicy_serato"
-version = "0.0.1"
+version = "0.0.2"
authors = [
{ name="Davis_Software", email="davissoftware6@gmail.com" },
]