Downloading from spotify works properly

This commit is contained in:
Erik 2024-03-27 20:03:05 +02:00
parent 822bf608f3
commit 729466a031
4 changed files with 10 additions and 8 deletions

View File

@ -1,3 +1,4 @@
FROM zotify as zotify
FROM node:lts-alpine as builder
RUN apk update && apk add build-base python3
@ -10,13 +11,11 @@ RUN yarn install
FROM node:lts-alpine
RUN apk update && apk add ffmpeg
# RUN python3 -m ensurepip
# RUN python3 -m pip install --user pipx
# RUN pipx install https://get.zotify.xyz
COPY --from=zotify /app/dist/zotify /bin/zotify
WORKDIR /musicbot
COPY build build
COPY --from=builder /musicbot/node_modules ./node_modules
COPY package.json package.json
VOLUME [ "/musicbot/cache" ]
CMD ["node", "--enable-source-maps", "build/index.js"]
# CMD ["/bin/ash"]
# CMD ["node", "--enable-source-maps", "build/index.js"]
CMD ["/bin/ash"]

View File

@ -14,13 +14,13 @@ class MusicDownloader implements Initialisable
#logger: LoggerClient;
#client: DiscordClient;
#downloadDir: string;
constructor (client: DiscordClient)
constructor (client: DiscordClient, downloads?: string)
{
this.#ready = false;
this.#logger = client.createLogger(this);
this.#client = client;
this.#availableDownloaders = new Collection();
this.#downloadDir = 'Z:\\media\\downloads';
this.#downloadDir = downloads ?? './cache/downloads';
}
async initialise (): Promise<void>

View File

@ -26,7 +26,7 @@ class MusicLibrary implements Initialisable
this.#path = libraryPath;
this.#ready = false;
this.#index = new Collection();
this.#downloader = new MusicDownloader(client);
this.#downloader = new MusicDownloader(client, path.join(libraryPath, '.downloads'));
this.#logger = client.createLogger(this);
this.#currentId = 0;
}

View File

@ -28,6 +28,8 @@ class SpotifyDownloader extends Downloader
'--output "{artist} - {song_name} - {album}.{ext}"',
'--print-downloads true',
];
if (process.env.CREDENTIAL_PATH)
this.#options.push('--credentials-location ' + process.env.CREDENTIAL_PATH);
}
override test (): void | Promise<void>
@ -99,6 +101,7 @@ class SpotifyDownloader extends Downloader
ext
});
});
// child.stdout?.on('data', (chunk => this.logger.debug('child stdout:', chunk)));
});
}