Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v2
with:
node-version: '18'
cache: 'yarn'
- name: Install dependencies
run: yarn install
- name: Generate Prisma client
run: yarn prisma generate
- name: Run lint
run: yarn lint
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Generate Prisma client
run: yarn prisma generate

- name: Run lint
run: yarn lint
28 changes: 17 additions & 11 deletions .github/workflows/type-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ jobs:
name: Type Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v2
with:
node-version: '18'
cache: 'yarn'
- name: Install dependencies
run: yarn install
- name: Generate Prisma client
run: yarn prisma generate
- name: Run type check
run: yarn tsc
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Generate Prisma client
run: yarn prisma generate

- name: Run type check
run: yarn tsc
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
FROM node:18-bullseye-slim AS base
FROM node:22-bullseye-slim AS base

# openssl will be a required package if base is updated to 18.16+ due to node:*-slim base distro change
# https://github.com/prisma/prisma/issues/19729#issuecomment-1591270599
# Install ffmpeg
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
build-essential \
python3 \
python3-distutils \
python3-venv \
ffmpeg \
tini \
openssl \
Expand All @@ -13,6 +17,8 @@ RUN apt-get update \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*

ENV PYTHON=/usr/bin/python3

# Install dependencies
FROM base AS dependencies

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"@discordjs/opus": "^0.8.0",
"@discordjs/rest": "1.0.1",
"@discordjs/voice": "0.17.0",
"@distube/ytdl-core": "^4.15.9",
"@distube/ytdl-core": "^4.16.2",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you gander at #1195 and #1180

What is different exactly? It's been an issue for a few months now, and has a few of us... well stumped.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question.
In my PR, I only upgraded the version of ytdl-core to get music downloads working again.
#1180 do the same, but I needed to update to version 4.16 because there were changes in the page's regex.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I update the node version to 20, to prevent some errors too

"@distube/ytsr": "^2.0.4",
"@prisma/client": "4.16.0",
"@types/libsodium-wrappers": "^0.7.9",
Expand Down
16 changes: 11 additions & 5 deletions src/services/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,17 +665,23 @@ export default class {
}
}

private async createReadStream(options: {url: string; cacheKey: string; ffmpegInputOptions?: string[]; cache?: boolean; volumeAdjustment?: string}): Promise<Readable> {
private async createReadStream(options: {
url: string;
cacheKey: string;
ffmpegInputOptions?: string[];
cache?: boolean;
volumeAdjustment?: string;
}): Promise<Readable> {
return new Promise((resolve, reject) => {
const capacitor = new WriteStream();
let hasReturnedStreamClosed = false;

if (options?.cache) {
const cacheStream = this.fileCache.createWriteStream(this.getHashForCache(options.cacheKey));
capacitor.createReadStream().pipe(cacheStream);
capacitor.createReadStream()?.pipe(cacheStream);
}

const returnedStream = capacitor.createReadStream();
let hasReturnedStreamClosed = false;

const stream = ffmpeg(options.url)
.inputOptions(options?.ffmpegInputOptions ?? ['-re'])
Expand All @@ -689,13 +695,13 @@ export default class {
}
})
.on('start', command => {
debug(`Spawned ffmpeg with ${command as string}`);
debug(`Spawned ffmpeg with ${command}`);
});

stream.pipe(capacitor);

returnedStream.on('close', () => {
if (!options.cache) {
if (!options?.cache) {
stream.kill('SIGKILL');
}

Expand Down
Loading