Showing posts with label Tricks. Show all posts
Showing posts with label Tricks. Show all posts

Friday, November 28, 2008

Rip Youtube the CLI way

There are many applications for extracting and downloading videos from youtube and other video hosts like web-based KeepVid or addons like VideoDownloader, and many others. There's also a very good technique of saving any streaming video by buffering it till 100%, navigate to the Cache folder and simply copy the video file (which is /tmp in case of linux).

But recently I got a python based CLI tool youtube-dl, which is a nifty yet a powerful must have tool. You can get it from your default repositories or for youtube-dl under Windows XP. Get it :

$ sudo yum install youtube-dl

Usage
  • Simply download :
    $ youtube-dl http://www.youtube.com/watch?v=video_id

  • Specify filename

    Manually specify :
    $ youtube-dl -o output.flv http://www.youtube.com/watch?v=video_id
    Use the original video title :
    $ youtube-dl -t http://www.youtube.com/watch?v=video_id
    Have a literal title :
    $ youtube-dl -l http://www.youtube.com/watch?v=video_id

  • Download videos which requires your youtube account privileges and confirmation :
    $ youtube-dl -u username -p password http://www.youtube.com/watch?v=video_id

    Or read account details from .netrc file :
    $ youtube-dl -n http://www.youtube.com/watch?v=video_id
    Append this line to ~/.netrc file :
    machine youtube login username password password

  • Simply print video URL instead of downloading :
    $ youtube-dl -g http://www.youtube.com/watch?v=video_id
    Or grab the Title :
    $ youtube-dl -2 http://www.youtube.com/watch?v=video_id

  • Download in silent mode (like wget) :
    $ youtube-dl -q http://www.youtube.com/watch?v=video_id &

  • Get Help :
    $ youtube-dl -h


Know more at the Official Page.

Saturday, October 25, 2008

Custom Search Tool in Firefox

There are search engines which you visit/use frequently and are not listed in Firefox plugin page, so what you will do? Create your own simple :

I will making a Google Linux search tool :
  • Open any text editor and paste this code :
    <search 
    name="Google Linux"
    method="GET"
    action="http://www.google.co.in/linux"
    queryCharset="utf-8"
    >
    <input name="q" user>
    </search>

  • You can add more parameters other than query like "Search within a domain".
    Add
    <input name="sitesearch" value="gnu.org">
    below
    <input name="q" user>
    Just carefully observe the URL after you hit a search for the parameter name/value and keep adding for a filtered search.

  • Save the file as filename.src (I am using glinux.src) to ~/.mozilla/firefox/<profile>/searchplugins/

    TIP : To display icon next to your search engine create a 16X16 PNG or GIF image and save it in the same folder as glinux.src and name it glinux.png or glinux.gif as per your file format

  • Restart Firefox, your source will be compiled and converted into a .XML file automatically and what next! use your engine

Also check : Mycroft Project

Attached few of my favorites : search.tar.gz

Tuesday, October 14, 2008

IP address from NetBIOS name

I will use ping command for knowing the IP address, but for a default *nix system we cannot ping a node using its NetBIOS name. So with a minor edit we can do it all. Here's the process :

  • Edit /etc/nsswitch.conf :
    $ vim /etc/nsswitch.conf
    Or use any other editor of your choice

  • Search for something similar to this :
    hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4
    and add wins at the end of the line
    hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4 wins
    Save the file and exit

  • Now use ping command :
    $ ping xyz
    You will get a output something like this :
    PING xyz (192.168.2.1) 56(84) bytes of data.
    Here 192.168.2.1 is the required IP

There may be different ways but I find this one quite simple.

Source(s) : Samba HOWTO

Saturday, September 20, 2008

(wget = DM) != GUI

