diff --git a/Server/databaseGenerator.py b/Server/databaseGenerator.py index 70ffa5f..e83cbc3 100644 --- a/Server/databaseGenerator.py +++ b/Server/databaseGenerator.py @@ -69,12 +69,19 @@ for i in songFiles: title = song['title'][0] artist = song['artist'][0] except: - try: + if "_" in i: # if metadata is missing, try to use file name following title_artist.mp3 song = i.split("_") title = song[0] artist = song[1].split(".")[0] - except: + elif "-" in i: + # if there's no underscore, try artist - title.mp3 + song = i.split("-") + title = song[1].split(".")[0] + artist = song[0] + title = title.strip() + artist = artist.strip() + else: #if the file is not formatted with an underscore, the title is the file name title = i artist = None diff --git a/readme.md b/readme.md index 1315787..e63bcbd 100644 --- a/readme.md +++ b/readme.md @@ -39,7 +39,7 @@ These are specific details on each section of the app, and how to use them - `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* + - *If the title and artist are not in the mp3 metadata, it looks for a format of* `TITLE_ARTIST.mp3` *then of* `ARTIST - TITLE.mp3` *and otherwise defaults to the file name as the title, and no artist* - Art is retrieved from LastFM - Running with `--mode (update/new)` either updates the current database and adds new songs/removes deleted songs, or recreates the entire database (update is default, and is faster in art mode) - Running with `--art (True/False)` retrieves art from LastFM or doesn't (True is default)