Notices


Reply
Thread Tools
Posts: 187 | Thanked: 345 times | Joined on Nov 2009
#1
Hello everyone.

I've hacked together a small tool that lets you:
  • Search for videos
  • Download videos via a queue that runs in the background
  • Manipulate the download queue
  • Watch videos directly without the queued download

It's in extras-devel.

But why? There are plenty of GUI frontends for youtube already! True, but to be honest after trying all of them, I found that not a single one of them is usable for me. They all are slow to load and navigate (the N900 is to blame for this, not the authors of the GUI tools), searching is a pain (The Youtube API is responsible for this one) and all I really want is to quickly find and download and watch some videos that I remember having seen on youtube - this is my use case.

About the Youtube API problem (you can skip this): The search results the Youtube API gives are utter shite. For example, try doing a web search for "gremlinz aspect gavel" and you'll find a perfectly fine list of results. However supplying the Youtube API with this search string reveals no results at all. All of the GUI tools are using the API directly and hence I can't really find anything I previously found on a PC. With this CLI tool, you can just search for something really broad and then grep for whatever is important to you.

Demonstration:
Let's do a search for 'gremlinz'. The Youtube API provides 50 search results at a time at max. Run the same command repeatedly and it will show 50 more results each time.
Code:
user@Nokia-N900:~/ytcli$ ytcli -f "gremlinz"
1: GBP.Gremlinz Teaser.
2: GBP.Gremlinz.NORTHSTAR 2010. Caked
3: GBP Boreal Gremlinz 2010
4: Gremlinz & Stranjah - Blues VIP (Metalheadz Exclusive) [HD]
5: Gremlinz - Armshouse
6: GBP.Gremlinz.RIP KingVale.2010
7: Terror Danjah Gremlinz (The Instrumentals) Planet Mu 29/9/08 3LP/CD
8: Gremlinz - Annexed
--snip--
So I wanted to find a track by Gremlinz called 'The Gavel'. Note that the Youtube API provides zero results for "gremlinz gavel" or similar terms. This is why it sucks. But no problem:
Code:
user@Nokia-N900:~/ytcli$ ytcli -f "gremlinz" | grep -i "gavel"
28: Gremlinz featuring Aspect - The Gavel [HD]
There it is! I want to queue that track for download:
Code:
user@Nokia-N900:~/ytcli$ ytcli -q 28
Added: Gremlinz featuring Aspect - The Gavel [HD]
It will now be downloaded to /home/user/MyDocs/.videos/ytcli/. When it's done there will be a banner info and I can check what's in the queue and how far the download is using the -s trigger:
Code:
user@Nokia-N900:~/ytcli$ ytcli -s
>> 1 downloads in the queue:
0: Gremlinz featuring Aspect - The Gavel [HD]
>> Current or most recent download log:
[youtube] Setting language
[youtube] AnPDHRqLVEk: Downloading video webpage
[youtube] AnPDHRqLVEk: Downloading video info webpage
[youtube] AnPDHRqLVEk: Extracting video information
[download] Destination: Gremlinz_featuring_Aspect_The_Gavel_HD-AnPDHRqLVEk.flv
[download]   7.4% of 12.20M at  227.32k/s ETA 00:50
Let's search and queue some more stuff...
Code:
user@Nokia-N900:~/ytcli$ ytcli -f "technical itch" | grep -i rukus
1: Technical Itch - The Rukus
8: Tech itch 1337-The Rukus
23: Technical Itch - The Rukus
38: Technical Itch - The Rukus (D. Kay VIP)
user@Nokia-N900:~/ytcli$ ytcli -q 38
Added: Technical Itch - The Rukus (D. Kay VIP)
user@Nokia-N900:~/ytcli$ ytcli -s
>> 2 downloads in the queue:
0: Gremlinz featuring Aspect - The Gavel [HD]
1: Technical Itch - The Rukus (D. Kay VIP)
>> Current or most recent download log:
[youtube] Setting language
[youtube] AnPDHRqLVEk: Downloading video webpage
[youtube] AnPDHRqLVEk: Downloading video info webpage
[youtube] AnPDHRqLVEk: Extracting video information
[download] Destination: Gremlinz_featuring_Aspect_The_Gavel_HD-AnPDHRqLVEk.flv
[download]  21.3% of 12.20M at   79.78k/s ETA 02:03
user@Nokia-N900:~/ytcli$ ytcli -f "a-sides" | grep -i ruff
4: a sides - ruff it up
user@Nokia-N900:~/ytcli$ ytcli -q 4
Added: a sides - ruff it up
Now there are three items in the queue:
Code:
user@Nokia-N900:~/ytcli$ ytcli -s
>> 3 downloads in the queue:
0: Gremlinz featuring Aspect - The Gavel [HD]
1: Technical Itch - The Rukus (D. Kay VIP)
2: a sides - ruff it up
>> Current or most recent download log:
[youtube] Setting language
[youtube] AnPDHRqLVEk: Downloading video webpage
[youtube] AnPDHRqLVEk: Downloading video info webpage
[youtube] AnPDHRqLVEk: Extracting video information
[download] Destination: Gremlinz_featuring_Aspect_The_Gavel_HD-AnPDHRqLVEk.flv
[download]  39.5% of 12.20M at   56.83k/s ETA 02:12
Now I decide that I actually don't want the A-Sides video, so I remove it:
Code:
user@Nokia-N900:~/ytcli$ ytcli -r 2
Removed: a sides - ruff it up
user@Nokia-N900:~/ytcli$ ytcli -s
>> 2 downloads in the queue:
0: Gremlinz featuring Aspect - The Gavel [HD]
1: Technical Itch - The Rukus (D. Kay VIP)
>> Current or most recent download log:
[youtube] Setting language
[youtube] AnPDHRqLVEk: Downloading video webpage
[youtube] AnPDHRqLVEk: Downloading video info webpage
[youtube] AnPDHRqLVEk: Extracting video information
[download] Destination: Gremlinz_featuring_Aspect_The_Gavel_HD-AnPDHRqLVEk.flv
[download]  44.2% of 12.20M at   55.05k/s ETA 02:06
Of course you can also play videos right away without queing them:
Code:
user@Nokia-N900:~/ytcli$ ytcli -f "katamari damacy" | grep -i "lonely"
28: Katamari Damacy Soundtrack - 05 - Lonely Rolling Star
36: Best VGM 329 - Katamari Damacy - Lonely Rolling Star
user@Nokia-N900:~/ytcli$ ytcli -p 28
Fetching Katamari Damacy Soundtrack - 05 - Lonely Rolling Star
MPlayer SVN-r30099-4.2.1 (C) 2000-2009 MPlayer Team