Wget the default download manager in *nix systems is a very versatile tool. I will be focusing on some of its very important features useful to a end user. So here we begin :

  1. Simply downloading a file :
    $ wget <URL>
    Or better :
    $ wget -c <URL>
    -c or --continue lets you resume your incomplete download done using wget or a different program

  2. Downloading a file silently (a very imp. feature in wget, to work in background) :
    $ wget -q <URL> &
  3. Taking a log of all messages :
    $ wget <URL> -o filename
  4. Downloading files from a Queue :
    $ wget -i filename
    Strore all download links in a file separated by Return key and link it with wget
  5. Set your no. of retries and timeout seconds :
    $ wget -t <no. to tries> -T <duration> <URL>
  6. Displaying the content of a file rather than saving it on Hard Disk :
    $ wget -O - <URL>
  7. Retrieving all file with a particular extension from a web directory :
    $ wget -r -l1 -np -A.<extension> <directory>
    Example for http://www.abc.com/def/*.jpg
    $ wget -r -l1 -np -A.jpg http://www.abd.com/def/
  8. Downloading an entire Web Site :
    $ wget -c -r -nc -p -D <domain> -k <URL>
    For this I have written a script for easy downloading :
    #!/bin/bash

    # Bash Script for Web Site downloading by GNUger
    # Syntax : $ sitesdwn [URL]

    command="wget -c -r -p -k"
    domain=$(echo $1 | cut -d/ -f3 | cut --complement -d. -f1)

    echo
    read -p "Download within $domain only (y/n) : " opinion
    if [[ $opinion == 'y' ]] ; then
    command="$command -D $domain"
    fi
    read -p "Disable overwriting existing files (y/n) : " opinion
    if [[ $opinion == 'y' ]] ; then
    command="$command -nc"
    fi
    read -p "Download outside the current directory (y/n) : " opinion
    if [[ $opinion == 'n' ]] ; then
    command="$command -np"
    fi
    read -p "Save as HTML extension (y/n) : " opinion
    if [[ $opinion == 'y' ]] ; then
    command="$command -E"
    fi
    read -p "Enable compatibility with Windows (y/n) : " opinion
    if [[ $opinion == 'y' ]] ; then
    command="$command --restrict-file-names=windows"
    fi
    echo "Downloading ... "
    echo
    $command $1
    echo
    echo "End"
    exit 1
    fi
    Or download the script from here. Syntax :
    ./sitedwn.sh <URL>


This is not it.. there's hell lot more but beyond the scope of this post. So just read the Manuals (worth reading specially the Examples part). There are GUI version for wget :
  • GWget - For Gnome
  • Kget - For KDE
But they does not provide you so many options and manual customizations as wget (CLI) does.

References : man pages of wget, Linux Journal

Tuesday, September 16, 2008

Audio Boost using MPlayer

I often felt pissed off when my friends used VLC and others programs for software level volume amplification, so I searched for a similar kind in mplayer and guess what! It was already there in mplayer since ages. You just need to RTFM.

Syntax :

mplayer -af volume=20:0 mediafile
Would amplify the sound by 20dB and hard-clip if the sound level is too high

Reference ( man pages of mplayer ) :

AUDIO FILTERS
Audio filters allow you to modify the audio stream and its properties. The syntax is:

-af <filter1[=parameter1:parameter2:...],filter2,...>
Setup a chain of audio filters.

NOTE: To get a full list of available audio filters, see -af help.

