codecત્યpl
This commit is contained in:
parent
b8da59086b
commit
f233d9e64f
10 changed files with 343 additions and 1121 deletions
|
@ -3,10 +3,13 @@ import { spawn } from "node:child_process";
|
|||
import path from "node:path";
|
||||
import { addToCache, isCached } from "../cache.js";
|
||||
|
||||
// TODO: make this have a return type
|
||||
export async function downloadSong(streamUrl: string, decryptionKey: string): Promise<void> {
|
||||
const baseOutputName = streamUrl.split("/").at(-1)?.split("?").at(0)?.split(".").splice(0, 1).join(".")?.trim();
|
||||
// TODO: make this have a return type (file path)
|
||||
// TODO: refresh cache timer on download
|
||||
// TODO: remux to m4a?
|
||||
export async function downloadSong(streamUrl: string, decryptionKey: string, songCodec: RegularCodec | WebplaybackCodec): Promise<void> {
|
||||
let baseOutputName = streamUrl.split("/").at(-1)?.split("?").at(0)?.split(".").splice(0, 1).join(".")?.trim();
|
||||
if (!baseOutputName) { throw "could not get base output name from stream url"; }
|
||||
baseOutputName += `_${songCodec}`;
|
||||
const encryptedName = baseOutputName + "_enc.mp4";
|
||||
const encryptedPath = path.join(config.downloader.cache.directory, encryptedName);
|
||||
const decryptedName = baseOutputName + ".mp4";
|
||||
|
@ -48,3 +51,21 @@ export async function downloadSong(streamUrl: string, decryptionKey: string): Pr
|
|||
addToCache(encryptedName);
|
||||
addToCache(decryptedName);
|
||||
}
|
||||
|
||||
// TODO: find a better spot for this
|
||||
export enum RegularCodec {
|
||||
Aac = "aac",
|
||||
AacHe = "aac_he",
|
||||
AacBinaural = "aac_binaural",
|
||||
AacDownmix = "aac_downmix",
|
||||
AacHeBinaural = "aac_he_binaural",
|
||||
AacHeDownmix = "aac_he_downmix",
|
||||
Atmos = "atmos",
|
||||
Ac3 = "ac3",
|
||||
Alac = "alac"
|
||||
}
|
||||
|
||||
export enum WebplaybackCodec {
|
||||
AacLegacy = "aac_legacy",
|
||||
AacHeLegacy = "aac_he_legacy"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue