Re: [mpd-devel] find track "1" not working as expected

2015-10-21 Thread Max Kellermann
On 2015/10/21 08:58, Andreas Mair  wrote:
> Hi Max,
> 
> I've now created a pull request: Filter out this extra data and
> leading zeroes in "track" and "disc" tags.

Merged with a few minor corrections.

By the way, please don't send GitHub pull requests.  Those are very
cumbersome for me to use.  Just post the git:// URL and the branch
name.
___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


Re: [mpd-devel] find track "1" not working as expected

2015-10-20 Thread Andreas Mair
Hi Max,

I've now created a pull request: Filter out this extra data and
leading zeroes in "track" and "disc" tags.

Best regards,
Andreas


2015-08-13 12:42 GMT+02:00 Max Kellermann :
> On 2015/08/12 13:16, Andreas Mair  wrote:
>> Hi Max,
>>
>> OK, I see. I've changed the patch to cover your suggestion.
>
> Commit message is missing.
___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


Re: [mpd-devel] find track "1" not working as expected

2015-08-14 Thread Andreas Mair
Hi Max,

2015-08-13 12:42 GMT+02:00 Max Kellermann :
> Commit message is missing.

"Store track and disc numbers without leading zeros and trailing extra
information (like "/") in database."

I don't know if that's exactly what you want as I'm no experienced GIT user.

Best regards,
Andreas
___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


Re: [mpd-devel] find track "1" not working as expected

2015-08-13 Thread Max Kellermann
On 2015/08/12 13:16, Andreas Mair  wrote:
> Hi Max,
> 
> OK, I see. I've changed the patch to cover your suggestion.

Commit message is missing.
___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


Re: [mpd-devel] find track "1" not working as expected

2015-08-13 Thread Andreas Mair
Hi Max,

OK, I see. I've changed the patch to cover your suggestion.

Best regards,
Andreas


2015-08-12 12:15 GMT+02:00 Max Kellermann :
> On 2015/08/12 09:20, Andreas Mair  wrote:
>> Hi Max,
>>
>> I've built a small patch that will "clean" the track and disc numbers.
>> Maybe you want to apply that attached patch.
>
> I'm not happy with that.  If the "TRACK" tag is non-numeric garbage,
> MPD will assume track number "0", which is not correct.  It would be
> better not to expose a "TRACK" tag at all than one with an incorrect
> value.
diff --git a/src/tag/TagHandler.cxx b/src/tag/TagHandler.cxx
index 9bbaae3..4a8c5eb 100644
--- a/src/tag/TagHandler.cxx
+++ b/src/tag/TagHandler.cxx
@@ -17,6 +17,9 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include 
+#include 
+
 #include "config.h"
 #include "TagHandler.hxx"
 #include "TagBuilder.hxx"
