Mon 19 Oct 2009 04:27:31 PM UTC, comment #2:
Taking another look at your patch it seems quite clear that your mp3 tags are very broken..
You test for "(ord(substr($s,0,1))==3)" so i guess your mp3files are that way. Very strange.
> if (substr($s,$l/2,1)!="/" ||
substr($s,$l/2-1,1)!=" " ||
substr($s,$l/2+1,1)!="/")
This will always match except for when you you happen to
have " //" as separator exactly in the middle of your string.
It doesn't take into account that there could be more than one unicode character in the first part of the string and that the first and second part of the string therefore could be of rather different length.
and so on ..
I suggest you get your mp3tags fixed instead of patching gnupod. In the long run you will be happier.
|
Thu 01 Oct 2009 07:22:54 AM UTC, original submission:
Unicode:
Bad naming of 'unicode' albums/artists/title, gets say a dual album name like ">Øvli / Oevli"
and causes breakup of album into many parts.
Fix: fix strings by calling FixUnicode, see diff below
diff /usr/local/bin/gnupod_addsong.pl gnupod_addsong3.pl
96a97,127
> sub trim {
> my $string = shift;
> $string =~ s/^\s+//;
> $string =~ s/\s+$//;
> return $string;
> }
>
> sub FixUnicode {
> my $s = shift;
> my $l=length($s);
> # print "\ntrying to fix <$s>, of lenght $l <".ord(substr($s,0,1)).">";
>
> if ($l<=1) {
> print "\nWARNING: expected string of lenght len >= 1 (s=<$s>)";
> }
> else {
> if (ord(substr($s,0,1))==3){
> #if ($l%2!=0) {
> # print "\nWARNING: expected string of lenght mod 2==0 (s=<$s>)";
> #}
> if (substr($s,$l/2,1)!="/" || substr($s,$l/2-1,1)!=" " || substr($s,$l/2+1,1)!="/") {
> print "\nWARNING: expected ' / ' in mid-string (s=<$s>)";
> }
>
> # print "\nreturning substring of size ".$l/2-2;
> #return substr($s,0,$l/2-1);
> return trim(substr($s,$l/2+2));
> }
> }
> return $s;
> }
>
203a238,241
> $fh->{artist}=FixUnicode($fh->{artist});
> $fh->{album}=FixUnicode($fh->{album});
> $fh->{title}=FixUnicode($fh->{title});
>
|