You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to recent changes in the YouTube API, Sayuna is currently unable to load music from YouTube correctly because ffmpeg crashes with error code 8: YouTube throws 403 thus making streaming music not possible.
While there is no official fix yet, a temporary workaround has been identified that partially resolves the issue. This workaround is detailed in the following pull request from the distubejs/ytdl-core repository.
Why isn't this included in Sayuna's repository and Docker image?
This workaround is considered a temporary and suboptimal solution with known limitations, such as frequent 403 errors causing songs to be cut off prematurely. Due to these issues, it has not been integrated into the official Sayuna repository or Docker image. The necessary fixes will be implemented once they are officially merged into the upstream branch of the distubejs/ytdl-core repository.
Steps to Apply the Workaround
1. Create the Patch Utility
Create file utils/ytdlPatch.ts with this contents:
importfsfrom'fs'importfsPromisefrom'fs/promises'import{Readable}from'stream'import{finished}from'stream/promises'exportconstytdlPatch=async()=>{//@ts-ignoreconstpatchFile=async(file,patchUrl)=>{conststream=fs.createWriteStream(file)const{ body }=awaitfetch(patchUrl)//@ts-ignorereturnfinished(Readable.fromWeb(body).pipe(stream))}//@ts-ignoreconstreplaceInFile=(file,find,replace)=>fsPromise.readFile(file)//@ts-ignore.then(data=>data.toString().replace(find,replace))//@ts-ignore.then(data=>fsPromise.writeFile(file,data))// https://github.com/distubejs/ytdl-core/pull/163constpatchBaseUrl='https://raw.githubusercontent.com/ToddyTheNoobDud/ytdl-core-stuff/37acb1c7ca203bb33c1219bffe5fb2b820b52f69/'constbuggedInfo='./node_modules/@distube/ytdl-core/lib/info.js'constbuggedUtils='./node_modules/@distube/ytdl-core/lib/utils.js'constbuggedYoutubeIndex='./node_modules/@distube/youtube/dist/index.js'awaitpatchFile(buggedInfo,patchBaseUrl+'lib/info.js')awaitpatchFile(buggedUtils,patchBaseUrl+'lib/utils.js')// https://github.com/distubejs/ytdl-core/issues/118#issuecomment-2441791441// I think you can also edit YoutubePlugin.ytdlOptions,// but I like to keep this in a single function// (https://discord.com/channels/732254550689316914/1272308260061319269/1330693171172343840)awaitreplaceInFile(buggedUtils,`["WEB", "WEB_CREATOR", "IOS", "WEBEMBEDDED", "MWEB"]`,`["WEB", "WEB_CREATOR", "IOS", "WEBEMBEDDED", "MWEB", "ANDROID"]`)// https://github.com/distubejs/ytdl-core/issues/84#issuecomment-2295590460// https://discord.com/channels/732254550689316914/1271765204253933609/1275273097120841781awaitreplaceInFile(buggedYoutubeIndex,`const info = await import_ytdl_core.default.getInfo(song.url, this.ytdlOptions);`,`let info = await import_ytdl_core.default.getInfo(song.url, this.ytdlOptions); info.formats = info.formats.filter((f) => f.hasAudio); /* 403 Error Workaround */`)console.log(`Applied hotfix for DisTubeError "ffmpeg exited with code 1" or 403 Errors`)}
2. Modify main.ts
Update code in main.ts:
import{ytdlPatch}from'./utils/ytdlPatch.js'// ...publicasyncbot(token: string){try{awaitimportx(`${dirname(import.meta.url)}/{events,commands,api}/**/*.{ts,js}`)awaitytdlPatch()// this lineawaitthis.client.login(token)this.logger.info('Bot has logged in...')}catch(err){console.log(err)throwerr}}
The text was updated successfully, but these errors were encountered:
Workaround for YouTube API Issues
Due to recent changes in the YouTube API, Sayuna is currently unable to load music from YouTube correctly because ffmpeg crashes with error code 8: YouTube throws 403 thus making streaming music not possible.
While there is no official fix yet, a temporary workaround has been identified that partially resolves the issue. This workaround is detailed in the following pull request from the distubejs/ytdl-core repository.
Why isn't this included in Sayuna's repository and Docker image?
This workaround is considered a temporary and suboptimal solution with known limitations, such as frequent 403 errors causing songs to be cut off prematurely. Due to these issues, it has not been integrated into the official Sayuna repository or Docker image. The necessary fixes will be implemented once they are officially merged into the upstream branch of the distubejs/ytdl-core repository.
Steps to Apply the Workaround
1. Create the Patch Utility
Create file
utils/ytdlPatch.ts
with this contents:2. Modify
main.ts
Update code in
main.ts
:The text was updated successfully, but these errors were encountered: