diff --git a/Server/databaseGenerator.py b/Server/databaseGenerator.py index 9428460..78d65c0 100644 --- a/Server/databaseGenerator.py +++ b/Server/databaseGenerator.py @@ -4,15 +4,19 @@ from mutagen.mp3 import MP3 import requests, ast, time, math, argparse, json loading = ["-","\\","|","/"] -songFiles = os.listdir(r'./sound') + parser=argparse.ArgumentParser(description="Options for the generation of the song database") parser.add_argument('-k','--apikey', help='String: LastFM api key', default="") parser.add_argument('-m', '--mode', help='new/update: Remake database or update current', default= "update") parser.add_argument('-a', '--art', help="True/False: Add art to the database using LastFm (takes minimum 0.25s per song)", default="True") +parser.add_argument('-d','--directory',help="Directory of the song files (USING FORWARD SLASHES)", default="./sound") args = parser.parse_args() apikeylastfm = args.apikey -# if you want to set the api key permenantly for your setup just uncomment the next line +soundLocation = args.directory +# if you want to set the api key/sound directory permenantly for your setup just uncomment the next line # apikeylastfm = "KeyHere" +# soundLocation = "directoryHere" +songFiles = os.listdir(soundLocation) if args.mode == "update": try: with open('songDatabase.json', 'r') as handle: @@ -42,7 +46,7 @@ if args.art.lower() == "true": for i in songFiles: try: - song = EasyID3("sound/"+i) + song = EasyID3(soundLocation+"/"+i) title = song['title'][0] artist = song['artist'][0] except: @@ -66,7 +70,7 @@ for i in songFiles: else: image=None try: - length = math.ceil(MP3("sound/"+i).info.length) + length = math.ceil(MP3(soundLocation+"/"+i).info.length) except: length = 0 if len(songFiles) != 1: diff --git a/readme.md b/readme.md index f2361d1..b7f53d0 100644 --- a/readme.md +++ b/readme.md @@ -36,7 +36,7 @@ Read on for specific information on each piece of the app. ## Details These are specific details on each section of the app, and how to use them ### Server: -- `sound/` contains all mp3 files +- `./sound` contains all mp3 files by default - `databaseGenerator.py` scans through mp3 files and gets information about them - `Filename, Title, Artist, Art, Length` are all saved - *If the title and artist are not in the mp3 metadata, it looks for a format of* `TITLE_ARTIST.mp3` *and otherwise defaults to the file name as the title, and no artist* @@ -46,6 +46,10 @@ These are specific details on each section of the app, and how to use them - *Can only generate one song / 0.25 seconds, to avoid pinging the LastFM server too much* - Running with `--apikey (KEYhere)` sets the LastFM key for that run - If this is set to an empty string (Default) the app runs in non-art mode + - Running with `--directory (directoryOfmp3s)` allows for sound files to be in a different place + - Default `"./sound"` + - _This setting might be kinda iffy on Linux. You're on Linux just go and edit it if you have issues_ + - __Make certain you only use forward slashes in your directory, even on Windows__ - `songDatabase.json` stores all the information about each song in this format: ``` [