Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download youtube video in iOS Swift

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.

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

like image 973
Anand Mishra Avatar asked Jul 13 '16 09:07

Anand Mishra


2 Answers

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:

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:

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/

like image 137
Ayush Avatar answered Oct 13 '22 09:10

Ayush


If you are looking for a library then XCDYouTubeKit would be a good choice. If you are looking for an open source app then YouTag might be helpful.

like image 44
Youstanzr Avatar answered Oct 13 '22 09:10

Youstanzr