Динамический топ за месяц через Lastfm.getCustomTop #46
-
Написал такой код :
Для этой функции :
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
Если нужен топ на месяц, можно использовать getTopTracks с периодом
|
Beta Was this translation helpful? Give feedback.
-
function createTopMonth() {
let period = makeMonthPeriod();
let tracks = Lastfm.getCustomTop({
user: '',
from: period.from,
to: period.to,
limit: 50,
});
Playlist.saveWithReplace({
id: '',
tracks: tracks,
});
function makeMonthPeriod() {
let fromDay = new Date();
fromDay.setDate(1);
return {
from: fromDay.toLocaleDateString('en-US', { timeZone: 'Europe/Moscow' }),
to: new Date().toLocaleDateString('en-US', { timeZone: 'Europe/Moscow' }),
};
}
} |
Beta Was this translation helpful? Give feedback.
-
Добавил проверку типа. Если обновите библиотеку, сможете использовать следующий код. Принцип тот же: первое и текущее число месяца. let tracks = Lastfm.getCustomTop({
user: '',
from: new Date().setDate(1),
to: new Date(),
limit: 50
}); |
Beta Was this translation helpful? Give feedback.
Добавил проверку типа. Если обновите библиотеку, сможете использовать следующий код. Принцип тот же: первое и текущее число месяца.