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

Fix various ways of album cover download #31

Merged
merged 3 commits into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qml/pages/AlbumListView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Page {
PullDownMenu {
MenuItem {
text: qsTr("Search artist image")
enabled: artist!==qsTr("Unknown artist") && artistcount==="1"
enabled: artist!==qsTr("Unknown artist")
onClicked: {
coversearch.clearData()
pageStack.push ("CoverDownload.qml", {"artist":artist, "searchingArtist":true, "album":""})
Expand Down
10 changes: 6 additions & 4 deletions qml/pages/CoverArtList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ BackgroundItem
Connections {
target: coversearch
onImageChanged: {
if ((artist===dartist && album==dalbum) || (album===dartist && album==dalbum)) {
if ((artist===dartist && album==dalbum)
|| (album===dartist && album==dalbum)
Olf0 marked this conversation as resolved.
Show resolved Hide resolved
|| (album===dartist && !dalbum)) {
console.log("Updated: " + artist + " - " + album)
reload()
}
Expand Down Expand Up @@ -113,9 +115,9 @@ BackgroundItem

Label {
id: vtext
anchors.verticalCenter: coverImg.status!=Image.Error && textvisible? undefined : parent.verticalCenter
anchors.bottom: coverImg.status!=Image.Error && textvisible? parent.bottom : undefined
anchors.bottomMargin: coverImg.status!=Image.Error && textvisible? Theme.paddingSmall : undefined
y: coverImg.status!=Image.Error && textvisible
Olf0 marked this conversation as resolved.
Show resolved Hide resolved
? parent.height - height - Theme.paddingSmall
: (parent.height - height) / 2
anchors.left: parent.left
anchors.leftMargin: Theme.paddingMedium
width: parent.width - Theme.paddingMedium*2
Expand Down
4 changes: 4 additions & 0 deletions src/coversearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

//#include <QDeclarativeView>
#include <QDebug>
#include <QDir>
#include <QString>
#include <QStringList>
#include <QJsonDocument>
Expand Down Expand Up @@ -39,6 +40,9 @@ CoverSearch::CoverSearchPrivate::CoverSearchPrivate(CoverSearch * parent) : q(pa
//q->pepe = new WebThread();
//connect (q->pepe, SIGNAL(imgLoaded(QString,int)), parent, SLOT(paintImg(QString,int)) );

// Ensure that download destination exists.
QDir d;
d.mkpath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
}

CoverSearch::CoverSearchPrivate::~CoverSearchPrivate()
Expand Down
14 changes: 3 additions & 11 deletions src/loadwebimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,8 @@ void WebThread::checkAll()
//QString url = "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=7f338c7458e7d1a9a6204221ff904ba1";

// QUASAR
QString url = "http://coverart.katastrophos.net/index.php?";
url += "&artist="+QUrl::toPercentEncoding(artist)+"&album="+QUrl::toPercentEncoding(album)+"&search=Search";

QString url = "https://coverart.katastrophos.net/query.php?";
url += "&artist="+QUrl::toPercentEncoding(artist)+"&album="+QUrl::toPercentEncoding(album)+"&mode=imageurls&limit=1";


//AMAZON - SIMPLE
Expand Down Expand Up @@ -211,16 +210,9 @@ void WebThread::downloaded(QNetworkReply *respuesta)

QString tmp = datos1;


//QUASAR
if (tmp.contains("<ul title=\"Cover Arts\">"))
if (tmp.startsWith("http"))
{
int x = tmp.indexOf("<li><a href=\"");
tmp.remove(0,x+13);
x = tmp.indexOf("\">");
tmp.remove(x,tmp.length()-x);
tmp = tmp.trimmed();

qDebug() << "Link for" << files[0][0] << files[0][1] << tmp;

downloadImage(tmp);
Expand Down