A Home-made Video Download Helper (Client + Server) – Simple way to Download Videos


About 2 months ago, I have created an online tool https://weibomiaopai.com that helps to analyse the real video URL behind some popular video resources e.g. youtube, tumblr, instagram etc.

The idea behind the web tool is to use Ajax to contact 3 powerful API servers. The advantage is that you can focus on the URL-parsing algorithms on the server without touch a single line of code in the client. And the users will be using the latest API instantly without having to upgrade their client software.

Later, The Chrome Extension (Video Download Helper) comes out, which is the client software and it is luckily updated by Chrome WebStore at regular basis. It is a handy tiny tool that does not take too much the users’ space (a tiny icon and less than 1MB resources files). It helps to get the real video URL of the current active tab without having to visit the online tool.

video-download-helper-chrome-extension A Home-made Video Download Helper (Client + Server) - Simple way to Download Videos tools / utilities video download tutorial

video-download-helper-chrome-extension

However, it does not improve the accuracy. For some video sites, the PHP crawler is hard or nearly impossible to see the useful HTML as the logged-in users see. So it makes it hard for remote servers to parse the real video URLs without being actually logged-in to the site.

It is still possible, but harder to let the bots log in with the official APIs (but they usually require manual approval and are rate limited). Some proposes simulating crawling the user login page and prepare the cookie data. But both methods are not easy.

Video Client Parser

It turns out that with Chrome Extension, it is easy to get the HTML string of arbitrary video URLs without having to worry about the Ajax same-origin policy. You just have to give your extension “all-urls” permission and it is good to go.

For example, the following JS snippet is the core piece of code that downloads the Instagram video.

1
2
3
4
5
6
7
// instagram
if (!ValidURL(video_url)) {
    video_dom = document.querySelector("meta[property='og:video:secure_url']");
    if (video_dom) {
        video_url = video_dom.getAttribute("content");
    }
}
// instagram
if (!ValidURL(video_url)) {
    video_dom = document.querySelector("meta[property='og:video:secure_url']");
    if (video_dom) {
        video_url = video_dom.getAttribute("content");
    }
}

With the Client + Server approach, I believe this tiny Chrome Extension will be very much useful and powerful. Currently, it supports Youtube, Instagram, Tumblr, and so many more!

Relevant Video Download Posts

Here are some posts that relate to download videos (parser):

You may also like: 说说我那复活的视频下载插件

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
578 words
Last Post: How to Download Instagram Videos using PHP and Javascript?
Next Post: Why and When should you do a Profiling on Your Application?

The Permanent URL is: A Home-made Video Download Helper (Client + Server) – Simple way to Download Videos

One Response

Leave a Reply