I’m using Audacious 4.0.4 (latest version doesn’t want to build on my system) and it seems to be working.
Here’s how I patched it. These patches are for 4.0.4 but should hopefully be adaptable to newer versions. (It looks like this forum software is putting them in scrolling boxes so you might have to scroll to see the whole patches.)
Disclaimer: I’m not a C++ programmer so this is probably buggy!
1st the new URL…
diff --git a/src/scrobbler2/scrobbler.h b/src/scrobbler2/scrobbler.h
index 9236a3159..07c96a27f 100644
--- a/src/scrobbler2/scrobbler.h
+++ b/src/scrobbler2/scrobbler.h
@@ -24,7 +24,7 @@
#define SCROBBLER_API_KEY "4b4f73bda181868353f9b438604adf52"
#define SCROBBLER_SHARED_SECRET "716cc0a784bb62835de5bd674e65eb57"
-#define SCROBBLER_URL "https://ws.audioscrobbler.com/2.0/"
+#define SCROBBLER_URL "https://listenbrainz.org/2.0/"
extern const PluginPreferences configuration;
Work around authorization check not working… (not sure if you may still have to click the button to check the login anyway, I don’t recall)
diff --git a/src/scrobbler2/scrobbler_communication.cc b/src/scrobbler2/scrobbler_communication.cc
index 29dfbcf96..ee5db8d3d 100644
--- a/src/scrobbler2/scrobbler_communication.cc
+++ b/src/scrobbler2/scrobbler_communication.cc
@@ -217,11 +217,11 @@ static gboolean scrobbler_test_connection() {
if (success == false) {
AUDDBG("Network problems. Will not scrobble any tracks.\n");
- scrobbling_enabled = false;
+ scrobbling_enabled = true;
if (permission_check_requested) {
- perm_result = PERMISSION_NONET;
+ perm_result = PERMISSION_ALLOWED;
}
- return false;
+ return true;
}
String error_code;
@@ -236,12 +236,12 @@ static gboolean scrobbler_test_connection() {
)) {
session_key = String();
aud_set_str("scrobbler", "session_key", "");
- scrobbling_enabled = false;
+ scrobbling_enabled = true;
} else {
//network problem.
- scrobbling_enabled = false;
+ scrobbling_enabled = true;
AUDDBG("Connection NOT OK. Scrobbling disabled\n");
- success = false;
+ success = true;
}
} else {
//THIS IS THE ONLY PLACE WHERE SCROBBLING IS SET TO ENABLED IN RUN-TIME
Disable now playing feature, and clean up titles with SoundCloud IDs in them
diff --git a/src/scrobbler2/scrobbler.cc b/src/scrobbler2/scrobbler.cc
index 9c44b9465..74fc3aebd 100644
--- a/src/scrobbler2/scrobbler.cc
+++ b/src/scrobbler2/scrobbler.cc
@@ -7,6 +7,8 @@
* It is licensed under the GNU General Public License, version 3.
*/
+#include <regex>
+#include <string>
#include <glib/gstdio.h>
//audacious includes
@@ -91,8 +93,10 @@ static gboolean queue_track_to_scrobble (void * data) {
char *queuepath = g_strconcat(aud_get_path(AudPath::UserDir),"/scrobbler.log", nullptr);
+ std::regex filter ("(-(([-\\w]{11})|(\\d{9,10})))$");
+
StringBuf artist = clean_string (playing_track.get_str (Tuple::Artist));
- StringBuf title = clean_string (playing_track.get_str (Tuple::Title));
+ StringBuf title = clean_string (std::regex_replace(std::string (playing_track.get_str (Tuple::Title)), filter, "").c_str());
StringBuf album = clean_string (playing_track.get_str (Tuple::Album));
int track = playing_track.get_int (Tuple::Track);
diff --git a/src/scrobbler2/scrobbler_communication.cc b/src/scrobbler2/scrobbler_communication.cc
index b3d343c37..3e03d1c4b 100644
--- a/src/scrobbler2/scrobbler_communication.cc
+++ b/src/scrobbler2/scrobbler_communication.cc
@@ -3,6 +3,7 @@
#include <stdarg.h>
#include <stdlib.h>
#include <sys/time.h>
+#include <regex>
#include <curl/curl.h>
#include <glib.h>
@@ -500,8 +501,12 @@ static void send_now_playing() {
*/
Tuple curr_track = now_playing_track.ref ();
+ std::regex filter ("-(([-\\w]{11})|(\\d{9,10}))$");
+
StringBuf artist = clean_string (curr_track.get_str (Tuple::Artist));
- StringBuf title = clean_string (curr_track.get_str (Tuple::Title));
+ StringBuf titletemp = clean_string (curr_track.get_str (Tuple::Title));
+ const char * titletempb = std::regex_replace((const char *)titletemp, filter, "").c_str();
+ StringBuf title = str_copy(titletempb);
StringBuf album = clean_string (curr_track.get_str (Tuple::Album));
int track = curr_track.get_int (Tuple::Track);
@@ -517,7 +522,8 @@ static void send_now_playing() {
"duration", (const char *) length_str, "api_key", SCROBBLER_API_KEY,
"sk", (const char *) session_key);
- gboolean success = send_message_to_lastfm(playingmsg);
+ // gboolean success = send_message_to_lastfm(playingmsg);
+ gboolean success = true;
if (success == false) {
AUDDBG("Network problems. Could not send \"now playing\" to last.fm\n");
Probably don’t need this, but I did anyway…
diff --git a/src/scrobbler2/config_window.cc b/src/scrobbler2/config_window.cc
index 374c04b73..3663cdb1d 100644
--- a/src/scrobbler2/config_window.cc
+++ b/src/scrobbler2/config_window.cc
@@ -37,7 +37,7 @@ static gboolean permission_checker_thread (void *) {
auto msg1 = _("Permission denied. Open the following "
"URL in a browser, allow Audacious access to your account, and "
"then click 'Check Permission' again:");
- auto url = str_printf("http://www.last.fm/api/auth/?api_key=%s"
+ auto url = str_printf("https://listenbrainz.org/api/auth/?api_key=%s"
"&token=%s", SCROBBLER_API_KEY, (const char *)request_token);
hook_call("ui show error", (void *)(const char *)str_concat
Prevent empty album tag getting rejected by LB… ([LB-1283] Suggestion - Treat empty release name as omitted? - MetaBrainz JIRA)
diff --git a/audacious-plugins-4.0.4/src/scrobbler2/scrobbler_communication.cc b/audacious-plugins-4.0.4/src/scrobbler2/scrobbler_communication.cc
index 40c9d1b..29dfbcf 100644
--- a/src/scrobbler2/scrobbler_communication.cc
+++ b/src/scrobbler2/scrobbler_communication.cc
@@ -398,7 +397,7 @@ static void scrobble_cached_queue() {
if (line[0] && line[2] && (strcmp(line[5], "L") == 0) && line[6] && (line[7] == nullptr))
{
String scrobblemsg = create_message_to_lastfm ("track.scrobble",
- 8, "artist", line[0], "album", line[1], "track", line[2],
+ 8, "artist", line[0], "album", (line[1] != nullptr && (bool)strlen(line[1])) ? line[1] : "UnknownAlbum", "track", line[2],
"trackNumber", line[3], "duration", line[4],
"timestamp", line[6], "api_key", SCROBBLER_API_KEY,
"sk", (const char *) session_key);
I hope this helps!