meeb / tubesync

Syncs YouTube channels and playlists to a locally hosted media server
GNU Affero General Public License v3.0
1.88k stars 119 forks source link

Option to download file parts into a temporary directory for combination #218

Open dgomer opened 2 years ago

dgomer commented 2 years ago

When downloading files into a directory that's actively being monitored by a media server (I'm experiencing this with Jellyfin but I've seen this behavior with Plex as well), sometimes the media server will attempt to start indexing files before the video/audio combination has happened, which leads to the part files being locked so that they can't be renamed or deleted. This makes the downloader fail to finish the download even though it was actually successful - you usually end up with an audio.mkv, video.mkv, and combined.temp.mkv file.

If the audio and video file parts could be downloaded and combined in a temporary directory, and then moved into the monitored directory, this would no longer be a problem.

meeb commented 2 years ago

Nice suggestion, thanks. I'll see if you can easily get yt-dlp to download to a temp directory before merging streams.

dgomer commented 2 years ago

I believe if you use the paths argument for yt-dlp you can set a temp: location for the intermediate files.

https://github.com/yt-dlp/yt-dlp/blob/master/yt_dlp/YoutubeDL.py#L244-L245

meeb commented 2 years ago

Yes I had noticed that, I need to confirm that I can still specify an absolute output path along with just a temp entry for that config option works as expected. If it does I'll add this into the next release.

dgomer commented 2 years ago

Fantastic! Thank you so much for looking into this :)