[Xfce4-commits] [panel-plugins/xfce4-pulseaudio-plugin] 01/01: Condition track titles now that we can work with online videos (via the plasma-browser-integration plugin)
noreply at xfce.org
noreply at xfce.org
Sun Mar 29 15:29:35 CEST 2020
This is an automated email from the git hooks/post-receive script.
b l u e s a b r e p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository panel-plugins/xfce4-pulseaudio-plugin.
commit b4fcc1d82ae31981c539d0ef5eb402bf570ec7d6
Author: Sean Davis <smd.seandavis at gmail.com>
Date: Sun Mar 29 09:29:23 2020 -0400
Condition track titles now that we can work with online videos (via the plasma-browser-integration plugin)
---
panel-plugin/pulseaudio-mpris-player.c | 70 ++++++++++++++++++++++++++++++++++
1 file changed, 70 insertions(+)
diff --git a/panel-plugin/pulseaudio-mpris-player.c b/panel-plugin/pulseaudio-mpris-player.c
index 0c0b581..e27f755 100644
--- a/panel-plugin/pulseaudio-mpris-player.c
+++ b/panel-plugin/pulseaudio-mpris-player.c
@@ -141,6 +141,67 @@ pulseaudio_mpris_player_class_init (PulseaudioMprisPlayerClass *klass)
+static gboolean
+pulseaudio_mpris_player_can_condition_track_info (PulseaudioMprisPlayer *player)
+{
+ if (player->title == NULL || player->artist == NULL)
+ return FALSE;
+
+ if (!g_utf8_validate (player->title, -1, NULL) || !g_utf8_validate (player->artist, -1, NULL))
+ return FALSE;
+
+ if (g_utf8_strlen (player->title, -1) <= 0 || g_utf8_strlen (player->artist, -1) <= 0)
+ return FALSE;
+
+ return TRUE;
+}
+
+
+static gboolean
+pulseaudio_mpris_player_condition_track_info (PulseaudioMprisPlayer *player,
+ const gchar *delimiter)
+{
+ gchar *lookup = NULL;
+ gchar *replace = NULL;
+ gboolean found = FALSE;
+
+ lookup = g_strconcat (player->artist, delimiter, NULL);
+ if (g_str_has_prefix (player->title, lookup))
+ {
+ replace = g_utf8_substring (player->title, g_utf8_strlen (lookup, -1), g_utf8_strlen (player->title, -1));
+ g_free (player->title);
+ player->title = replace;
+ found = TRUE;
+ }
+ g_free (lookup);
+
+ if (found)
+ return TRUE;
+
+ // Track titles match ARTIST - TITLE
+ if (g_str_has_suffix (player->artist, "VEVO"))
+ {
+ gchar **components = g_strsplit (player->title, delimiter, 2);
+
+ if (g_strv_length (components) == 2)
+ {
+ g_free (player->artist);
+ player->artist = g_strdup (components[0]);
+
+ g_free (player->title);
+ player->title = g_strdup (components[1]);
+
+ found = TRUE;
+ }
+
+ g_strfreev (components);
+ }
+
+ return found;
+}
+
+
+
static void
pulseaudio_mpris_player_parse_metadata (PulseaudioMprisPlayer *player,
GVariant *dictionary)
@@ -195,6 +256,15 @@ pulseaudio_mpris_player_parse_metadata (PulseaudioMprisPlayer *player,
}
}
}
+
+ if (!pulseaudio_mpris_player_can_condition_track_info (player))
+ return;
+
+ if (pulseaudio_mpris_player_condition_track_info (player, " - "))
+ return;
+
+ if (pulseaudio_mpris_player_condition_track_info (player, ": "))
+ return;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list