在iOS Swift中下载youtube视频

时间:2022-01-07 18:57:42

I am looking for solution to download video from youtube. i saw in youtube native application in ios they are providing a feature to save video for offline.

我正在寻找从youtube下载视频的解决方案。我在ios中看到了ios的原生应用程序,他们提供了一个保存视频离线的功能。

Is there any solution to download video in application? Or any API to download video.

在应用程序中下载视频有什么解决方案吗?或任何下载视频的API。

1 个解决方案

#1


2  

You can download video file from Youtube if we know youtube URL of the video. First you need to download files (HCYoutubeParser) into your project. Now you need to call following function into your code:

如果我们知道视频的youtube网址,您可以从Youtube下载视频文件。首先,您需要将文件(HCYoutubeParser)下载到项目中。现在您需要在代码中调用以下函数:

let video =  HCYoutubeParser.h264videosWithYoutubeURL(yturl!)
let downloadURL = video["medium"] as! String

Where yturl is video URL. We need to pass it into h264videosWithYoutubeURL function. HCYoutubeParser is a class which provides methods for converting Youtube video watch URL into video download URL. This can be done by Youtube video id also. Following method is used for that:

其中yturl是视频网址。我们需要将它传递给h264videosWithYoutubeURL函数。 HCYoutubeParser是一个提供将Youtube视频观看URL转换为视频下载URL的方法的类。这也可以通过Youtube视频ID来完成。以下方法用于:

let video =  HCYoutubeParser.h264videosWithYoutubeID(ytID!)
let downloadURL = video["medium"] as! String

Where ytID is id of Youtube video. In these code snippet we are getting download URL of medium quality video. For more info and HCYoutubeParser class follow this link: http://findnerd.com/list/view/How-to-download-videos-from-YouTube-in-iOS/22437/

其中ytID是Youtube视频的ID。在这些代码段中,我们获取了中等质量视频的下载URL。有关更多信息和HCYoutubeParser类,请点击此链接:http://findnerd.com/list/view/How-to-download-videos-from-YouTube-in-iOS/22437/

#1


2  

You can download video file from Youtube if we know youtube URL of the video. First you need to download files (HCYoutubeParser) into your project. Now you need to call following function into your code:

如果我们知道视频的youtube网址,您可以从Youtube下载视频文件。首先,您需要将文件(HCYoutubeParser)下载到项目中。现在您需要在代码中调用以下函数:

let video =  HCYoutubeParser.h264videosWithYoutubeURL(yturl!)
let downloadURL = video["medium"] as! String

Where yturl is video URL. We need to pass it into h264videosWithYoutubeURL function. HCYoutubeParser is a class which provides methods for converting Youtube video watch URL into video download URL. This can be done by Youtube video id also. Following method is used for that:

其中yturl是视频网址。我们需要将它传递给h264videosWithYoutubeURL函数。 HCYoutubeParser是一个提供将Youtube视频观看URL转换为视频下载URL的方法的类。这也可以通过Youtube视频ID来完成。以下方法用于:

let video =  HCYoutubeParser.h264videosWithYoutubeID(ytID!)
let downloadURL = video["medium"] as! String

Where ytID is id of Youtube video. In these code snippet we are getting download URL of medium quality video. For more info and HCYoutubeParser class follow this link: http://findnerd.com/list/view/How-to-download-videos-from-YouTube-in-iOS/22437/

其中ytID是Youtube视频的ID。在这些代码段中,我们获取了中等质量视频的下载URL。有关更多信息和HCYoutubeParser类,请点击此链接:http://findnerd.com/list/view/How-to-download-videos-from-YouTube-in-iOS/22437/