gmusicbrowser Forum

Main board => Questions => Topic started by: aboettger on April 26, 2014, 21:13:01

Title: problems with special characters in shortcut parameters
Post by: aboettger on April 26, 2014, 21:13:01
I have a shortcut defined that calls a shell script and passes the parameter %f. But there are problems with special characters.

Here is the call for the shortcut:
Code: [Select]
gmb_call_picard "%f"
Here is the code for gmb_call_picard
Code: [Select]
#!/bin/bash -
zenity --info --text "$1"
picard "$(dirname "$1")"

And the zenity ouput:
Code: [Select]
/home/aboettger/Musik/-=C=-/Phil Collins/Serious Hitsâ?¦ Live! (2236b7ec-6e3e-4467-8aaf-377ff4699138)/1-02 - Phil Collins - Against All Odds (Take a Look at Me Now).flac
And this is the correct file name:
Code: [Select]
/home/aboettger/Musik/-=C=-/Phil Collins/Serious Hits… Live! (2236b7ec-6e3e-4467-8aaf-377ff4699138)/1-02 - Phil Collins - Against All Odds (Take a Look at Me Now).flac
Title: Re: problems with special characters in shortcut parameters
Post by: djachill on April 27, 2014, 23:58:04
@aboettger
I can't figure out what your post is. Is it a question? Is it a solution? I really can't see it ... looked at your post because i want to prelisten to a track in another audio player by calling eg. deadbeef and pass the current track via the export feature. Can you pls. shed some light?
Title: Re: problems with special characters in shortcut parameters
Post by: Quentin Sculo on April 28, 2014, 01:33:04
Thanks for reporting this, the file names were auto-upgraded to utf8 by perl because the command string (for example 'gmb_call_picard "%f"') was utf8.
I've just committed a fix, let me know if there are still problems.
Title: Re: problems with special characters in shortcut parameters
Post by: aboettger on April 28, 2014, 15:40:19
Thank you, it works since the release 1.1.12+1209.  ;D
Title: Re: problems with special characters in shortcut parameters
Post by: aboettger on May 02, 2014, 17:10:11
The problem exists even in the plugin "Export".
Title: Re: problems with special characters in shortcut parameters
Post by: aboettger on May 02, 2014, 18:15:29
quick and dirty patch

plugins/export.pm
Code: [Select]
sub RunCommand
{ my $IDs=$_[0]{IDs} || $_[0]{filter}->filter;
my @cmd=split / /,$::Options{OPT.'tocmd_cmd'};
return unless @cmd;
for my $arg (@cmd) { ::_utf8_off($arg) if $arg=~m/^[\x00-\x7f]*$/; } # remove utf8 flag from arguments that don't need it to prevent autoupgrade to utf8  of potentially non-utf8 filenames when replacing %f with a filename
if (grep $_ eq '$files', @cmd)
{ my @files=map ::ReplaceFields($_,'%f'), @$IDs;
@cmd=map { $_ ne '$files' ?  $_ :  @files } @cmd;
::forksystem(@cmd);
}
else
{ my @todo;
for my $ID (@$IDs)
{ push @todo, [ map ::ReplaceFields($ID,$_), @cmd ];
}
my $ChildPID=fork;
if (!defined $ChildPID) { warn ::ErrorMessage("export plugin : fork failed : $!"); }
elsif ($ChildPID==0) #child
{ system @$_ for @todo;
POSIX::_exit(0);
}
}
}
Title: Re: problems with special characters in shortcut parameters
Post by: Quentin Sculo on May 05, 2014, 04:10:35
I've committed a patch that fixes the non-utf8 problem in a better way than before, and move all the system command calling in a single function with the features needed by the export plugin.
Let me know if there is any bug with the new version.
Title: Re: problems with special characters in shortcut parameters
Post by: aboettger on May 05, 2014, 16:18:20
I can't build the latest version:

Code: [Select]
msgmerge -s -U -N po/cs.po po/gmusicbrowser.pot
po/gmusicbrowser.pot:2560:56: invalid control sequence
msgmerge: found 1 fatal error
make: *** [po/cs.po] Error 1
Title: Re: problems with special characters in shortcut parameters
Post by: Quentin Sculo on May 05, 2014, 22:00:03
thanks, it should work now