
Script to copy Favorite songs from Banshee
Suffering for a long time and trying to figure out / find how to copy your favorite music from Banshee player to usb media - I spat on everything and quickly wrote a simple php script to copy music with a rating above 0 to a specific folder.
Requires:
Launch:
where / media / disk / audio / - where we will copy (slash at the beginning and end are required)
PS: I hope someone will rewrite this with GUI =)
PPS: later I will make a version so that files with the original name are not copied to the folder file, and% album% -% artist% -% name% - as it turned out in the collection a lot of TrackXX.mp3
// определяем пользователя
$user_name=str_replace(array("\n","\r"),"",shell_exec ("whoami"));
// путь к SQLite3 базе Banshee
$db="/home/".$user_name."/.config/banshee-1/banshee.db";
// папка фонотеки
$file_start="/home/".$user_name."/Музыка/";
// узнаем куда копировать
$copy_to=$_SERVER['argv'][1];
print "| Banshee-1 | Copy favorite music to folder | SovGVD@gmail.com (2009) | v0.1 |\n";
print "------------------------------------------------------------------------------\n";
if ($copy_to=='') die ("ERROR: false destination\nuse: php script_name.php path_to_folder\n");
$db = new SQLite3($db);
$result = $db->query('select Uri from CoreTracks where rating>0');
$arr=array();
while($tmp=$result->fetchArray()) {
if (!stristr($tmp['Uri'],'file://')) {
$arr[]=$tmp['Uri'];
}
}
$db->close();
reset ($arr);
while (list($key,$val)=each($arr)) {
$tmp_file=$file_start.$val;
print $val." ";
if (@copy($tmp_file, $copy_to.basename($val))) {
print " [ok]";
} else {
print " [false]";
}
print "\n";
}
?>
php и php-SQLite3
php script_name.php /media/disk/audio/