jmshrv / finamp

A Jellyfin music client for mobile
Mozilla Public License 2.0
1.87k stars 123 forks source link

[Redesign] [Bug] Cant download library #733

Closed flloschy closed 4 months ago

flloschy commented 4 months ago

Im currently using finamp 0.9.6 on IOS, and with the redesign comes the ability to download a whole library (from the left slide-over list). When clicking the download button and confirming the download, the download starts but then ends relatively quick with the size display saying 0 B with no songs downloaded

The logs when doing this are the following:

[downloadsService/INFO] 2024-05-16 19:35:10.056328: Starting sync of MUSIC Backup.
[SyncBuffer/FINER] 2024-05-16 19:35:10.061155: Syncing library MUSIC Backup with required:true viewId:4bc0ccfd42c2d17b71f74b80fec26011
[JellyfinApiHelper/FINE] 2024-05-16 19:35:10.063405: Getting children of MUSIC Backup
[GlobalSnackbar/INFO] 2024-05-16 19:35:10.087936: Displaying message: Download started
[JellyfinApiHelper/FINE] 2024-05-16 19:35:11.136400: Getting items with ids [4bc0ccfd42c2d17b71f74b80fec26011]
[SyncBuffer/FINER] 2024-05-16 19:35:11.402035: Syncing library Image for MUSIC Backup with required:true viewId:4bc0ccfd42c2d17b71f74b80fec26011
[SyncBuffer/INFO] 2024-05-16 19:35:11.406533: All syncs complete.
[downloadsService/INFO] 2024-05-16 19:35:11.407944: Moving to deletes for MUSIC Backup.
[DeleteBuffer/INFO] 2024-05-16 19:35:11.409232: All deletes complete.
[downloadsService/INFO] 2024-05-16 19:35:11.410437: Triggering enqueues for MUSIC Backup.
[downloadsService/INFO] 2024-05-16 19:35:11.411783: Sync of MUSIC Backup complete.
[IsarTaskQueue/FINE] 2024-05-16 19:35:11.413462: Submitting download Image for MUSIC Backup to background_downloader.
[GlobalSnackbar/INFO] 2024-05-16 19:35:11.416796: Displaying message: Download prepared, downloading files
[IsarTaskQueue/INFO] 2024-05-16 19:35:11.450585: All downloads enqueued.
[downloadsService/FINE] 2024-05-16 19:35:12.964241: Downloaded Image for MUSIC Backup
[downloadsService/INFO] 2024-05-16 19:35:20.757614: Attempting to restart queues.
[SyncBuffer/INFO] 2024-05-16 19:35:20.779332: All syncs complete.
[DeleteBuffer/INFO] 2024-05-16 19:35:20.780371: All deletes complete.
[IsarTaskQueue/INFO] 2024-05-16 19:35:20.781119: All downloads enqueued.

Downloading single songs or playlists works well, as well as the playlist syncing, the library download is the only feature affected by this bug

Chaphasilor commented 4 months ago

Anything special about that library? How large is it? Do you have additional libraries of just the one?

It seems like no albums are found within the library, otherwise they should be fetches right after the library itself got fetched.
The actual, untempered logs would probably be helpful here :)

Also, if you don't mind, please check how that library is displayed in Jellyfin itself. Browser logs of accessing the library might help...

flloschy commented 4 months ago

My libraries range from 5 to 620 songs, totaling a around 5GB and it doesnt work on any of those. Now that you mentioned it, i dont have any albums in any library, I simply use a folder in which i dump all the audio files. I do this just for simplicity since playlists can't be synced to folders as far as i know

(updated original message to use the real logs)

Chaphasilor commented 4 months ago

Okay, yes that would be the culprit then. Albums are needed for library sync, the relationship is library->album->track. Playlisty might also work, you could try that out.

The one album should get synced though, are you sure it really also isn't downloaded?

Because in some scenarios (like podcasts or music videos maybe?) it might not make sense to use albums, we could also think about supporting downloading individual tracks that are part of a library. We'd need a way to get only those without an album though (possibly through a parentId filter?) to avoid duplicates in regular libraries.
Maybe @Komodo5197 could weigh in if this would be feasible to do?

For now and in your case, you should be able to fix this my using a proper directory structure for your library, like artist directories which contain album directories which contain tracks (or disc directories).
Depending on your use-case, creating a .m3u(8) playlist file that references all tracks inside the directory might be the easier solution, with only a slight overhead...

flloschy commented 4 months ago

mhm, okay. I already have playlists for every library, its just a bit annoying when adding something because the playlist needs to be updated manually. Syncing the libraries would be easier because jellyfin automatically fetches new files already. I might try to put all my current music libraries into one and have those as albums? Worth a try

Edit: I put all my libraries on the filesystem into one folder and used those as albums, and it works now :D Would still have been cool for it to work without sub-folders, but eh. Works now so no reason to change anything from my side now.

Thank you so much for your work, the redesign is coming along nicely and is amazing <3

Chaphasilor commented 4 months ago

That's good to hear!

I think the request about downloading tracks that are not within an album is reasonable, and it's possible to get those items by using the /Users/<uid>/Items endpoint while providing the library ID as the ParentId and setting Recursive to false (or omitting it completely). So API-wise, it's doable without grabbing duplicates.
I'm just not sure how dependent the download system is on albums. It could be that downloading the "orphaned" tracks isn't the problem, but that any later syncs wouldn't pick up new tracks. I simply haven't looked into it yet...

Komodo5197 commented 4 months ago

If you've found out how to fetch just the orphan tracks in a library, it should be possible to add them in without too much effort. New tracks should be picked up without issue on resyncs. I can put together a PR for this, although I don't have any orphan tracks to test it with.

flloschy commented 4 months ago

Ill close this since in the new beta release notes say its bee fixed! Thank you for your Service, much appreciated

Chaphasilor commented 4 months ago

Well, test it out and let us know if it works! :D

flloschy commented 4 months ago

Will do once the testflight release is verified

flloschy commented 4 months ago

Since I already changed the structure of my music i couldn't effortlessly with my original library, but I made a new one with a single song in it and it appears to work now. Officially closed now :D