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]>
83 lines
2.5 KiB
JavaScript
Executable File
83 lines
2.5 KiB
JavaScript
Executable File
'use strict'
|
|
|
|
const { readBody, ok, bad } = require('../lib/http')
|
|
|
|
// POST endpoints that map 1:1 to a renderer media action with no body.
|
|
const SIMPLE = {
|
|
'/playpause': 'playpause',
|
|
'/next': 'next',
|
|
'/previous': 'prev',
|
|
'/like': 'like',
|
|
'/shuffle': 'shuffle',
|
|
'/repeat': 'repeat',
|
|
'/autoplay': 'autoplay',
|
|
}
|
|
|
|
const clamp01 = (v) => Math.max(0, Math.min(1, v))
|
|
|
|
// Playback command routes. All forward to the renderer via ctx.sendAction, which
|
|
// main.ts wires to `win.webContents.send('crosssound-media-action', …)`.
|
|
module.exports = async function playbackRoutes(req, res, path, ctx) {
|
|
if (req.method !== 'POST') return false
|
|
|
|
if (SIMPLE[path]) {
|
|
ctx.sendAction(SIMPLE[path])
|
|
ok(res)
|
|
return true
|
|
}
|
|
|
|
switch (path) {
|
|
case '/volume': {
|
|
const b = await readBody(req)
|
|
const v = Number(b.value ?? b.v)
|
|
if (!isFinite(v)) return (bad(res, 'missing "value" (0..1)'), true)
|
|
ctx.sendAction('volume', { value: clamp01(v) })
|
|
return (ok(res), true)
|
|
}
|
|
case '/seek': {
|
|
const b = await readBody(req)
|
|
const seconds = Number(b.seconds ?? b.position)
|
|
if (!isFinite(seconds)) return (bad(res, 'missing "seconds"'), true)
|
|
ctx.sendAction('seek', { position: seconds })
|
|
return (ok(res), true)
|
|
}
|
|
case '/play': {
|
|
const b = await readBody(req)
|
|
if (b.id == null && !b.url && !b.urn) return (bad(res, 'need "id", "url" or "urn"'), true)
|
|
ctx.sendAction('play', b)
|
|
return (ok(res), true)
|
|
}
|
|
case '/play-index': {
|
|
const b = await readBody(req)
|
|
const index = Number(b.index ?? b.i)
|
|
if (!Number.isInteger(index)) return (bad(res, 'missing "index"'), true)
|
|
ctx.sendAction('playIndex', { index })
|
|
return (ok(res), true)
|
|
}
|
|
case '/play-playlist': {
|
|
const b = await readBody(req)
|
|
const id = Number(b.id)
|
|
if (!Number.isInteger(id)) return (bad(res, 'missing playlist "id"'), true)
|
|
ctx.sendAction('playPlaylist', { id })
|
|
return (ok(res), true)
|
|
}
|
|
case '/play-queue': {
|
|
const b = await readBody(req)
|
|
if (!Array.isArray(b.urns)) return (bad(res, 'missing "urns" array'), true)
|
|
ctx.sendAction('playQueue', { urns: b.urns })
|
|
return (ok(res), true)
|
|
}
|
|
case '/command': {
|
|
// Generic escape hatch: { action, ...data }. Kept for back-compat with the
|
|
// original Game Bar widget (which posts { action: "toggle" }, etc.).
|
|
const b = await readBody(req)
|
|
if (typeof b.action !== 'string') return (bad(res, 'missing "action"'), true)
|
|
const { action, ...data } = b
|
|
ctx.sendAction(action, data)
|
|
return (ok(res), true)
|
|
}
|
|
default:
|
|
return false
|
|
}
|
|
}
|