Skip to content

sonichy/VideoGrab

Repository files navigation

Chrome Extension: VideoGrab

Analyze video webpage, and display video url in a box.
You can play HLS(m3u8) in Chrome by HLSPlayer extention.

alt

Thanks

Video providers.

Reference

YouKuDownLoader

Supported Sites

LOGONameSiteCondition
音悦Taiyinyuetai.commp4
优酷youku.comflv或mp4片段列表 + m3u8(不能拖动进度)
芒果tvmgtv.comm3u8(能拖动进度)
搜狐视频tv.sohu.commp4片段列表
腾讯视频v.qq.com...
5656.com...

2.0 (2017-10)

Video right menu send to native video player.

Chrome Extension Start Up Native Software

http://match-yang.blog.163.com/blog/static/2109902542014319103739996/
http://blog.csdn.net/ztmaster/article/details/52684772
1.Chrome Extension Support

manifest.json
"permissions": [ "nativeMessaging" ]
var port = null;
var nativeHostName = "videograb";

function onDisconnected(){
	console.log( "Disconnect " + chrome.runtime.lastError.message);
	port = null;
}

function connectToNativeHost(){
	port = chrome.runtime.connectNative(nativeHostName);
	port.onDisconnect.addListener(onDisconnected);
}

chrome.contextMenus.create({
	"id" : "CMVideoGrab",
	"title" : "播放视频",
	"contexts" : ["video","link"]
});

chrome.contextMenus.onClicked.addListener(function(info, tab){
	//console.log(info);
	if(info.menuItemId == 'CMVideoGrab'){
		connectToNativeHost();
		console.log(info.srcUrl);
		port.postMessage(info.srcUrl);
	}
});

2.Software Receive Parameters
Qt(C++)

QMediaPlayer *player;
QStringList Largs = QApplication::arguments();
qDebug() << Largs;
if(Largs.length()>1){
    if(!Largs.at(1).contains("chrome-extension://")){
    QUrl url(Largs.at(1));
    open(url.toLocalFile());
}else{    
    int length = 0;
    //read the first four bytes (=> Length)
    //getwchar: receive char from stdin
    //putwchar: write char to stdout
    for (int i = 0; i < 4; i++) {
        length += getwchar();
    }
    //read the json-message
    QString url = "";
    for (int i = 0; i < length; i++) {
        url += getwchar();
    }
    //浏览器端传来的数据会有一个双引号引在两端
    url = url.mid(1, url.length()-2);
    qDebug() << url;
    if(url != ""){
        ui->tableWidget->hide();
        player->setMedia(QUrl(url));
        player->play();
        setWindowTitle(url);
    }
}

3.Config file
path: Software absolute path
allowed_origins: chrome-extension://*

videograb.json
{
	"name": "videograb",
	"description": "Chrome send video url to native app.",
	"path": "/media/sonichy/job/HY/Linux/Qt/HTYMP/HTYMP",
	"type": "stdio",
	"allowed_origins": [ "chrome-extension://jiahehpnnhnnohoaknibedkbkdkibeho/"	]
}

Linux Path:~/.config/google-chrome/NativeMessagingHosts
Windows运行:REG ADD "HKCU\Software\Google\Chrome\NativeMessagingHosts\videograb" /ve /t REG_SZ /d "%~dp0videograb.json" /f

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published