You are not logged in.

#1 2010-08-23 19:11:10

honki
Member
Registered: 2005-11-04
Posts: 16

ytmp - youtube without flash thanks to ngrep and mplayer

Hi,

I was looking for a good way to view youtube videos on my atom based netbook without flash (for obvious reasons...) and I actually used brad212's script for a while but it annoyed me that I still had to use flash to download the videos (for some reason flash can quite cpu intensive even when it's not actually playing a video). Therefore I wrote a small script which uses ngrep to search for youtube urls in my network traffic and youtube-dl to get the video urls for mplayer to playback. I've just been using it for a couple of hours but it actually seems to work surprisingly well smile So feel free to test it an report back if you find any bugs etc.

PKGBUILD: http://aur.archlinux.org/packages.php?ID=40172

Config:
- change INTERFACE in /usr/bin/ytmpd if you're not using eth0 (eg wlan0 if you're using wifi)
- by default, ytmp automatically downloads the best quality version of the video but with a max resolution of 480p. If you want to download the best version available (=HD), then simply remove (--max-quality=35 from /usr/bin/ytmpc in line 17). You can also customize the max-quality variable to your own liking (see here for available formats on youtube).

Usage:
- start the ngrep wrapper as root: /etc/rc.d/ytmpd start
- start the 'client' script as user: /usr/bin/ytmpc
- open any youtube video (url) in your browser

If you have zenity installed, it will display a small dialog when it detects a youtube url asking you if you want to view it with mplayer. If not, it will just start mplayer without confirmation. There will be a small delay before the video starts because youtube-dl needs a couple of seconds to detect the url and mplayer is caching 2mb of video data before starting playback.

Have fun wink

Last edited by honki (2010-08-23 19:17:08)

Offline

#2 2010-08-24 18:53:46

Rasi
Member
From: Germany
Registered: 2007-08-14
Posts: 1,914
Website

Re: ytmp - youtube without flash thanks to ngrep and mplayer

works nicely... do you think you can add a download option to the zenity message box?


He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.

Douglas Adams

Offline

#3 2010-08-24 20:56:10

Andrwe
Member
From: Leipzig/Germany
Registered: 2009-06-17
Posts: 322
Website

Re: ytmp - youtube without flash thanks to ngrep and mplayer

That's really nice work.
It would be nice if you can configure the client and daemon using a config-file in /etc/ so you don't have to modify the "binary".


Website: andrwe.org

Offline

#4 2010-08-24 23:32:29

honki
Member
Registered: 2005-11-04
Posts: 16

Re: ytmp - youtube without flash thanks to ngrep and mplayer

Thanks for the feedback guys. I just uploaded a new version.

New features:
- Configuration in /etc/ytmp.conf
- You can choose between zenity, kdialog and no GUI
- You can choose to download the video

Offline

#5 2010-08-25 17:24:23

Andrwe
Member
From: Leipzig/Germany
Registered: 2009-06-17
Posts: 322
Website

Re: ytmp - youtube without flash thanks to ngrep and mplayer

Would it be possible to expand ytmp to support other sites using flash too?


Website: andrwe.org

Offline

#6 2010-08-25 18:29:12

splittercode
Member
From: WI, USA
Registered: 2010-03-16
Posts: 203

Re: ytmp - youtube without flash thanks to ngrep and mplayer

This is really great, I highly recommend it to... everyone. Thanks for taking the time to create/share it honki, it's great to not have to bother with cpu-intensive flash or youtube's crappy interface. smile

Offline

#7 2010-08-25 20:17:29

Rasi
Member
From: Germany
Registered: 2007-08-14
Posts: 1,914
Website

Re: ytmp - youtube without flash thanks to ngrep and mplayer

honki wrote:

Thanks for the feedback guys. I just uploaded a new version.

New features:
- Configuration in /etc/ytmp.conf
- You can choose between zenity, kdialog and no GUI
- You can choose to download the video

on some videos i get a "youtube-dl: unknown option -W" now...


He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.

Douglas Adams

Offline