Playing http://v8.lscache4.c.youtube.com/videoplayback?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor%2Coc%3AU0hQSFJSVF9FSkNOMF9KTFhF&fexp=907060%2C906717%2C904102&algorithm=throttle-factor&itag=34&ip=0.0.0.0&burst=40&sver=3&signature=3719BB98DF5B74187F2D43A4C74A52289A147CEB.D968A7D6FB7B0CA7113C38FAAD0B00CE086679A4&expire=1313276400&key=yt1&ipbits=0&factor=1.25&id=eff43274d5c8fe89.
Resolving v8.lscache4.c.youtube.com for AF_INET6...
Connecting to server v8.lscache4.c.youtube.com[42.0.20.80]: 80...
Failed to connect to server with AF_INET6
Resolving v8.lscache4.c.youtube.com for AF_INET...
Connecting to server v8.lscache4.c.youtube.com[193.192.226.165]: 80...
Cache size set to 320 KBytes
Cache fill: 17.50% (57344 bytes)   
libavformat file format detected.
--snip--
Note that complete or even partial downloads will never be deleted. Here's the help:

Code:
user@Nokia-N900:~/ytcli$ ytcli -h
Usage: ytcli.py [-a] {-f TERM|-r ID|-q ID|-p ID|-y YID|-s|-u|-k|-x REALLY} 

