Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package osdlyrics for openSUSE:Factory checked in at 2023-02-16 16:55:53 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/osdlyrics (Old) and /work/SRC/openSUSE:Factory/.osdlyrics.new.22824 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "osdlyrics" Thu Feb 16 16:55:53 2023 rev:10 rq:1065986 version:0.5.13 Changes: -------- --- /work/SRC/openSUSE:Factory/osdlyrics/osdlyrics.changes 2022-10-18 12:46:03.617868590 +0200 +++ /work/SRC/openSUSE:Factory/.osdlyrics.new.22824/osdlyrics.changes 2023-02-16 16:56:07.410765766 +0100 @@ -1,0 +2,7 @@ +Wed Feb 15 13:14:18 UTC 2023 - Dirk Müller <[email protected]> + +- update to 0.5.13: + * Second attempt on inferring the artist from the title when + the former is invalid. + +------------------------------------------------------------------- Old: ---- osdlyrics-0.5.12.tar.gz New: ---- osdlyrics-0.5.13.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ osdlyrics.spec ++++++ --- /var/tmp/diff_new_pack.adT6G4/_old 2023-02-16 16:56:08.170768803 +0100 +++ /var/tmp/diff_new_pack.adT6G4/_new 2023-02-16 16:56:08.178768835 +0100 @@ -1,7 +1,7 @@ # # spec file for package osdlyrics # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: osdlyrics -Version: 0.5.12 +Version: 0.5.13 Release: 0 Summary: A third-party lyrics display program License: GPL-3.0-or-later ++++++ osdlyrics-0.5.12.tar.gz -> osdlyrics-0.5.13.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.12/check-version.sh new/osdlyrics-0.5.13/check-version.sh --- old/osdlyrics-0.5.12/check-version.sh 2022-09-01 22:01:57.000000000 +0200 +++ new/osdlyrics-0.5.13/check-version.sh 2023-01-27 14:58:42.000000000 +0100 @@ -1,7 +1,7 @@ #h!/usr/bin/env sh GIT="${GIT:-git}" -OL_VERSION="${OL_VERSION:-0.5.11}" +OL_VERSION="${OL_VERSION:-0.5.13}" if [ ! "$("$GIT" rev-parse --show-prefix 2>/dev/null)" ]; then _GIT_VERSION="$("$GIT" describe --always --tags 2>/dev/null)" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.12/src/ol_lyric_source.c new/osdlyrics-0.5.13/src/ol_lyric_source.c --- old/osdlyrics-0.5.12/src/ol_lyric_source.c 2022-09-01 22:01:57.000000000 +0200 +++ new/osdlyrics-0.5.13/src/ol_lyric_source.c 2023-01-27 14:58:42.000000000 +0100 @@ -547,21 +547,10 @@ ol_lyric_source_info_free (info); } source_ids = g_list_reverse (source_ids); - - // create a new metadata with real title and artist to search - OlMetadata * search_metadata = ol_metadata_dup (metadata); - ol_metadata_set_artist (search_metadata, - ol_metadata_get_search_artist(metadata)); - ol_metadata_set_title (search_metadata, - ol_metadata_get_search_title(metadata)); + OlMetadata *search_metadata = ol_metadata_dup (metadata); + ol_metadata_sanitize_title_artist (search_metadata); task = ol_lyric_source_search (source, search_metadata, source_ids); - - // comment out original call - // task = ol_lyric_source_search (source, metadata, source_ids); - - // free created metadata ol_metadata_free (search_metadata); - for (; source_ids; source_ids = g_list_delete_link (source_ids, source_ids)) { g_free (source_ids->data); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.12/src/ol_metadata.c new/osdlyrics-0.5.13/src/ol_metadata.c --- old/osdlyrics-0.5.12/src/ol_metadata.c 2022-09-01 22:01:57.000000000 +0200 +++ new/osdlyrics-0.5.13/src/ol_metadata.c 2023-01-27 14:58:42.000000000 +0100 @@ -316,6 +316,97 @@ return metadata->duration; } +static gboolean artist_valid (const OlMetadata *metadata) +{ + ol_assert_ret (metadata != NULL, FALSE); + + /* List of invalid artist names */ + static const char * const invalid_arts[] = {"unknown", "æªç¥", "群æ", NULL}; + + if (metadata->artist == NULL || strlen (metadata->artist) == 0) + { + return FALSE; + } + + gboolean valid = TRUE; + char * artist = g_ascii_strdown (metadata->artist, -1); + for (const char * const *a = invalid_arts; *a; a++) + { + /* + * To minimise the risks of false positives, only consider it a match if + * the artist field starts with the string + */ + if (g_strstr_len (artist, -1, *a) == artist) + { + valid = FALSE; + break; + } + } + g_free(artist); + + return valid; +} + +void +ol_metadata_sanitize_title_artist (OlMetadata *metadata) +{ + ol_assert (metadata != NULL); + + if (metadata->title == NULL || artist_valid (metadata)) + { + return; + } + + char *orig_title = metadata->title; + char *orig_artist = metadata->artist; + char *new_title = orig_title; + char *new_artist = orig_artist; + char *tmp, *rhs; + + /* Remove track number, if any */ + if ((tmp = strstr (new_title, "."))) + { + rhs = g_strstrip (tmp + 1); + if (strlen (rhs) > 0) + { + new_title = rhs; + } + } + + /* + * If any separator is that found in the title (in that order), set the + * artist to the LHS and the title to the RHS + */ + static const char * const separators[] = {"--", " - ", "-", NULL}; + + for (const char * const *sep = separators; *sep; sep++) + { + if ((tmp = strstr (new_title, *sep))) + { + rhs = g_strstrip (tmp + strlen (*sep)); + if (strlen (rhs) > 0) + { + *tmp = '\0'; + new_artist = new_title; + new_title = rhs; + break; + } + } + } + + if (new_artist != orig_artist) + { + metadata->artist = g_strdup (new_artist); + g_free (orig_artist); + } + + if (new_title != orig_title) + { + metadata->title = g_strdup (new_title); + g_free (orig_title); + } +} + static int internal_snprint (void *buffer, size_t count, @@ -501,178 +592,3 @@ g_variant_builder_unref (builder); return ret; } - -/* - chech whether tag artist is valid - */ -static gboolean artist_valid(const OlMetadata *metadata) -{ - ol_assert_ret (metadata != NULL, FALSE); - - // no artist name list - char * arts[] = {"unknown", "æªç¥", "群æ", NULL}; - - if (metadata->artist == NULL || strlen(metadata->artist) == 0) - { - return FALSE; - } - - gboolean valid = TRUE; - char * artist = g_ascii_strdown(metadata->artist, -1); - for (char ** a = arts; *a; a++) - { - if (g_strstr_len (artist, -1, *a) != NULL) - { - valid = FALSE; - break; - } - } - g_free(artist); - - return valid; -} - -/* - get real title: - if tag artist is valid, assume tag title is correct and return it, else parse it and return real title - support tag title formats: - %n.%p-%t, %n.%t--%p, %n.%t, %p-%t, %t--%p, %t - intend to be called in search action - */ -const char * -ol_metadata_get_search_title (const OlMetadata *metadata) -{ - ol_assert_ret (metadata != NULL, NULL); - - if (metadata->title == NULL) - { - return metadata->title; - } - - gboolean valid_artist = artist_valid(metadata); - - char * title = NULL; - char * title1 = NULL; - - // get title without track number - gchar **pathv = g_strsplit (metadata->title, ".", 0); - gchar **p; - if (g_strv_length (pathv) == 2) - { - p = pathv; - p++; - title = g_strstrip(g_strdup(*p)); - } - else - { - title = g_strdup(metadata->title); - } - g_free(pathv); - - // if tag artist is valid, assume the title is correct - if (valid_artist) { - return title; - } - - // parse title from tag title - gchar **pathv2 = g_strsplit (title, "--", 0); - gchar **p2; - if (g_strv_length (pathv2) == 2) - { - p2 = pathv2; - title1 = g_strstrip(g_strdup(*p2)); - } - else - { - gchar **pathv3 = g_strsplit (title, "-", 0); - gchar **p3; - if (g_strv_length (pathv3) == 2) - { - p3 = pathv3; - p3++; - title1 = g_strstrip(g_strdup(*p3)); - } - else - { - title1 = g_strdup(title); - } - g_free(pathv3); - } - g_free(pathv2); - g_free(title); - - return title1; -} - -/* - get real artist: - if tag artist is valid, return it, else parse tag title and return real artist - support tag title formats: - %n.%p-%t, %n.%t--%p, %n.%t, %p-%t, %t--%p, %t - intend to be called in search action - */ -const char * -ol_metadata_get_search_artist (const OlMetadata *metadata) -{ - ol_assert_ret (metadata != NULL, NULL); - - if (metadata->title == NULL) - { - return metadata->artist; - } - - gboolean valid_artist = artist_valid(metadata); - - // if tag artist is valid, return - if (valid_artist) - { - return metadata->artist; - } - - char * title = NULL; - char * artist = NULL; - - // get title without track number - gchar **pathv = g_strsplit (metadata->title, ".", 0); - gchar **p; - if (g_strv_length (pathv) == 2) - { - p = pathv; - p++; - title = g_strstrip(g_strdup(*p)); - } - else - { - title = g_strdup(metadata->title); - } - g_free(pathv); - - // get artist from title - gchar **pathv2 = g_strsplit (title, "--", 0); - gchar **p2; - if (g_strv_length (pathv2) == 2) - { - p2 = pathv2; - p2++; - artist = g_strstrip(g_strdup(*p2)); - } - else - { - gchar **pathv3 = g_strsplit (title, "-", 0); - gchar **p3; - if (g_strv_length (pathv3) == 2) - { - p3 = pathv3; - artist = g_strstrip(g_strdup(*p3)); - } - else - { - artist = ""; - } - g_free(pathv3); - } - g_free(pathv2); - g_free(title); - - return artist; -} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.12/src/ol_metadata.h new/osdlyrics-0.5.13/src/ol_metadata.h --- old/osdlyrics-0.5.12/src/ol_metadata.h 2022-09-01 22:01:57.000000000 +0200 +++ new/osdlyrics-0.5.13/src/ol_metadata.h 2023-01-27 14:58:42.000000000 +0100 @@ -141,6 +141,21 @@ guint64 ol_metadata_get_duration (const OlMetadata *metadata); /** + * @brief Sanitize the title and artist fields + * + * @param metadata A Metadata + * + * If the artist field is absent or looks invalid, check if the title field + * actually contains multiple tags, and if so update the artist and title + * fields in place. Supported formats (whitespace ignored): + * + * [<track>.]<artist>SEP<title> + * + * where SEP can be either "-" or "--". + */ +void ol_metadata_sanitize_title_artist (OlMetadata *metadata); + +/** * @brief Check whether two Metadatas are equal * Two Metadatas are equal if and only if all their fields are equal * @@ -192,9 +207,3 @@ */ GVariant *ol_metadata_to_variant (OlMetadata *metadata); #endif /* _OL_METADATA_H_ */ - -// get real title -const char *ol_metadata_get_search_title (const OlMetadata *metadata); - -// get real artist -const char *ol_metadata_get_search_artist (const OlMetadata *metadata); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/osdlyrics-0.5.12/src/ol_search_dialog.c new/osdlyrics-0.5.13/src/ol_search_dialog.c --- old/osdlyrics-0.5.12/src/ol_search_dialog.c 2022-09-01 22:01:57.000000000 +0200 +++ new/osdlyrics-0.5.13/src/ol_search_dialog.c 2023-01-27 14:58:42.000000000 +0100 @@ -281,24 +281,19 @@ if (global_metadata == NULL) global_metadata = ol_metadata_new (); - ol_metadata_copy (global_metadata, ol_app_get_current_music ()); -/* fill with real title and artist + OlMetadata *search_metadata = ol_metadata_dup (ol_app_get_current_music ()); + ol_metadata_copy (global_metadata, search_metadata); + ol_metadata_sanitize_title_artist (search_metadata); gtk_entry_set_text (widgets.title, - ol_metadata_get_title (global_metadata)); + ol_metadata_get_title (search_metadata)); gtk_entry_set_text (widgets.artist, - ol_metadata_get_artist (global_metadata)); -*/ -// - gtk_entry_set_text (widgets.title, - ol_metadata_get_search_title (global_metadata)); - gtk_entry_set_text (widgets.artist, - ol_metadata_get_search_artist (global_metadata)); -// - + ol_metadata_get_artist (search_metadata)); gtk_widget_set_sensitive (widgets.download, FALSE); gtk_label_set_text (widgets.msg, ""); + ol_metadata_free (search_metadata); + OlLyricSource *lyric_source = ol_app_get_lyric_source (); GList *info_list = ol_lyric_source_list_sources (lyric_source); ol_lyric_source_list_set_info_list (GTK_TREE_VIEW (widgets.engine),