#8 2010-08-25 22:37:46

honki
Member
Registered: 2005-11-04
Posts: 16

Re: ytmp - youtube without flash thanks to ngrep and mplayer

Rasi wrote:
honki wrote:

Thanks for the feedback guys. I just uploaded a new version.

New features:
- Configuration in /etc/ytmp.conf
- You can choose between zenity, kdialog and no GUI
- You can choose to download the video

on some videos i get a "youtube-dl: unknown option -W" now...

Hm, I can't reproduce this myself, but it's probably because I forgot to quote a string in the youtube-dl call. I just uploaded a new version which should hopefully fix this. If not please send me a link to a video where this happens.

Andrwe wrote:

Would it be possible to expand ytmp to support other sites using flash too?

I don't see a way for this method to work for flash videos in general, but I can add support for flash video sites provided there is a known way to download the video based on only the url/html. Which sites do you have in mind particularly? youtube-dl supports metacafe.com, google video, photobucket, yahoo video an dailymotion, so these should be really easy to implement. I'll probably add support for them and vimeo in the next version.

Offline

#9 2010-08-26 05:03:40

Sara
Member
From: USA
Registered: 2009-07-09
Posts: 219
Website

Re: ytmp - youtube without flash thanks to ngrep and mplayer

This works beautifully with YouTube videos opened with my text browser of choice, w3m. Thanks! big_smile


Registed Linux User 483618

Offline

#10 2010-08-26 07:23:04

hatten
Arch Linux f@h Team Member
From: Sweden, Borlange
Registered: 2009-02-23
Posts: 736

Re: ytmp - youtube without flash thanks to ngrep and mplayer

Wanna add support for dmenu too? Then it would be perfect for me!

Offline

#11 2010-08-26 10:14:36

idosh
Member
Registered: 2008-11-07
Posts: 42

Re: ytmp - youtube without flash thanks to ngrep and mplayer

Works perfectly on my netbook! Thank you very much!

Offline

#12 2010-08-26 13:37:38

whompus
Member
From: Durham. UK
Registered: 2005-08-09
Posts: 256

Re: ytmp - youtube without flash thanks to ngrep and mplayer

Just tried this and it works great. Thanks

Offline

#13 2010-08-26 20:49:02

Rasi
Member
From: Germany
Registered: 2007-08-14
Posts: 1,914
Website

Re: ytmp - youtube without flash thanks to ngrep and mplayer

hatten wrote:

Wanna add support for dmenu too? Then it would be perfect for me!

oh yes, that would rock totally! smile


He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.

Douglas Adams

Offline

#14 2010-08-27 09:57:19

archman-cro
Member
From: Croatia
Registered: 2010-04-04
Posts: 943
Website

Re: ytmp - youtube without flash thanks to ngrep and mplayer

Wow, this plugin is nice!! Keep up the good work! smile
Edit: Getting this error

youtube-dl: error: no such option: -0

on http://www.youtube.com/watch?v=-0NT0dmxtdY
Video won't play. Can it be cause of the video url part (...=-0NT0...)? Can anyone reproduce?

Last edited by archman-cro (2010-08-27 11:30:06)

Offline

#15 2010-08-27 15:09:37

Rasi
Member
From: Germany
Registered: 2007-08-14
Posts: 1,914
Website

Re: ytmp - youtube without flash thanks to ngrep and mplayer

archman-cro wrote:

Wow, this plugin is nice!! Keep up the good work! smile
Edit: Getting this error

youtube-dl: error: no such option: -0

on http://www.youtube.com/watch?v=-0NT0dmxtdY
Video won't play. Can it be cause of the video url part (...=-0NT0...)? Can anyone reproduce?

i want to add this one:

cUsage: youtube-dl [options] url...

youtube-dl: error: no such option: -7
Usage: youtube-dl [options] url...

on this url:
http://www.youtube.com/watch?v=-79gQG-UGZo&feature=sub

Last edited by Rasi (2010-08-27 15:09:53)


He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.

Douglas Adams

Offline

#16 2010-08-27 15:11:43

