Add queue list

This commit is contained in:
Matteo Bossi
2023-06-02 14:57:27 +02:00
parent caa1b94fd6
commit 28e39e46ae
7 changed files with 232 additions and 34 deletions

View File

@@ -8,9 +8,10 @@ const widget = {
mappings: {
series: {
endpoint: "series",
map: (data) => ({
total: asJson(data).length,
})
map: (data) => asJson(data).map((entry) => ({
title: entry.title,
id: entry.id
}))
},
queue: {
endpoint: "queue",
@@ -24,6 +25,38 @@ const widget = {
"totalRecords"
]
},
"queue/details": {
endpoint: "queue/details",
map: (data) => asJson(data).map((entry) => ({
trackedDownloadState: entry.trackedDownloadState,
trackedDownloadStatus: entry.trackedDownloadStatus,
timeLeft: entry.timeleft,
size: entry.size,
sizeLeft: entry.sizeleft,
seriesId: entry.seriesId,
episodeTitle: entry.episode?.title,
episodeId: entry.episodeId
})).sort((a, b) => {
const downloadingA = a.trackedDownloadState === "downloading"
const downloadingB = b.trackedDownloadState === "downloading"
if (downloadingA && !downloadingB) {
return -1;
}
if (downloadingB && !downloadingA) {
return 1;
}
const percentA = a.sizeLeft / a.size;
const percentB = b.sizeLeft / b.size;
if (percentA < percentB) {
return -1;
}
if (percentA > percentB) {
return 1;
}
return 0;
})
}
},
};