Skip to content

Commit

Permalink
HTTP 404 Early Return and FLAC Metadata Bug Fix (#51)
Browse files Browse the repository at this point in the history
* 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] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
ebb-earl-co and dependabot[bot] authored Jan 17, 2024
1 parent d5487d7 commit d25761d
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 }}
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -31,6 +31,7 @@ LABEL org.opencontainers.image.authors "colinho <github@colin.technology>"
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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down
4 changes: 4 additions & 0 deletions tidal_wave/album.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions tidal_wave/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions tidal_wave/mix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("|", "_")
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions tidal_wave/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("|", "_")
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions tidal_wave/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -463,7 +463,6 @@ def get(
self.metadata = metadata

if self.metadata is None:
# self.failed = True
self.outfile = None
return

Expand Down
1 change: 0 additions & 1 deletion tidal_wave/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ def get(
else:
self.metadata = metadata

# check for 404 error with metadata
if self.metadata is None:
return None

Expand Down

0 comments on commit d25761d

Please sign in to comment.