summaryrefslogtreecommitdiff
path: root/.config/qutebrowser/userscripts/camel.py
blob: 926d6e94844652fc903b605880560385b8e09093 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/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()