📜 ⬆️ ⬇️

Copy script Favorite songs from Banshee

Long suffering and trying to think of / find how to copy your favorite music from the Banshee player to usb media - spat on everything and quickly wrote a simple php script to copy music with a rating higher than 0 to a specific folder.

<?
//
$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";
}
?>


Requires:
php php-SQLite3
Run:
php script_name.php /media/disk/audio/
where / media / disk / audio / - where we will copy (slash at the beginning and end are required)

PS: I hope someone will rewrite it with the GUI =)
PPS: later I will make a version so that files with the original file name are not copied to the folder, and% album% -% artist% -% name% - as it turned out in the collection a lot TrackXX.mp3

')

Source: https://habr.com/ru/post/60385/


All Articles