Added a Python plugin to continously monitor our clipboard to start the download automatically
This commit is contained in:
parent
23edc49509
commit
039a74b984
23
python_plugin/README.md
Normal file
23
python_plugin/README.md
Normal file
@ -0,0 +1,23 @@
|
||||
# Youtube-dl plugin to automatically start your download:
|
||||
A Python script to constantly watch your clipboard content, and download if its a youtube link!
|
||||
|
||||
|
||||
#Python Libraries you might need to install:
|
||||
-> Pyperclip
|
||||
|
||||
#Steps to setup:
|
||||
1. Install Pyperclip python plugin
|
||||
2. Place youtube.py in the same folder where your youtube-dl executable(by rg3) is there
|
||||
3. Make sure the name of the downloader executable is youtube.exe
|
||||
4. Run Youtube.py
|
||||
|
||||
#Screenshot:
|
||||

|
||||
|
||||
# You are good to go!
|
||||
|
||||
So from now on, if you copy a youtube link it will automatically start to download the video!
|
||||
Cheers :)
|
||||
|
||||
|
||||
Thanks rg3 for youtube-dl and making it as open source!
|
BIN
python_plugin/screenshot.png
Normal file
BIN
python_plugin/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 155 KiB |
59
python_plugin/youtube.py
Normal file
59
python_plugin/youtube.py
Normal file
@ -0,0 +1,59 @@
|
||||
import time
|
||||
import threading
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
import pyperclip
|
||||
|
||||
def is_url_but_not_bitly(url):
|
||||
if url.startswith("https://www.youtube.com"):
|
||||
return True
|
||||
return False
|
||||
|
||||
def print_to_stdout(clipboard_content):
|
||||
print " Yosh! Found an URL"
|
||||
tempstring = str(clipboard_content)
|
||||
pyperclip.copy('')
|
||||
print " Launching youtube-dl to download"
|
||||
with open(os.devnull, "w") as fnull:
|
||||
subprocess.call("start youtube "+tempstring, stdout = fnull, stderr = fnull, shell = True)
|
||||
|
||||
class ClipboardWatcher(threading.Thread):
|
||||
def __init__(self, predicate, callback, pause=5.):
|
||||
super(ClipboardWatcher, self).__init__()
|
||||
self._predicate = predicate
|
||||
self._callback = callback
|
||||
self._pause = 5
|
||||
self._stopping = False
|
||||
|
||||
def run(self):
|
||||
recent_value = ""
|
||||
while not self._stopping:
|
||||
tmp_value = pyperclip.paste()
|
||||
if tmp_value != recent_value:
|
||||
recent_value = tmp_value
|
||||
if self._predicate(recent_value):
|
||||
self._callback(recent_value)
|
||||
time.sleep(self._pause)
|
||||
|
||||
def stop(self):
|
||||
self._stopping = True
|
||||
|
||||
def main():
|
||||
watcher = ClipboardWatcher(is_url_but_not_bitly,
|
||||
print_to_stdout,
|
||||
5.)
|
||||
watcher.start()
|
||||
while True:
|
||||
try:
|
||||
print "Waiting for a youtube URL..."
|
||||
time.sleep(10)
|
||||
except KeyboardInterrupt:
|
||||
watcher.stop()
|
||||
break
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
x
Reference in New Issue
Block a user