Options:
  -h, --help            show this help message and exit
  -f TERM, --find=TERM  do a search for TERM. Searching repeatedly for the
                        same TERM will load 50 more results
  -q ID, --queue=ID     queue the search result number ID for downloading
  -a, --authors         also show authors of videos
  -s, --status          show the status of the download queue
  -p ID, --play=ID      play the video number ID as a direct stream
  -y YID, --play-youtube=YID
                        play a video with youtube id YID
  -k, --kill            kill the queue downloader. Partially downloaded
                        videos will be continued in the future.
  -u, --resume          start the downloader and continue downloading
  -r ID, --remove=ID    Remove position ID from the download queue. Removing
                        ID 0 cancels the current download.
  -x REALLY, --reset=REALLY
                        kill the queue and remove all ytcli temp files.
                        Supply 'REALLY' as an argument to do this
So, the code has a couple of uncaught exceptions and it's not exactly a masterpiece of beauty (code-wise) but at least for me, it gets the job done a lot quicker than all the GUI tools.

I just -f | grep what I need, -q it and when the banner comes up I can play it in mplayer. Or I can play it immediately using -p.

By the way, the downloader runs as long as there is stuff in the queue. If you want to interrupt the download and pick it up at a later point, run it with -k to kill it, then later with -u to resume. It will continue where it stopped. ytcli depends on mplayer for playback and youtube-dl for downloading.



Enjoy!


known issues / room for improvement
- if it happens to you that a video only plays the first few frames (in mplayer), press SPACE twice. This is a problem with mplayer.
- sometimes webm videos get downloaded, not sure what to do with them yet since mplayer doesn't seem to be willing to play them
- fancy features like extracting sound or converting videos to a native codec/container
- trying to use maemo media player instead of mplayer to make use of the DSP
- all ytcli temp files get wiped upon a reboot
__________________
Author of:
  • The "Alarmed" scheduling and automation app. (Supports alarms, switching profiles, resetting the GPRS counter, setting custom commands to go off, cron syntax and much more. GUI and CLI).
  • "Reaction face-off", a two-player puzzle/knowledge/reaction game.
  • "ytcli", a simple but effective command line youtube client which allows you to play videos from the CLI instantly or download videos on a queue.

Last edited by shapeshifter; 2011-08-13 at 22:11.
 

The Following 8 Users Say Thank You to shapeshifter For This Useful Post:
Posts: 539 | Thanked: 518 times | Joined on May 2010 @ nanaurbusiness
#2
I'm getting an error.
Code:
BusyBox v1.18.5 (Debian 1.18.5power3) built-in shell (ash)
Enter 'help' for a list of built-in commands.

~ $ ytcli -f "technical itch" | grep -i rukus
Traceback (most recent call last):
  File "/opt/ytcli/ytcli.py", line 13, in <module>
    import gdata.youtube
ImportError: No module named gdata.youtube
~ $
 
Posts: 187 | Thanked: 345 times | Joined on Nov 2009
#3
Originally Posted by J4ZZ View Post
I'm getting an error.
Whoops, forgot to add python-gdata as a dependency. Fixed in 0.0.1-6 which should arrive in extras-devel within 10 minutes. To force the update, run apt-get update; apt-get install ytcli as root.
__________________
Author of:
  • The "Alarmed" scheduling and automation app. (Supports alarms, switching profiles, resetting the GPRS counter, setting custom commands to go off, cron syntax and much more. GUI and CLI).
  • "Reaction face-off", a two-player puzzle/knowledge/reaction game.
  • "ytcli", a simple but effective command line youtube client which allows you to play videos from the CLI instantly or download videos on a queue.

Last edited by shapeshifter; 2011-08-14 at 15:49.
 

The Following User Says Thank You to shapeshifter For This Useful Post:
Posts: 539 | Thanked: 518 times | Joined on May 2010 @ nanaurbusiness
#4
Forgot to thank you mate. It's working fine now, after the update.

