mirror of
https://github.com/clangen/musikcube.git
synced 2024-10-02 04:52:32 +00:00
Moved LastFm
to core, and wired it directly into PlaybackService so it
works from `musikcubed` as well. In the future we'll probably want a repository for scrobblers... but for now this works.
This commit is contained in:
parent
386eae43df
commit
016176103c
@ -81,6 +81,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
|||||||
include_directories("/usr/local/include")
|
include_directories("/usr/local/include")
|
||||||
link_directories ("/opt/local/lib")
|
link_directories ("/opt/local/lib")
|
||||||
include_directories("/opt/local/include")
|
include_directories("/opt/local/include")
|
||||||
|
include_directories("/usr/local/opt/openssl/include")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (EXISTS "/etc/arch-release" OR EXISTS "/etc/manjaro-release" OR NO_NCURSESW)
|
if (EXISTS "/etc/arch-release" OR EXISTS "/etc/manjaro-release" OR NO_NCURSESW)
|
||||||
|
5
clean-nix.sh
Executable file
5
clean-nix.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
make clean 2> /dev/null
|
||||||
|
rm -rf bin
|
||||||
|
find . -name CMakeCache.txt -delete
|
||||||
|
find . -name CMakeFiles -type d -exec rm -r "{}" \; 2> /dev/null
|
@ -48,6 +48,7 @@ set(CORE_SOURCES
|
|||||||
./runtime/MessageQueue.cpp
|
./runtime/MessageQueue.cpp
|
||||||
./support/Duration.cpp
|
./support/Duration.cpp
|
||||||
./support/Common.cpp
|
./support/Common.cpp
|
||||||
|
./support/LastFm.cpp
|
||||||
./support/Playback.cpp
|
./support/Playback.cpp
|
||||||
./support/Preferences.cpp
|
./support/Preferences.cpp
|
||||||
./support/PreferenceKeys.cpp
|
./support/PreferenceKeys.cpp
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include <core/runtime/Message.h>
|
#include <core/runtime/Message.h>
|
||||||
#include <core/support/PreferenceKeys.h>
|
#include <core/support/PreferenceKeys.h>
|
||||||
#include <core/support/Playback.h>
|
#include <core/support/Playback.h>
|
||||||
|
#include <core/support/LastFm.h>
|
||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
@ -456,6 +457,10 @@ void PlaybackService::OnTrackChanged(size_t pos, TrackPtr track) {
|
|||||||
this->playingTrack = track;
|
this->playingTrack = track;
|
||||||
this->TrackChanged(this->index, track);
|
this->TrackChanged(this->index, track);
|
||||||
|
|
||||||
|
if (track && this->GetPlaybackState() == PlaybackPlaying) {
|
||||||
|
lastfm::Scrobble(track);
|
||||||
|
}
|
||||||
|
|
||||||
for (auto it = remotes.begin(); it != remotes.end(); it++) {
|
for (auto it = remotes.begin(); it != remotes.end(); it++) {
|
||||||
(*it)->OnTrackChanged(track.get());
|
(*it)->OnTrackChanged(track.get());
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
#include <core/support/Preferences.h>
|
#include <core/support/Preferences.h>
|
||||||
#include <core/io/HttpClient.h>
|
#include <core/io/HttpClient.h>
|
||||||
#include <core/support/PreferenceKeys.h>
|
#include <core/support/PreferenceKeys.h>
|
||||||
#include <app/util/PreferenceKeys.h>
|
|
||||||
#include <json.hpp>
|
#include <json.hpp>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -65,7 +64,7 @@ static std::shared_ptr<LastFmClient> createClient() {
|
|||||||
return LastFmClient::Create(std::stringstream());
|
return LastFmClient::Create(std::stringstream());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void validate(musik::cube::lastfm::Session& session) {
|
static void validate(musik::core::lastfm::Session& session) {
|
||||||
session.valid =
|
session.valid =
|
||||||
session.sessionId.size() &&
|
session.sessionId.size() &&
|
||||||
session.username.size() &&
|
session.username.size() &&
|
||||||
@ -129,7 +128,7 @@ static inline Prefs settings() {
|
|||||||
return Preferences::ForComponent(components::Settings);
|
return Preferences::ForComponent(components::Settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace musik { namespace cube { namespace lastfm {
|
namespace musik { namespace core { namespace lastfm {
|
||||||
|
|
||||||
void CreateAccountLinkToken(TokenCallback callback) {
|
void CreateAccountLinkToken(TokenCallback callback) {
|
||||||
std::string url = generateSignedUrl(GET_TOKEN);
|
std::string url = generateSignedUrl(GET_TOKEN);
|
||||||
@ -184,7 +183,7 @@ namespace musik { namespace cube { namespace lastfm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Session LoadSession() {
|
Session LoadSession() {
|
||||||
namespace keys = cube::prefs::keys;
|
namespace keys = core::prefs::keys;
|
||||||
auto prefs = settings();
|
auto prefs = settings();
|
||||||
Session session;
|
Session session;
|
||||||
session.token = prefs->GetString(keys::LastFmToken);
|
session.token = prefs->GetString(keys::LastFmToken);
|
||||||
@ -195,7 +194,7 @@ namespace musik { namespace cube { namespace lastfm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SaveSession(const Session& session) {
|
void SaveSession(const Session& session) {
|
||||||
namespace keys = cube::prefs::keys;
|
namespace keys = core::prefs::keys;
|
||||||
auto prefs = settings();
|
auto prefs = settings();
|
||||||
prefs->SetString(keys::LastFmToken.c_str(), session.token.c_str());
|
prefs->SetString(keys::LastFmToken.c_str(), session.token.c_str());
|
||||||
prefs->SetString(keys::LastFmSessionId.c_str(), session.sessionId.c_str());
|
prefs->SetString(keys::LastFmSessionId.c_str(), session.sessionId.c_str());
|
@ -37,7 +37,7 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include <core/library/track/Track.h>
|
#include <core/library/track/Track.h>
|
||||||
|
|
||||||
namespace musik { namespace cube { namespace lastfm {
|
namespace musik { namespace core { namespace lastfm {
|
||||||
struct Session {
|
struct Session {
|
||||||
bool valid{ false };
|
bool valid{ false };
|
||||||
std::string username, token, sessionId;
|
std::string username, token, sessionId;
|
@ -58,6 +58,9 @@ namespace musik { namespace core { namespace prefs {
|
|||||||
const std::string keys::SaveSessionOnExit = "SaveSessionOnExit";
|
const std::string keys::SaveSessionOnExit = "SaveSessionOnExit";
|
||||||
const std::string keys::LastPlayQueueIndex = "LastPlayQueueIndex";
|
const std::string keys::LastPlayQueueIndex = "LastPlayQueueIndex";
|
||||||
const std::string keys::LastPlayQueueTime = "LastPlayQueueTime";
|
const std::string keys::LastPlayQueueTime = "LastPlayQueueTime";
|
||||||
|
const std::string keys::LastFmToken = "LastFmToken";
|
||||||
|
const std::string keys::LastFmSessionId = "LastFmSessionId";
|
||||||
|
const std::string keys::LastFmUsername = "LastFmUsername";
|
||||||
|
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
|
@ -62,6 +62,9 @@ namespace musik { namespace core { namespace prefs {
|
|||||||
extern const std::string SaveSessionOnExit;
|
extern const std::string SaveSessionOnExit;
|
||||||
extern const std::string LastPlayQueueIndex;
|
extern const std::string LastPlayQueueIndex;
|
||||||
extern const std::string LastPlayQueueTime;
|
extern const std::string LastPlayQueueTime;
|
||||||
|
extern const std::string LastFmToken;
|
||||||
|
extern const std::string LastFmSessionId;
|
||||||
|
extern const std::string LastFmUsername;
|
||||||
}
|
}
|
||||||
|
|
||||||
} } }
|
} } }
|
||||||
|
@ -23,7 +23,6 @@ set (CUBE_SRCS
|
|||||||
./app/overlay/VisualizerOverlay.cpp
|
./app/overlay/VisualizerOverlay.cpp
|
||||||
./app/util/GlobalHotkeys.cpp
|
./app/util/GlobalHotkeys.cpp
|
||||||
./app/util/Hotkeys.cpp
|
./app/util/Hotkeys.cpp
|
||||||
./app/util/LastFm.cpp
|
|
||||||
./app/util/PreferenceKeys.cpp
|
./app/util/PreferenceKeys.cpp
|
||||||
./app/util/Playback.cpp
|
./app/util/Playback.cpp
|
||||||
./app/util/UpdateCheck.cpp
|
./app/util/UpdateCheck.cpp
|
||||||
|
@ -34,14 +34,15 @@
|
|||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "LastFmOverlay.h"
|
#include "LastFmOverlay.h"
|
||||||
#include <app/util/LastFm.h>
|
|
||||||
#include <app/util/Messages.h>
|
#include <app/util/Messages.h>
|
||||||
|
#include <core/support/LastFm.h>
|
||||||
#include <core/support/Common.h>
|
#include <core/support/Common.h>
|
||||||
#include <cursespp/App.h>
|
#include <cursespp/App.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using namespace musik::cube;
|
using namespace musik::cube;
|
||||||
|
using namespace musik::core;
|
||||||
using namespace musik;
|
using namespace musik;
|
||||||
using namespace cursespp;
|
using namespace cursespp;
|
||||||
|
|
||||||
@ -131,6 +132,9 @@ void LastFmOverlay::UpdateMessage() {
|
|||||||
core::ReplaceAll(message, "{{link}}", url);
|
core::ReplaceAll(message, "{{link}}", url);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->SetMessage(message);
|
this->SetMessage(message);
|
||||||
@ -207,6 +211,9 @@ void LastFmOverlay::UpdateButtons() {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cursespp/DialogOverlay.h>
|
#include <cursespp/DialogOverlay.h>
|
||||||
#include <app/util/LastFm.h>
|
|
||||||
|
|
||||||
namespace musik { namespace cube {
|
namespace musik { namespace cube {
|
||||||
/* in general we probably shouldn't subclass DialogOverlay because
|
/* in general we probably shouldn't subclass DialogOverlay because
|
||||||
|
@ -51,9 +51,6 @@ namespace musik { namespace cube { namespace prefs {
|
|||||||
const std::string keys::LastBrowseDirectoryRoot = "LastBrowseDirectoryRoot";
|
const std::string keys::LastBrowseDirectoryRoot = "LastBrowseDirectoryRoot";
|
||||||
const std::string keys::LastCategoryFilter = "LastCategoryFilter";
|
const std::string keys::LastCategoryFilter = "LastCategoryFilter";
|
||||||
const std::string keys::LastTrackFilter = "LastTrackFilter";
|
const std::string keys::LastTrackFilter = "LastTrackFilter";
|
||||||
const std::string keys::LastFmToken = "LastFmToken";
|
|
||||||
const std::string keys::LastFmSessionId = "LastFmSessionId";
|
|
||||||
const std::string keys::LastFmUsername = "LastFmUsername";
|
|
||||||
|
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
|
@ -53,9 +53,6 @@ namespace musik { namespace cube { namespace prefs {
|
|||||||
extern const std::string LastBrowseDirectoryRoot;
|
extern const std::string LastBrowseDirectoryRoot;
|
||||||
extern const std::string LastCategoryFilter;
|
extern const std::string LastCategoryFilter;
|
||||||
extern const std::string LastTrackFilter;
|
extern const std::string LastTrackFilter;
|
||||||
extern const std::string LastFmToken;
|
|
||||||
extern const std::string LastFmSessionId;
|
|
||||||
extern const std::string LastFmUsername;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} } }
|
} } }
|
||||||
|
@ -50,7 +50,6 @@
|
|||||||
|
|
||||||
#include <app/util/Hotkeys.h>
|
#include <app/util/Hotkeys.h>
|
||||||
#include <app/util/Messages.h>
|
#include <app/util/Messages.h>
|
||||||
#include <app/util/LastFm.h>
|
|
||||||
|
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
@ -427,11 +426,6 @@ void TransportWindow::OnPlaybackServiceTrackChanged(size_t index, TrackPtr track
|
|||||||
this->currentTrack = track;
|
this->currentTrack = track;
|
||||||
this->lastTime = DEFAULT_TIME;
|
this->lastTime = DEFAULT_TIME;
|
||||||
this->UpdateReplayGainState();
|
this->UpdateReplayGainState();
|
||||||
|
|
||||||
if (playback.GetPlaybackState() == PlaybackPlaying) {
|
|
||||||
lastfm::Scrobble(track);
|
|
||||||
}
|
|
||||||
|
|
||||||
DEBOUNCE_REFRESH(TimeSync, 0);
|
DEBOUNCE_REFRESH(TimeSync, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +227,6 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win32\font\*.ttf" "$(TargetDir)fonts\" /Y
|
|||||||
<ClInclude Include="app\overlay\VisualizerOverlay.h" />
|
<ClInclude Include="app\overlay\VisualizerOverlay.h" />
|
||||||
<ClInclude Include="app\util\GlobalHotkeys.h" />
|
<ClInclude Include="app\util\GlobalHotkeys.h" />
|
||||||
<ClInclude Include="app\util\Hotkeys.h" />
|
<ClInclude Include="app\util\Hotkeys.h" />
|
||||||
<ClInclude Include="app\util\LastFm.h" />
|
|
||||||
<ClInclude Include="app\util\Messages.h" />
|
<ClInclude Include="app\util\Messages.h" />
|
||||||
<ClInclude Include="app\util\Playback.h" />
|
<ClInclude Include="app\util\Playback.h" />
|
||||||
<ClInclude Include="app\util\PreferenceKeys.h" />
|
<ClInclude Include="app\util\PreferenceKeys.h" />
|
||||||
|
@ -367,9 +367,6 @@
|
|||||||
<ClInclude Include="app\layout\CategorySearchLayout.h">
|
<ClInclude Include="app\layout\CategorySearchLayout.h">
|
||||||
<Filter>app\layout</Filter>
|
<Filter>app\layout</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="app\util\LastFm.h">
|
|
||||||
<Filter>app\util</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="app\overlay\LastFmOverlay.h">
|
<ClInclude Include="app\overlay\LastFmOverlay.h">
|
||||||
<Filter>app\overlay</Filter>
|
<Filter>app\overlay</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
Loading…
Reference in New Issue
Block a user