by Andre_H » Sun Jan 16, 2022 11:55 am
Hi sonos,
thats what i do (as part of a larger script):
Code: Select all
actions.saveStatistics = {
title: _('Speichere Statistik-Daten in CustomFields ...'),
hotkeyAble: false,
icon: 'saveStatistics',
disabled: uitools.notMediaListSelected,
visible: window.uitools.getCanEdit,
execute: async function () {
var list = await uitools.getSelectedTracklist().whenLoaded();
if (list.count === 0) {
return;
}
list.forEach(function(track) {
var modified = false;
let varrating = track.rating/20;
////////////////////////////////////////////////////////////////////////////////////
// PLAYCOUNTER & LASTPLAYED: "PlayCounter"=1 & "LastPlayed"=Now(), wenn "PlayCounter"=0 und "Rating">1 ...
if(track.playCounter === 0 && varrating > 1) {
track.playCounter = 1;
track.lastTimePlayed_UTC = app.utils.timestamp2DateTime(new Date().toISOString());
// track.commitAsync();
modified = true;
};
if (modified)
track.commitAsync();
});
}
}
window._menuItems.editTags.action.submenu.push({
action: actions.saveStatistics,
order: 10,
grouporder: 10
});
... so, no direct SQL statements. the script runs on every change of the track as well as on right-click.
if you want the whole script (all the files needed to run it), just PM me.
Hi sonos,
thats what i do (as part of a larger script):
[code]actions.saveStatistics = {
title: _('Speichere Statistik-Daten in CustomFields ...'),
hotkeyAble: false,
icon: 'saveStatistics',
disabled: uitools.notMediaListSelected,
visible: window.uitools.getCanEdit,
execute: async function () {
var list = await uitools.getSelectedTracklist().whenLoaded();
if (list.count === 0) {
return;
}
list.forEach(function(track) {
var modified = false;
let varrating = track.rating/20;
////////////////////////////////////////////////////////////////////////////////////
// PLAYCOUNTER & LASTPLAYED: "PlayCounter"=1 & "LastPlayed"=Now(), wenn "PlayCounter"=0 und "Rating">1 ...
if(track.playCounter === 0 && varrating > 1) {
track.playCounter = 1;
track.lastTimePlayed_UTC = app.utils.timestamp2DateTime(new Date().toISOString());
// track.commitAsync();
modified = true;
};
if (modified)
track.commitAsync();
});
}
}
window._menuItems.editTags.action.submenu.push({
action: actions.saveStatistics,
order: 10,
grouporder: 10
});[/code]
... so, no direct SQL statements. the script runs on every change of the track as well as on right-click.
if you want the whole script (all the files needed to run it), just PM me.