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]>
92 lines
3.3 KiB
JavaScript
Executable File
92 lines
3.3 KiB
JavaScript
Executable File
'use strict'
|
|
|
|
const { URL } = require('url')
|
|
const { sendJson, unavailable } = require('../lib/http')
|
|
|
|
const qp = (req, key, def = null) => {
|
|
const v = new URL(req.url, 'http://127.0.0.1').searchParams.get(key)
|
|
return v == null ? def : v
|
|
}
|
|
const int = (v, def) => {
|
|
const n = parseInt(v, 10)
|
|
return isNaN(n) ? def : n
|
|
}
|
|
|
|
// SoundCloud library/browse routes. All require ctx.client (the signed-in API
|
|
// client); without it they answer 503 so callers can degrade gracefully.
|
|
module.exports = async function libraryRoutes(req, res, path, ctx) {
|
|
if (req.method !== 'GET') return false
|
|
|
|
const isDynamic =
|
|
path.startsWith('/playlist/') ||
|
|
path.startsWith('/track/') ||
|
|
(path.startsWith('/station/') && path.endsWith('/tracks'))
|
|
const STATIC = ['/search', '/resolve', '/discover/mixed', '/discover/history', '/playlists', '/tracks/batch', '/station']
|
|
if (!STATIC.includes(path) && !isDynamic) return false
|
|
|
|
const client = ctx.client
|
|
if (!client) { unavailable(res); return true }
|
|
|
|
try {
|
|
if (path === '/search') {
|
|
const q = qp(req, 'q')
|
|
if (!q) { sendJson(res, 400, { error: 'missing query param "q"' }); return true }
|
|
sendJson(res, 200, await client.search(q, qp(req, 'kind', 'tracks'), int(qp(req, 'limit'), 20)))
|
|
return true
|
|
}
|
|
if (path === '/resolve') {
|
|
const target = qp(req, 'url') || qp(req, 'urn')
|
|
if (!target) { sendJson(res, 400, { error: 'missing "url" or "urn"' }); return true }
|
|
sendJson(res, 200, await client.resolve(target))
|
|
return true
|
|
}
|
|
if (path === '/discover/mixed') {
|
|
sendJson(res, 200, await client.getMixedSelections(int(qp(req, 'limit'), 10)))
|
|
return true
|
|
}
|
|
if (path === '/discover/history') {
|
|
sendJson(res, 200, await client.getPlayHistory(int(qp(req, 'limit'), 20)))
|
|
return true
|
|
}
|
|
if (path === '/playlists') {
|
|
sendJson(res, 200, (await client.getMyPlaylists(int(qp(req, 'limit'), 50))) || [])
|
|
return true
|
|
}
|
|
if (path === '/tracks/batch') {
|
|
const ids = (qp(req, 'ids', '') || '').split(',').map((n) => parseInt(n.trim(), 10)).filter((n) => !isNaN(n))
|
|
if (!ids.length) { sendJson(res, 400, { error: 'missing "ids"' }); return true }
|
|
sendJson(res, 200, await client.getTracksBatch(ids))
|
|
return true
|
|
}
|
|
if (path.startsWith('/playlist/')) {
|
|
const id = parseInt(path.slice('/playlist/'.length), 10)
|
|
if (isNaN(id)) { sendJson(res, 400, { error: 'invalid playlist id' }); return true }
|
|
sendJson(res, 200, await client.getPlaylist(id))
|
|
return true
|
|
}
|
|
if (path.startsWith('/track/')) {
|
|
const id = parseInt(path.slice('/track/'.length), 10)
|
|
if (isNaN(id)) { sendJson(res, 400, { error: 'invalid track id' }); return true }
|
|
sendJson(res, 200, await client.getTrackV2(id))
|
|
return true
|
|
}
|
|
if (path.startsWith('/station/') && path.endsWith('/tracks')) {
|
|
const urn = decodeURIComponent(path.slice('/station/'.length, -'/tracks'.length))
|
|
sendJson(res, 200, await client.getStationTracks(urn, int(qp(req, 'limit'), 50)))
|
|
return true
|
|
}
|
|
if (path === '/station') {
|
|
const urn = qp(req, 'urn')
|
|
const url = qp(req, 'url')
|
|
if (urn) { sendJson(res, 200, await client.getStationTracks(urn, int(qp(req, 'limit'), 50))); return true }
|
|
if (url) { sendJson(res, 200, await client.resolve(url)); return true }
|
|
sendJson(res, 400, { error: 'missing "url" or "urn"' })
|
|
return true
|
|
}
|
|
} catch (e) {
|
|
sendJson(res, 500, { error: e.message })
|
|
return true
|
|
}
|
|
return false
|
|
}
|