From d25761dbdc50bfb02a0416de86714a45f1f3823e Mon Sep 17 00:00:00 2001 From: Colin Coe Date: Wed, 17 Jan 2024 14:37:56 -0700 Subject: [PATCH] HTTP 404 Early Return and FLAC Metadata Bug Fix (#51) * Add -j flag to 'make' command in Dockerfile * Handle album 404 (#50) * Add 404 short circuit: In all of {album,artist,mix,playlist,track,video}.py, insert early return if get_metadata hits 404 * Bump version and add licenses LABEL to Dockerfile * Add multi-arch QEMU to Dockerfile * Fix .flac metadata bug: Instead of storing DISC and DISCTOTAL (in multi-volume albums) correctly, they have been swapped! * Fix botched DISC, DISCTOTAL swap --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/docker-image.yml | 4 ++++ Dockerfile | 3 ++- pyproject.toml | 2 +- tidal_wave/album.py | 4 ++++ tidal_wave/artist.py | 4 ++++ tidal_wave/mix.py | 9 +++++++++ tidal_wave/playlist.py | 9 +++++++++ tidal_wave/track.py | 5 ++--- tidal_wave/video.py | 1 - 9 files changed, 35 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index c50f1e1..ce4f1d9 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -24,6 +24,9 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -47,5 +50,6 @@ jobs: push: true cache-from: type=gha cache-to: type=gha,mode=max + platforms: linux/amd64, linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index 9a609b2..cd4bc3c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ RUN cd ~/ffmpeg_sources && \ --extra-libs="-lpthread -lm" \ --ld="g++" \ --bindir="$HOME/bin" && \ - PATH="$HOME/bin:$PATH" make && \ + PATH="$HOME/bin:$PATH" make -j$(nproc) && \ make install && \ hash -r @@ -31,6 +31,7 @@ LABEL org.opencontainers.image.authors "colinho " LABEL org.opencontainers.image.description "Waving at the TIDAL music service with Python" LABEL org.opencontainers.image.documentation "https://github.com/ebb-earl-co/tidal-wave/blob/trunk/README.md" LABEL org.opencontainers.image.source "https://github.com/ebb-earl-co/tidal-wave" +LABEL org.opencontainers.image.licenses "LGPL-2.1-only AND Apache-2.0" ENV PIP_DEFAULT_TIMEOUT=100 \ # Allow statements and log messages to immediately appear diff --git a/pyproject.toml b/pyproject.toml index 056b7a3..43cc484 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ requires = ["setuptools", "wheel"] universal = 0 # Make the generated wheels have "py3" tag [project] name = "tidal-wave" -version = "2024.1.9" +version = "2024.1.10" description = "A tool to wave at the TIDAL music service." authors = [ {name = "colinho", email = "pypi@colin.technology"} diff --git a/tidal_wave/album.py b/tidal_wave/album.py index 58a73e4..4f8b6bb 100644 --- a/tidal_wave/album.py +++ b/tidal_wave/album.py @@ -137,6 +137,10 @@ def get( self.get_metadata(session) else: self.metadata = metadata + + if self.metadata is None: + self.track_files = {} + return self.get_items(session) self.save_cover_image(session, out_dir) diff --git a/tidal_wave/artist.py b/tidal_wave/artist.py index 79186b9..0da6e8a 100644 --- a/tidal_wave/artist.py +++ b/tidal_wave/artist.py @@ -143,6 +143,10 @@ def get( 5. get_albums """ self.set_metadata(session) + + if self.metadata is None: + return + self.set_dir(out_dir) self.save_artist_image(session) self.get_videos(session, out_dir) diff --git a/tidal_wave/mix.py b/tidal_wave/mix.py index 8d2c7c9..9cf2cc2 100644 --- a/tidal_wave/mix.py +++ b/tidal_wave/mix.py @@ -38,6 +38,10 @@ def get_metadata(self, session: Session): self.metadata: Optional[PlaylistsEndpointResponseJSON] = request_mixes( session=session, mix_id=self.mix_id ) + + if self.metadata is None: + return + self.name = ( self.metadata.title.replace("/", "_") .replace("|", "_") @@ -233,6 +237,11 @@ def get(self, session: Session, audio_format: AudioFormat, out_dir: Path): - self.flatten_playlist_dir() """ self.get_metadata(session) + + if self.metadata is None: + self.files = {} + return + self.set_items(session) self.set_dir(out_dir) self.save_cover_image(session, out_dir) diff --git a/tidal_wave/playlist.py b/tidal_wave/playlist.py index 8116bf4..5dcf5bc 100644 --- a/tidal_wave/playlist.py +++ b/tidal_wave/playlist.py @@ -39,6 +39,10 @@ def get_metadata(self, session: Session): self.metadata: Optional[PlaylistsEndpointResponseJSON] = request_playlists( session=session, identifier=self.playlist_id ) + + if self.metadata is None: + return + self.name = ( self.metadata.title.replace("/", "_") .replace("|", "_") @@ -297,6 +301,11 @@ def get(self, session: Session, audio_format: AudioFormat, out_dir: Path): - self.flatten_playlist_dir() """ self.get_metadata(session) + + if self.metadata is None: + self.files = {} + return + self.set_items(session) self.set_dir(out_dir) self.save_cover_image(session, out_dir) diff --git a/tidal_wave/track.py b/tidal_wave/track.py index 76e0530..422f917 100644 --- a/tidal_wave/track.py +++ b/tidal_wave/track.py @@ -377,8 +377,8 @@ def craft_tags(self): if self.codec == "flac": # track and disk - tags["DISCTOTAL"] = f"{self.metadata.volume_number}" - tags["DISC"] = f"{self.album.number_of_volumes}" + tags["DISCTOTAL"] = f"{self.album.number_of_volumes}" + tags["DISC"] = f"{self.metadata.volume_number}" tags["TRACKTOTAL"] = f"{self.album.number_of_tracks}" tags["TRACKNUMBER"] = f"{self.metadata.track_number}" # instrument-specific @@ -463,7 +463,6 @@ def get( self.metadata = metadata if self.metadata is None: - # self.failed = True self.outfile = None return diff --git a/tidal_wave/video.py b/tidal_wave/video.py index c6c4e84..a725016 100644 --- a/tidal_wave/video.py +++ b/tidal_wave/video.py @@ -203,7 +203,6 @@ def get( else: self.metadata = metadata - # check for 404 error with metadata if self.metadata is None: return None