From f1986f54d552a6ce8466b6e5386d26f6df220fe5 Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Tue, 6 Sep 2016 21:11:17 +0100 Subject: [PATCH] Wrote a small utility for parsing KShoot player score data into a song favourites list. --- .gitignore | 1 + README.md | 36 ++++++++++++++++++++++++++++++++++++ ksmplayedsongs.nim | 19 +++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 ksmplayedsongs.nim diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..739a54a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +nimcache diff --git a/README.md b/README.md new file mode 100644 index 0000000..8e203c1 --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# KSM Songs Played +## Synopsis + +A simple utility that looks at the player's score folder and generates a K-Shoot +favourites folder containing all songs the player has ever played. + +## Building + + nim c ksmplayedsongs.nim + +## Download + +[Windows x64](https://neviyn.co.uk/release/ksmplayedsongs.exe) + +## License + +The MIT License (MIT) + +Copyright (c) 2016 Nathan Cannon + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/ksmplayedsongs.nim b/ksmplayedsongs.nim new file mode 100644 index 0000000..d5c6ec4 --- /dev/null +++ b/ksmplayedsongs.nim @@ -0,0 +1,19 @@ +import os + +echo("Input KSM directory") +let mainDir: string = readLine(stdin) +let userDir: string = mainDir & DirSep & "score" & DirSep & "PLAYER" +let outFileName: string = mainDir & DirSep & "songs" & DirSep & "Played.fav" +var f: File +if open(f, outFileName, fmWrite): + try: + for kind, path in walkDir(userDir, true): + if kind == pcDir: + let fullPath = userDir & DirSep & path + for k2, p2 in walkDir(fullPath, true): + if k2 == pcDir: + f.writeLine(path & DirSep & p2) + finally: + close(f) +else: + quit("Error writing to file: " & outFileName)