From ba57c1bb7010856a8ce5f489a2738bf59b7979dc Mon Sep 17 00:00:00 2001 From: Givou Date: Thu, 25 Mar 2021 21:43:23 +0100 Subject: [PATCH] Respority created --- README.md | 18 ++++++++++++++++++ umwandler.php | 24 ++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 README.md create mode 100644 umwandler.php diff --git a/README.md b/README.md new file mode 100644 index 0000000..74c3747 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +Hey folks, +this is a very simple PHP Code that renames your Sinusbot music files back to their old name. +It only removes special chars, because that made some small errors....and it was not worth to me to fix the issues. +The Songs are still readable f.E "Udo Jrgens - Griechischer Wein HBz Hard-Bounce Remix" + +How to use. +Close the respority with "git clone http://git.thiemoo.at/Givou/Sinusbot_song_renamer.git" +Go into your Sinusbot foot filesystem. +Copy your Database from /rootfs/data/db/[UUID from Instance].sqlite +Download the file and put it into the renamers main directory. +Rename it to db.db + +Now download your songs from /rootfs/data/store/[UUID from Instance]/ and put them into the storage directory from the renamer. + +Execute the PHP Code with "php umwandler.php" or call it in your browser +The Musik files should code up in the /output directory, if you made all steps correctly. + +#Tested with Sinusbot 1.0.0-beta.10-202ee4d! diff --git a/umwandler.php b/umwandler.php new file mode 100644 index 0000000..8b7d9ad --- /dev/null +++ b/umwandler.php @@ -0,0 +1,24 @@ +query("SELECT trackinfo FROM storage_files"); + +while($datalist = $result->fetchArray(SQLITE3_ASSOC)) { + $content = json_decode($datalist['trackinfo'], true); + + $path = $content['path']; + if(file_exists("storage/".$path)) { + $filelocation = "storage/".$path; + $name = $content['title']; + + nameFile($filelocation, $name); + } + echo "

All files in /storage renamed and fixed up. \n

Output is in /output/songnames/"; + $db->close(); +} + +function nameFile($file, $name) { + $fname = preg_replace('/[^A-Za-z0-9- \-]/', '', $name); + rename($file, "output/".utf8_decode($fname).".mp3"); +} + ?>