Skip to content

Commit

Permalink
Feat: add innitial support for last_modified tag #200
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorporation committed Jan 27, 2020
1 parent b2bde7a commit 67c58d7
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions htdocs/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,9 @@ function parseMPDSettings() {
if (settings.colsPlayback[i] === 'Duration') {
pbtl += (lastSongObj[settings.colsPlayback[i]] ? beautifySongDuration(lastSongObj[settings.colsPlayback[i]]) : '');
}
else if (settings.colsPlayback[i] === 'LastModified') {
pbtl += (lastSongObj[settings.colsPlayback[i]] ? localeDate(lastSongObj[settings.colsPlayback[i]]) : '');
}
else if (settings.colsPlayback[i] === 'Fileformat') {
pbtl += (lastState ? fileformat(lastState.audioFormat) : '');
}
Expand Down Expand Up @@ -788,6 +791,7 @@ function filterCols(x) {
if (x === 'colsPlayback') {
tags.push('Filetype');
tags.push('Fileformat');
tags.push('LastModified');
}
let cols = [];
for (let i = 0; i < settings[x].length; i++) {
Expand Down
1 change: 1 addition & 0 deletions htdocs/js/song.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function parseSongDetails(obj) {
e(basename(obj.result.uri)) + '</span></td></tr>';
}
songDetails += '<tr><th>' + t('Filetype') + '</th><td>' + filetype(obj.result.uri) + '</td></tr>';
songDetails += '<tr><th>' + t('LastModified') + '</th><td>' + localeDate(obj.result.LastModified) + '</td></tr>';
if (settings.featFingerprint === true) {
songDetails += '<tr><th>' + t('Fingerprint') + '</th><td class="breakAll" id="fingerprint"><a class="text-success" data-uri="' +
encodeURI(obj.result.uri) + '" id="calcFingerprint" href="#">' + t('Calculate') + '</a></td></tr>';
Expand Down
5 changes: 4 additions & 1 deletion htdocs/js/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,12 @@ function songChange(obj) {
if (value === undefined) {
value = '';
}
if (settings.colsPlayback[i] == 'Duration') {
if (settings.colsPlayback[i] === 'Duration') {
value = beautifySongDuration(value);
}
else if (settings.colsPlayback[i] === 'LastModified') {
value = localeDate(value);
}
c.getElementsByTagName('p')[0].innerText = value;
c.setAttribute('data-name', encodeURI(value));
}
Expand Down
1 change: 1 addition & 0 deletions htdocs/js/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ function setColTags(table) {
if (table === 'Playback') {
tags.push('Filetype');
tags.push('Fileformat');
tags.push('LastModified');
}

tags.sort();
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/de-DE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1139,3 +1139,6 @@ So

System command
Systembefehl

LastModified
Zuletzt geändert
6 changes: 6 additions & 0 deletions src/i18n/en-US.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ Min

Seconds
Sec

LastModified
Last modified

AlbumArtist
Albumartist
1 change: 1 addition & 0 deletions src/mpd_client/mpd_client_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ sds put_song_tags(sds buffer, t_mpd_state *mpd_state, const t_tags *tagcols, con
buffer = tojson_char(buffer, "Title", tag_value == NULL ? "-" : tag_value, true);
}
buffer = tojson_long(buffer, "Duration", mpd_song_get_duration(song), true);
buffer = tojson_long(buffer, "LastModified", mpd_song_get_last_modified(song), true);
buffer = tojson_char(buffer, "uri", mpd_song_get_uri(song), false);
return buffer;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mympd_api/mympd_api_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void free_mympd_state(t_mympd_state *mympd_state) {
FREE_PTR(mympd_state);
}

static const char *mympd_cols[]={"Pos", "Duration", "Type", "LastPlayed", "Filename", "Filetype", "Fileformat", 0};
static const char *mympd_cols[]={"Pos", "Duration", "Type", "LastPlayed", "Filename", "Filetype", "Fileformat", "LastModified", 0};

static bool is_mympd_col(sds token) {
const char** ptr = mympd_cols;
Expand Down

0 comments on commit 67c58d7

Please sign in to comment.