This post shows you how to download the video from the ted.com using the Javascript:
The video URLs of ted.com have been stored explicitly in HTML source code, as follows:
It can be parsed via regular expressions despite that the URIs are expressed over Javascript code snippets instead of actual HTML tags. The video URIs were stored using meta tag video:src, which is easier to parse.
We can use regular expression to parse these URIs, which store the real ted video URLs for different resolution. The following Javascript code has been added to the ted video downloader.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | if (domain.includes("ted.com")) { if (!ValidURL(video_url)) { var re = /{"uri":"([^"\']+)"/gi; var found = re.exec(html); var video_url_arr = []; while (found != null) { var tmp_url = CheckURL(found[1]); if (ValidURL(tmp_url)) { video_url_arr.push(tmp_url); } found = re.exec(html); } if (valid_domain) { if (video_url_arr.length > 0) { chrome.runtime.sendMessage({ action: "getSource", source: JSON.stringify(video_url_arr) }); } else { chrome.runtime.sendMessage({ action: "getSource", source: JSON.stringify(CheckURL(video_url)) }); } } } } |
if (domain.includes("ted.com")) { if (!ValidURL(video_url)) { var re = /{"uri":"([^"\']+)"/gi; var found = re.exec(html); var video_url_arr = []; while (found != null) { var tmp_url = CheckURL(found[1]); if (ValidURL(tmp_url)) { video_url_arr.push(tmp_url); } found = re.exec(html); } if (valid_domain) { if (video_url_arr.length > 0) { chrome.runtime.sendMessage({ action: "getSource", source: JSON.stringify(video_url_arr) }); } else { chrome.runtime.sendMessage({ action: "getSource", source: JSON.stringify(CheckURL(video_url)) }); } } } }
This has been added to the Chrome Extension Video Download Helper and also available in Online Universal Video Downloader and TED Video Downloader.
This is how it looks like when the Video Download Helper is able to parse the multiple Video URIs.
Relevant Video Download Posts
Here are some posts that relate to download videos (parser):- How to Download Any Videos in Chrome Browser and Merge Video Segments?
- How to Solve 403 Forbidden Error (Denied by Referer ACL) when Downloading Weibo Video?
- VideoDownloader Update: New UI, d.tube and steemit video URL parser, code refactoring!
- VideoDownloader Update: VIP Feature of Server Video Parser
- How to Download Tumblr Posts?
- A Home-made Video Download Helper (Client + Server)
- The Simple Video .m3u8 Downloader/Parser in PHP and Javascript
- How to Download Instagram Videos using PHP and Javascript?
- How to Download Video via Workflow APP?
- The TED Video Downloader
- Adding `Image Download List` to the Popular `VideoDownloadHelper` Chrome Extension
You may also like: 怎么样下载 TED 视频?
–EOF (The Ultimate Computing & Technology Blog) —
loading...
Last Post: Does CloudFlare Cache 403 and 503 By Default?
Next Post: Coding Review - How would you convert this 'goto' ?
Lorem ipsum 123 789