From 5c849e16a74e5dd4b09c78811a80d9a228c1220d Mon Sep 17 00:00:00 2001 From: aria blue Date: Thu, 18 Apr 2024 19:31:26 -0400 Subject: [PATCH] fix tidal issue, format/lint other modules, bump version --- package.json | 2 +- src/streamers/soundcloud/main.ts | 8 +++++++- src/streamers/spotify/main.ts | 2 +- src/streamers/tidal/main.ts | 22 +++++++++++++++------- src/types.ts | 2 +- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 60be66e..962519e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lucida", - "version": "2.0.0-1", + "version": "2.0.0-2", "description": "A modular music downloader tool", "main": "build/index.js", "type": "module", diff --git a/src/streamers/soundcloud/main.ts b/src/streamers/soundcloud/main.ts index e32cf97..5226057 100644 --- a/src/streamers/soundcloud/main.ts +++ b/src/streamers/soundcloud/main.ts @@ -1,6 +1,12 @@ import fetch, { HeadersInit } from 'node-fetch' import { DEFAULT_HEADERS, SC_VERSION } from './constants.js' -import { ItemType, Streamer, SearchResults, GetByUrlResponse, GetStreamResponse } from '../../types.js' +import { + ItemType, + Streamer, + SearchResults, + GetByUrlResponse, + GetStreamResponse +} from '../../types.js' import { parseAlbum, parseTrack, diff --git a/src/streamers/spotify/main.ts b/src/streamers/spotify/main.ts index 4ffc6b1..ad7f6e3 100644 --- a/src/streamers/spotify/main.ts +++ b/src/streamers/spotify/main.ts @@ -1,6 +1,6 @@ import Librespot, { LibrespotOptions } from 'librespot' import { parseArtist, parseAlbum, parseTrack } from './parse.js' -import { ItemType, GetByUrlResponse, SearchResults, StreamerWithLogin } from '../../types.js' +import { GetByUrlResponse, SearchResults, StreamerWithLogin } from '../../types.js' class Spotify implements StreamerWithLogin { client: Librespot diff --git a/src/streamers/tidal/main.ts b/src/streamers/tidal/main.ts index b2337e9..586f177 100644 --- a/src/streamers/tidal/main.ts +++ b/src/streamers/tidal/main.ts @@ -1,6 +1,13 @@ import fetch from 'node-fetch' import { spawn } from 'child_process' -import { ItemType, GetByUrlResponse, GetStreamResponse, SearchResults, Streamer, Track } from '../../types.js' +import { + ItemType, + GetByUrlResponse, + GetStreamResponse, + SearchResults, + Streamer, + Track +} from '../../types.js' import { TIDAL_AUTH_BASE, TIDAL_API_BASE } from './constants.js' import { Contributor, @@ -271,11 +278,12 @@ export default class Tidal implements Streamer { } ) const manifestStr = Buffer.from(playbackInfoResponse.manifest, 'base64').toString('utf-8') + interface Manifest { + mimeType: string + urls: string[] + } + if (playbackInfoResponse.manifestMimeType != 'application/dash+xml') { - interface Manifest { - mimeType: string - urls: string[] - } const manifest = JSON.parse(manifestStr) const streamResponse = await fetch(manifest.urls[0]) return { @@ -284,6 +292,7 @@ export default class Tidal implements Streamer { stream: streamResponse.body } } + const trackUrls = parseMpd(manifestStr) const ffmpegProc = spawn('ffmpeg', [ @@ -318,8 +327,7 @@ export default class Tidal implements Streamer { load() return { - mimeType: playbackInfoResponse.manifestMimeType, - sizeBytes: manifestStr.length, + mimeType: 'audio/flac', stream: ffmpegProc.stdout } } diff --git a/src/types.ts b/src/types.ts index df195f0..ca28bb5 100644 --- a/src/types.ts +++ b/src/types.ts @@ -55,7 +55,7 @@ export interface SearchResults { } export interface GetStreamResponse { - sizeBytes: number + sizeBytes?: number stream: NodeJS.ReadableStream mimeType: string }