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

Ampache support #60

Closed
MorrisJobke opened this issue Aug 14, 2013 · 79 comments
Closed

Ampache support #60

MorrisJobke opened this issue Aug 14, 2013 · 79 comments

Comments

@MorrisJobke
Copy link
Contributor

credits to @DeepDiver1975

@ghost ghost assigned MorrisJobke Aug 14, 2013
@DeepDiver1975
Copy link
Member

pulling in @sezuan as you did some on the old music app as well - THX

@MorrisJobke
Copy link
Contributor Author

@MorrisJobke MorrisJobke mentioned this issue Sep 5, 2013
20 tasks
@MorrisJobke
Copy link
Contributor Author

@DeepDiver1975 If we support ampache we weaken the ownCloud infrastructure, because I have to save unsalted password hashes. (Rainbow tables, ...)

@BernhardPosselt
Copy link

Because of how Ampache API does authentication, the password handling will be made a whole lot less secure. IMO the API must be turned off by default and administrators must be warned when activating the API in the app admin settings. Also turning off the API should drop the stored newly hashed passwords.

@MorrisJobke
Copy link
Contributor Author

Current state: see #91

@MorrisJobke MorrisJobke added this to the First release candidate milestone Mar 24, 2014
@jancborchardt
Copy link
Member

Pull request was merged a while ago: #91 :)

@MU7L3Y
Copy link

MU7L3Y commented Jul 16, 2014

I was just trying to test out this ampache with the new music app in OC7 RC2 but Just Player on Android keeps telling me that UserID/password might be wrong. Why is that? I put the full address in (http://mydomain.com/cloud/index.php/apps/music/ampache/server/xml.server.php), used my username and generated a password. Tomahawk on windows PC also can't connect. I can listen in my browser on windows though.

@MorrisJobke
Copy link
Contributor Author

@MU7L3Y What version of the music app do you use?

@MU7L3Y
Copy link

MU7L3Y commented Jul 16, 2014

I clicked download zip from here:
https://github.com/owncloud/music

@MorrisJobke
Copy link
Contributor Author

@MU7L3Y I didn't tested the current master branch with ampache players yet ... I'm currently too busy to test and package a new release. Maybe give 0.2 a try: https://github.com/owncloud/music/releases/tag/v0.2

@MU7L3Y
Copy link

MU7L3Y commented Jul 16, 2014

I just tried 0.2 and I can get Just Player on Android to connect and it finds all my music. It won't play anything though.
Tomahawk on Win7 connects as well but the list doesn't show all my music, only some of it. It will play the music it found though.

@MorrisJobke
Copy link
Contributor Author

@MU7L3Y That's weird. With "all music" do you mean the music you see in the webinterface or the audio files you upload to your ownCloud?

@MU7L3Y
Copy link

MU7L3Y commented Jul 17, 2014

@MorrisJobke I mean Tomahawk doesn't show all the music in my ownCloud. The ownCloud web interface shows it all.

@MU7L3Y
Copy link

MU7L3Y commented Jul 22, 2014

@MorrisJobke I've had this error in my admin panel too. Just thought I'd let you know.

Error   hook        error while running hook (OCA\Music\Utility\HookHandler::fileUpdated): Identifier "Scanner" is not defined.

Also with Tomahawk: it tells me the correct amount of music files in my cloud as seen here:
image
But the files shown in the collection that it lets me actually play are only a few:
image

@MU7L3Y
Copy link

MU7L3Y commented Aug 7, 2014

@MorrisJobke I've just tried 0.3 with OC 7.0.1 and all my music is now found in Tomahawk and it seems to work, thanks. Can't get Just Player to work though....well it connects and lists all my music but playback doesn't work very well but that could be a problem with Just Player and not the music app. It plays some songs but the song it says it's playing is not actually the right one. Not really sure how it's supposed to work...but it's not very good. Have you tried?

I also get this error in my admin panel which repeats with every cron job:

Argument 10 passed to OCA\Music\Utility\Scanner::__construct() must be an instance of OCP\Files\Folder, null given, called in /home/mutleypr/public_html/cloud/apps/music/app/music.php on line 259 and defined at /home/mutleypr/public_html/cloud/apps/music/utility/scanner.php#51

One more thing I've found is that when playing in the OC interface, the progress bar of the current song moves along and I can see it buffer the song but I can't skip forward or back by clicking on it even though there is a hand there?

Thanks for all your hard work, I'm enjoying listening to my music nonetheless.

@MorrisJobke
Copy link
Contributor Author

@MU7L3Y I also have seen this issue. A fix is just ahead, but not in the current master branch yet.

@MorrisJobke
Copy link
Contributor Author

@MorrisJobke I've just tried 0.3 with OC 7.0.1 and all my music is now found in Tomahawk and it seems to work, thanks. Can't get Just Player to work though....well it connects and lists all my music but playback doesn't work very well but that could be a problem with Just Player and not the music app. It plays some songs but the song it says it's playing is not actually the right one. Not really sure how it's supposed to work...but it's not very good. Have you tried?

I've not experienced that. I need to check against that.

@MU7L3Y
Copy link

MU7L3Y commented Aug 7, 2014

Ok thanks

@MorrisJobke
Copy link
Contributor Author

I will reopen this issue, to not forget about you changes. For the next time, simply open a new issue ;)

