Skip to content
This repository has been archived by the owner on Aug 10, 2022. It is now read-only.

Commit

Permalink
add a station label for filename creation
Browse files Browse the repository at this point in the history
closes #48
  • Loading branch information
nega committed Aug 6, 2013
1 parent cf6ffaa commit a2fc699
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions contrib/config-example
Expand Up @@ -43,6 +43,7 @@
# %disc = The disc number
# %track = The track number
# %title = The song title
# %station = The station name
#audio_file_name = %artist/%album/%artist-%title
# If true spaces will not be replaced with '_' in the file names.
#use_spaces = false
Expand Down
15 changes: 12 additions & 3 deletions src/fly.c
Expand Up @@ -102,7 +102,7 @@ static int _BarFlyFileDelete(BarFly_t const* fly,
* freed when done.
*/
static char* _BarFlyFileGetPath(char const* artist, char const* album,
char const* title, short unsigned track, short unsigned disc,
char const* title, short unsigned track, short unsigned disc, char const* station,
PianoAudioFormat_t audio_format, BarSettings_t const* settings);

/**
Expand Down Expand Up @@ -341,14 +341,15 @@ static int _BarFlyFileDelete(BarFly_t const* fly,
}

static char* _BarFlyFileGetPath(char const* artist, char const* album,
char const* title, short unsigned track, short unsigned disc,
char const* title, short unsigned track, short unsigned disc, char const* station,
PianoAudioFormat_t audio_format, BarSettings_t const* settings)
{
char* path = NULL;
size_t path_length;
char path_artist[BAR_FLY_NAME_LENGTH];
char path_album[BAR_FLY_NAME_LENGTH];
char path_title[BAR_FLY_NAME_LENGTH];
char path_station[BAR_FLY_NAME_LENGTH];
char const* extension;
char const* file_pattern_ptr;
size_t count;
Expand All @@ -366,6 +367,7 @@ static char* _BarFlyFileGetPath(char const* artist, char const* album,
_BarFlyNameTranslate(path_artist, artist, BAR_FLY_NAME_LENGTH, settings);
_BarFlyNameTranslate(path_album, album, BAR_FLY_NAME_LENGTH, settings);
_BarFlyNameTranslate(path_title, title, BAR_FLY_NAME_LENGTH, settings);
_BarFlyNameTranslate(path_station, station, BAR_FLY_NAME_LENGTH, settings);

/*
* Get the extension.
Expand Down Expand Up @@ -422,6 +424,9 @@ static char* _BarFlyFileGetPath(char const* artist, char const* album,
} else if (strncmp("%disc", file_pattern_ptr, 5) == 0) {
path_length += snprintf(NULL, 0, "%hu", disc);
file_pattern_ptr += 5;
} else if (strncmp("%station", file_pattern_ptr, 8) == 0) {
path_length += strlen(path_station);
file_pattern_ptr += 8;
} else {
file_pattern_ptr += 1;
}
Expand Down Expand Up @@ -478,6 +483,10 @@ static char* _BarFlyFileGetPath(char const* artist, char const* album,
sprintf(path_ptr, "%hu", disc);
file_pattern_ptr += 5;
path_ptr += snprintf(NULL, 0, "%hu", disc);
} else if (strncmp("%station", file_pattern_ptr, 8) == 0) {
strcpy(path_ptr, path_station);
file_pattern_ptr += 8;
path_ptr += strlen(path_station);
} else {
file_pattern_ptr += 1;
}
Expand Down Expand Up @@ -1331,7 +1340,7 @@ int BarFlyOpen(BarFly_t* fly, PianoSong_t const* song,
* Get the path to the file.
*/
output_fly.audio_file_path = _BarFlyFileGetPath(song->artist, song->album,
song->title, output_fly.track, output_fly.disc,
song->title, output_fly.track, output_fly.disc, output_fly.stationName,
song->audioFormat, settings);
if (output_fly.audio_file_path == NULL) {
goto error;
Expand Down

0 comments on commit a2fc699

Please sign in to comment.