Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use path from config when resolving playlist items #510

Merged
merged 4 commits into from
Nov 17, 2020
Merged

Conversation

zimj0
Copy link
Contributor

@zimj0 zimj0 commented Nov 15, 2020

fix #495

@Rello
Copy link
Owner

Rello commented Nov 15, 2020

Hi,
thank you for this suggestion. actually it makes sense if using a folder. wonder why no one came up with this before.

but:
I think your position is not good.
It needs to be in the first "if", I guess

if ($line[0] === '/') {

because your approach makes sense for absolute file paths only. the other 2 cases of that if are relative paths. and they will be based on the (absolute nextcloud-)location of the playlist file. So this will have whatever music directory you have already attached.

what do you think?

@Rello Rello added this to the 2.13.0 milestone Nov 15, 2020
@Rello Rello self-requested a review November 15, 2020 19:49
@Rello Rello added the browser label Nov 15, 2020
@zimj0
Copy link
Contributor Author

zimj0 commented Nov 15, 2020

I'm not sure about absolute paths, in my library all playlists use relative path and they had this problem. After your comment I did some additional testing: It turns out, that the absolute path of the playlist file is not determined correctly by getInternalPath if the file is on external storage. I modified the fix to check if the folder path is already present in the string and only add it if not.

A quick test with absolute path also yielded the correct path. But files did not show up in the audioplayer playlist. I guess because the file was outside of the www folder and the webserver forbids access. Therefore, I'm not sure if absolute path is a relevant use case. Anyway it should be covered by this fix as well.

@zimj0
Copy link
Contributor Author

zimj0 commented Nov 16, 2020

Sorry, I was mistaken: The problem is not due to the folder specified in config, but due to external storage only.
So, turns out there is a much simpler and more general solution: Getting the full path of the playlist file.
What do you think?

@Rello
Copy link
Owner

Rello commented Nov 17, 2020

I will test locally also.
thank you

@Rello Rello merged commit 40a219d into Rello:master Nov 17, 2020
Rello added a commit that referenced this pull request Nov 17, 2020
@Rello
Copy link
Owner

Rello commented Nov 17, 2020

Hello,
how does this work for you?
"music" is my external storage folder (SMB) in files app

old: $streamfile[0]->getPath()
returns: /admin/files/music/playlist/relative.m3u

new: $streamfile[0]->getInternalPath()
returns: playlist/relative.m3u

Then the title needs to be matched to this position. in your case its missing the subfolder.
this can not work I would say

Rello added a commit that referenced this pull request Nov 17, 2020
@Rello
Copy link
Owner

Rello commented Nov 17, 2020

ok, it is solved. there was another issue!

https://github.com/Rello/audioplayer/blob/master/lib/Controller/CategoryController.php#L500-L501
first I was using array_shift which cut of the beginning - but I need to cut the folder off.
second I overwrote the $playlistFilePath which was supposed to be reused

can you try on your side?

Rello added a commit that referenced this pull request Nov 17, 2020
(cherry picked from commit 9264449)
@zimj0
Copy link
Contributor Author

zimj0 commented Nov 17, 2020

Hi,

old: $streamfile[0]->getPath()
returns: /admin/files/music/playlist/relative.m3u

looks odd, did you mix up old and new?
The following code
https://github.com/Rello/audioplayer/blob/master/lib/Controller/CategoryController.php#L454-L458
should turn /admin/files/music/playlist/relative.m3u
into music/playlist/relative.m3u

Regarding the case with relative path and '../' I can't say, because I do not have such playlists.
Will test tomorrow.

@zimj0
Copy link
Contributor Author

zimj0 commented Nov 18, 2020

Can confirm working for relative path with '../'
Two levels up '../../' is not working though. Maybe looping until the string contains no more '../' will do the trick?

@Rello
Copy link
Owner

Rello commented Nov 18, 2020

Thats correct of course. 🤦🏼‍♂️

Rello added a commit that referenced this pull request Nov 19, 2020
@Rello
Copy link
Owner

Rello commented Nov 19, 2020

done

Rello added a commit that referenced this pull request Nov 19, 2020
(cherry picked from commit b3fdf2e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Playlists do not work when library path is set
2 participants