Greetz,

J4ZZ
 
Posts: 32 | Thanked: 9 times | Joined on Feb 2011
#5
hy!

i have a problem with install this app !

this is a copy of my error :

momak:~# apt-get install ytcli
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
ytcli
0 upgraded, 1 newly installed, 0 to remove and 5 not upgraded.
Need to get 8850B of archives.
After this operation, 73,7kB of additional disk space will be used.
Get:1 http://repository.maemo.org fremantle/free ytcli 0.0.1-6 [8850B]
Fetched 8850B in 0s (34,5kB/s)
Selecting previously deselected package ytcli.
(Reading database ... 24348 files and directories currently installed.)
Unpacking ytcli (from .../archives/ytcli_0.0.1-6_all.deb) ...
Setting up ytcli (0.0.1-6) ...
dpkg (subprocess): unable to execute post-installation script: No such file or directory
dpkg: error processing ytcli (--configure):
subprocess post-installation script returned error exit status 2
Errors were encountered while processing:
ytcli
E: Sub-process /usr/bin/dpkg returned an error code (1)
momak:~#

help please thanks
 
Posts: 66 | Thanked: 87 times | Joined on Aug 2010
#6
Originally Posted by sehrz View Post
hy!
i have a problem with install this app !
..
help please thanks
Yes, I had the same problem.

But actually ytcli are only two Python scripts, /opt/ytcli/ytcli.py and /opt/ytcli/ytcli_queue.py plus the shell wrapper /usr/bin/ytcli. Those scripts should be there even after the incomplete installation, so just fix ytcli and replace "bash" with "sh" in the shebang line as there is no default bash on the N900 afaik.

If the files are not there you can extract them from the ytcli .deb package, copy them to their respective folders and set ytcli to executable as I did.

The ytcli script now works for me but I get the following error message while queuing a video for download:
"ERROR no fmt_url_map or conn information found in video info"

The video of course doesn't get downloaded at all. Is there a restriction to download certain videos?

Cheers, M.
 
Posts: 32 | Thanked: 9 times | Joined on Feb 2011
#7
Originally Posted by mick3_de View Post
Yes, I had the same problem.

But actually ytcli are only two Python scripts, /opt/ytcli/ytcli.py and /opt/ytcli/ytcli_queue.py plus the shell wrapper /usr/bin/ytcli. Those scripts should be there even after the incomplete installation, so just fix ytcli and replace "bash" with "sh" in the shebang line as there is no default bash on the N900 afaik.

If the files are not there you can extract them from the ytcli .deb package, copy them to their respective folders and set ytcli to executable as I did.

The ytcli script now works for me but I get the following error message while queuing a video for download:
"ERROR no fmt_url_map or conn information found in video info"

The video of course doesn't get downloaded at all. Is there a restriction to download certain videos?

Cheers, M.
i dont know is there a restriction but i know that this app work over the youtube-dl app and this app have the same error but for ubuntu is some fix done and there is workig ok!

sorry for my eng.
how to replace bash with sh!?
tell me more closely please... what change in script

ps: it is only half install ....
 
Posts: 66 | Thanked: 87 times | Joined on Aug 2010
#8
Originally Posted by sehrz View Post
sorry for my eng.
how to replace bash with sh!?
tell me more closely please... what change in script
0. Open the X Terminal

1. Make shure that python-gdata is installed:
$python
>>>import gdata
There shouldn't be any error message.

2.Make shure that /opt/ytcli/ytcli.py + /opt/ytcli/ytcli_queue.py are installed.

3.Go root and edit /usr/bin/ytcli: replace "bash" with "sh" at line #1

4. Check if ytcli is user executable or use chmod to set it.

If any of those steps do not work you should wait until shapeshifter will hopefully provide a new fixed package.

Cheers, M.
 
Reply


 
Forum Jump


All times are GMT. The time now is 01:31.