alexta69 / metube

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

Cancelling a livestream doesn't stop the download #282

Open ehfraim opened 1 year ago

ehfraim commented 1 year ago

When I add a livestream, for example https://www.twitch.tv/pewdiepie it starts to download. When I cancel the download, it is removed from the UI, but in my file system I can see the file is still there and the filesize is increasing. I have to restart the container to stop the download. Stopping a youtube video download works as expected.

The docker log is showing a post to /delete POST /delete HTTP/1.1" 200 267

I have tested with an unmodified fresh container using the stable yt-dlp release, and another container using the nightly release, same result.

ehfraim commented 1 year ago

When the livestream is downloading it shows an animated green bar, but not any progression status. My guess would be that the status is never set to started so the cancel function is never run on it, but I have not tested it. https://github.com/alexta69/metube/blob/dd0f96c6af1994fbf050f6475ab862d4064daae8/app/ytdl.py#L284

async def cancel(self, ids):
        for id in ids:
            if not self.queue.exists(id):
                log.warn(f'requested cancel for non-existent download {id}')
                continue
            if self.queue.get(id).started():
                self.queue.get(id).cancel()
            else:
                self.queue.delete(id)
                await self.notifier.canceled(id)
        return {'status': 'ok'}