alexta69 / metube

Self-hosted YouTube downloader (web UI for youtube-dl / yt-dlp)
GNU Affero General Public License v3.0
3.96k stars 259 forks source link

`paths` parameter not passed to API when extracting info #363

Closed JonasR closed 6 months ago

JonasR commented 6 months ago

After some debugging fun today I came across the following discrepancy. I'm not sure if I'm missing something and this is actually intentional, but it's causing me isuses.

There seem to be two calls two the yt-dlp API, here when downloading videos and here when extracting metadata. The first call passes paths, but the second one does not.

When downloading a Youtube playlist with "writethumbnail": True the second call will therefore attempt to save the playlist (not video) thumbnail to ./ which in my setup (Truecharts' metube on TrueNAS Scale) results in a permission denied OSError.

Is there a reason the second call could not look like this, also passing paths?

    def __extract_info(self, url):
        log.info('Extracting info')
        log.info(self.config)
        return yt_dlp.YoutubeDL(params={
            'quiet': True,
            'no_color': True,
            'paths': {"home": self.config.DOWNLOAD_DIR, "temp": self.config.TEMP_DIR},
            'extract_flat': True,
            'ignore_no_formats_error': True,
            **self.config.YTDL_OPTIONS,
        }).extract_info(url, download=False)

I could work around this for now, by passing paths in YTDL_OPTIONS but it seems counter-intuitive that this is necessary, and it will also overwrite the download directory selection from the UI.

(Edit: Of course I'm happy to create the PR if it helps and there aren't any downstream effects I'm overlooking by performing this change)

alexta69 commented 6 months ago

It doesn't pass paths because it's a call to extract metadata and not to download stuff. But in the case of writethumbnail it actually does download something. The best solution would be to stop it from downloading (maybe skip_download can help? I don't know..), but perhaps it's worth passing paths just in case anyway. I don't see a particular reason why not.

JonasR commented 6 months ago

For my particular issue I found the solution in passing an additional parameter that completely inhibits playlist thumbnail downloading here but I guess there might be people out there that actually want this thumbnail and if so probably in their DOWNLOAD_DIR

alexta69 commented 6 months ago

I agree that if it's downloaded, it should be to DOWNLOAD_DIR. Perhaps it's safer to pass paths there, no matter what else we decide to do. If you like, push a PR, and if not then I'll do it sometime.