archman-cro
Member
From: Croatia
Registered: 2010-04-04
Posts: 943
Website

Re: ytmp - youtube without flash thanks to ngrep and mplayer

Seems like the "minus" ("-" sign) in url is a problem here. Just my inexperienced opinion. big_smile

Btw, is there a way to mod the app to use SMPlayer? I've tried bashing the code by replacing "mplayer" with "smplayer", but it failed to start cause SMPlayer doesn't recognize the "cache" flag.

Also, is it supposed to cache the file? I get "Cache not filling!" in a terminal.

Last edited by archman-cro (2010-08-27 16:15:21)

Offline

#17 2010-08-27 18:28:23

hatten
Arch Linux f@h Team Member
From: Sweden, Borlange
Registered: 2009-02-23
Posts: 736

Re: ytmp - youtube without flash thanks to ngrep and mplayer

Always enclose the URL with " , there are many signs that will make it fail or act weird, eg: & -

Offline

#18 2010-08-28 07:18:02

tlvince
Member
Registered: 2010-07-06
Posts: 68
Website

Re: ytmp - youtube without flash thanks to ngrep and mplayer

There are many alternative ways to do this, but I like the idea behind this one. It may not be the most simple, but it's browser agnostic and works rather well!

However, I wanted to make some changes, but found the code difficult to read. Therefore, since it's GPL, I've made a fork:

ytmp

