swingmx/swingmusic

Timezone error

janaxhell opened this issue ยท 14 comments

I have deployed swingmusic on a x86 docker machine with this compose:

services:
  swingmusic:
    image: ghcr.io/swing-opensource/swingmusic:latest
    container_name: swingmusic
    volumes:
      - /srv/dev-disk-by-uuid-BAF04088F0404D37/data/media/music:/music
      - /srv/dev-disk-by-uuid-BAF04088F0404D37/data/media/unmapped:/music
      - /srv/dev-disk-by-uuid-5b67514d-485e-4306-873e-b1cbb54ccf99/Config/swingmusic:/config
    ports:
      - "1970:1970"
    networks:
      - omv1
    restart: unless-stopped
    
networks:
  omv1:
    external: true

I have used image: ghcr.io/swing-opensource/swingmusic:latest because using just image:swingmusic refused to be deployed as it couldn't find the image.
After a night of library scan, this morning the GUI showed a single album cover (out of 33k+ albums) and the log was like this:

Exception in thread Thread-3 (run_periodic_scans):
Traceback (most recent call last):
  File "threading.py", line 1016, in _bootstrap_inner
  File "threading.py", line 953, in run
  File "app/periodic_scan.py", line 26, in run_periodic_scans
  File "app/lib/populate.py", line 96, in __init__
  File "app/store/albums.py", line 58, in load_albums
  File "app/models/album.py", line 206, in get_date_from_tracks
ValueError: year 0 is out of range
39714693 ERROR: Exception on /getall/albums [GET]
Traceback (most recent call last):
  File "flask/app.py", line 1484, in full_dispatch_request
  File "flask/app.py", line 1469, in dispatch_request
  File "flask_restful/__init__.py", line 489, in wrapper
  File "flask/views.py", line 109, in view
  File "flask_restful/__init__.py", line 604, in dispatch_request
  File "app/api/getall/resources.py", line 70, in get
  File "app/utils/dates.py", line 26, in date_string_to_time_passed
  File "pendulum/__init__.py", line 211, in now
  File "pendulum/tz/__init__.py", line 60, in local_timezone
  File "pendulum/tz/local_timezone.py", line 35, in get_local_timezone
  File "pendulum/tz/local_timezone.py", line 63, in _get_system_timezone
  File "pendulum/tz/local_timezone.py", line 242, in _get_unix_timezone
RuntimeError: Unable to find any timezone configuration

I have restarted the container and after another 30mins of scanning, 2 album covers appeard in the GUI e the log said:

 * Serving Flask app 'app.api'
 * Debug mode: off
-e 
Exception in thread Thread-1 (run_swingmusic):
Traceback (most recent call last):
  File "threading.py", line 1016, in _bootstrap_inner
  File "threading.py", line 953, in run
  File "manage.py", line 91, in run_swingmusic
  File "app/setup/__init__.py", line 27, in run_setup
  File "app/store/albums.py", line 58, in load_albums
  File "app/models/album.py", line 206, in get_date_from_tracks
ValueError: year 0 is out of range

Should I add a timezone ENV? In what format?
I have a Navidrome server running on the same machine pointing at the same exact library.

I had to manually fix it in order to be able to view Artists, Albums, etc in my install.

A temporary workaround is to connect to the container and run the following command:

apt-get update && apt-get install -yq tzdata

Follow the prompts to setup the TZ for your region and after that just refresh the page and you should see the errors gone. Any restart of the container will require this step to be repeat.

In order to properly fix it, a new version of the docker image must be created with that CMDs added to the docker file.

Thank you! What is the syntax for the compose? I'm semi-newbie, I don't want to break things.
Something like
TZ=Europe/Rome
would do?
And what indentation?

EDIT
With the apt command many albums have indeed appeared, but the count is wrong. Swingmusic says You have 5,775 albums in your library , while I can easily check from Navidrome that I have 33,289, so something's not working fine.
After applying the apt commands, swingmusic scanned for about 30 mins, showed those 5k albums and log said:

 * Serving Flask app 'app.api'
 * Debug mode: off
-e 
Exception in thread Thread-1 (run_swingmusic):
Traceback (most recent call last):
  File "threading.py", line 1016, in _bootstrap_inner
  File "threading.py", line 953, in run
  File "manage.py", line 91, in run_swingmusic
  File "app/setup/__init__.py", line 27, in run_setup
  File "app/store/albums.py", line 58, in load_albums
  File "app/models/album.py", line 206, in get_date_from_tracks
ValueError: year 0 is out of range

I have launched a Library rescan which took a couple of minutes and it keeps saying I have 5,775 albums.
I wonder if I have to split the 2 folders I have mounted to :/music as separate, like :/music/lidarr and :/music/unmapped.

Thank you! What is the syntax for the compose? I'm semi-newbie, I don't want to break things. Something like TZ=Europe/Rome would do? And what indentation?

You cannot do it via ENV vars until the docker image is updated. To use my suggested workaround you need to:

1 - Find the CONTAINER_ID of the SwingMusic container using docker ps
2 - Attach to the container using the id from the step 1: docker exec -it CONTAINER_ID bash
3 - When attached to the container, execute: apt-get update && apt-get install -yq tzdata
4 - Follow the prompts to setup your timezone

In case you stop/restart the container, you will need to repeat the steps above.

EDIT With the apt command many albums have indeed appeared, but the count is wrong. Swingmusic says You have 5,775 albums in your library , while I can easily check from Navidrome that I have 33,289, so something's not working fine. After applying the apt commands, swingmusic scanned for about 30 mins, showed those 5k albums and log said:

 * Serving Flask app 'app.api'
 * Debug mode: off
