Commit 62680ef1 authored by Camilo higuita's avatar Camilo higuita

start working on fixing pulpo for rc

parent 0721692b
......@@ -469,27 +469,27 @@ void Babe::loadCover(const QString &url)
void Babe::fetchCoverArt(FMH::MODEL &song)
{
// auto pulpo = new Pulpo;
auto pulpo = new Pulpo;
// if(BAE::artworkCache(song, FMH::MODEL_KEY::ALBUM)) return song[FMH::MODEL_KEY::ARTWORK];
// if(BAE::artworkCache(song, FMH::MODEL_KEY::ARTIST)) return song[FMH::MODEL_KEY::ARTWORK];
if(BAE::artworkCache(song, FMH::MODEL_KEY::ALBUM)) emit this->coverReady(song[FMH::MODEL_KEY::ARTWORK]);
if(BAE::artworkCache(song, FMH::MODEL_KEY::ARTIST)) emit this->coverReady(song[FMH::MODEL_KEY::ARTWORK]);
// pulpo->registerServices({SERVICES::LastFm, SERVICES::Spotify});
// pulpo->setOntology(PULPO::ONTOLOGY::ALBUM);
// pulpo->setInfo(PULPO::INFO::ARTWORK);
pulpo->registerServices({SERVICES::LastFm, SERVICES::Spotify});
pulpo->setOntology(PULPO::ONTOLOGY::ALBUM);
pulpo->setInfo(PULPO::INFO::ARTWORK);
// connect(&pulpo, &Pulpo::infoReady, [&](const FMH::MODEL &track,const PULPO::RESPONSE &res)
// {
// Q_UNUSED(track);
// if(!res[PULPO::ONTOLOGY::ALBUM][PULPO::INFO::ARTWORK].isEmpty())
// {
// auto artwork = res[PULPO::ONTOLOGY::ALBUM][PULPO::INFO::ARTWORK][PULPO::CONTEXT::IMAGE].toByteArray();
// BAE::saveArt(song, artwork, BAE::CachePath);
// emit this->coverReady(artwork);
// }
// });
connect(pulpo, &Pulpo::infoReady, [&](const FMH::MODEL &track,const PULPO::RESPONSE &res)
{
Q_UNUSED(track);
if(!res[PULPO::ONTOLOGY::ALBUM][PULPO::INFO::ARTWORK].isEmpty())
{
auto artwork = res[PULPO::ONTOLOGY::ALBUM][PULPO::INFO::ARTWORK][PULPO::CONTEXT::IMAGE].toByteArray();
BAE::saveArt(song, artwork, BAE::CachePath);
emit this->coverReady(song[FMH::MODEL_KEY::ARTWORK]);
}
});
// pulpo->feed(song, PULPO::RECURSIVE::OFF);
pulpo->feed(song, PULPO::RECURSIVE::OFF);
}
QVariantList Babe::transformData(const FMH::MODEL_LIST &dbList)
......
......@@ -613,7 +613,7 @@ Maui.ApplicationWindow
modal: !root.isWide
handleVisible: false
closePolicy: Popup.NoAutoClose
contentItem: MainPlaylist
{
id: mainPlaylist
......@@ -996,7 +996,13 @@ Maui.ApplicationWindow
// onRefreshAlbums: H.refreshAlbums()
// onRefreshArtists: H.refreshArtists()
onCoverReady: console.log("COVER ARTWORK IS READY", path);
onCoverReady:
{
root.currentArtwork = path
currentTrack.artwork = currentArtwork
mainPlaylist.list.update(currentTrack, currentTrackIndex);
}
onTrackLyricsReady:
{
console.log(lyrics)
......
......@@ -363,3 +363,24 @@ void TracksModel::refresh()
{
this->setList();
}
bool TracksModel::update(const QVariantMap &data, const int &index)
{
if(index >= this->list.size() || index < 0)
return false;
auto newData = this->list[index];
QVector<int> roles;
for(auto key : data.keys())
if(newData[FMH::MODEL_NAME_KEY[key]] != data[key].toString())
{
newData.insert(FMH::MODEL_NAME_KEY[key], data[key].toString());
roles << FMH::MODEL_NAME_KEY[key];
}
this->list[index] = newData;
emit this->updateModel(index, roles);
return true;
}
#ifndef TRACKSMODEL_H
#ifndef TRACKSMODEL_H
#define TRACKSMODEL_H
#include <QObject>
......@@ -66,6 +66,7 @@ public slots:
bool countUp(const int &index);
bool remove(const int &index) override;
void refresh();
bool update(const QVariantMap &data, const int &index) override;
};
#endif // TRACKSMODEL_H
......@@ -150,8 +150,8 @@ Maui.Page
list.appendQuery(query);
}
if(autoplay)
Player.playAt(0)
// if(autoplay)
// Player.playAt(0)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment