fix tidal issue, format/lint other modules, bump version

This commit is contained in:
aria blue
2024-04-18 19:31:26 -04:00
parent 827b8ce91a
commit 5c849e16a7
5 changed files with 25 additions and 11 deletions

View File

@@ -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,

View File

@@ -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

View File

@@ -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 = <Manifest>JSON.parse(manifestStr)
const streamResponse = await fetch(manifest.urls[0])
return {
@@ -284,6 +292,7 @@ export default class Tidal implements Streamer {
stream: <NodeJS.ReadableStream>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
}
}

View File

@@ -55,7 +55,7 @@ export interface SearchResults {
}
export interface GetStreamResponse {
sizeBytes: number
sizeBytes?: number
stream: NodeJS.ReadableStream
mimeType: string
}