Added download feature for Unix, Linux, and MacOS systems using native messaging.

This commit is contained in:
2019-01-07 01:48:10 -06:00
parent e5d019fdbf
commit a638cefe21
7 changed files with 80 additions and 9 deletions

7
app/web_video_dl.json Normal file
View File

@@ -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": [ "webVidDownloader@1itdominator.com", "betterYoutube@itdominator.com" ]
}

23
app/youtube-dl-bridge.py Executable file
View File

@@ -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)