-e 
Exception in thread Thread-1 (run_swingmusic):
Traceback (most recent call last):
  File "threading.py", line 1016, in _bootstrap_inner
  File "threading.py", line 953, in run
  File "manage.py", line 91, in run_swingmusic
  File "app/setup/__init__.py", line 27, in run_setup
  File "app/store/albums.py", line 58, in load_albums
  File "app/models/album.py", line 206, in get_date_from_tracks
ValueError: year 0 is out of range

I have launched a Library rescan which took a couple of minutes and it keeps saying I have 5,775 albums. I wonder if I have to split the 2 folders I have mounted to :/music as separate, like :/music/lidarr and :/music/unmapped.

I'm not sure how to help with that.

You cannot do it via ENV vars until the docker image is updated.

Ahh, ok sorry. I didn't get the fact that as of now there is no way to apply this permanently.
Meanwhile I had tried to add these lines to compose

    environment:
      - TZ=Europe/Rome

which I suppose will have no effect.
Thanks anyway, I'll wait for a newer build.

@btalanski
Thanks for helping @janaxhell with this issue. I appreciate it (honestly, I didn't know where to begin).

@janaxhell
The ValueError: year 0 is out of range, it's caused by some of your songs having unparseable date tag. I've patched it to fallback to the current year.

Pull the patch using:

docker pull ghcr.io/swing-opensource/swingmusic:v1.4.5.janaxhell.year_patch

Let me know whether it fixes the error so that I can include the fix in the next release.

Thank you.

Last night I have pulled that patch and restarted the container. It's been scanning the library since (almost 12 hours now). I don't see any error in the log, only tons of percentages moving on. It takes pauses between batches during which no log is produced, then goes on with another batch. The amount of recognized albums has grown a lot to 23,684, but it's still about 10,000 shy of what's there for real. Any idea why? My library is heavily curated both manually by me with mp3tag and Musicbee, and automatically by Deemix and Lidarr. So the amount of albums missing metadata is very close to 0. Only a few bootlegs might not have some data.

@janaxhell

How many tracks do you have in your library? Check whether all the tracks are indexed. Swing Music cleans metadata using various techniques to merge duplicate albums.

Root folder says 267062 Files, but I can't compare with Navidrome because I can't see any entry about tracks, only albums.
Maybe singles are not counted as albums? Navidrome counts them as such. But surely I don't have 10K singles, I tend to not keep them except in some limited cases. Maybe EPs are considered Singles and not counted? I keep EPs and may have many.

EDIT A side note while it's still scanning (and I'm not sure what it is scanning, since I only see numbers and percentages): I cannot see the heart icon anywhere. In the Favorite section it says to click the heart icon to add a song, but I have explored the entire GUI and I cannot see it anywhere.

EDIT 2 I think it's finished, log seems to have stopped for good after many lines like these

100%|?????????????????????????????????????????????|2475/2478
100%|?????????????????????????????????????????????|2477/2478
100%|?????????????????????????????????????????????|2478/2478

Nothing has changed in numbers. Looks like the patch fixed the year 0 issue.
When you release the new build I'll switch tag to :latest.

@janaxhell
The progress bars are just periodic scans to check for new music, etc. You can disable them by using the -nps flag. See the Docker section on the guide:

https://swingmusic.vercel.app/guide/getting-started.html#docker

How do I apply those flags in the compose?
Something like
environment:
- nps
?

@janaxhell

This stack overflow answer suggests you add a command property on the compose file:

services:
  swingmusic:
    image: ghcr.io/swing-opensource/swingmusic:latest
    container_name: swingmusic
+   command: -nps
    # the other here

I have been having the timezone error (Unable to find any timezone configuration), but didn't want to install a package inside the container. After some thinking, if my host system's timezone is already setup, why don't I just link that file.

With that idea in mind, I added a volume to my docker compose.

services:
  swingmusic:
    image: ghcr.io/swing-opensource/swingmusic:latest
    container_name: swingmusic
    volumes:
      - /path/to/music:/music
      - /path/to/config/config:/config
+     - /etc/timezone:/etc/timezone
    ports:
      - "1970:1970"
    restart: unless-stopped

By doing that, the container could find my timezone, solving the issue.

With that idea in mind, I added a volume to my docker compose.

  • - /etc/timezone:/etc/timezone
    

Thanks, it seems to be working fine, I have updated the compose with that line, also replacing image with :latest and it's showing no error of sort.

EDIT
Nope. Just rebooted the server for other reasons and noticed a lot of HDD thrashing. Checked log and it says:

2024-01-04T17:15:29.021468852Z  * Serving Flask app 'app.api'
2024-01-04T17:15:29.021535319Z  * Debug mode: off
2024-01-04T17:15:29.021913897Z -e 
2024-01-04T17:41:34.327824388Z Exception in thread Thread-1 (run_swingmusic):
2024-01-04T17:41:34.327862456Z Traceback (most recent call last):
2024-01-04T17:41:34.327870364Z   File "threading.py", line 1016, in _bootstrap_inner
2024-01-04T17:41:34.327879012Z   File "threading.py", line 953, in run
2024-01-04T17:41:34.327915622Z   File "manage.py", line 91, in run_swingmusic
2024-01-04T17:41:34.327984377Z   File "app/setup/__init__.py", line 27, in run_setup
2024-01-04T17:41:34.328044417Z   File "app/store/albums.py", line 58, in load_albums
2024-01-04T17:41:34.328095104Z   File "app/models/album.py", line 206, in get_date_from_tracks
2024-01-04T17:41:34.328148927Z  * ValueError: year 0 is out of range *
2024-01-06T08:32:02.063149490Z  * Serving Flask app 'app.api'
2024-01-06T08:32:02.459144302Z  * Debug mode: off
2024-01-06T08:32:02.459201394Z -e 

Should be fixed in the next release v1.4.8