2

我写了一个shell脚本来下载视频并做一些操作。我正在使用 youtube-dl,因为我有一个网页 URL,需要从该页面下载视频。脚本是

#!/bin/bash
cd /media/user/path/home/user/Videos/X
youtube-dl http://someUrl.com/somePath
#Do other operations

视频开始下载并在一段时间后显示ERROR: unable to download video data: [Errno 104] Connection reset by peer

我尝试从 Ubuntu 终端运行此命令。当我重新运行相同的命令时,视频下载会在几秒/分钟后恢复并再次停止。有什么方法可以让我自动重新运行相同的命令,直到视频下载完成?如何捕获此错误并youtube-dl递归运行命令?

作为参考,我在终端中运行了命令,下面显示了终端输出:

user@user-ThinkPad-T430:/media/user/path/home/user/Videos/X$ youtube-dl http://someUrl.com/somePath
[generic] somePath: Requesting header
WARNING: Falling back on generic information extractor.
[generic] somePath: Downloading webpage
[generic] somePath: Extracting information
[download] Resuming download at byte 79260669
[download] Destination:   someVideo - someUrl.-somePath.mp4
[download]  42.2% of 185.01MiB at 18.13KiB/s ETA 01:40:45ERROR: unable to download video data: [Errno 104] Connection reset by peer
user@user-ThinkPad-T430:/media/user/path/home/user/Videos/X$ youtube-dl http://someUrl.com/somePath
[generic] somePath: Requesting header
WARNING: Falling back on generic information extractor.
[generic] somePath: Downloading webpage
[generic] somePath: Extracting information
[download] Resuming download at byte 81777461
[download] Destination:   someVideo - someUrl.-somePath.mp4
[download]  44.3% of 185.01MiB at 21.68KiB/s ETA 01:21:12ERROR: unable to download video data: [Errno 104] Connection reset by peer

还告诉我是否有其他替代方式。

4

0 回答 0