(hope you don't mind).

As well as turning it into a proper project, the main changes can be found here and here.

Offline

#19 2010-08-28 08:58:50

Rasi
Member
From: Germany
Registered: 2007-08-14
Posts: 1,914
Website

Re: ytmp - youtube without flash thanks to ngrep and mplayer

tlvince wrote:

There are many alternative ways to do this, but I like the idea behind this one. It may not be the most simple, but it's browser agnostic and works rather well!

However, I wanted to make some changes, but found the code difficult to read. Therefore, since it's GPL, I've made a fork:

ytmp

(hope you don't mind).

As well as turning it into a proper project, the main changes can be found here and here.

your fork also has the escaping errors...


He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.

Douglas Adams

Offline

#20 2010-08-28 12:33:16

tlvince
Member
Registered: 2010-07-06
Posts: 68
Website

Re: ytmp - youtube without flash thanks to ngrep and mplayer

So it does... (sorry I didn't check for that). However, it looks like its an issue with youtube-dl itself:

$ youtube-dl "-0NT0dmxtdY"
Usage: youtube-dl [options] url...

youtube-dl: error: no such option: -0

$ youtube-dl "-79gQG-UGZo"
Usage: youtube-dl [options] url...

youtube-dl: error: no such option: -7

$ youtube-dl "flglMLKnoRY"
[youtube] Setting language
[youtube] flglMLKnoRY: Downloading video webpage
[youtube] flglMLKnoRY: Downloading video info webpage
[youtube] flglMLKnoRY: Extracting video information
...

Reported here: #199 Leading dash in url throws error

Last edited by tlvince (2010-08-28 12:54:28)

Offline

#21 2010-08-28 19:39:07

honki
Member
Registered: 2005-11-04
Posts: 16

Re: ytmp - youtube without flash thanks to ngrep and mplayer

hi guys,

thanks for all the feedback. I just merged my changes with tlvince's improved version (thanks again!) and updated the PKGBUILD to fetch the newest version of ytmp from http://github.com/tlvince/ytmp smile

changes so far:
* youtube urls with - fixed
* support for vimeo
* a couple of small bugfixes / cosmetic changes
by tlvince:
* support for xdg config files ($HOME/.config/ytmp/ytmp.conf)
* initial support for dmenu

Offline

#22 2010-08-28 21:22:49

honki
Member
Registered: 2005-11-04
Posts: 16

Re: ytmp - youtube without flash thanks to ngrep and mplayer

archman-cro wrote:

Seems like the "minus" ("-" sign) in url is a problem here. Just my inexperienced opinion. big_smile

Btw, is there a way to mod the app to use SMPlayer? I've tried bashing the code by replacing "mplayer" with "smplayer", but it failed to start cause SMPlayer doesn't recognize the "cache" flag.

Also, is it supposed to cache the file? I get "Cache not filling!" in a terminal.

Just update to the newest version and configure PLAYER= in /etc/ytmp.conf smile You don't need caching with smplayer because it already passes this parameter to mplayer (Preferences -> Performance -> Cache). But yes, it is actually supposed to cache the file and as far as I can tell it is also working, at least on my machine. But caching is not to important anyways as long as your internet connection is fast enough...

Offline

#23 2010-08-28 21:29:26

archman-cro
Member
From: Croatia
Registered: 2010-04-04
Posts: 943
Website

Re: ytmp - youtube without flash thanks to ngrep and mplayer

honki wrote:

Just update to the newest version and configure PLAYER= in /etc/ytmp.conf smile

Nice! smile

honki wrote:

You don't need caching with smplayer because it already passes this parameter to mplayer (Preferences -> Performance -> Cache). But yes, it is actually supposed to cache the file and as far as I can tell it is also working, at least on my machine. But caching is not to important anyways as long as your internet connection is fast enough...

Heh, well, when I'm trying to watch some 720p video, it's all choppy, and then I instictively press pause in hope it will cache some, so I can view it. smile
Without that feature (caching) I must just use a normal flash, pause at the start, wait for it to finish caching, and then view it mplayer. That way the clip is watchable.

Cheers!

Offline

#24 2010-09-02 19:26:13

cmudik
Member
From: Czech Republic
Registered: 2010-06-02
Posts: 12

Re: ytmp - youtube without flash thanks to ngrep and mplayer

Hi,

nice work, but ytmp works for me only on vimeo.com site. Ytmpd is storing only vimeo video ids in /tmp/ytmpurls. I tried run this command in terminal


sudo ngrep -W byline -qilw 'get' tcp dst port 80 -d eth0

and for videos on youtube.com i get this

T 10.109.253.113:40425 -> 74.125.157.101:80 [AP]
GET /csi?v=2&s=youtube&action=watch5&srt=527&fmt=34&asv=3&plid=AASPS6NaK3VK-kTy&sprot=0&fv=LNX%2010%2C1%2C82%2C76&manu=Adobe%20Linux&vid=jfveZIXSDCg&rt=ct.102,bf.107,ol.487,fs.907,gv.1342,fvb.3620,vr.3709,vl.2367,aft.3709&e=907113,907025,905602 HTTP/1.1.
Host: csi.gstatic.com.
Connection: keep-alive.
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.127 Safari/533.4.
Referer: [url]http://www.youtube.com/watch?v=G0_2FvKkDPo&feature=rec-LGOUT-real_rn-1r-35-HM[/url].
Accept: */*.
Accept-Encoding: gzip,deflate,sdch.
Accept-Language: cs-CZ,cs;q=0.8.
Accept-Charset: windows-1250,utf-8;q=0.7,*;q=0.3.
youtube-dl G0_2FvKkDPo

works.

Ngrep for vimeo.com

T 10.109.253.113:52323 -> 92.122.188.107:80 [AP]
GET /images/staff.gif HTTP/1.1.
Host: a.vimeocdn.com.
Connection: keep-alive.
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.127 Safari/533.4.
Referer: [url]http://vimeo.com/14592941[/url].
Accept: */*.
Accept-Encoding: gzip,deflate,sdch.
Accept-Language: cs-CZ,cs;q=0.8.
Accept-Charset: windows-1250,utf-8;q=0.7,*;q=0.3.

Offline

#25 2010-09-03 06:21:57

tlvince
Member
Registered: 2010-07-06
Posts: 68
Website

Re: ytmp - youtube without flash thanks to ngrep and mplayer

@cmudik: we experienced some oddities recently similar to what you describe. Firstly can you try updating? The latest commit hash is: c032575682b1a3150b64

Last edited by tlvince (2010-09-03 06:45:29)

Offline

Board footer

Powered by FluxBB