jaedb / Iris

Discover, explore and manage your music library across multiple sources with this beautiful web-based interface. Iris is a Mopidy frontend extension.
Apache License 2.0
1.13k stars 132 forks source link

Local playlist support for Album and Artist URIs #708

Open artbird309 opened 3 years ago

artbird309 commented 3 years ago

Describe the bug After I upgraded from 3.52.4 to 3.53.0 and still in 3.56.0 I am unable to play my local media album/artist from .m3u8 playlist.

My playlist shows correctly as an album but when I try to play the playlist it only plays the first song for each album.

To Reproduce Steps to reproduce the behavior: Manually create a playlist with an album from local media using the URI "local:album:md5:29effead7af7158e15cb09f937dcd11b" then in Iris go to the playlist and click play it will only add the first song, not the whole album.

Expected behavior When you load a playlist with a local media album URI it adds the whole album to the queue.

Environment details:

Additional context It still works fine using the MPD command to add the playlist correctly.

partofthething commented 3 years ago

I'm having a potentially-related issue where I can't play local files seemingly at random. Like some of them work but some don't. When they don't, the Firefox web console says:

Object { message: "Mopidy: Failed to add some tracks", description: null, state: {…} }
app.min.js:111:100872
    nt http://audio.lan:6680/iris/app.min.js?v=1616054526:111
    G http://audio.lan:6680/iris/app.min.js?v=1616054526:111
    dispatch http://audio.lan:6680/iris/app.min.js?v=1616054526:1
    It http://audio.lan:6680/iris/app.min.js?v=1616054526:111

Same tracks add fine in ncmcpp. The weird thing is that other tracks in the library work fine. I totally reinstalled everything including wiping out my various caches and data files and the issue persists across browsers (Chrome, Firefox, desktop/mobile), etc. Verbose logging in mopidy didn't show much of interest.

jaedb commented 3 years ago

Can you both please provide the URIs of the tracks you're trying to add? I can only guess, but I am expecting the issue to be with URI encoding but need some examples to be certain.

partofthething commented 3 years ago

These don't work:

These work:

artbird309 commented 3 years ago

The example UIR I was using was "local:album:md5:29effead7af7158e15cb09f937dcd11b" and it works fine if I manually add that URI to the play now queue but if I play a playlist with that URI in it only the first track of album gets added.

jaedb commented 3 years ago

@artbird309 your URI is an album URI, so it will be expanded to tracks by Mopidy when adding to the queue or to a playlist. When playing the playlist you will be using the expanded track URIs. Can you please provide me the URIs of that album's tracks?

Ultimately I think this is a duplicate of #711

artbird309 commented 3 years ago

The expanded UIRs after I manually add the album:

I do not have any issue playing the playlist with the album UIRs when it is played from my Home Assistant MPD integration only when I am manually playing that playlist from iris. It seems like playing the playlist from iris it does not expand the the whole album correctly anymore.

I upgraded to 3.57.0 and still have this issue.

jaedb commented 3 years ago

The handling of accented characters is now fixed (see 3.57.1), but I can see some of your example URIs don't actually have accented characters. Are you able to upgrade Iris (making sure to clear all caches and restart Mopidy) to ascertain whether this patch fixed the issue for you?

artbird309 commented 3 years ago

I upgraded my container to 3.57.1 and there was no change it is still only adding the first track of every album.

jaedb commented 3 years ago

@artbird309 can you please open the album, select all tracks and copy their URIs and paste them in here? Then right click on the selected tracks and hit Add to queue. Observe which ones are added and which ones are not so we can figure out what URIs are working and those that are not.

partofthething commented 3 years ago

As for my non-accented cases, I think the hyphens in the "don't work" category include unicode hyphens rather than normal hyphens. Copying and pasting them from my list above:

In [1]: a = "‐"

In [2]: a
Out[2]: '‐'

In [3]: ord(a)
Out[3]: 8208

In [4]: b = '–'

In [5]: ord(b)
Out[5]: 8211

whereas a normal hyphen (-) is ascii code 45.

jaedb commented 3 years ago

That would definitely do it. The immediate fix is for you to remove em and en dashes from your filenames in favor of hyphens.

The reason this problem exists is because Mopidy backends require (to varying degrees) URL-safe URIs. Iris uses URLs to build links to content, so URIs need to be URL-safe in their entirety, however the encoding preferences vary between browsers and Mopidy extensions. Iris is stuck in the middle.

The way to fix this is to either (in order of preference):

  1. use encryption (base64 for example) to create URL-safe URIs without using encodeURIComponent
  2. use state instead of URL to reference content URIs
  3. add (yet) another rule to support encoding of em and en dashes
artbird309 commented 3 years ago

I upgraded to 3.57.3 and nothing changed. I reverted back to 3.52.4 to see if I could see any changes and it looks like we might be look at this incorrectly. When I am looking at the playlist in the current versions it shows just the first track per album, in 3.52.4 it just shows the album URI "local:album:md5:29effead7af7158e15cb09f937dcd11b" this makes me thing it is how Iris is rendering the playlist and then sending that to the queue. It is not pulling in the whole album so that is the only thing that is getting sent to the queue. See screenshots below.

image 3.52.4 screenshot

image 3.57.3 screenshot

jaedb commented 3 years ago

You're quite right. I think I assumed @partofthething's issue was related, but in fact his was quite different. While that issue is now resolved, yours remains.

Can you please run me through the process of actually adding an Album URI to a playlist in Iris? I believe Add to playlist capabilities only exist for Tracks.

artbird309 commented 3 years ago

I manually created the playlist as I was not able to find an easy way to add whole albums/artists as I have over 200 tracks in two different playlists.

This is one of the playlists I have been using: local:album:md5:b6e6e9fa1730241a0f33dca698bcc7c0 local:album:md5:1d009539778d871ddcd5919b0cebfc61 local:album:md5:8d63ddc11ee62af4a6f2f18bc9544010 local:album:md5:d6b4580bb31ec71fd540dbd5ac712e78 local:album:md5:62fbe49a72a9b182c760b03174184cf0 local:artist:md5:b28be3abe478d93820b05f8f5fc162e2 local:album:md5:66d63a35ec6dde83de6f65b20523ed4d local:album:md5:477e6f062e3789beb36c029bfcb3fd98 local:album:md5:5e35d3a1d558cc439a4fb659d767c889 local:album:md5:29effead7af7158e15cb09f937dcd11b

jaedb commented 3 years ago

Ok cool, that makes more sense now. I shall change this to a Feature Request to better reflect the development work required. Existing functionality is not broken, rather new functionality is desired.