Fix ampache compatibility

This commit is contained in:
Jonas Kvinge 2019-09-08 19:46:51 +02:00
parent fb377c32ea
commit c0ebbc8e2f
4 changed files with 22 additions and 7 deletions

View File

@ -74,10 +74,10 @@ QUrl SubsonicBaseRequest::CreateUrl(const QString &ressource_name, const QList<P
QUrl url(server_url()); QUrl url(server_url());
if (!url.path().isEmpty() && url.path().right(1) == "/") { if (!url.path().isEmpty() && url.path().right(1) == "/") {
url.setPath(url.path() + QString("rest/") + ressource_name); url.setPath(url.path() + QString("rest/") + ressource_name + QString(".view"));
} }
else else
url.setPath(url.path() + QString("/rest/") + ressource_name); url.setPath(url.path() + QString("/rest/") + ressource_name + QString(".view"));
url.setQuery(url_query); url.setQuery(url_query);

View File

@ -264,6 +264,10 @@ void SubsonicRequest::AlbumsReplyReceived(QNetworkReply *reply, const int offset
} }
qint64 album_id = json_obj["id"].toString().toLongLong(); qint64 album_id = json_obj["id"].toString().toLongLong();
if (album_id == 0) {
album_id = json_obj["id"].toInt();
}
QString artist = json_obj["artist"].toString(); QString artist = json_obj["artist"].toString();
QString album; QString album;
if (json_obj.contains("album")) album = json_obj["album"].toString(); if (json_obj.contains("album")) album = json_obj["album"].toString();
@ -495,8 +499,13 @@ int SubsonicRequest::ParseSong(Song &song, const QJsonObject &json_obj, const qi
} }
qint64 song_id = json_obj["id"].toString().toLongLong(); qint64 song_id = json_obj["id"].toString().toLongLong();
if (song_id == 0) song_id = json_obj["id"].toInt();
qint64 album_id = json_obj["albumId"].toString().toLongLong(); qint64 album_id = json_obj["albumId"].toString().toLongLong();
if (album_id == 0) album_id = json_obj["albumId"].toInt();
qint64 artist_id = json_obj["artistId"].toString().toLongLong(); qint64 artist_id = json_obj["artistId"].toString().toLongLong();
if (artist_id == 0) artist_id = json_obj["artistId"].toInt();
QString title = json_obj["title"].toString(); QString title = json_obj["title"].toString();
title.remove(Song::kTitleRemoveMisc); title.remove(Song::kTitleRemoveMisc);
@ -511,7 +520,10 @@ int SubsonicRequest::ParseSong(Song &song, const QJsonObject &json_obj, const qi
if (json_obj.contains("year")) year = json_obj["year"].toInt(); if (json_obj.contains("year")) year = json_obj["year"].toInt();
int disc = 0; int disc = 0;
if (json_obj.contains("disc")) disc = json_obj["disc"].toString().toInt(); if (json_obj.contains("disc")) {
disc = json_obj["disc"].toString().toInt();
if (disc == 0) disc = json_obj["disc"].toInt();
}
int track = 0; int track = 0;
if (json_obj.contains("track")) track = json_obj["track"].toInt(); if (json_obj.contains("track")) track = json_obj["track"].toInt();
@ -520,7 +532,10 @@ int SubsonicRequest::ParseSong(Song &song, const QJsonObject &json_obj, const qi
if (json_obj.contains("genre")) genre = json_obj["genre"].toString(); if (json_obj.contains("genre")) genre = json_obj["genre"].toString();
int cover_art_id = -1; int cover_art_id = -1;
if (json_obj.contains("coverArt")) cover_art_id = json_obj["coverArt"].toString().toInt(); if (json_obj.contains("coverArt")) {
cover_art_id = json_obj["coverArt"].toString().toInt();
if (cover_art_id == 0) cover_art_id = json_obj["coverArt"].toInt();
}
QUrl url; QUrl url;
url.setScheme(url_handler_->scheme()); url.setScheme(url_handler_->scheme());

View File

@ -57,7 +57,7 @@ using std::shared_ptr;
const Song::Source SubsonicService::kSource = Song::Source_Subsonic; const Song::Source SubsonicService::kSource = Song::Source_Subsonic;
const char *SubsonicService::kClientName = "Strawberry"; const char *SubsonicService::kClientName = "Strawberry";
const char *SubsonicService::kApiVersion = "1.13.0"; const char *SubsonicService::kApiVersion = "1.11.0";
const char *SubsonicService::kSongsTable = "subsonic_songs"; const char *SubsonicService::kSongsTable = "subsonic_songs";
const char *SubsonicService::kSongsFtsTable = "subsonic_songs_fts"; const char *SubsonicService::kSongsFtsTable = "subsonic_songs_fts";
const int SubsonicService::kMaxRedirects = 3; const int SubsonicService::kMaxRedirects = 3;

View File

@ -55,10 +55,10 @@ UrlHandler::LoadResult SubsonicUrlHandler::StartLoading(const QUrl &url) {
QUrl stream_url(server_url()); QUrl stream_url(server_url());
if (!stream_url.path().isEmpty() && stream_url.path().right(1) == "/") { if (!stream_url.path().isEmpty() && stream_url.path().right(1) == "/") {
stream_url.setPath(stream_url.path() + QString("rest/stream")); stream_url.setPath(stream_url.path() + QString("rest/stream.view"));
} }
else else
stream_url.setPath(stream_url.path() + QString("/rest/stream")); stream_url.setPath(stream_url.path() + QString("/rest/stream.view"));
stream_url.setQuery(url_query); stream_url.setQuery(url_query);