You are not logged in.

#1 2013-03-15 09:53:35

ma
Member
Registered: 2012-01-29
Posts: 47

ytcmd – execute shell commands on YouTube videos

ytcmd is a tool to execute shell commands on YouTube videos. It is written in Python 3.3, and is available under the MIT license. (GitHub page)

$ ytcmd SvaG0xDdP8g
Title:  The Space Shuttle (Narrated by William Shatner)
Length: 1:20:44
ID:     SvaG0xDdP8g

  45  720p webm 
  22  720p mp4  
  35  480p flv  
  43  360p webm 
  34  360p flv  
* 18  360p mp4  
   5  240p flv  
  36  240p 3gp  
  17  144p 3gp

Get the video URL (for the format marked with “*”):

$ ytcmd -u SvaG0xDdP8g
http://r6---sn-po8puxa-c0ql.c.youtube.com/ ...

Play with mplayer:

$ ytcmd --exec 'mplayer "$url"' SvaG0xDdP8g

Same, but fake the User-Agent, display the title in the titlebar, and allow seeking to a given time:

$ yt.play() { ytcmd -e 'exec mplayer -user-agent "$ua" -title "$title" ${ss:+-ss "$ss"} "$url"' "$@"; }
$ ss=15:00 yt.play SvaG0xDdP8g

Play in HD, but only WebM or MPEG-4 formats:

$ yt.play SvaG0xDdP8g 1080:720p/webm,mp4

Last edited by ma (2013-03-15 09:55:51)

Offline

#2 2013-04-07 18:09:54

prazzb
Member
Registered: 2012-10-12
Posts: 14

Re: ytcmd – execute shell commands on YouTube videos

it's good but it would have been better had you written a script on top of youtube-dl rather than re-inventing the wheel

Offline

#3 2013-04-07 19:11:02

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,644
Website

Re: ytcmd – execute shell commands on YouTube videos

prazzb wrote:

it's good but it would have been better had you written a script on top of youtube-dl rather than re-inventing the wheel

Re-inventing the wheel is a good way to learn. Of course, if this was purely for practical purposes then I agree.

Offline

Board footer

Powered by FluxBB