Chrome Extension: Adding XiaoKaXiu Video Download Support

Words
115
Reading
1 min
Listen
Play
9y

Previously, the Chrome Extension Video Download Helper has been accepted by Google Web Store (The number of Current Users is more than 10,000) and Utopian. Today, I have spent some time adding the support of parsing the video URLs from xiaokaxiu.com

The github project: https://github.com/DoctorLai/VideoDownloadHelper
The Chrome Webstore: https://chrome.google.com/webstore/detail/simple-video-download-hel/ilcdiicigjaccgipndigcenjieedjohj
This commit: https://github.com/DoctorLai/VideoDownloadHelper/commit/fd1822391ae3bc3dada448ed5d362506df2f6f72#diff-337d9b5b4942fb84e0ca186f8db40d15
It has also been implemented in Server's API - Online Universal Video Downloader and Xiaokaxiu Downloader

This commit

XiaoKaXiu uses Miaopai as the backend video storage server, so the task is to parse the video ID from HTML source.

    // https://v.xiaokaxiu.com/v/fhX23JOcSbVEJOQ9LFKtOP2WBkeP1AA-.html
    if (domain.includes("xiaokaxiu.com")) {
        if (!ValidURL(video_url)) {
            // http://gslb.miaopai.com/stream/fhX23JOcSbVEJOQ9LFKtOP2WBkeP1AA-_m.jpg
            var re = /player.swf\?scid=([^"\'&]+)/gi;
            var found = re.exec(html);                        
            var video_url_arr = [];
            while (found != null) {
                var tmp_url = "http://gslb.miaopai.com/stream/" + found[1] + ".mp4";
                var tmp_url = CheckURL(tmp_url);
                if (ValidURL(tmp_url)) {
                    video_url_arr.push(tmp_url);    
                    break;
                }                            
                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))
                    });                              
                }
            }
        }
    } 

It works!

image.png

Proof of Work

My github id is doctorlai and you can find my steemit URL at profile page: https://github.com/DoctorLai/



Posted on Utopian.io - Rewarding Open Source Contributors

Chrome Extension: Adding XiaoKaXiu Video Download Support | Ecency