@MorrisJobke MorrisJobke reopened this Aug 7, 2014
@MU7L3Y
Copy link

MU7L3Y commented Aug 15, 2014

@MorrisJobke I just updated to 0.3.3 and now I have no errors in my admin panel which is great, thanks! I still can't skip forward or back by clicking on the progress bar even though there is a hand there but no biggy as I don't do that often.

I've tried again with Just Player and it still doesn't really work but then I tried the ampache.net app and it seems to at least play my songs. It doesn't list them in the correct order though so I'm assuming this is a problem with the app and not the music app?

@MorrisJobke
Copy link
Contributor Author

I've tried again with Just Player and it still doesn't really work but then I tried the ampache.net app and it seems to at least play my songs.

Then I need to retest with Just Player. But I can remind that it uses some different HTTP verbs. I will have a look.

It doesn't list them in the correct order though so I'm assuming this is a problem with the app and not the music app?

I don't have seen a way to specify the order. This is most likely up to the app

@bence8810
Copy link

@MorrisJobke
Hi, I am on 0.3.3 and trying to connect from my iPhone via AmpacheX. It connects and recognizes all the songs. I can then click on a song which will seem like it's loading but then it'll quickly skip to the next one and the next one until it reaches the end and then say Not Playing.

Thanks,
Ben

Edit: Corrected the typo in the app's name.
https://itunes.apple.com/us/app/ampachex/id532578754?mt=8

@paulijar
Copy link
Collaborator

paulijar commented Aug 6, 2018

@Zykino Okay, I have now implemented providing "All tracks" as a playlist in the Ampache API. The feature shall be included in the next release which will probably be published within 1-3 weeks.

Edit: The release v0.9.0 with this feature is now out, a bit sooner than I expected :).

@floe
Copy link

floe commented Aug 26, 2018

AFAICT Ampache has a feature called "channels" (https://github.com/ampache/ampache/wiki/Channels) which is sort of a "poor man's Icecast server", and which I would find immensely useful. Is this also possible with the Ampache implementation within the Music app? I haven't been able to find any references...

@paulijar
Copy link
Collaborator

@floe Sorry, that's not supported in the Music app. The "real" Ampache server provides some half a dozen different protocols so that it can serve as replacement for many different servers. The Music app, on the other hand, provides only the Ampache XML protocol.

@floe
Copy link

floe commented Aug 27, 2018

Thanks for the quick response :-) Any ideas whether there's something similar available for Nextcloud? If not, no worries...

@floe
Copy link

floe commented Aug 27, 2018

Sorry, too-unspecific question earlier. I've been googling around, and it seems that this functionality is currently not available for Nextcloud. I think it would be a nice addition, though - can you maybe give me a pointer where I could hack this in? After some code browsing, it seems that controller/ampachecontroller.php would be the right place to start?

@paulijar
Copy link
Collaborator

paulijar commented Aug 28, 2018

@floe I'm not really at all familiar with Icecast so I'm only guessing here. But I assume that Icecast has a protocol of its own which consists of HTTP requests and responses. You probably can't just hack it to any existing module but you should create new modules to handle the protocol.

