【问题标题】:Download videos from TVE (Spanish TV site) using python使用 python 从 THE(西班牙电视网站)下载视频
【发布时间】:2019-11-25 12:26:04
【问题描述】:

我想使用 python 从 TVE(西班牙电视网站)下载视频,以便创建手语数据库。 Example

由于有大量视频,我正在尝试使用 python 来做。

事实上,我对 Web 编程和 HTML 都一无所知。我试图检查该网站以找到指向原始视频的链接,但我认为它不起作用。我发现最相似的是这个link 我尝试使用此代码下载。

import requests
from bs4 import BeautifulSoup

'''
URL of the archive web-page which provides link to
all video lectures. It would have been tiring to
download each video manually.
In this example, we first crawl the webpage to extract
all the links and then download videos.
'''



def download_video_series(link):


    '''iterate through all links in video_links
    and download them one by one'''

    # obtain filename by splitting url and getting
    # last string
    file_name = link.split('/')[-1]+'.mp4'

    print
    "Downloading file:%s" % file_name

    # create response object
    r = requests.get(link, stream=True)

    # download started
    with open(file_name, 'wb') as f:
        for chunk in r.iter_content(chunk_size=1024 * 1024):
            if chunk:
                f.write(chunk)

    print(        "%s downloaded!\n" % file_name)




if __name__ == "__main__":
    # getting all video links

    # download all videos
    download_video_series('https://secure-embed.rtve.es/drmn/embed/video/5450714')

我也尝试使用wget,但它无法捕捉视频而不是text/html

有人知道吗?

【问题讨论】:

    标签: python html video download request


    【解决方案1】:

    首先,您需要确保您拥有下载和修改内容的权利——即使它是免费广播且未加密的,内容所有者也可能不允许修改和重复使用。

    假设您确实有紧身衣,那么您链接到的广播使用 HLS 流式传输视频。 HLS 是一种流式传输协议,可将视频分成多个块,通常为每个块提供不同的分辨率,以在给定设备和给定网络条件下实现最佳质量。

    构建一个从 HLS 直播流下载和重建视频的工具可能不是您想要解决的问题,因为您说您是该领域的新手,因此您很可能希望使用现有工具去做这个。

    如果您搜索“下载 HLS 视频”,有很多可用的 - 一个示例:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-02
      • 2022-07-21
      • 2017-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-10
      相关资源
      最近更新 更多