Initial code commit

master
Maxim Stewart 5 years ago
parent 031c4a2661
commit ab016cd7bf

@ -0,0 +1,14 @@
### Note ###
The WebExtension, which can be found under "add-on", connects to the native application and downloads the video using youtube-dl
The native application, which can be found under "app", listens for messages from the WebExtension. When it receives a message, the native application runs youtube-dl in the Downloads folder for the passed url from the WebExtension.
*** Look in your Downloads folder to find your video. ***
### Mac OS/Linux Setup ###
To get this working do the following:
1. Check that the [file permissions](https://en.wikipedia.org/wiki/File_system_permissions) for "youtube-dl-bridge.py" include the `execute` permission.
2. Edit the "path" property of "web_video_dl.json" to point to the location of "youtube-dl-bridge.py" on your computer.
3. copy "web_video_dl.json" to the correct location on your computer. See [App manifest location ](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Native_manifests#Manifest_location) to find the correct location for your OS.
4. Install the webextension and enjoy!

@ -0,0 +1,10 @@
// On a click on the browser action, send the app a message.
browser.browserAction.onClicked.addListener(() => {
// Create new connect to the app so we can dl multiple stuff at same time.
let port = browser.runtime.connectNative("web_video_dl");
browser.tabs.query({currentWindow: true, active: true}).then((tab) => {
tab = tab[0];
console.log("Downloding: " + tab.url);
port.postMessage(tab.url);
});
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

@ -0,0 +1,19 @@
{
"name": "Web Video Downloader",
"description": "Use youtube-dl to download videos from the web.",
"manifest_version": 2,
"version": "1.0",
"icons": { "64": "icons/video.png" },
"applications": {
"gecko": {
"id": "1itdominator@gmail.com",
"strict_min_version": "50.0"
}
},
"permissions": ["nativeMessaging", "activeTab"],
"background": { "scripts": ["background.js"] },
"browser_action": { "default_icon": "icons/video.png" }
}

@ -0,0 +1,7 @@
{
"name": "web_video_dl",
"description": "Video downloader using youtube-dl",
"path": "/insert/your/path/here/to/youtube-dl-bridge.py",
"type": "stdio",
"allowed_extensions": [ "1itdominator@gmail.com" ]
}

@ -0,0 +1,23 @@
#!/usr/bin/env python
import sys
import json
import struct
import subprocess
# Python 2.x version (if sys.stdin.buffer is not defined)
# Read a message from stdin and decode it.
def getMessage():
rawLength = sys.stdin.read(4)
if len(rawLength) == 0:
sys.exit(0)
messageLength = struct.unpack('@I', rawLength)[0]
message = sys.stdin.read(messageLength)
return json.loads(message)
while True:
receivedMessage = getMessage()
if receivedMessage:
command = "cd ~/Downloads && youtube-dl " + receivedMessage;
subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
Loading…
Cancel
Save