It may of course be educative to look how the Ampache protocol has been implemented on top of the Music app. I'm not the original author of this part of the code, but it works roughly like this:

  1. File appinfo/routes.php directs HTTP requests with certain path to ampachecontroller.php and its function ampache. Note that routes.php defines this with the name ampache#ampache where the first part refers to the controller and the second part to the function name.
  2. The function AmpacheController.ampache() gets the URL parameters and dispatches the request according the parameter called action. Each action has its own handler function.
  3. The handler functions fetch the requested data from BusinessLayer and build the responses using templates which can be found under templates/ampache.
  4. As final related component, all HTTP requests to the Music app go through the module middleware/ampachemiddleware.php. It checks if the request is in fact an Ampache request and, if so, checks the Ampache session token. Requests with invalid token are blocked.

@floe
Copy link

floe commented Aug 29, 2018

Thanks, this is quite helpful. FWIW, the Icecast "protocol" is not much more than MP3 frames with a few extra headers over HTTP, there's an old PHP implementation in just 100 LOC (https://github.com/gadgetguru/PHP-Streaming-Audio). I'll have a look if I can put together an alpha for testing using an existing playlist.

@marcelklehr
Copy link

marcelklehr commented Sep 6, 2018

I also get 401 - Invalid password, with the logs even with debug level showing nothing more than

FileHooks::updated triggered for a non-existing file

(I've tried using "Amplify", "Power Ampache" and "Amdroid" on Android, Amarok on Linux; I've copy&pasted the password displayed in the app, so no typos :/)

@paulijar
Copy link
Collaborator

paulijar commented Sep 6, 2018

@marcelklehr Apart from actually having incorrect password, the Ampache login may fail also because of differences in the system time of the client and the server: to succeed, the client clock must not be more than 100 seconds ahead of the server clock and not more than 6000 seconds behind it. Could this be your problem? That 100 seconds is actually quite tight requirement; I think we could loosen that to e.g. 10 minutes without compromising the security too much.

Ideally, the client should query the server's current time and use that on Ampache handshake instead of its own local time, and this would eliminate the need for the clocks to be in sync. But at least Power Ampache doesn't seem to do this, and we can't fix this on the server.

@marcelklehr
Copy link

@paulijar Interesting. The clocks are within 10s of each other, though, afaict. When I use the Ampache URL with /server/xml.server.php I get Something went wrong. instead of the 401, so I guess that is no good either.

@paulijar
Copy link
Collaborator

paulijar commented Sep 6, 2018

@marcelklehr Yeah, the 401 indicates that at least the request has reached the Music app. The call probably gets blocked already earlier if the message is just Something went wrong.

Do you see any message in addition to the code 401? Looking at the code, it seems to me that 401 can be emitted with five different messages: Invalid Login, Invalid Login - cannot parse time, Invalid Login - session is outdated, Invalid Login - timestamp is in future, or Invalid Login - passphrase does not match. At least Power Ampache seems to be showing the error message from the server.

@marcelklehr
Copy link

marcelklehr commented Sep 6, 2018

Yep, it's the passphrase mismatch. I've tried to reproduce this with curl in the terminal:

curl -v "https://SERVER/index.php/apps/music/ampache/server/xml.server.php?action=handshake&user=USERNAME&timestamp=""$(php -r '$time = time(); echo $time . "&auth=".hash("sha256", $time . hash("sha256", "TOKEN"));')"

yields

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><root>
	<error code='401'>Invalid Login - passphrase does not match</error>
</root>

EDIT: Simplified the code :)

I'm on nextcloud 13.0.6 if that helps.

@marcelklehr
Copy link

marcelklehr commented Sep 6, 2018

So, I couldn't stop myself from debugging a little and it turns out that in my case, the array of hashes is empty, which is why the login fails.

I also know why: I'm using the LDAP user backend and for some reason because of that my userid in the nextcloud database is some kind of numeric id instead of the identifier I login with. If I use the numeric ID, ampache login succeeds. 🎉

@paulijar
Copy link
Collaborator

paulijar commented Sep 7, 2018

@marcelklehr Okay, thanks for debugging, that's an interesting piece of information! I'm not familiar with the LDAP integration of Nextcloud/ownCloud but I now read some online documentation. It was stated here that, by default, the internal user name for LDAP users will be the UUID of the user.

