@@ -125,6 +125,17 @@ class YtdlpCommandBuilder {
125125 return [ ] ;
126126 }
127127
128+ /**
129+ * Build temp path args for yt-dlp internal temp files
130+ * This redirects yt-dlp's internal temp files (used during download/merge operations)
131+ * to our already-writable staging directory, fixing permission errors on some Docker setups.
132+ * @returns {string[] } - Array with --paths temp: argument
133+ */
134+ static buildTempPathArgs ( ) {
135+ const tempPath = tempPathManager . getTempBasePath ( ) ;
136+ return [ '--paths' , `temp:${ tempPath } ` ] ;
137+ }
138+
128139 /**
129140 * Build audio extraction args for MP3 downloads
130141 * @param {string|null } audioFormat - 'video_mp3' or 'mp3_only', null for video only
@@ -150,7 +161,7 @@ class YtdlpCommandBuilder {
150161
151162 /**
152163 * Build arguments that ALWAYS apply to any yt-dlp invocation
153- * Includes: IPv4 enforcement, proxy, sleep-requests, and cookies
164+ * Includes: IPv4 enforcement, proxy, sleep-requests, cookies, and temp path
154165 * @param {Object } config - Configuration object
155166 * @param {Object } options - Options for building args
156167 * @param {boolean } options.skipSleepRequests - Skip adding --sleep-requests (for single metadata fetches)
@@ -184,6 +195,10 @@ class YtdlpCommandBuilder {
184195 args . push ( '--cookies' , cookiesPath ) ;
185196 }
186197
198+ // Add temp path for yt-dlp's internal temp files
199+ // This fixes permission errors on Docker setups where /tmp may not be writable
200+ args . push ( ...this . buildTempPathArgs ( ) ) ;
201+
187202 return args ;
188203 }
189204
0 commit comments