Tidal: Guess filetype by filename extension in URL when missing codec.

This commit is contained in:
Jonas Kvinge 2020-10-21 01:12:46 +02:00
parent 5fe658bb16
commit 8197ae2a2d
1 changed files with 7 additions and 1 deletions

View File

@ -25,6 +25,7 @@
#include <QMimeType>
#include <QIODevice>
#include <QFile>
#include <QFileInfo>
#include <QDir>
#include <QList>
#include <QByteArray>
@ -184,7 +185,7 @@ void TidalStreamURLRequest::StreamURLReceived() {
return;
}
Song::FileType filetype(Song::FileType_Unknown);
Song::FileType filetype(Song::FileType_Stream);
if (json_obj.contains("codec") || json_obj.contains("codecs")) {
QString codec;
@ -275,6 +276,11 @@ void TidalStreamURLRequest::StreamURLReceived() {
else if (json_obj.contains("url")) {
QUrl new_url(json_obj["url"].toString());
urls << new_url;
if (filetype == Song::FileType_Stream) {
// Guess filetype by filename extension in URL.
filetype = Song::FiletypeByExtension(QFileInfo(new_url.path()).suffix());
if (filetype == Song::FileType_Unknown) filetype = Song::FileType_Stream;
}
}
if (urls.isEmpty()) {