rkd77 / elinks

Fork of elinks
Other
350 stars 38 forks source link

Youtube music #180

Open Zedai00 opened 2 years ago

Zedai00 commented 2 years ago

Can youtube music run in elinks in anyway since it shows deprecated browser warning and to install chrome.

rkd77 commented 2 years ago

I don't know how looks like html source code of youtube music page, but do not expect elinks js to handle it soon. If you have some programming skills it should be doable I guess in your favourite scripting language and preformat_html_hook of elinks. For example mpv accept urls, so task would be to "combine" such a url and pass it to mpv.

rkd77 commented 2 years ago

If youtube music are youtube videos, then you can do something like this: Requirements: systemd (optional) mpv socat elinks with python scripting 1) create systemd unit for mpv as in contrib/audio . You can add --no-video. Enable and start it. 2) compile contrib/audio/echo.c as echo.exe and put in path 3) build elinks --with-python or -Dpython=true 4) copy contrib/python/* to ~/.elinks/ and in ~/.elinks/hooks.py add some code:

import elinks
import os
from urllib.parse import urlparse, parse_qs
from importlib import reload

def follow_url_hook(url):
    google_redirect = ('https://www.google.com/url?','http://www.google.com/url?')
    if url.startswith(google_redirect):
        try:
            url = parse_qs(urlparse(url).query)['q'][0]
        except:
            pass
    if url.startswith('https://www.youtube.com/watch?'):
        os.system("echo.exe %s | socat - /tmp/mpv.sock 2> /dev/null > /dev/null" % url)
        return ''

and other code .

Now go to google.com or duckduckgo.com and search: site:youtube.com something If you click on links it should be added to playing queue.

Note that you should add some anti command injection before os.system(...), but I don't know yet how to do it.