@@ -35,7 +38,18 @@ add_tag_tag(TagType type, const char *value, void *ctx)
 {
 	TagBuilder &tag = *(TagBuilder *)ctx;
 
-	tag.AddItem(type, value);
+	if (type == TAG_TRACK || type == TAG_DISC) {
+		char *end;
+		int n = strtol(value, &end, 10);
+		if (value != end) {
+			char s[21];
+			if (snprintf(s, 21, "%d", n) >= 0) {
+tag.AddItem(type, s);
+			}
+		}
+	} else  {
+		tag.AddItem(type, value);
+	}
 }
 
 const struct tag_handler add_tag_handler = {
___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


Re: [mpd-devel] find track "1" not working as expected

2015-08-13 Thread Andreas Mair
Hi Stefan,

I tried to use the "window" argument as described at
http://www.musicpd.org/doc/protocol/database.html#command_find but it
seems that it has not arrived in v0.19.10, right?
Maybe the website should make clear in which release the "window"
argument can be used.

Best regards,
Andreas


2015-07-05 18:02 GMT+02:00 Stefan Monnier :
>> That's a valid question, but I don't know.  I'm no MPDroid developer.
>> Is there an alternative to get a single track of an album, no matter
>> what track number?
>
> You can get all the tracks for a given artist, all the tracks for
> a given album name, take the intersection, and then pick one.
>
> Doing any better than that is probably rather difficult since MPD has no
> notion of "album" (as opposed to album *name*), largely because this
> notion is missing from the id3 tags.
>
>
> Stefan
___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


Re: [mpd-devel] find track "1" not working as expected

2015-08-13 Thread Andreas Mair
Hi Max,

I've built a small patch that will "clean" the track and disc numbers.
Maybe you want to apply that attached patch.

Best regards,
Andreas


2015-07-01 8:07 GMT+02:00 Max Kellermann :
> On 2015/06/28 08:40, Andreas Mair  wrote:
>> I've taken a look at the MPD sources and I think the problem is, that
>> MPD tries an exact *string* match. If I use "... find 01/10" it works,
>> but I think that's not ideal to work like this because one has to know
>> (1)  how many songs an album has and (2) if the number of total tracks
>> is stored and (3) if leading zeros are used.
>
> Actually, MPD does not expect the "track" tag to have something other
> than the track number.  The problem is that some tag specifications
> (such as ID3) allow the total number of tracks appended to the "track"
> tag.
>
> What MPD should do is filter out this extra data.  And filter out
> leading zeroes.
diff --git a/src/tag/TagHandler.cxx b/src/tag/TagHandler.cxx
index 9bbaae3..dfebfa9 100644
--- a/src/tag/TagHandler.cxx
+++ b/src/tag/TagHandler.cxx
@@ -17,6 +17,9 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include 
+#include 
+
 #include "config.h"
 #include "TagHandler.hxx"
 #include "TagBuilder.hxx"
@@ -35,7 +38,13 @@ add_tag_tag(TagType type, const char *value, void *ctx)
 {
 	TagBuilder &tag = *(TagBuilder *)ctx;
 
-	tag.AddItem(type, value);
+	if (type == TAG_TRACK || type == TAG_DISC) {
+		char s[6];
+		snprintf(s, 6, "%d", atoi(value));
+		tag.AddItem(type, s);
+	} else  {
+		tag.AddItem(type, value);
+	}
 }
 
 const struct tag_handler add_tag_handler = {
___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


Re: [mpd-devel] find track "1" not working as expected

2015-08-12 Thread Max Kellermann
On 2015/08/12 09:20, Andreas Mair  wrote:
> Hi Max,
> 
> I've built a small patch that will "clean" the track and disc numbers.
> Maybe you want to apply that attached patch.

I'm not happy with that.  If the "TRACK" tag is non-numeric garbage,
MPD will assume track number "0", which is not correct.  It would be
better not to expose a "TRACK" tag at all than one with an incorrect
value.
___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


Re: [mpd-devel] find track "1" not working as expected

2015-07-08 Thread Andreas Mair
Hi Stefan,

2015-07-01 19:26 GMT+02:00 Stefan Monnier :
>> client: [12] process command "find "albumartist" "Aerosmith" "album"
>> "Pump" "track" "1""
>
> Not directly relevant: why does MPDroid do that?
> I mean, what if the album doesn't have a track 1 (not so unusual
> nowadays that people buy individual songs rather than CDs).

That's a valid question, but I don't know. I'm no MPDroid developer.
Is there an alternative to get a single track of an album, no matter
what track number?

Best regards,
Andreas
___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


Re: [mpd-devel] find track "1" not working as expected

2015-07-05 Thread Bart Nagel
On 5 Jul 2015 09:02, "Stefan Monnier"  wrote:
>
> > That's a valid question, but I don't know.  I'm no MPDroid developer.
> > Is there an alternative to get a single track of an album, no matter
> > what track number?
>
> You can get all the tracks for a given artist, all the tracks for
> a given album name, take the intersection, and then pick one.
>
> Doing any better than that is probably rather difficult since MPD has no
> notion of "album" (as opposed to album *name*), largely because this
> notion is missing from the id3 tags.

The notion is present if you tag your files with Musicbrainz info. Not sure
if that helps with your specific problem.
___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


Re: [mpd-devel] find track "1" not working as expected

2015-07-05 Thread Stefan Monnier
> That's a valid question, but I don't know.  I'm no MPDroid developer.
> Is there an alternative to get a single track of an album, no matter
> what track number?

You can get all the tracks for a given artist, all the tracks for
a given album name, take the intersection, and then pick one.

Doing any better than that is probably rather difficult since MPD has no
notion of "album" (as opposed to album *name*), largely because this
notion is missing from the id3 tags.


Stefan
___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


Re: [mpd-devel] find track "1" not working as expected

2015-07-01 Thread Stefan Monnier
> client: [12] process command "find "albumartist" "Aerosmith" "album"
> "Pump" "track" "1""

Not directly relevant: why does MPDroid do that?
I mean, what if the album doesn't have a track 1 (not so unusual
nowadays that people buy individual songs rather than CDs).