volume[=v[:sc]]
Implements software volume control. Use this filter with cau‐
tion since it can reduce the signal to noise ratio of the sound.
In most cases it is best to set the level for the PCM sound to
max, leave this filter out and control the output level to your
speakers with the master volume control of the mixer. In case
your sound card has a digital PCM mixer instead of an analog
one, and you hear distortion, use the MASTER mixer instead. If
there is an external amplifier connected to the computer (this
is almost always the case), the noise level can be minimized by
adjusting the master level and the volume knob on the amplifier
until the hissing noise in the background is gone.
This filter has a second feature: It measures the overall maxi‐
mum sound level and prints out that level when MPlayer exits.
This volume estimate can be used for setting the sound level in
MEncoder such that the maximum dynamic range is utilized.
NOTE: This filter is not reentrant and can therefore only be en‐
abled once for every audio stream.
<v>
Sets the desired gain in dB for all channels in the
stream from -200dB to +60dB, where -200dB mutes the
sound completely and +60dB equals a gain of 1000 (de‐
fault: 0).
<sc>
Turns soft clipping on (1) or off (0). Soft-clipping
can make the sound more smooth if very high volume lev‐
els are used. Enable this option if the dynamic range
of the loudspeakers is very low.
WARNING: This feature creates distortion and should be
considered a last resort.


Enjoy your home theater ... :)

Wednesday, July 30, 2008

Grab your IP

Often you need to know your IP, particularly when your are connected by DCHP kinda connection. So here are some handy tips :

CLI
  • Displaying the current config for all NIC's :
    $ ifconfig

  • Displaying the current config for a particular device :
    $ ifconfig device
    Example:
    $ ifconfig ppp0

  • For knowing your IP via which you are accessing WWW:
    $ ifconfig  | grep 'P-t-P' | cut -d: -f2 | awk {'print $1'}
    OR
    $ wget -q -O- http://www.whatismyip.com/automation/n09230945.asp
    Here we are taking the help of http://www.whatismyip.com/

  • Additional Jobs:

    Display the kernel’s IPv4 network neighbour cache:
    $ arp

    Display the kernel’s IP routing tables
    $ route

    Pinging:
    $ ping IP addr
    Example:
    $ ping 192.169.25.15


There are many more tools for advanced usage like nmap and others, but these are the basics.

SOURCE

Thursday, July 24, 2008

LAN Messenger

Today I was searching for a LAN messaging client on my Ubuntu box, so after a bit of googling I turned to Pidgin. I searched if it was possible to configure Pidgin as a LAN Messenger and out of my surprise it was simpler than I ever thought of. Here's how:

1> Open Pidgin

2> Then Navigate to Accounts > Manage > Add

3> Select Bonjour

4> Fill the other details as per your choice.

5> Do the same setting in other nodes and enjoying offline chat

Pidgin is a Crossplatform Mutliprotocol Instant Messaging client, so it doesn't matters if you are in Windows or Linux. The only thing that may matter is it comes preloaded in most of the present Linux Distros where as you have to install it in Windows.

Monday, June 30, 2008

Battey Stats

There are ready made panel applets available for viewing your battery remaining, current state and others.. Well here I give you more geekier an efficient way of doing that .. CLI ofcourse :
  1. Know your battery's specification :
    $ cat /proc/acpi/battery/BAT0/info

  2. Know your current battery status :
    $ cat /proc/acpi/battery/BAT0/state
    NOTE: BAT0 may differ as per your Laptop model, look for what you have got in /proc/acpi/battery directory.


I have made a small script for Battery Status :
#!/bin/bash
# Battery Status by GNUger

current=`grep remaining /proc/acpi/battery/BAT0/state | awk {'print $3'}`
total=`grep "design capacity:" /proc/acpi/battery/BAT0/info | awk {'print $3'}`

percent=$[100*$current/$total]

echo `grep charging /proc/acpi/battery/BAT0/state | awk {'print $3'}` $percent%
Attached the script file here

TIP: You can add this script in conkyrc file

Sunday, June 29, 2008

Ctrl + Alt + Del

Sometimes users get annoyed with not having their favorite Windows key combination "Ctrl + Alt + Del" working on Linux Box. Well here's how to view your process manager for "Ctrl + Alt + Del" :

GNOME :
  1. Start gconf-editor via terminal / Alt+F2 & navigate to : apps > metacity > global_keybindings

  2. Double click on run_command_1 and change its value to <Control><Alt>Delete

  3. The navigate to : apps > metacity > keybinding_commands

  4. Double click on command_1 and change its value to gnome-system-monitor

