Commit 0db14be5 authored by Camilo Higuita's avatar Camilo Higuita

revision of brainz and pulpo

parent c1cc4a3b
......@@ -57,6 +57,18 @@ Babe::Babe(QObject *parent) : CollectionDB(parent)
emit this->refreshTables(size);
});
connect(settings, &BabeSettings::refreshATable, [this](BAE::TABLE table)
{
switch(table)
{
case BAE::TABLE::TRACKS: emit this->refreshTracks(); break;
case BAE::TABLE::ALBUMS: emit this->refreshAlbums(); break;
case BAE::TABLE::ARTISTS: emit this->refreshArtists(); break;
}
});
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
this->nof = new Notify(this);
connect(this->nof,&Notify::babeSong,[this]()
......
......@@ -146,6 +146,9 @@ private:
signals:
void refreshTables(int size);
void refreshTracks();
void refreshAlbums();
void refreshArtists();
void trackLyricsReady(QString lyrics, QString url);
void skipTrack();
void babeIt();
......
......@@ -20,6 +20,12 @@ var GET = {
playlistTracks_ : "select t.* , al.artwork from tracks t inner join albums al on t.album = al.album and t.artist = al.artist inner join tracks_playlists pl on pl.url = t.url where pl.playlist = \"%1\" order by strftime(\"%s\", pl.addDate) desc",
playlists: "select * from playlists order by strftime(\"%s\", addDate) desc",
genres: "select genre as tag from tracks",
tags : "select distinct tag from tags where context = 'tag' limit 1000",
trackTags : "select distinct tag from tracks_tags where context = 'tag' and tag collate nocase not in (select artist from artists) and tag in (select tag from tracks_tags group by tag having count(url) > 1) order by tag collate nocase limit 1000",
colorTracks_: "select t.*, al.artwork from tracks t inner join albums al on al.album = t.album and al.artist = t.artist where t.art = \"%1\""
......
......@@ -839,7 +839,6 @@ Kirigami.ApplicationWindow
animTxt.running = true
}
Component.onCompleted:
{
if(isMobile) settingsDrawer.switchColorScheme(bae.loadSetting("THEME", "BABE", "Dark"))
......@@ -865,8 +864,13 @@ Kirigami.ApplicationWindow
Connections
{
target: bae
onRefreshTables: H.refreshCollection(size)
onRefreshTracks: H.refreshTracks()
onRefreshAlbums: H.refreshAlbums()
onRefreshArtists: H.refreshArtists()
onTrackLyricsReady:
{
if(url === currentTrack.url)
......
......@@ -15,7 +15,6 @@
*/
#include "pulpo.h"
#include "services/lastfmService.h"
#include "services/spotifyService.h"
......@@ -31,11 +30,17 @@ Pulpo::Pulpo(QObject *parent): QObject(parent) {}
Pulpo::~Pulpo() {}
void Pulpo::feed(const BAE::DB &song, const RECURSIVE &recursive)
bool Pulpo::feed(const BAE::DB &song, const RECURSIVE &recursive)
{
this->track = song;
this->recursive = recursive;
if(this->registeredServices.isEmpty()) return false;
if(this->track.isEmpty()) return false;
this->initServices();
return true;
}
void Pulpo::registerServices(const QList<PULPO::SERVICES> &services)
......@@ -63,13 +68,10 @@ void Pulpo::setRecursive(const RECURSIVE &state)
this->recursive=state;
}
bool Pulpo::initServices()
void Pulpo::initServices()
{
if(this->registeredServices.isEmpty()) return false;
if(this->track.isEmpty()) return false;
for(auto service : this->registeredServices)
{
switch (service)
{
case SERVICES::LastFm:
......@@ -77,11 +79,11 @@ bool Pulpo::initServices()
lastfm lastfm(this->track);
connect(&lastfm, &lastfm::infoReady, this, &Pulpo::passSignal);
if(lastfm.setUpService(this->ontology,this->info))
if(lastfm.setUpService(this->ontology, this->info))
{
if(recursive== RECURSIVE::OFF) return true;
if(recursive == RECURSIVE::OFF) return;
}else qDebug()<<"error settingUp lastfm service";
}else qDebug()<<"Error settingUp lastfm service";
break;
}
......@@ -93,9 +95,9 @@ bool Pulpo::initServices()
if(spotify.setUpService(this->ontology,this->info))
{
if(recursive== RECURSIVE::OFF) return true;
if(recursive== RECURSIVE::OFF) return;
}else qDebug()<<"error settingUp spotify service";
}else qDebug()<<"Error settingUp spotify service";
break;
}
......@@ -106,9 +108,9 @@ bool Pulpo::initServices()
if(genius.setUpService(this->ontology,this->info))
{
if(recursive== RECURSIVE::OFF) return true;
if(recursive== RECURSIVE::OFF) return;
}else qDebug()<<"error settingUp spotify service";
}else qDebug()<<"Error settingUp spotify service";
break;
}
......@@ -119,9 +121,9 @@ bool Pulpo::initServices()
if(musicbrainz.setUpService(this->ontology,this->info))
{
if(recursive== RECURSIVE::OFF) return true;
if(recursive== RECURSIVE::OFF) return;
}else qDebug()<<"error settingUp musicBrainz service";
}else qDebug()<<"Error settingUp musicBrainz service";
break;
}
......@@ -140,9 +142,9 @@ bool Pulpo::initServices()
if(lyricwikia.setUpService(this->ontology,this->info))
{
if(recursive== RECURSIVE::OFF) return true;
if(recursive== RECURSIVE::OFF) return;
}else qDebug()<<"error settingUp lyricwikia service";
}else qDebug()<<"Error settingUp lyricwikia service";
break;
}
......@@ -158,9 +160,9 @@ bool Pulpo::initServices()
if(deezer.setUpService(this->ontology, this->info))
{
if(recursive== RECURSIVE::OFF) return true;
if(recursive== RECURSIVE::OFF) return;
}else qDebug()<<"error settingUp deezer service";
}else qDebug()<<"Error settingUp deezer service";
break;
}
......@@ -173,12 +175,6 @@ bool Pulpo::initServices()
break;
}
}
qDebug()<<"PULPO::ERROR HAPPENED!";
// emit infoReady(this->track, this->packResponse(this->ontology, this->info, {{}}));
}
return false;
}
void Pulpo::passSignal(const BAE::DB &track, const PULPO::RESPONSE &response)
......
......@@ -32,7 +32,7 @@ public:
explicit Pulpo(QObject *parent = nullptr);
~Pulpo();
void feed(const BAE::DB &song, const PULPO::RECURSIVE &recursive = PULPO::RECURSIVE::ON );
bool feed(const BAE::DB &song, const PULPO::RECURSIVE &recursive = PULPO::RECURSIVE::ON );
void registerServices(const QList<PULPO::SERVICES> &services);
void setInfo(const PULPO::INFO &info);
void setOntology(const PULPO::ONTOLOGY &ontology);
......@@ -40,9 +40,9 @@ public:
void setRecursive(const PULPO::RECURSIVE &state);
private:
bool initServices();
void initServices();
PULPO::RECURSIVE recursive = PULPO::RECURSIVE::ON;
QList<SERVICES> registeredServices = {SERVICES::ALL};
QList<SERVICES> registeredServices = {};
void passSignal(const BAE::DB &track, const PULPO::RESPONSE &response);
......
......@@ -33,7 +33,6 @@ BabeSettings::BabeSettings(QObject *parent) : QObject(parent)
this->ytFetch = new YouTube(this);
this->babeSocket = new Socket(static_cast<quint16>(BAE::BabePort.toInt()),this);
qDebug() << "Getting collectionDB info from: " << BAE::CollectionDBPath;
qDebug() << "Getting settings info from: " << BAE::SettingPath;
qDebug() << "Getting artwork files from: " << BAE::CachePath;
......@@ -82,16 +81,17 @@ BabeSettings::BabeSettings(QObject *parent) : QObject(parent)
connect(this->brainDeamon, &Brain::done, [this](const TABLE type)
{
emit this->refreshTables(0);
emit this->refreshATable(type);
});
connect(this->fileLoader, &FileLoader::finished,[this](int size)
{
if(size > 0)
{
this->startBrainz(true, BAE::SEG::ONEHALF);
bDebug::Instance()->msg("Finished inserting into DB "+QString::number(size)+" tracks");
bDebug::Instance()->msg("Starting Brainz with interval: " + QString::number(BAE::SEG::ONEHALF));
this->startBrainz(true, BAE::SEG::ONEHALF);
}else
this->startBrainz(BAE::loadSettings("BRAINZ", "BABE", false).toBool(), BAE::SEG::THREE);
......
......@@ -47,6 +47,7 @@ private:
signals:
void collectionPathChanged(QStringList newPaths);
void refreshATable(BAE::TABLE table);
void refreshTables(int size);
void albumArtReady(const DB &album);
void brainFinished();
......
......@@ -45,13 +45,26 @@ function refreshCollection(size)
if(!isMobile && size>0) bae.notify("Collection updated", size+" new tracks added...")
console.log("Clearing tables")
refreshTracks()
refreshAlbums()
refreshArtists()
}
function refreshTracks()
{
tracksView.clearTable()
tracksView.populate()
}
function refreshAlbums()
{
albumsView.clearGrid()
albumsView.populate()
}
function refreshArtists()
{
artistsView.clearGrid()
artistsView.populate()
}
......@@ -9,15 +9,13 @@ function playTrack(track)
if(bae.fileExists(currentTrack.url))
{
console.log("PLAY: "+currentTrack.url)
player.source(currentTrack.url);
player.play()
// root.playIcon.iconName = "media-playback-pause"
var artwork = currentTrack.artwork
// root.mainPlaylist.list.currentItem.playingIndicator = true
currentArtwork = artwork && artwork.length>0 && artwork !== "NONE" ? artwork : bae.loadCover(currentTrack.url)
currentArtwork = artwork && artwork.length>0 && artwork !== "NONE"? artwork : bae.loadCover(currentTrack.url)
currentTrack.artwork = currentArtwork
currentBabe = bae.trackBabe(currentTrack.url)
......
......@@ -433,7 +433,6 @@ inline bool artworkCache(DB &track, const KEY &type = KEY::NONE)
default: break;
}
}
return false;
}
......
This diff is collapsed.
......@@ -10,12 +10,12 @@
#include "bae.h"
#include "../pulpo/pulpo.h"
#include "../db/collectionDB.h"
class CollectionDB;
using namespace BAE;
using namespace PULPO;
class Brain : public QObject
class Brain : public CollectionDB
{
Q_OBJECT
......@@ -42,7 +42,6 @@ public slots:
private:
QThread t;
CollectionDB *con;
Pulpo pulpo;
uint interval = 1500;
bool go = false;
......
......@@ -4,27 +4,34 @@ import QtQuick.Layouts 1.3
BabeDialog
{
id: babeMessageRoot
property string message
property string messageBody
standardButtons: Dialog.Yes | Dialog.No
ColumnLayout
{
anchors.fill: parent
width: parent.width
height: parent.height
Label
{
Layout.margins: contentMargins
text: message ? message : ""
width: parent.width
width: babeMessageRoot.width
elide: Text.ElideRight
color: foregroundColor
}
Label
TextArea
{
Layout.margins: contentMargins
Layout.maximumWidth: parent.width
text: messageBody ? messageBody : ""
width: parent.width
elide: Text.ElideRight
wrapMode: TextEdit.WrapAnywhere
readOnly: true
color: foregroundColor
}
}
......
......@@ -51,14 +51,42 @@ Kirigami.PageRow
spacing: 0
Layout.margins: 0
PlaylistsViewModel
SwipeView
{
id: playlistViewModel
id: playlistSwipe
Layout.fillHeight: true
Layout.fillWidth: true
onPlaySync: syncAndPlay(index)
PlaylistsViewModel
{
id: playlistViewModel
onPlaySync: syncAndPlay(index)
}
BabeList
{
id: playlistViewModelFilter
headerBarExitIcon: "arrow-left"
model : ListModel {}
delegate: BabeDelegate
{
id: delegate
label : tag
Connections
{
target: delegate
onClicked: {}
}
}
onExit: playlistSwipe.currentIndex = 0
}
}
Kirigami.Separator{ Layout.fillWidth: true; width: parent.width; height: 1}
......@@ -181,6 +209,18 @@ Kirigami.PageRow
}
function populateExtra(query, title)
{
playlistSwipe.currentIndex = 1
var res = bae.get(query)
playlistViewModelFilter.clearTable()
playlistViewModelFilter.headerBarTitle = title
if(res.length>0)
for(var i in res)
playlistViewModelFilter.model.append(res[i])
}
function populate(query)
{
playlistQuery = query
......
......@@ -105,8 +105,7 @@ BabeList
break;
case "Tags":
playlistViewRoot.populate(Q.GET.favoriteTracks);
populateExtra(Q.GET.tags, "Tags")
break;
case "Relationships":
......@@ -119,10 +118,9 @@ BabeList
playlistViewRoot.populate(Q.GET.favoriteTracks);
break;
case "Genre":
case "Genres":
filterList.section.property = "genre"
playlistViewRoot.populate(Q.GET.favoriteTracks);
populateExtra(Q.GET.genres, "Genres")
break;
default:
......
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