A single-commit snapshot of better-remote (7a8c4cb plus the uncommitted remote.js work), with every DRM-bearing piece replaced by a stub that keeps the same interface: - src/ui/drm.js: no DRM pipelines; needsDrm/isDrmUrl false, bestEncryptedTranscoding null, playDrmAudio rejects. The engine switcher and drmVjs* helpers stay as no-ops. - src/electron/drm.ts: initCdm/setupLicenseCors no-ops; the drm:license and api:stream:drm-info IPC handlers reject with "DRM is not available". - src/api/soundcloud.ts: resolveEncryptedStream keeps its signature, rejects. - src/electron/main.ts: license host dropped from the header rewrite. - src/ui/pb-lease.js: the expiry self-check uses a placeholder URL instead of a captured DRM manifest URL (same policy values, still passes). - scripts/vmp-sign.js, forge.config.js vmpSign: Widevine signing skipped, so no castLabs EVS account is needed to run or package. - README: says DRM is stubbed here. Go+ tracks SoundCloud only serves encrypted are unplayable and skipped; previews and everything else play as before. No history: the private branches' DRM code is not reachable from this commit. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
57 lines
1.9 KiB
JavaScript
Executable File
57 lines
1.9 KiB
JavaScript
Executable File
'use strict'
|
|
|
|
const { URL } = require('url')
|
|
const { sendJson, unavailable } = require('../lib/http')
|
|
|
|
const limitOf = (req, def) => {
|
|
const n = parseInt(new URL(req.url, 'http://127.0.0.1').searchParams.get('limit') || String(def), 10)
|
|
return isNaN(n) ? def : n
|
|
}
|
|
const byPlays = (a, b) => (b.playback_count || 0) - (a.playback_count || 0)
|
|
|
|
// /user/:id and its sub-resources.
|
|
module.exports = async function userRoutes(req, res, path, ctx) {
|
|
if (req.method !== 'GET') return false
|
|
const m = path.match(/^\/user\/(\d+)(?:\/(tracks|playlists|albums|likes|reposts|popular|spotlight))?$/)
|
|
if (!m) return false
|
|
|
|
const client = ctx.client
|
|
if (!client) { unavailable(res); return true }
|
|
|
|
const id = parseInt(m[1], 10)
|
|
const sub = m[2] || ''
|
|
try {
|
|
switch (sub) {
|
|
case '':
|
|
sendJson(res, 200, await client.getUser(id)); return true
|
|
case 'tracks':
|
|
sendJson(res, 200, await client.getUserTracks(id, limitOf(req, 50))); return true
|
|
case 'playlists':
|
|
sendJson(res, 200, await client.getUserPlaylists(id, limitOf(req, 50))); return true
|
|
case 'albums': {
|
|
const d = await client.getUserPlaylists(id, limitOf(req, 50))
|
|
sendJson(res, 200, Array.isArray(d) ? d.filter((p) => p.is_album) : [])
|
|
return true
|
|
}
|
|
case 'likes':
|
|
sendJson(res, 200, await client.getUserLikedTracks(id, limitOf(req, 50))); return true
|
|
case 'reposts':
|
|
sendJson(res, 200, await client.getUserRepostedTracks(id, limitOf(req, 50))); return true
|
|
case 'popular': {
|
|
const d = await client.getUserTracks(id, limitOf(req, 50))
|
|
sendJson(res, 200, Array.isArray(d) ? [...d].sort(byPlays) : [])
|
|
return true
|
|
}
|
|
case 'spotlight': {
|
|
const d = await client.getUserTracks(id, 50)
|
|
sendJson(res, 200, Array.isArray(d) ? [...d].sort(byPlays).slice(0, 3) : [])
|
|
return true
|
|
}
|
|
}
|
|
} catch (e) {
|
|
sendJson(res, 500, { error: e.message })
|
|
return true
|
|
}
|
|
return false
|
|
}
|