Fluxbox
  1. With any text editor edit you ~/.fluxbox/keys file, Example:
    $ vim ~/.fluxbox/keys

  2. Append this at the end of the file:
    Control Mod1 Delete :ExecCommand xterm -e top
    You can use gnome-system-monitor instead of xterm -e top, but I have used it to retain Fluxbox's spirit of minimalism


Relogin to check its effect...

Friday, June 27, 2008

Feeling Geeky...

Fed up with GNOME/KDE resource hogging Desktop Environment, but do not want to loose GUI! So now its time when you turn to fluxbox. Call this page "HowTo forge a simple geeky environment"..

Packages Recommended :
Other light-weight applications as per your requirement, there are many pages on it just Google.

Install them :
 # yum install fluxbox pcmanfm imagemagick mplayer epiphany

Start Fluxbox :
After finishing off with installation just log out and select fluxbox in the Session Type and Login.

Start Configuring :
  • Generate a perfect menu, it will take some time
    $ fluxbox-generate_menu -kgB -is -ds -t xterm -b epiphany
    You can also add custom items to your menu : Editing Menu

  • Set Wallpaper :
    $ fbsetbg /path/to/wallpaper
    Now edit you ~/.fluxbox/init file with any editor and search for session.screen0.rootCommand: and add fbsetbg -l beside it.

  • Binding your ~/Desktop folder with your desktop, use PCMan FM :
    Start your pcmanfm file manager and navigate to Edit>Preference>Desktop and mark "Show files on Desktop", "Wallpaper" and "Allow window manager to decide right click". Edit you ~/.fluxbox/init file with any editor and search for session.screen0.rootCommand: and add pcmanfm beside it (replace fbsetbg -l).

  • Use a animated wallpaper instead!
    You can use your screen-saver as a wallpaper. Edit your ~/.fluxbox/init file with any editor and search for session.screen0.rootCommand: and add /usr/lib/xscreensaver/gears -root beside it (you can use other screen-savers too). Actually you have to choose between normal wallpaper, desktop with icons or animated desktop.
    For having icons on desktop check this : Idesk

  • System Monitor widget : install conky, get its readymade configuration files (conkyc) here

  • Choose your default applications :
    Image Files : display
    Media Files (Audio/Video) : xterm -e mplayer
Further keep experimenting with the CLI commands, it makes you make proficient with Linux platform and do check this link (Linux Command Line).

Sunday, May 25, 2008

Mplayer : Universal Media Player

Since mplayer is the only multimedia player on my PC other than Amarok, so I will obviously want it to work with each and every media file I have or may encounter and mplayer did all its work with 100% perfection till one day when I tried to play .rm/.rmvb files with it.. So what next, install a separate player for that? Never..the solution is more simple than anyone can expect :

1> If you have not installed the codecs for mplayer then download them from here or mirrors. Extract the contents and copy them to /usr/lib/codecs directory.

2> Now for enabling Real Player support, download this or mirror, extract the contents to the above mentioned folder.
Note: For copying files to /usr/lib/codecs u will need administrative rights (sudo)

TIP:
For opening any file with mplayer (CLI), Right Click File > Properties > Open with > Add > xterm -e mplayer > Click on "Always open with same application". This is quite fast and handy.

Saturday, May 24, 2008

Video Rotation

One line command for rotating a video by 90 degrees :
$ mplayer -vf rotate=<value> filename


Saving as a AVI file :
$ mencoder -vf rotate=<value> -ovc lavc -oac copy filename -o output.avi


Substitute <value> by a number 0-3 for preferred rotation:

* 0 -> 90 Degree Clockwise + Mirrored
* 1-> 90 Degree Clockwise
* 2-> 90 Degree Anticlockwise
* 3-> 90 Degree Anticlockwise + Mirrored