I'm working on a python program which organizes a music library. The program will basically help me detect misspelled file or directory names, wrong FLAC tags or unknown/superfluous files. It will also make sure that the FLAC files are named correctly according to their FLAC tags etc.
The structure I though of looks as follows (/
being the root of the music library):
/
[category]
[artist]
[year] - [release]
[track number] - [title].flac
[...]
[artist] - [release].jpg
[artist] - [release].cue
[artist] - [release].log
Various Artists
[artist_0 [, artist_1 [, ...]]] - [year] - [release]
[track number] - [title].flac
[...]
[artist_0 [, artist_1 [, ...]]] - [release].jpg
[artist_0 [, artist_1 [, ...]]] - [release].cue
[artist_0 [, artist_1 [, ...]]] - [release].log
[...]
[...]
I started writing some code but pretty soon I noticed that this is actually not a too easy problem to solve. I wrote 4 functions, category
, artist
, release
and file
, which are called accordingly while iterating through all the directories. Basically like that (pseudo code):
func category:
do some checks
for each file in this directory:
artist(file)
func artist:
do some checks
for each file in this directory:
release(file)
func release:
do some checks
for each file in this directory:
file(file)
func file:
do some checks (FLAC tags etc)
for each file in the root directory:
category(file)
Now I'm wondering, are there any known algorithms or techniques which could be used to solve this problem in an elegant way?