How I browse and watch youtube

5 replies [Last post]
albertoefg
Offline
Joined: 04/21/2016

There are 2 options that I use to watch youtube

1.- Our friend JadedCtrl has a collection of (pretty POSIX) shell scripts to browse YouTube quickly, efficiently, and without the bloat most command-line clients require.

Also, shellTube doesn't use the YouTube API at all. This avoids the annoying red-tapey stuff that goes with it -- IDs, registration, quota.

https://github.com/JadedCtrl/Shelltube

(yeah I pretty much copypaste the description :P her words are better than mine though )

2.- I also use this GUI client called Kaku http://kaku.rocks/ some videos some times not work though, but I think it is related to youtube limiting some videos (a couple months back a few applications like VLC, youtube-dl and new pipe broke because of changes on youtube)

https://github.com/EragonJ/Kaku

So that is what I mostly use. Any comments and advice would be appreciated. In virtue of the recent problems with youtube-dl I thought this might help.

hack and hack
Offline
Joined: 04/02/2015

Kaku uses json, which doesn't mean a thing yet, but might be the same problem youtube-dl has.
Shelltube looks good, but a bit complicated (to me).

What about using wget? A simple script from these principles might be all it takes:
https://www.marksanborn.net/howto/using-wget-to-download-youtube-videos/

Well, at least for downloading, but not for streaming. Maybe this kind of script would be enough:
http://xmodulo.com/watch-live-streaming-video-command-line-linux.html

EDIT:
I just now modified my script to stream videos, and it just works using vlc + URL that I get from the browser with xclip. What *might* be problematic is the lack of video quality choice, but for streaming, I don't care at all. EDIT: https://askubuntu.com/questions/796575/how-to-force-command-line-vlc-to-stream-youtube-videos-of-specific-quality
In this specific case, youtube-dl was just an unnecessary step. But hey, I'm no programmer.

Now for download, It should work (gotta test) if expanding the script to tacke what's in the link above into account. Again, I have no idea if I can make a video quality choice, even if I never had to for now.

EDIT:
I'm a genius. Actually, not just yet :p
it works with youtube (basically it's vlc + URL), but not dailymotion for example (whereas youtube-dl does).
Ah, explanation here:https://forum.videolan.org/viewtopic.php?t=111180
Unfortunately, for now it works only with youtube. But it seems faster and more reliable.

albertoefg
Offline
Joined: 04/21/2016

Los of edits :) lol

Let me try it

hack and hack
Offline
Joined: 04/02/2015

Sure, here it is:
-
#!/bin/bash
xclip -selection clipboard blank
xdotool key --clearmodifiers F6
var=$(xclip -o)
#vlc $(youtube-dl --prefer-free-formats -g $var)
vlc $var
-
I kept the line with youtube-dl commented for illustration, though I used the clearmodifiers line twice in a row with it.
I just have the script linked to a keyboard shortcut.
The only obligation is to have the browser and the page active (selected).

Way too much edits ^^"
OK, one more EDIT, while I'm at it:
even on youtube, some videos don't work. it seems it's because the URL is super long.
So it's not really good enough yet :7

Aaaand I just found a (not tested) workaround :D
https://forum.videolan.org/viewtopic.php?t=120491
(though in the lua file, there's something called js_url, so maybe it's still not a solution.

Well, at least the lua parser works, if updated:
https://askubuntu.com/questions/197739/vlc-youtube-videos-wont-play-anymore/197766#197766

But then I'd neet other lua files for other websites.
Got it for dailymotion (just find dailymotion.lua, and put it in /usr/lib/vlc/lua/playlist/

Magic Banana

I am a member!

Offline
Joined: 07/24/2010

See (and maybe contribute to) https://trisquel.info/en/wiki/play-videos-without-using-flash for different solutions, which are not restricted to YouTube.

hack and hack
Offline
Joined: 04/02/2015

Good idea, and it does work better than Viewtube for me.
The only interrogation is, do the .lua files lead to JS execution? I can't find that js_url thing anywhere:

-- Descramble the URL signature using the javascript code that does that
-- in the web page
function js_descramble( sig, js_url )
-- Fetch javascript code
local js = { stream = vlc.stream( js_url ), lines = {}, i = 0 }

It seems there's also a local URL descrambler:
http://vlc-commits.videolan.narkive.com/ks7HYGfd/youtube-lua-remove-obsolete-static-signature-descrambling-code

It seems youtube-dl uses that too: https://github.com/nficano/pytube/issues/117

Else, catching the URL of the script with F6 and xclip and xdotool is still a bit tricky. Sometimes I have to try twice. but it's still less keystrokes than copying and pasting.

My own conclusion (based on my limited skills and research):
Viewtube is the safest, but doesn't work even with all youtube videos (I just tried with one).
Both using vlc with updated lua scripts and youtube-dl seem to be executing a short bit of js code from the web page that akes the URL readable.
Not sure for vlc, but it seems it does.
youtube-dl accesses more websites.

From there, it's up to each user: having a crippled access to the web, but fully safe,
or allowing some bit of JS from the webpage, which most likely isn't harmful
(at worst, it can steal data/install spyware, and this can be countered by sandboxing in theory).

Tough choices.