I believe that it would be possible for the Music app to map the LDAP user name to the internal name on Nextcloud using the API method ILDAPProvider::getUserName. However, there doesn't seem to be equivalent API on ownCloud. Hence, it would probably be easiest if we just show the (internal) user name on the Music app settings page. Maybe not the neatest possible solution but should be sufficient to make the Ampache feature usable also for the LDAP users.

@marcelklehr
Copy link

However, there doesn't seem to be equivalent API on ownCloud. Hence, it would probably be easiest if we just show the (internal) user name on the Music app settings page. Maybe not the neatest possible solution but should be sufficient to make the Ampache feature usable also for the LDAP users.

@paulijar yep, I agree :) 👍

paulijar added a commit to paulijar/music that referenced this issue Sep 8, 2018
In case the user has been logged in via LDAP, the internal username on
ownCloud/Nextcloud may differ from the login name. To access the
Ampache API, the user has to use this internal username but previously
there was no easy way to know this.

refs owncloud#60
paulijar added a commit that referenced this issue Sep 8, 2018
In the Ampache handshake, it was previously checked that the timestamp
supplied by the client in not more than 100 seconds ahead of the system
time of the server. In case the client is using its own system clock to
create the timestamp and the client and/or the server does not
synchronize its time from the network, it could quite easily happen
that the local times of client and server differ by more than 100
seconds. The handshake failed in such cases.

Now we allow the the timestamps to differ at maximum by 10 minutes.
That shouldn't compromise the security in any significant manner but
will make the handshake more robust against small clock deviations.

refs #60
@paulijar
Copy link
Collaborator

paulijar commented Sep 9, 2018

@marcelklehr The new Music app release v0.9.1 now shows also the username when a new Ampache password is generated. I didn't care to setup LDAP just to be able to test this, so if you could give it a try I would appreciate your feedback.

@marcelklehr
Copy link

@paulijar 🎉 Works like a charm, thanks :)

@cervantesd
Copy link

cervantesd commented Feb 22, 2019

Hello,

Cannot connect with my account, seems like if we are using an account with a dot it doesn't work.
Tried with an account without dot, it work like a charm

@npodbielski
Copy link

I this possible to run this API behind reverse proxy? It works with PowerAmpache but only directly otherwise application hangs.

@paulijar
Copy link
Collaborator

I this possible to run this API behind reverse proxy? It works with PowerAmpache but only directly otherwise application hangs.

I have no idea, but aren't proxies supposed to be invisible for both clients and servers? So if the proxy is doing its job properly, then the Music app should see the proxy just as any other client app and PowerAmpache should see the proxy just the same as any actual Ampache server.

@npodbielski
Copy link

npodbielski commented Apr 1, 2019

So if the proxy is doing its job properly

Theoretically. In practice not every kind of communication can be serve that way, but ampache seems to use some kind of xml files which are ok to pass through reverse proxy.
I tested this application with PowerAmpache and it works OK.
I had some problems but it turns out it was caused by something else not music plugin.

@jakobroehrl
Copy link

It's working pretty good, thanks.
Is it in the feature possible to use the owncloud passwort for login on ampache?

@paulijar
Copy link
Collaborator

@jakobroehrl Nope, using the ownCloud password with the Ampache API is not possible now or in the future. There are technical and security reasons for this.

@jakobroehrl
Copy link

@paulijar Thank you!
Another question: I can stream with ampache or directly with webdav. Where is the difference? What's better?

@paulijar
Copy link
Collaborator

@jakobroehrl It mostly depends on which client you want to use. Or were you planning to implement your own client? There are a few music player applications which can connect to remote server via Ampache API. I guess there are some players supporting WebDAV, too, but I'm not familiar with those.

The Ampache API of the Music app serves the files organized by the scanned metadata. Meanwhile, the WebDAV API of ownCloud reveals them organized by the directory hierarchy. This is probably the most significant difference in the capabilities of the APIs.

@paulijar
Copy link
Collaborator

After a year of inactivity, I think it's time to close this bundle issue of miscellaneous Ampache problems and requests. Any future bug reports and feature requests should be filed in their own, more specific github issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests