Creating favourite songs playlists for archiving #150
-
Hello, firstly I would like to thank you for this program! I am attempting to collect an archive of my Spotify favourites by making the following playlists :
I have managed to make Playlist 3 successfully. I would like advice on how to write the first two playlists in a simple way. Apologies if anything doesn't make sense, please let me know. :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Set trigger to function Constant function logFavoriteSongs() {
const FILENAME = 'ArchiveFavoriteSongs';
const COUNT_TRACKS = 50;
let banTracks = Source.getPlaylistTracks('', 'id');
let archiveTracks = Cache.read(FILENAME);
let currentTracks = Source.getSavedTracks(archiveTracks.length > 0 ? COUNT_TRACKS : undefined);
Combiner.push(archiveTracks, currentTracks);
Filter.dedupTracks(archiveTracks);
Filter.removeTracks(archiveTracks, banTracks);
Cache.write(FILENAME, archiveTracks);
Library.checkFavoriteTracks(archiveTracks);
let obj = archiveTracks.reduce((obj, track) => {
track.isFavorite ? obj.saved.push(track) : obj.unsaved.push(track);
return obj;
}, { saved: [], unsaved: [] })
Order.sort(archiveTracks, 'meta.added_at', 'asc');
Order.sort(obj.unsaved, 'meta.added_at', 'asc');
Order.sort(obj.saved, 'meta.added_at', 'asc');
save('All favorite', archiveTracks);
save('Removed favorite', obj.unsaved);
save('Present favorite', obj.saved);
function save(name, tracks, id) {
Playlist.saveWithUpdate({
//id: id,
name: name,
tracks: tracks,
randomCover: 'update',
public: false,
toEnd: true,
});
}
} |
Beta Was this translation helpful? Give feedback.
Set trigger to function
logFavoriteSongs
(is saving snapshot of present favorite tracks and append to last with dedup).In dependence from your activity choose period. If every day, tracks that liked and removed in one day dont push to cache. You can set an hour. But such fleeting tracks dont make sense. In case day of week can lost many tracks that liked and removed before to create new snapshot.
Constant
COUNT_TRACKS
is how many last favorite tracks need to check. If you can save more than 50 tracks in trigger period, increase value. And insertid
for playlist with ban tracks.