Stefan

___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


Re: [mpd-devel] find track "1" not working as expected

2015-07-01 Thread Andreas Mair
Hi Max,

2015-07-01 8:07 GMT+02:00 Max Kellermann :
> On 2015/06/28 08:40, Andreas Mair  wrote:
>> I've taken a look at the MPD sources and I think the problem is, that
>> MPD tries an exact *string* match. If I use "... find 01/10" it works,
>> but I think that's not ideal to work like this because one has to know
>> (1)  how many songs an album has and (2) if the number of total tracks
>> is stored and (3) if leading zeros are used.
>
> Actually, MPD does not expect the "track" tag to have something other
> than the track number.  The problem is that some tag specifications
> (such as ID3) allow the total number of tracks appended to the "track"
> tag.
>
> What MPD should do is filter out this extra data.  And filter out
> leading zeroes.

OK, I see. I didn't know that ID3 stores "01/10" in the track tag
instead of having one for "track number" and one for "total tracks".

So I really think that MPD should filter out that extra data and
leading zeros, like you suggested. It should not be limited to the
track tag, because it's the same for disc number.
Any chance to change that in MPD?

Best regards,
Andreas
___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


Re: [mpd-devel] find track "1" not working as expected

2015-06-30 Thread Max Kellermann
On 2015/06/28 08:40, Andreas Mair  wrote:
> I've taken a look at the MPD sources and I think the problem is, that
> MPD tries an exact *string* match. If I use "... find 01/10" it works,
> but I think that's not ideal to work like this because one has to know
> (1)  how many songs an album has and (2) if the number of total tracks
> is stored and (3) if leading zeros are used.

Actually, MPD does not expect the "track" tag to have something other
than the track number.  The problem is that some tag specifications
(such as ID3) allow the total number of tracks appended to the "track"
tag.

What MPD should do is filter out this extra data.  And filter out
leading zeroes.
___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel


[mpd-devel] find track "1" not working as expected

2015-06-30 Thread Andreas Mair
Hi,

I'm trying to find out why MPDroid is so slow when it lists an
artist's albums. So I enabled debug logging in MPD and noticed that
MPDroid issues three MPD queries for each album it has to show.

For example:
client: [12] process command "find "albumartist" "Aerosmith" "album"
"Pump" "track" "1""
client: [12] command returned 0
client: [12] process command "find "albumartist" "Aerosmith" "album"
"Pump" "track" "01""
client: [12] command returned 0
client: [12] process command "search "albumartist" "Aerosmith" "album"
"Pump" "track" "1""
client: [12] command returned 0

I would expect, that the first command (track "1") should work, but
there's no result. That's also true for the second command (track
"01"). The third command returns every song of that album (because it
has 10 songs).
I've taken a look at the MPD sources and I think the problem is, that
MPD tries an exact *string* match. If I use "... find 01/10" it works,
but I think that's not ideal to work like this because one has to know
(1)  how many songs an album has and (2) if the number of total tracks
is stored and (3) if leading zeros are used.

I'd suggest that MPD uses *numeric* matches for numeric fields like
track or disc number. Or do I miss something?

What do you think?
Any chance to change that?

Best regards,
Andreas
___
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel