Add save-to-device export, server export route and an On other devices P2P list
This commit is contained in:
@@ -279,3 +279,19 @@ export async function recentContent(limit = 30) {
|
||||
});
|
||||
return rowsOf(r).map((x) => ({ ...x, holders: Number(x.holders) || 0 }));
|
||||
}
|
||||
|
||||
// One verified file per video (newest), with how many sharing devices hold it —
|
||||
// the "On other devices" playlist. Holders themselves come from listHolders.
|
||||
export async function listSharedContent(limit = 100) {
|
||||
const r = await db.execute({
|
||||
sql: `SELECT c.cid, c.video_id, c.size, c.height, c.vcodec, c.duration, c.meta, c.verified_at,
|
||||
(SELECT COUNT(*) FROM p2p_holders h JOIN p2p_devices d ON d.device_id = h.device_id
|
||||
WHERE h.cid = c.cid AND h.status = 'active' AND d.share = 1) AS holders
|
||||
FROM p2p_content c
|
||||
WHERE c.status = 'verified'
|
||||
AND c.created_at = (SELECT MAX(c2.created_at) FROM p2p_content c2 WHERE c2.video_id = c.video_id AND c2.status = 'verified')
|
||||
ORDER BY c.verified_at DESC LIMIT ?`,
|
||||
args: [limit],
|
||||
});
|
||||
return rowsOf(r).map((x) => ({ ...x, holders: Number(x.holders) || 0 }));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user