#!/usr/bin/env python # coding=utf-8 """ Description: Qutebrowser userscript. Allows you to download and watch a youtube video Keyboard binding: config.bind("\\", 'hint all userscript watchyt.py') Config file location: ~/.config/qutebrowser/config.py Script file location: ~/.local/share/qutebrowser/userscripts/watchyt.py Manually set keybinding: :bind \ hint all userscript watchyt.py Usage: Press \ then the hint keys for the video you wish to watch. You must select the video title not the image This is my first Qutebrowser plugin so it is pretty basic right now. Why download and watch when you can stream to mpv? mpv has a thumbnails plugin that doesn't work when streaming. You don't have to deal with buffering when it is already downloaded. """ from __future__ import unicode_literals import os from executor import execute from lxml import html from qutescript import userscript @userscript def search_camel(request): # TODO: Add title, url, img, filepath to a database #dom = html.parse(request.html) camel_url = 'https://camelcamelcamel.com/search?sq=%s' % os.environ["QUTE_URL"].strip() with open(os.environ['QUTE_FIFO'], 'w') as fifo: fifo.write('open -t %s' % camel_url) if __name__ == "__main__": search_camel()