我正在尝试从 Youtube 下载视频,并尝试了以下方法:
url = "http://www.youtube.com/watch?v=f4l3pBovB_c"
urllib.urlretrieve(url,"test.mp4")
它创建文件 test.mp4,但出现以下错误:
Windows media player cannot play the file. The Player might not support the file type or might not support the codec that was used to compress the file.
我想尝试自己了解如何完成此操作,我已经看过 youtube-dl.py 之类的模块,但再次希望以最简单的形式使代码工作,以便我可以在构建脚本时理解它。
最佳答案
Youtube 视频不存储在 youtube.com
域,因此您尝试下载的视频不存在该 URL。下载 youtube 视频是一个复杂的过程,但您可以使用 youtube-dl为了它。
关于youtube 的 Python urllib 基本脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15060186/