Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - hakerdefo

Pages: 1 2 [3] 4
31
Scripts / RADIO VSIDO - VSIDO's very own Internet radio player
« on: July 20, 2015, 07:14:28 PM »
EDIT BEGINS (23, July 2015) :
Made changes to mplayer cache for efficient handling of streams.
EDIT ENDS:

Snap's topic here,
What do you use for radio?
inspired this script. Save it somewhere in your $PATH with the name 'radio_vsido' and 'chmod 755' it. I've included 43 radio stations. If you wish to expand the list or include your own favorite stations all you need to do is open the script in your text-editor, have a good look at it and add the new stations to it. If you have a problem understanding the script you can always ask about it here. The script doesn't have any dependencies outside the standard VSIDO install.
Make sure you run the script with the terminal emulator (xfce4-terminal in VSIDO) maximized to be able to view the complete station list. Looking forward to suggestions-views-reviews.

Code: [Select]
#!/bin/bash

RED='\e[41m'
BLUE='\e[44m'
NC='\e[0m'

PLAYER="mplayer -nolirc -really-quiet -cache 512 -cache-min 25"

while :
do
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo ""
echo -e "Station $BLUE List $NC :"
echo ""
echo -e "$BLUE 01 $NC  7 Inch Soul                     $BLUE 02 $NC  BAGeL Radio"
echo -e "$BLUE 03 $NC  Beat Blender                    $BLUE 04 $NC  Boot Liquor"
echo -e "$BLUE 05 $NC  Black Rock FM                   $BLUE 06 $NC  cliqhop idm"
echo -e "$BLUE 07 $NC  Covers                          $BLUE 08 $NC  Deep Space One"
echo -e "$BLUE 09 $NC  DEF CON Radio                   $BLUE 10 $NC  Digitalis"
echo -e "$BLUE 11 $NC  Doomed                          $BLUE 12 $NC  Drone Zone"
echo -e "$BLUE 13 $NC  Dub Step Beyond                 $BLUE 14 $NC  Earwaves"
echo -e "$BLUE 15 $NC  Folk Forward                    $BLUE 16 $NC  Groove Salad"
echo -e "$BLUE 17 $NC  Illinois Street Lounge          $BLUE 18 $NC  Indie Pop Rocks!"
echo -e "$BLUE 19 $NC  Lush                            $BLUE 20 $NC  Mission Control"
echo -e "$BLUE 21 $NC  PopTron                         $BLUE 22 $NC  Secret Agent"
echo -e "$BLUE 23 $NC  SF 10–33                        $BLUE 24 $NC  Sonic Universe"
echo -e "$BLUE 25 $NC  Space Station Soma              $BLUE 26 $NC  Suburbs of Goa"
echo -e "$BLUE 27 $NC  The Trip                        $BLUE 28 $NC  Underground 80s"
echo -e "$BLUE 29 $NC  BBC Radio 1                     $BLUE 30 $NC  BBC Radio 2"
echo -e "$BLUE 31 $NC  BBC Radio 3                     $BLUE 32 $NC  BBC Radio 4"
echo -e "$BLUE 33 $NC  BBC Radio 4 Extra               $BLUE 34 $NC  BBC World Service"
echo -e "$BLUE 35 $NC  All 60s All the Time            $BLUE 36 $NC  Beatles-A-Rama"
echo -e "$BLUE 37 $NC  RADIO ENERGY                    $BLUE 38 $NC  Radio Paradise"
echo -e "$BLUE 39 $NC  Radio Record                    $BLUE 40 $NC  RADIO ROCK"
echo -e "$BLUE 41 $NC  Radio Swing Worldwide           $BLUE 42 $NC  Smooth Jazz"
echo -e "$BLUE 43 $NC  True Oldies Channel             $RED 44 $BLUE  Exit RADIO VSIDO $NC"
echo ""
echo ""
echo -e "Select a $BLUE station $NC between 1 to 43 and hit $BLUE [Enter] $NC to $BLUE PLAY $NC :"
echo ""
echo -e "Select $RED 44 $NC to $BLUE Exit $NC :"
echo ""
read VSIDO
case $VSIDO in

1)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE 7 Inch Soul $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/7soul
continue
;;

2)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE BAGeL Radio $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/bagel
continue
;;

3)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Beat Blender $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/beatblender
continue
;;

4)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Boot Liquor $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/bootliquor
continue
;;

5)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Black Rock FM $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/brfm
continue
;;

6)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE cliqhop idm $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/cliqhop
continue
;;

7)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Covers $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/covers
continue
;;

8)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Deep Space One $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/deepspaceone
continue
;;

9)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE DEF CON Radio $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/defcon
continue
;;

10)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Digitalis $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/digitalis
continue
;;

11)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Doomed $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/doomed
continue
;;

12)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Drone Zone $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/dronezone
continue
;;

13)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Dub Step Beyond $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/dubstep
continue
;;

14)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Earwaves $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/earwaves
continue
;;

15)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Folk Forward $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/folkfwd
continue
;;

16)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Groove Salad $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/groovesalad
continue
;;

17)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Illinois Street Lounge $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/illstreet
continue
;;

18)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Indie Pop Rocks! $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/indiepop
continue
;;

19)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Lush $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/lush
continue
;;

20)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Mission Control $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/missioncontrol
continue
;;

21)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE PopTron $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/poptron
continue
;;

22)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Secret Agent $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/secretagent
continue
;;

23)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE SF 10–33 $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/sf1033
continue
;;

24)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Sonic Universe $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/sonicuniverse
continue
;;

25)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Space Station Soma $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/spacestation
continue
;;

26)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Suburbs of Goa $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/suburbsofgoa
continue
;;

27)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE The Trip $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/thetrip
continue
;;

28)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Underground 80s $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://ice.somafm.com/u80s
continue
;;

29)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE BBC Radio 1 $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_q
continue
;;

30)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE BBC Radio 2 $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio2_mf_q
continue
;;

31)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE BBC Radio 3 $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://open.live.bbc.co.uk/mediaselector/5/select/version/2.0/mediaset/http-icy-aac-lc-a/format/pls/vpid/bbc_radio_three.pls
continue
;;

32)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE BBC Radio 4 $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio4fm_mf_q
continue
;;

33)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE BBC Radio 4 Extra $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio4extra_mf_q
continue
;;

34)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE BBC World Service $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://wsdownload.bbc.co.uk/worldservice/meta/live/shoutcast/mp3/eieuk.pls
continue
;;

35)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE All 60s All the Time $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://streaming303.radionomy.com:80/keepfree60s
continue
;;

36)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Beatles-A-Rama $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://streaming303.radionomy.com:80/beatlesarama
continue
;;

37)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE RADIO ENERGY $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://stream.radioreklama.bg:80/nrj.ogg
continue
;;

38)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Radio Paradise $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://stream-uk1.radioparadise.com:80/mp3-192
continue
;;

39)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Radio Record $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://air.radiorecord.ru:8101/rr_128
continue
;;

40)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE RADIO ROCK $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://stream.radioreklama.bg:80/radio1rock.ogg
continue
;;

41)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Radio Swing Worldwide $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://streaming303.radionomy.com:80/radioswingworldwide
continue
;;

42)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE Smooth Jazz $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://hestia.cdnstream.com:80/1256_128
continue
;;

43)
clear
echo ""
echo -e "$BLUE RADIO VSIDO $NC"
echo ""
echo -e "Now $BLUE Playing $NC Station: $BLUE True Oldies Channel $NC"
echo ""
echo -e "Press $BLUE [Space] $NC to pause Press $BLUE [Q] $NC to stop"
echo ""
$PLAYER http://streaming304.radionomy.com:80/trueoldies
continue
;;

44)
clear
echo ""
echo -e "$BLUE 'When I die, just keep playing the records' $RED Jimi Hendrix $NC"
echo ""
sleep 3
clear
break
exit 0
;;

*)
clear
echo ""
echo -e "$RED Wrong Choice!!! $NC"
echo ""
sleep 3
clear
continue
;;

esac
done


Cheers!!!

32
pmdc is a simple bash script that calculates distance & travel time between two locations. Distance & travel time are calculated using the road network (Driving mode in map parlance). Those of you living in the good ol' US of A can even use short names for their states like ca, ny, dc, etc. etc.
Any dependencies? Well only one. And it's simple to install too,
Code: [Select]
sudo apt-get install jq

Ready for the script? Here you go,
Code: [Select]
#!/bin/bash

clear

echo ""
echo -e "pmdc calculates distance & travel time between two locations."
echo ""
echo -e "Distance & travel time are calculated using the road network."
echo ""
echo -e "Press Enter key to continue...."
echo ""
read EnterKey
clear
echo ""
echo -e "Location 1 - From:"
echo ""
echo ""
echo -e "Enter the name of city-town-village"
echo ""
read village
echo ""
echo -e "Enter the name of state-county-province"
echo ""
read province
echo ""
echo -e "Enter the name of country"
echo ""
read country
clear
echo ""
echo -e "Location 2 - To:"
echo ""
echo ""
echo -e "Enter the name of city-town-village"
echo ""
read city
echo ""
echo -e "Enter the name of state-county-province"
echo ""
read state
echo ""
echo -e "Enter the name of country"
echo ""
read name
clear

city_1=$(echo "$village" | sed 's/ \+/+/g')
state_1=$(echo "$province" | sed 's/ \+/+/g')
country_1=$(echo "$country" | sed 's/ \+/+/g')
city_2=$(echo "$city" | sed 's/ \+/+/g')
state_2=$(echo "$state" | sed 's/ \+/+/g')
country_2=$(echo "$name" | sed 's/ \+/+/g')

curl -s --connect-timeout 30 -o /tmp/pmdc.json "https://maps.googleapis.com/maps/api/distancematrix/json?origins=$city_1+$state_1+$country_1&destinations=$city_2+$state_2+$country_2&language=en"

if [ ! -f /tmp/pmdc.json ]; then
echo ""
echo -e "Unable to connect to Internet!"
echo -e "Check your Internet connection!"
echo ""

exit 1

else

addvalid=$(cat /tmp/pmdc.json | grep "NOT_FOUND")

if [[ -n "$addvalid" ]]; then
echo ""
echo -e "No results found!"
echo -e "May be you misspelled a name?!?"
echo ""

exit 1

else

resvalid=$(cat /tmp/pmdc.json | grep "ZERO_RESULTS")

if [[ -n "$resvalid" ]]; then
echo ""
echo -e "Sorry! No distance data is available!"
echo ""

exit 1

else

orgadd=$(cat /tmp/pmdc.json | jq -r '.origin_addresses' | sed -e 's/\"//g' -e 's/\[//g' -e 's/\]//g' -e 's/^[ \t]*//')
desadd=$(cat /tmp/pmdc.json | jq -r '.destination_addresses' | sed -e 's/\"//g' -e 's/\[//g' -e 's/\]//g' -e 's/^[ \t]*//')
distbet=$(cat /tmp/pmdc.json | jq -r '.rows[].elements[].distance.text')
durabet=$(cat /tmp/pmdc.json | jq -r '.rows[].elements[].duration.text')

echo ""
echo -e "From: $orgadd"
echo ""
echo -e "To: $desadd"
echo ""
echo -e "Distance -> $distbet"
echo ""
echo -e "Travel time -> $durabet"
echo ""

rm /tmp/pmdc.json

fi
fi
fi

exit 0


Save this script with the name 'pmdc' somewhere in your $PATH and 'chmod 755' it.
Open terminal and run 'pmdc' whenever you are planning a driving trip and it will give you the exact distance and approximate travel time.
By the way pmdc means Poor Man's Distance Calculator.
Cheers!!!

33
Good news for all those interested in astronomy and space science. I've created a silly little bash script called 'iss' that gets you the following information right in your terminal,
  • Current position of International Space Station (ISS) in latitude-longitude. And if map data is available for the current location then the script will display name-address of the location.
  • Passing date-time and duration of ISS for your location.
  • Number of people currently in space, their name(s), and the name(s) of spacecraft they are on.
Sounds interesting? Only dependency of this script is 'jq'.
Code: [Select]
sudo apt-get install jq

Here is the script 'iss',
Code: [Select]
#!/bin/bash

latit=
longi=
eleva=

curl -s --connect-timeout 30 -o /tmp/issn.json "http://api.open-notify.org/iss-now.json"
curl -s --connect-timeout 30 -o /tmp/issp.json "http://api.open-notify.org/iss-pass.json?lat=$latit&lon=$longi&alt=$eleva&n=10"
curl -s --connect-timeout 30 -o /tmp/astros.json "http://api.open-notify.org/astros.json"

issnowtu=$(cat /tmp/issn.json | jq -r '.timestamp')
issnowth=$(date -d @"$issnowtu" +'%H:%M:%S (%d-%m-%Y)')
latit=$(cat /tmp/issn.json | jq -r '.iss_position.latitude')
longi=$(cat /tmp/issn.json | jq -r '.iss_position.longitude')
isspd1=$(cat /tmp/issp.json | jq -r '.response[0].duration')
isspd11=$(printf '%d:%02d\n' $(($isspd1/60%60)) $(($isspd1%60)))
isspd2=$(cat /tmp/issp.json | jq -r '.response[1].duration')
isspd22=$(printf '%d:%02d\n' $(($isspd2/60%60)) $(($isspd2%60)))
isspd3=$(cat /tmp/issp.json | jq -r '.response[2].duration')
isspd33=$(printf '%d:%02d\n' $(($isspd3/60%60)) $(($isspd3%60)))
isspd4=$(cat /tmp/issp.json | jq -r '.response[3].duration')
isspd44=$(printf '%d:%02d\n' $(($isspd4/60%60)) $(($isspd4%60)))
isspd5=$(cat /tmp/issp.json | jq -r '.response[4].duration')
isspd55=$(printf '%d:%02d\n' $(($isspd5/60%60)) $(($isspd5%60)))
isspd6=$(cat /tmp/issp.json | jq -r '.response[5].duration')
isspd66=$(printf '%d:%02d\n' $(($isspd6/60%60)) $(($isspd6%60)))
isspd7=$(cat /tmp/issp.json | jq -r '.response[6].duration')
isspd77=$(printf '%d:%02d\n' $(($isspd7/60%60)) $(($isspd7%60)))
isspd8=$(cat /tmp/issp.json | jq -r '.response[7].duration')
isspd88=$(printf '%d:%02d\n' $(($isspd8/60%60)) $(($isspd8%60)))
isspd9=$(cat /tmp/issp.json | jq -r '.response[8].duration')
isspd99=$(printf '%d:%02d\n' $(($isspd9/60%60)) $(($isspd9%60)))
isspd10=$(cat /tmp/issp.json | jq -r '.response[9].duration')
isspd100=$(printf '%d:%02d\n' $(($isspd10/60%60)) $(($isspd10%60)))
isspt1=$(cat /tmp/issp.json | jq -r '.response[0].risetime')
isspt11=$(date -d @"$isspt1" +'%d-%m-%Y (%H:%M:%S)')
isspt2=$(cat /tmp/issp.json | jq -r '.response[1].risetime')
isspt22=$(date -d @"$isspt2" +'%d-%m-%Y (%H:%M:%S)')
isspt3=$(cat /tmp/issp.json | jq -r '.response[2].risetime')
isspt33=$(date -d @"$isspt3" +'%d-%m-%Y (%H:%M:%S)')
isspt4=$(cat /tmp/issp.json | jq -r '.response[3].risetime')
isspt44=$(date -d @"$isspt4" +'%d-%m-%Y (%H:%M:%S)')
isspt5=$(cat /tmp/issp.json | jq -r '.response[4].risetime')
isspt55=$(date -d @"$isspt5" +'%d-%m-%Y (%H:%M:%S)')
isspt6=$(cat /tmp/issp.json | jq -r '.response[5].risetime')
isspt66=$(date -d @"$isspt6" +'%d-%m-%Y (%H:%M:%S)')
isspt7=$(cat /tmp/issp.json | jq -r '.response[6].risetime')
isspt77=$(date -d @"$isspt7" +'%d-%m-%Y (%H:%M:%S)')
isspt8=$(cat /tmp/issp.json | jq -r '.response[7].risetime')
isspt88=$(date -d @"$isspt8" +'%d-%m-%Y (%H:%M:%S)')
isspt9=$(cat /tmp/issp.json | jq -r '.response[8].risetime')
isspt99=$(date -d @"$isspt9" +'%d-%m-%Y (%H:%M:%S)')
isspt10=$(cat /tmp/issp.json | jq -r '.response[9].risetime')
isspt100=$(date -d @"$isspt10" +'%d-%m-%Y (%H:%M:%S)')
astrock=$(cat /tmp/astros.json | grep "0,")

curl -s --connect-timeout 30 -o /tmp/gcd.json "https://maps.googleapis.com/maps/api/geocode/json?latlng=$latit,$longi&components=locality&language=en"

issnowl=$(cat /tmp/gcd.json | jq -r '.results[0].formatted_address')
issnowlc=$(cat /tmp/gcd.json | grep "ZERO_RESULTS")
echo ""
#echo -e "International Space Station (ISS) on $issnowth is over,"
echo -e "Current Time -> $issnowth"
echo ""
echo -e "Current Location of ISS :"
echo ""
echo -e "Latitude -> $latit"
echo -e "Longitude -> $longi"
echo ""
echo -e "In layman's term ISS is currently over the skies of,"
echo ""

if [[ -z "$issnowlc" ]]; then
echo -e "$issnowl"
else
echo -e "Some unmapped region of earth."
echo ""
fi

echo ""
echo -e "ISS will pass over your location at these times :"
echo ""
echo -e "Passing Date & Time -> $isspt11"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd11"
echo ""
echo -e "Passing Date & Time -> $isspt22"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd22"
echo ""
echo -e "Passing Date & Time -> $isspt33"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd33"
echo ""
echo -e "Passing Date & Time -> $isspt44"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd44"
echo ""
echo -e "Passing Date & Time -> $isspt55"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd55"
echo ""
echo -e "Passing Date & Time -> $isspt66"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd66"
echo ""
echo -e "Passing Date & Time -> $isspt77"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd77"
echo ""
echo -e "Passing Date & Time -> $isspt88"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd88"
echo ""
echo -e "Passing Date & Time -> $isspt99"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd99"
echo ""
echo -e "Passing Date & Time -> $isspt100"
echo -e "Passing Duration (Minutes:Seconds) -> $isspd100"
echo ""
echo ""

if [[ -z "$astrock" ]]; then

astrop=$(cat /tmp/astros.json | jq -r '.people[] | .name')
astroc=$(cat /tmp/astros.json | jq -r '.people[] | .craft')
astropc=$(paste <(echo "$astrop") <(echo "$astroc"))
astropn=$(cat /tmp/astros.json | jq -r '.number')

echo -e "Do you know there are $astropn humans in space currently!"
echo -e "Here are the names of astronauts & spacecraft they are on,"
echo ""
echo -e "$astropc" | sed -e "s/[[:space:]]\+/ /g"
echo ""
else
echo ""
fi

rm /tmp/issn.json
rm /tmp/issp.json
rm /tmp/astros.json
rm /tmp/gcd.json
exit 0


Save the script 'iss' somewhere in your $PATH and 'chmod 755' it. You need to add values to a few variables in the script before using it. First variable is 'latit'. Assign the latitude of your location to it. The second variable is 'longi'. Assign the longitude of your location to it, Last variable is 'eleva'. Assign the elevation (in meters) of your location to it. Save the changes. Where do you get the latitude-longitude-elevation for your place? Easy! Just go to the following website and search for the laitude-longitude-elevation of your location,

HeavensAbove - Location selector

Type 'iss' in your terminal, hit enter and have sum astronomical fun!
Looking forward to your feedback on this script.
Cheers!!!

34
Scripts / unshorten - Expands a short URL & displays the original URL
« on: June 07, 2015, 06:16:14 PM »
Short URLs can be a security risk. 'unshorten' is a simple bash script that displays the original link of a short URL. It doesn't depend on any third party service.

Code: [Select]
#!/bin/sh
echo ""
echo "Expands a short url & displays the original url."
echo ""
echo "Enter a short url: "
read input_variable
if long=$(curl -s -o /dev/null --head -w "%{url_effective}\n" -L "$input_variable"); then
echo "Original url -> $long"
else
echo "Sorry! Invalid url!"
fi


Save this script some where in your path with the name 'unshorten' and give it 'Execute' permission. Next time you come across a short URL, Don't blindly click-open it in your Browser or Mail Application, Run 'unshorten' from your terminal and enter the short URL when prompted and 'unshorten' will return the original URL.
More info on 'unshorten' can be found here,
unshorten
Cheers!!!

35
Here is a simple bash script that shortens a long URL using tny.im. It can also shorten email, Bitcoin, Dogecoin, Litecoin addresses.

Code: [Select]
#!/bin/sh
if [ -t 0 ]; then
if [ -z "$1" ]; then
echo ""
echo "Shortens url with tny.im url shortener."
echo ""
echo "It shortens email & Bitcoin-Dogecoin-Litecoin addresses too."
echo ""
echo "Usage: tny long_url_address keyword"
echo ""
echo "Second argument 'keyword' is optional. Use it to customize the short url."
echo ""
exit 1
fi
url=$1;
else
while read -r line; do
url=$line
done
fi
printf "%s" "Short url -> " && echo `wget -q -O - http://tny.im/yourls-api.php?action=shorturl\&format=simple\&url="$url"\&keyword="$2"`


Save this script some where in your path with the name 'tny' and give it 'Execute' permission. Next time you want to shorten a long URL, simply run 'tny' from your terminal.
More info can be found here,
tny
Cheers!!!

36
General Support / logout option in vsido website from a mobile device
« on: April 29, 2015, 05:43:41 AM »
I'm sure there used to be a logout button on vsido site even when visited via a mobile browser. But now I can't seem to find it anywhere! It's not a huge problem but I thought I should bring this to VastOne's attension.
Cheers!!!

37
Scripts / Poor Man's Youtube Downloader
« on: April 26, 2015, 07:16:47 PM »

(11 September 2016) UPDATE BEGINS:

Added support to download videos in 4K and 1080P resolutions.
You can now download entire playlists in 4K -1080P resolutions.
Improved audio only download function. Audio only downloads are much faster now.
Suppressed scary & pointless youtube-dl warnings.

The script has become a bit too big to paste here directly so I'm linking the GitHub repo of pmytd here,
pmytd on GitHub
Please check-out the GitHub repo and update pmytd.

Cheers!!!

(11 September 2016) UPDATE ENDS:



(04 September 2016) UPDATE BEGINS:
A major update! Almost a complete rewrite!
Fixed the youtube-dl update function.
Added dependency check in the script.
Added option to install youtube-dl if it's not available.
Added option to download the video in the best quality skipping the manual selection. Thanks a & Snap!
And many other improvements.
The script has become a bit too big to paste here directly so I'm linking the GitHub repo of pmytd here,
pmytd on GitHub
Please check-out the GitHub repo and update pmytd.
Cheers!!!
(04 September 2016) UPDATE ENDS:



(23 August 2015) UPDATE BEGINS:
Removed overly complicated sudo availability check. Improved update-check part.
So here it is, the latest-greatest version of pmytd.

Code: [Select]
#!/bin/bash

function ByE (){
clear
echo ""
echo -e '\E[1;31;40m'"It's "'\E[1;32;40m'"funny "'\E[1;33;40m'" how"'\E[1;35;40m'" the"'\E[1;36;40m'" colors"'\E[1;31;40m'" of"'\E[1;32;40m'" the"'\E[1;33;40m'" real"'\E[1;35;40m'" world"'\E[1;36;40m'" only"'\E[1;31;40m'" seem"'\E[1;32;40m'" really"'\E[1;33;40m'" real"
echo -e '\E[1;36;40m'"when "'\E[1;31;40m'"you "'\E[1;32;40m'"viddy "'\E[1;33;40m'"them "'\E[1;35;40m'"on "'\E[1;36;40m'"the "'\E[1;31;40m'"screen."
echo ""
echo -e '\e[0m'"Alex, A Clockwork Orange"
echo ""
sleep 4
clear
exit 0
}

function HelP (){
clear
printf "%s\n" "" "Having problems running PMYTD?" "" "First make sure you have all the required dependencies installed." "You can read more about it in 'Dependencies of PMYTD' option" "in PMYTD MENU." "" "Having problems downloading videos?" "" "Youtube and other video sharing sites continually change their APIs." "So it is advised to keep youtube-dl updated to latest version." "You can check for youtube-dl updates via 'Check for updates' option" "in PMYTD MENU." "If there is a newer version available then please update youtube-dl." "" "For any other queries you can contact me at," "http://hakerdefo.blogspot.com" "" "Press 'q' to return to PMYTD MENU" "" | less
}

function UpdatE (){
clear
ping -q -c 2 yt-dl.org >/dev/null 2>&1 || { clear; echo -e "Can't connect to youtube-dl server! Please try later!" >&2; read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key; MenU; }
ytdllv=$(curl -sL -w "%{url_effective}\\n" "https://yt-dl.org/downloads/latest/" -o /dev/null | cut -c 29- | sed 's/[/]//g')
ytdlcv=$(youtube-dl --version)
if [ "$ytdllv" == "$ytdlcv" ]; then
echo ""
echo -e "Installed version of youtube-dl - $ytdlcv"
echo -e "Available version of youtube-dl - $ytdllv"
echo ""
echo -e "youtube-dl is up-to-date."
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
else
echo ""
echo -e "Installed version of youtube-dl - $ytdlcv"
echo -e "Available version of youtube-dl - $ytdllv"
echo ""
echo -e "youtube-dl update is available."
echo ""
echo -e "Would you like to update youtube-dl?"
echo ""
echo -e "01 Update youtube-dl"
echo -e "02 Return to PMYTD MENU"
echo ""
echo -e "Enter your choice: "
echo ""
read choice
case $choice in
1 | 01)
clear
ytdll=$(which youtube-dl)
if [ -w "$ytdll" ]; then
youtube-dl -U
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
else
resu=$(whoami)
echo ""
echo "Please enter password for user $resu"
echo ""
sudo youtube-dl -U
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
fi
;;
2 | 02)
clear
MenU
;;
*)
clear
echo ""
echo -e "$choice is an invalid option!"
echo ""
sleep 4
UpdatE
;;
esac
fi
}

function DiE(){
clear
echo ""
echo -e "OOPS!!! Something Went Wrong!!!"
echo -e "Please make sure '$link' exists."
echo -e "Also make sure video is available."
echo ""
exit 1
}

function AplS(){
clear
printf "%s\n" "" "Enter the youtube playlist link: " ""
read link
clear
youtube-dl --continue --yes-playlist --ignore-errors --extract-audio --audio-format "mp3" --audio-quality 0 --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
}

function VplS(){
clear
printf "%s\n" "" "Enter the youtube playlist link: " ""
read link
clear
youtube-dl --continue --yes-playlist --ignore-errors --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
}

function AudiO(){
clear
printf "%s\n" "" "Enter the youtube video link: " ""
read link
clear
youtube-dl --continue --extract-audio --audio-format "mp3" --audio-quality 0 --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
}

function FormaT(){
clear
printf "%s\n" "" "Enter the youtube video link: " ""
read link
clear
youtube-dl --list-formats "$link" || DiE
printf "%s\n" "" "Enter your desired video format code from the above list:" ""
read list
clear
youtube-dl --continue --format "$list" --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
}

function DependencieS(){
clear
printf "%s\n" "" "PMYTD needs to have following applications installed in order to function," "" "1. youtube-dl" "A small command-line program to download videos from youtube and other" "video sharing sites. It is available in repos of some distros but it" "would most likely be severly outdated. Here is the right way to install it," "Open terminal and run following commands," "'sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O " "/usr/local/bin/youtube-dl'" "'sudo chmod a+x /usr/local/bin/youtube-dl'" "" "youtube-dl homepage -> https://rg3.github.io/youtube-dl/" "" "2. Python" "Python should most likely be installed by default on your system." "If not install it via your distro's package manager." "" "Python homepage -> http://python.org" "" "3. FFmpeg" "Again ffmpeg should already be installed by default on most distros." "If not install it via your distro's package manager." "In some distros it is called avconv. ffprobe or avprobe are also required." "" "FFmpeg homepage -> https://www.ffmpeg.org/" "" "4. cURL" "curl is an open source command line tool and library for transferring data" "with URL syntax, supporting DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP," "IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMTP, SMTPS," "Telnet and TFTP." "You can easily install it using your package manager." "" "cURL homepage -> http://curl.haxx.se/" "" "5. Ping" "ping uses the ICMP protocol's mandatory ECHO_REQUEST datagram to elicit an" "ICMP ECHO_RESPONSE from a host or gateway." "ping is part of iputils package. Install iputils via your package manager." "" "iputils homepage -> http://www.skbuff.net/iputils/" "" "6. Downloads directory" "PMYTD is hard-wired to download video and audio to the Downloads directory" "under user's home directory." "Downloads directory should already be there by default but just in case make" "sure you have Downloads directory under your home folder." "" "Press 'q' to return to PMYTD MENU" "" | less
}

function AbouT(){
clear
printf "%s\n" "" "PMYTD is a simple script that can," "" "1. Download videos from youtube and other video sharing
websites." "2. Download and extract audio [mp3] from videos on youtube" "and other video sharing websites." "3. Download entire youtube playlists (video and audio)." "" "" "PMYTD is just a helper script for Ricardo Garcia's wonderful" "youtube-dl." "You can view the list of all supported video sharing websites here," "http://rg3.github.io/youtube-dl/supportedsites.html" "" "By the way PMYTD means Poor Man's YouTube Downloader. PMYTD is" "available under CC0 1.0 Universal licesense." "Got any question-suggestion? Please visit," "http://hakerdefo.blogspot.in/" "" "Press 'q' to return to PMYTD MENU" "" | less
}

function MenU(){
clear
echo ""
echo -e "PMYTD MENU"
echo ""
echo -e "01 About PMYTD"
echo -e "02 Dependencies of PMYTD"
echo -e "03 Download a video"
echo -e "04 Download & extract audio from video"
echo -e "05 Download entire youtube playlist"
echo -e "06 Download & extract audio from playlist"
echo -e "07 Check for updates"
echo -e "08 Help"
echo -e "09 Quit PMYTD"
echo ""
echo -e "Enter your choice: "
echo ""
read choice
case $choice in

01 | 1)
AbouT
;;

02 | 2)
DependencieS
;;

03 | 3)
FormaT
;;

04 | 4)
AudiO
;;

05 | 5)
VplS
;;

06 | 6)
AplS
;;

07 | 7)
UpdatE
;;

08 | 8)
HelP
;;

09 | 9)
ByE
;;

*)
clear
echo ""
echo -e "$choice is an invalid option!"
echo ""
sleep 4
;;

esac
}

while :
do

MenU

done


Cheers!!!


(23 August 2015) UPDATE ENDS:





(09 August 2015) UPDATE BEGINS:
A few cosmetic changes and one important change. Updated Dependencies information.
Here is the latest version,

Code: [Select]
#!/bin/bash

function ByE (){
clear
echo ""
echo -e '\E[1;31;40m'"It's "'\E[1;32;40m'"funny "'\E[1;33;40m'" how"'\E[1;35;40m'" the"'\E[1;36;40m'" colors"'\E[1;31;40m'" of"'\E[1;32;40m'" the"'\E[1;33;40m'" real"'\E[1;35;40m'" world"'\E[1;36;40m'" only"'\E[1;31;40m'" seem"'\E[1;32;40m'" really"'\E[1;33;40m'" real"
echo -e '\E[1;36;40m'"when "'\E[1;31;40m'"you "'\E[1;32;40m'"viddy "'\E[1;33;40m'"them "'\E[1;35;40m'"on "'\E[1;36;40m'"the "'\E[1;31;40m'"screen."
echo ""
echo -e '\e[0m'"Alex, A Clockwork Orange"
echo ""
sleep 4
clear
exit 0
}

function HelP (){
clear
printf "%s\n" "" "Having problems running PMYTD?" "" "First make sure you have all the required dependencies installed." "You can read more about it in 'Dependencies of PMYTD' option" "in PMYTD MENU." "" "Having problems downloading videos?" "" "Youtube and other video sharing sites continually change their APIs." "So it is advised to keep youtube-dl updated to latest version." "You can check for youtube-dl updates via 'Check for updates' option" "in PMYTD MENU." "If there is a newer version available then please update youtube-dl." "" "For any other queries you can contact me at," "http://hakerdefo.blogspot.com" "" "Press 'q' to return to PMYTD MENU" "" | less
}

function UpdatE (){
clear
ping -q -c 2 yt-dl.org >/dev/null 2>&1 || { clear; echo -e "Can't connect to youtube-dl server! Please try later!" >&2; read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key; MenU; }
ytdllv=$(curl -sL -w "%{url_effective}\\n" "https://yt-dl.org/downloads/latest/" -o /dev/null | tail -c-12 | sed 's/[/]//g')
ytdlcv=$(youtube-dl --version)
if [ "$ytdllv" == "$ytdlcv" ]; then
echo ""
echo -e "Installed version of youtube-dl - $ytdlcv"
echo -e "Available version of youtube-dl - $ytdllv"
echo ""
echo -e "youtube-dl is up-to-date."
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
else
echo ""
echo -e "Installed version of youtube-dl - $ytdlcv"
echo -e "Available version of youtube-dl - $ytdllv"
echo ""
echo -e "youtube-dl update is available."
echo ""
echo -e "Would you like to update youtube-dl?"
echo ""
echo -e "01 Update youtube-dl"
echo -e "02 Return to PMYTD MENU"
echo ""
echo -e "Enter your choice: "
echo ""
read choice
case $choice in
1 | 01)
clear
ytdll=$(which youtube-dl)
if [ -w "$ytdll" ]; then
youtube-dl -U
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
else
resu=$(whoami)
resu_test=$(sudo -u "$resu" -n true >/dev/null 2>&1)
if [[ -z "$resu_test" ]]; then
echo ""
echo -e "Please enter root password"
echo ""
su -c 'youtube-dl -U'
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
else
echo ""
echo "Please enter password for user $resu"
echo ""
sudo youtube-dl -U
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
fi
fi
;;
2 | 02)
clear
MenU
;;
*)
clear
echo ""
echo -e "$choice is an invalid option!"
echo ""
sleep 4
UpdatE
;;
esac
fi
}

function DiE(){
clear
echo ""
echo -e "OOPS!!! Something Went Wrong!!!"
echo -e "Please make sure '$link' exists."
echo -e "Also make sure video is available."
echo ""
exit 1
}

function AplS(){
clear
printf "%s\n" "" "Enter the youtube playlist link: " ""
read link
clear
youtube-dl --continue --yes-playlist --ignore-errors --extract-audio --audio-format "mp3" --audio-quality 0 --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
}

function VplS(){
clear
printf "%s\n" "" "Enter the youtube playlist link: " ""
read link
clear
youtube-dl --continue --yes-playlist --ignore-errors --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
}

function AudiO(){
clear
printf "%s\n" "" "Enter the youtube video link: " ""
read link
clear
youtube-dl --continue --extract-audio --audio-format "mp3" --audio-quality 0 --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
}

function FormaT(){
clear
printf "%s\n" "" "Enter the youtube video link: " ""
read link
clear
youtube-dl --list-formats "$link" || DiE
printf "%s\n" "" "Enter your desired video format code from the above list:" ""
read list
clear
youtube-dl --continue --format "$list" --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
}

function DependencieS(){
clear
printf "%s\n" "" "PMYTD needs to have following applications installed in order to function," "" "1. youtube-dl" "A small command-line program to download videos from youtube and other" "video sharing sites. It is available in repos of some distros but it" "would most likely be severly outdated. Here is the right way to install it," "Open terminal and run following commands," "'sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O " "/usr/local/bin/youtube-dl'" "'sudo chmod a+x /usr/local/bin/youtube-dl'" "" "youtube-dl homepage -> https://rg3.github.io/youtube-dl/" "" "2. Python" "Python should most likely be installed by default on your system." "If not install it via your distro's package manager." "" "Python homepage -> http://python.org" "" "3. FFmpeg" "Again ffmpeg should already be installed by default on most distros." "If not install it via your distro's package manager." "In some distros it is called avconv. ffprobe or avprobe are also required." "" "FFmpeg homepage -> https://www.ffmpeg.org/" "" "4. cURL" "curl is an open source command line tool and library for transferring data" "with URL syntax, supporting DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP," "IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMTP, SMTPS," "Telnet and TFTP." "You can easily install it using your package manager." "" "cURL homepage -> http://curl.haxx.se/" "" "5. Ping" "ping uses the ICMP protocol's mandatory ECHO_REQUEST datagram to elicit an" "ICMP ECHO_RESPONSE from a host or gateway." "ping is part of iputils package. Install iputils via your package manager." "" "iputils homepage -> http://www.skbuff.net/iputils/" "" "6. Downloads directory" "PMYTD is hard-wired to download video and audio to the Downloads directory" "under user's home directory." "Downloads directory should already be there by default but just in case make" "sure you have Downloads directory under your home folder." "" "Press 'q' to return to PMYTD MENU" "" | less
}

function AbouT(){
clear
printf "%s\n" "" "PMYTD is a simple script that can," "" "1. Download videos from youtube and other video sharing
websites." "2. Download and extract audio [mp3] from videos on youtube" "and other video sharing websites." "3. Download entire youtube playlists (video and audio)." "" "" "PMYTD is just a helper script for Ricardo Garcia's wonderful" "youtube-dl." "You can view the list of all supported video sharing websites here," "http://rg3.github.io/youtube-dl/supportedsites.html" "" "By the way PMYTD means Poor Man's YouTube Downloader. PMYTD is" "available under CC0 1.0 Universal licesense." "Got any question-suggestion? Please visit," "http://hakerdefo.blogspot.in/" "" "Press 'q' to return to PMYTD MENU" "" | less
}

function MenU(){
clear
echo ""
echo -e "PMYTD MENU"
echo ""
echo -e "01 About PMYTD"
echo -e "02 Dependencies of PMYTD"
echo -e "03 Download a video"
echo -e "04 Download & extract audio from video"
echo -e "05 Download entire youtube playlist"
echo -e "06 Download & extract audio from playlist"
echo -e "07 Check for updates"
echo -e "08 Help"
echo -e "09 Quit PMYTD"
echo ""
echo -e "Enter your choice: "
echo ""
read choice
case $choice in

01 | 1)
AbouT
;;

02 | 2)
DependencieS
;;

03 | 3)
FormaT
;;

04 | 4)
AudiO
;;

05 | 5)
VplS
;;

06 | 6)
AplS
;;

07 | 7)
UpdatE
;;

08 | 8)
HelP
;;

09 | 9)
ByE
;;

*)
clear
echo ""
echo -e "$choice is an invalid option!"
echo ""
sleep 4
;;

esac
}

while :
do

MenU

done


Cheers!!!

(09 August 2015) UPDATE ENDS:





(07 August 2015) UPDATE BEGINS:
Another update to 'Poor Man's Youtube Downloader'
So what's new?
'Check for updates' option is vastly improved. It now comapres the installed version of youtube-dl with available version and if an update is available gives user option to update youtube-dl.
The script will also check whether the user has the permission to update youtube-dl or not. If the user doesn't have the permission then the script will check whether the user has access to sudo or not. If the user have access to sudo then the script will use sudo to update youtube-dl else the script will use 'su'. This doesn't directly affect VSIDO but I wanted to make ''Poor Man's Youtube Downloader'' work on any distribution.
This update also make the script handle the errors related to connection and video availability in more efficient way.
View-Reviews-Comments are welcome!
Here is the updated script,

Code: [Select]
#!/bin/bash

function ByE (){
clear
echo ""
echo -e '\E[1;31;40m'"It's "'\E[1;32;40m'"funny "'\E[1;33;40m'" how"'\E[1;35;40m'" the"'\E[1;36;40m'" colors"'\E[1;31;40m'" of"'\E[1;32;40m'" the"'\E[1;33;40m'" real"'\E[1;35;40m'" world"'\E[1;36;40m'" only"'\E[1;31;40m'" seem"'\E[1;32;40m'" really"'\E[1;33;40m'" real"
echo -e '\E[1;36;40m'"when "'\E[1;31;40m'"you "'\E[1;32;40m'"viddy "'\E[1;33;40m'"them "'\E[1;35;40m'"on "'\E[1;36;40m'"the "'\E[1;31;40m'"screen."
echo ""
echo -e '\e[0m'"Alex, A Clockwork Orange"
echo ""
sleep 4
clear
exit 0
}

function HelP (){
clear
printf "%s\n" "" "Having problems running PMYTD?" "" "First make sure you have all the required dependencies installed." "You can read more about it in 'Dependencies of PMYTD' option" "in PMYTD MENU." "" "Having problems downloading videos?" "" "Youtube and other video sharing sites continually change their APIs." "So it is advised to keep youtube-dl updated to latest version." "You can check for youtube-dl updates via 'Check for updates' option" "in PMYTD MENU." "If there is a newer version available then please update youtube-dl." "" "For any other queries you can contact me at," "http://hakerdefo.blogspot.com" "" "Press 'q' to return to PMYTD MENU" "" | less
}

function UpdatE (){
clear
ytdllv=$(curl -sL -w "%{url_effective}\\n" "https://yt-dl.org/downloads/latest/" -o /dev/null | tail -c-12 | sed 's/[/]//g')
ytdlcv=$(youtube-dl --version)
if [ "$ytdllv" == "$ytdlcv" ]; then
echo ""
echo -e "Installed version of youtube-dl - $ytdlcv"
echo -e "Available version of youtube-dl - $ytdllv"
echo ""
echo -e "youtube-dl is up-to-date."
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
else
echo ""
echo -e "Installed version of youtube-dl - $ytdlcv"
echo -e "Available version of youtube-dl - $ytdllv"
echo ""
echo -e "youtube-dl update is available."
echo ""
echo -e "Would you like to update youtube-dl?"
echo ""
echo -e "01 Update youtube-dl"
echo -e "02 Return to PMYTD MENU"
echo ""
echo -e "Enter your choice: "
echo ""
read choice
case $choice in
1 | 01)
clear
ytdll=$(which youtube-dl)
if [ -w "$ytdll" ]; then
youtube-dl -U
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
else
resu=$(whoami)
resu_test=$(sudo -u "$resu" -n true >/dev/null 2>&1)
if [[ -z "$resu_test" ]]; then
echo ""
echo -e "Please enter root password"
echo ""
su -c 'youtube-dl -U'
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
else
echo ""
echo "Please enter password for user $resu"
echo ""
sudo youtube-dl -U
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
fi
fi
;;

2 | 02)
clear
MenU
;;

*)
clear
echo ""
echo -e "$choice is an invalid option!"
echo ""
sleep 4
UpdatE
;;
esac
fi
}

function DiE(){
clear
echo ""
echo -e "OOPS!!! Something Went Wrong!!!"
echo -e "Please make sure '$link' exists."
echo -e "Also make sure video is available."
echo ""
exit 1
}

function AplS(){
clear
printf "%s\n" "" "Enter the youtube playlist link: " ""
read link
clear
youtube-dl --continue --yes-playlist --ignore-errors --extract-audio --audio-format "mp3" --audio-quality 0 --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
}

function VplS(){
clear
printf "%s\n" "" "Enter the youtube playlist link: " ""
read link
clear
youtube-dl --continue --yes-playlist --ignore-errors --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
}

function AudiO(){
clear
printf "%s\n" "" "Enter the youtube video link: " ""
read link
clear
youtube-dl --continue --extract-audio --audio-format "mp3" --audio-quality 0 --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
}

function FormaT(){
clear
printf "%s\n" "" "Enter the youtube video link: " ""
read link
clear
youtube-dl --list-formats "$link" || DiE
printf "%s\n" "" "Enter your desired video format code from the above list:" ""
read list
clear
youtube-dl --continue --newline --format "$list" --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
echo ""
read -rsp $'Press any key to return to PMYTD MENU...\n' -n1 key
echo ""
clear
MenU
}

function DependencieS(){
clear
printf "%s\n" "" "PMYTD needs to have following applications installed in order to function," "" "1. youtube-dl" "A small command-line program to download videos from youtube and other" "video sharing sites. It is available in repos of some distros but it" "would most likely be severly outdated. Here is the right way to install it," "Open terminal and run following commands," "'sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O " "/usr/local/bin/youtube-dl'" "'sudo chmod a+x /usr/local/bin/youtube-dl'" "" "youtube-dl homepage -> https://rg3.github.io/youtube-dl/" "" "2. Python" "Python should most likely be installed by default on your system." "If not install it via your distro's package manager." "" "Python homepage -> http://python.org" "" "3. FFmpeg" "Again ffmpeg should already be installed by default on most distros." "If not install it via your distro's package manager." "In some distros it is called avconv. ffprobe or avprobe are also required." "" "FFmpeg homepage -> https://www.ffmpeg.org/" "" "4. Downloads directory" "PMYTD is hard-wired to download video and audio to the Downloads directory" "under user's home directory." "Downloads directory should already be there by default but just in case make" "sure you have Downloads directory under your home folder." "" "Press 'q' to return to PMYTD MENU" "" | less
}

function AbouT(){
clear
printf "%s\n" "" "PMYTD is a simple script that can," "" "1. Download videos from youtube and other video sharing
websites." "2. Download and extract audio [mp3] from videos on youtube" "and other video sharing websites." "3. Download entire youtube playlists (video and audio)." "" "" "PMYTD is just a helper script for Ricardo Garcia's wonderful" "youtube-dl." "You can view the list of all supported video sharing websites here," "http://rg3.github.io/youtube-dl/supportedsites.html" "" "By the way PMYTD means Poor Man's YouTube Downloader. PMYTD is" "available under CC0 1.0 Universal licesense." "Got any question-suggestion? Please visit," "http://hakerdefo.blogspot.in/" "" "Press 'q' to return to PMYTD MENU" "" | less
}

function MenU(){
clear
echo ""
echo -e "PMYTD MENU"
echo ""
echo -e "01 About PMYTD"
echo -e "02 Dependencies of PMYTD"
echo -e "03 Download a video"
echo -e "04 Download & extract audio from video"
echo -e "05 Download entire youtube playlist"
echo -e "06 Download & extract audio from playlist"
echo -e "07 Check for updates"
echo -e "08 Help"
echo -e "09 Quit PMYTD"
echo ""
echo -e "Enter your choice: "
echo ""
read choice
case $choice in

01 | 1)
AbouT
;;

02 | 2)
DependencieS
;;

03 | 3)
FormaT
;;

04 | 4)
AudiO
;;

05 | 5)
VplS
;;

06 | 6)
AplS
;;

07 | 7)
UpdatE
;;

08 | 8)
HelP
;;

09 | 9)
ByE
;;

*)
clear
echo ""
echo -e "$choice is an invalid option!"
echo ""
sleep 4
;;

esac
}

while :
do

MenU

done


Cheers!!!

(07 August 2015) UPDATE ENDS:






(08 July 2015) EDIT BEGINS:

I've improved 'Check for updates' option. And there are numerous other cosmetic changes. Here is the latest version of pmytd,

Code: [Select]
#!/bin/bash

function Bye (){
clear
printf "%s\n" "" "Thanks.. Bye Bye.." ""
sleep 2
clear
exit 0
}

function Update (){
ytdllv=$(curl -sL -w "%{url_effective}\\n" "https://yt-dl.org/downloads/latest/" -o /dev/null | tail -c-12 | sed 's/[/]//g')
ytdlcv=$(youtube-dl --version)
printf "%s\n" "" "Installed version of youtube-dl is - $ytdlcv" "" "Latest available version of youtube-dl is - $ytdllv" "" "Press 'q' to return to PMYTD MENU" "" | less
}

function Apls(){
clear
printf "%s\n" "" "Enter the youtube playlist link: " ""
read link
clear
youtube-dl --continue --yes-playlist --ignore-errors --extract-audio --audio-format "mp3" --audio-quality 0 --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
exit 0
}

function Vpls(){
clear
printf "%s\n" "" "Enter the youtube playlist link: " ""
read link
clear
youtube-dl --continue --yes-playlist --ignore-errors --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
exit 0
}

function Audio(){
clear
printf "%s\n" "" "Enter the youtube video link: " ""
read link
clear
youtube-dl --continue --extract-audio --audio-format "mp3" --audio-quality 0 --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
exit 0
}

function Format(){
clear
printf "%s\n" "" "Enter the youtube video link: " ""
read link
clear
youtube-dl --list-formats "$link"
printf "%s\n" "" "Enter your desired video format code from the above list:" ""
read list
clear
youtube-dl --continue --format "$list" --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
exit 0
}

function Dependencies(){
printf "%s\n" "PMYTD needs to have following applications installed in order to function," "" "1. youtube-dl" "A small command-line program to download videos from youtube and other" "video sharing sites. It is available in repos of some distros but it" "would most likely be severly outdated. Here is the right way to install it," "Open terminal and run following commands," "'sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O " "/usr/local/bin/youtube-dl'" "'sudo chmod a+x /usr/local/bin/youtube-dl'" "" "youtube-dl homepage -> https://rg3.github.io/youtube-dl/" "" "2. Python" "Python should most likely be installed by default on your system." "If not install it via your distro's package manager." "" "Python homepage -> http://python.org" "" "3. FFmpeg" "Again ffmpeg should already be installed by default on most distros." "If not install it via your distro's package manager." "In some distros it is called avconv. ffprobe or avprobe are also required." "" "FFmpeg homepage -> https://www.ffmpeg.org/" "" "4. Downloads directory" "PMYTD is hard-wired to download video and audio to the Downloads directory" "under user's home directory." "Downloads directory should already be there by default but just in case make" "sure you have Downloads directory under your home folder." "" "Press 'q' to return to PMYTD MENU" "" | less
}

function About(){
printf "%s\n" "PMYTD is a simple script that can," "" "1. Download videos from youtube and other video sharing
websites." "2. Download and extract audio [mp3] from videos on youtube" "and other video sharing websites." "3. Download entire youtube playlists (video and audio)." "" "" "PMYTD is just a helper script for Ricardo Garcia's wonderful" "youtube-dl." "You can view the list of all supported video sharing websites here," "http://rg3.github.io/youtube-dl/supportedsites.html" "" "Youtube and other video sharing sites continually change their APIs." "So it is advised to keep youtube-dl updated to latest version." "You can check for youtube-dl updates via 'Check for updates' option" "in PMYTD MENU." "If there is a newer version available then you can update youtube-dl" "by running following command in terminal," "'sudo youtube-dl -U'" "" "By the way PMYTD means Poor Man's YouTube Downloader. PMYTD is" "available under CC0 1.0 Universal licesense." "Got any question-suggestion? Please visit," "http://hakerdefo.blogspot.in/" "" "Press 'q' to return to PMYTD MENU" "" | less
}

while :
do
clear
cat << !
PMYTD MENU

1. About PMYTD
2. Dependencies of PMYTD
3. Download a video
4. Download & extract audio from video
5. Download entire youtube playlist
6. Download & extract audio from playlist
7. Check for updates
8. Quit PMYTD

!
echo -n "Enter your choice: "
read choice
case $choice in
1) About ;;
2) Dependencies ;;
3) Format ;;
4) Audio ;;
5) Vpls ;;
6) Apls ;;
7) Update ;;
8) Bye ;;
*) clear; printf "%s\n" "\"$choice\" is an invalid option!"; sleep 3;;
esac
done


(08 July 2015) EDIT ENDS:


It's been a while since I visited the forum! Reason? I'm without any proper Internet connection lately! Anyways I came across this topic by VastOne,
CHALLENGE Muz/gyts script fix/alternatives Yad script
Now I'm not a Bash scripting guru so you are free to improve-modify this script. Just save this script somewhere in your path with the name 'pmytd' and 'chmod 755' it. Run 'pmytd' from your terminal whenever you feel like scraping youtube  :)

Code: [Select]
#!/bin/bash

function Bye (){
printf "%s\n" "" "Thanks.. Bye Bye.." ""
sleep 3
clear
exit 0
}

function Update (){
youtube-dl --simulate -U | less
}

function Apls(){
printf "%s\n" "" "Enter the youtube playlist link" ""
read link
youtube-dl --continue --yes-playlist --ignore-errors --extract-audio --audio-format "mp3" --audio-quality 0 --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
exit 0
}

function Vpls(){
printf "%s\n" "" "Enter the youtube playlist link" ""
read link
youtube-dl --continue --yes-playlist --ignore-errors --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
exit 0
}

function Audio(){
printf "%s\n" "" "Enter the youtube video link" ""
read link
youtube-dl --continue --extract-audio --audio-format "mp3" --audio-quality 0 --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
exit 0
}

function Format(){
printf "%s\n" "" "Enter the youtube video link" ""
read link
youtube-dl --list-formats "$link"
printf "%s\n" "" "Enter your desired video format code from the above list" ""
read list
youtube-dl --continue --format "$list" --output "/home/$USER/Downloads/%(title)s.%(ext)s" "$link"
exit 0
}

function Dependencies(){
printf "%s\n" "PMYTD needs to have following applications installed in order to function," "" "1. youtube-dl" "A small command-line program to download videos from youtube and other video sharing sites. It is available in repos of some distros but chances are that it is severly outdated. Here is the right way to install it," "Open terminal and run following commands," "'sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl'" "'sudo chmod a+x /usr/local/bin/youtube-dl'" "" "Youtube and other video sharing sites continually change their APIs." "So it is advised to keep youtube-dl updated to latest version." "You can check for youtube-dl updates via 'Check for update' option in PMYTD MENU." "If there is a newer version available then you can update youtube-dl by running following command in terminal," "'sudo youtube-dl -U'" "http://rg3.github.io/youtube-dl/" "" "2. Python" "Python should most likely be installed by default on your system. If not install it via your distro's package manager." "http://python.org" "" "3. FFmpeg" "Again ffmpeg should already be installed by default on most distros. If not install it via your distro's package manager." "In some distros it is called avconv. ffprobe or avprobe are also required." "https://www.ffmpeg.org/" "" "4. Downloads directory" "PMYTD is hard-wired to download video and audio to the Downloads directory under user's home directory." "Downloads directory should already be there by default but just in case make sure you have Downloads directory under your home folder." "" "Press 'q' to return to PMYTD MENU" | less
}

function About(){
printf "%s\n" "PMYTD is a simple script that can," "" "1. Download videos from youtube and other video sharing
websites." "" "2. Download and extract audio [mp3] from videos on youtube and other video sharing websites." "" "3. Download entire youtube playlists (video and audio)." "" "PMYTD is just a helper script for Ricardo Garcia's wonderful youtube-dl." "You can view the list of all supported websites here," "http://rg3.github.io/youtube-dl/supportedsites.html" "" "By the way PMYTD means Poor Man's YouTube Downloader. PMYTD is available under WTFPL licesense." "Got any question-suggestion? Please visit," "http://hakerdefo.blogspot.in/" "" "Press 'q' to return to PMYTD MENU" | less
}

while :
do
clear
cat << !
PMYTD MENU

1. About PMYTD
2. Dependencies of PMYTD
3. Download a video
4. Download & extract audio from video
5. Download entire youtube playlist
6. Download & extract audio from playlist
7. Check for update
8. Quit PMYTD

!
echo -n "Enter your choice "
read choice
case $choice in
1) About ;;
2) Dependencies ;;
3) Format ;;
4) Audio ;;
5) Vpls ;;
6) Apls ;;
7) Update ;;
8) Bye ;;
*) echo "\"$choice\" is invalid"; sleep 3;;
esac
done


Cheers!!!

38
I've Got a Life / Trouble with upgrades
« on: December 07, 2014, 09:04:04 AM »
I stumbled across this gem and felt that I had to share this,
Quote
Last year a friend of mine upgraded GirlFriend 1.0 to Wife 1.0 and found that it's a memory hog leaving very little system resources for other applications. He is only now noticing that Wife 1.0 also is spawning Child-Processes which are further consuming valuable resources. No mention of this particular phenomena was included in the product brochure or the documentation, though other users have informed him that this is to be expected due to the nature of the application.

Not only that, Wife 1.0 installs itself such that it is always launched at system initialization where it can monitor all other system activity. He's finding that some applications such as PokerNight 10.3, BeerBash 2.5, and PubNight 7.0 are no longer able to run in the system at all, crashing the system when selected (even though they always worked fine before). At installation, Wife 1.0 provides no option as to the installation of undesired Plug-Ins such as MotherInLaw 55.8 and BrotherInLaw Beta release. Also, system performance seems to diminish with each passing day.

Some features he'd like to see in the upcoming wife 2.0.

    A "Don't remind me again" button
    Minimize button
    An install shield feature that allows Wife 2.0 be installed with the option to uninstall at anytime without the loss of cache and other system resources.
    An option to run the network driver in promiscuous mode which would allow the systems hardware probe feature to be much more useful.

I myself decided to avoid all of the headaches associated with Wife 1.0 by sticking with Girlfriend 2.0. Even here, however, I found many problems. Apparently you cannot install Girlfriend 2.0 on top of Girlfriend 1.0. You must uninstall Girlfriend 1.0 first. Other users say this is a long standing bug which I should have been aware of. Apparently the versions of Girlfriend have conflicts over shared use of the I/O port. You think they would have fixed such a stupid bug by now. To make matters worse, The uninstall program for Girlfriend 1.0 doesn't work very well leaving undesirable traces of the application in the system.

Another irritating feature -- all versions of Girlfriend continually popup little annoying messages about the advantages of upgrading to Wife 2.0.

***** BUG WARNING *****

Wife 1.0 has an undocumented bug. If you try to install Mistress 1.1 before uninstalling Wife 1.0, Wife 1.0 will delete MSMoney files before doing the uninstall itself. Then Mistress 1.1 will refuse to install, claiming insufficient resources.

***** BUG WORK-AROUNDS *****

To avoid the above bug, try installing Mistress 1.1 on a different system and never run any file transfer applications such as Laplink 6.0.

Also, beware of similar shareware applications that have been known to carry viruses that may affect Wife 1.0. Another solution would be to run Mistress 1.0 via a UseNet provider under an anonymous name. Here again, beware of the viruses which can accidentally be downloaded from the UseNet.

More funny stuff here if you liked this one,
http://www.mipmip.org/tidbits/techie.shtml

Cheers!!!

39
How To's / exit status of last command in bash prompt
« on: May 23, 2014, 03:21:21 PM »
I know there are gazillion examples out there on the net about this but almost all of them use 'if-then-else' to achieve this. Which in my view is not very efficient. The one I'm going to present here uses built-in arithmetic option of bash shell and there for is more efficient and Eco-friendly  ;)
If the last command you ran in the terminal failed this will turn '$' ['#' for root] in bash prompt (PS1) an angry red like this,


But if the command was successful $' ['#' for root] will remain peaceful white,


If you think this is cool then all you need to do is open '.bashrc' file in your favorite text-editor and just copy-paste the following at the end of the file,

Code: [Select]
export PS1='${debian_chroot:+($debian_chroot)}\[\e[01;32m\]\u \[\e[01;37m\]> \[\e[01;33m\]\w\n\[\e[$(((($?>0))*31))m\]\$\[\e[0m\] '
Save the file and run the following in your terminal to apply the changes,

Code: [Select]
source .bashrc
Cheers!!!

40
Scripts / a little bash script to check package management history
« on: May 11, 2014, 11:35:44 AM »
This handy script makes it very easy to extract package management details like installation, update, removal, and rollback. Basic usage of script goes like this.
For getting information on packages installed,
Code: [Select]
apthistory installFor getting information on removed packages,
Code: [Select]
apthistory removeTo check package upgrades
Code: [Select]
apthistory upgradeTo list rolledback packages,
Code: [Select]
apthistory rollbackOfcourse you can pipe the output and grep to your heart's content  8)
Here's the script,
Code: [Select]
#!/bin/bash

### Author:      Benjamin York
### Date:        2011-01-08
###
### Based On:
### http://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
###
### Hosted At:
### https://github.com/blyork/apt-history
###
### Git Repository:
### git://github.com/blyork/apt-history.git
###
### Description:
### Parses dpkg log files to get package installation, removal, and rollback
### information.
###
### Ubuntu Server likes to split up the dpkg.log file and then compress the
### various pieces. After seeing LinuxCommando's function, I added functionality
### to pull the pieces back together. I also slightly adjusted the output to
### avoid false positives.

function echoHistory(){
    if [[ $1 == *.gz ]] ; then
        gzip -cd $1
    else
        if [[ $1 == *.log || $1 == *.log.1 ]] ; then
            cat $1
        else
            echo "\*\*\* Invalid File: ${1} \*\*\*" 1>&2
        fi
    fi
}

FILES=( `ls -rt /var/log/dpkg.log*` ) || exit 1

for file in "${FILES[@]}"
do
    case "$1" in
        install)
            echoHistory $file | grep " install "
        ;;

        upgrade|remove)
            echoHistory $file | grep " ${1} "
        ;;
                 
        rollback)
            echoHistory $file | grep upgrade | \
                grep "$2" -A10000000 | \
                grep "$3" -B10000000 | \
                awk '{print $4"="$5}'
        ;;

        list)
            echoHistory $file
        ;;

        *)
            echo "Parameters:"
            echo "     install  - Lists all packages that have been installed."
            echo "     upgrade  - Lists all packages that have been upgraded."
            echo "     remove   - Lists all packages that have been removed."
            echo "     rollback - Lists rollback information."
            echo "     list     - Lists all contents of dpkg logs."
            break
        ;;
    esac
done

exit 0
Cheers!!!

41
VastOne has worked very hard to create this beautiful fluxbox based environment. But when you open SMPlayer it doesn't blend with the look of Vsido. It looks kind of ugly. Why it does look different? Because it is built using Qt toolkit instead of Gtk toolkit. Other applications built using Qt will also look out of place in Vsido.
Solution? Very easy. Open your favourite text editor and add following,
Code: [Select]
[Qt]

style=GTK
Save this file as 'Trolltech.conf' in the '~/.config' directory. Chances are that the file already exists. If so just overwrite it when prompted. Logout and log back in. Now open SMPlayer and it will look exactly like the rest of the applications.
VastOne can add this 'Trolltech.conf' in '/etc/skel/.config' of the next Vsido iso and users won't have to do this manually.
Cheers!!!

42
VSIDO Discussions / IgnorantGuru put SpaceFM on indefinite hiatus
« on: May 04, 2014, 06:20:12 PM »
He announced this news six days back. I guess this was inevitable after Debian's move to systemd. Here is the link to his post,
http://igurublog.wordpress.com/2014/04/28/ignorantgurus-hiatus/

43
Scripts / Adblock Script
« on: March 25, 2014, 10:55:20 AM »
As reported here,
http://vsido.org/index.php?topic=752.msg8424#msg8424

and here,
http://vsido.org/index.php?topic=752.msg8447#msg8447

It seems AdBlock is going astray. Here is a simpler and system wide alternative to AdBlock. Just save this bash script somewhere in your path, Give it 'Execute' permission, Run it and follow simple instruction given by the script. That's it. You will have a system wide, Cross browser adblocker deployed. And yes don't forget to run the script once a week to keep the database updated.

Code: [Select]
#!/bin/bash

# If this is our first run, save a copy of the system's original hosts file and set to read-only for safety
if [ ! -f ~/.hosts-system ]
then
 echo "Saving copy of system's original hosts file..."
 cp /etc/hosts ~/.hosts-system
 chmod 444 ~/.hosts-system
fi

# Perform work in temporary files
temphosts1=$(mktemp)
temphosts2=$(mktemp)

# Obtain various hosts files and merge into one
echo "Downloading ad-blocking hosts files..."
wget -nv -O - http://winhelp2002.mvps.org/hosts.txt >> "$temphosts1"
wget -nv -O - http://hosts-file.net/ad_servers.asp >> "$temphosts1"
wget -nv -O - http://someonewhocares.org/hosts/hosts >> "$temphosts1"
wget -nv -O - "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext" >> "$temphosts1"

# Do some work on the file:
# 1. Remove MS-DOS carriage returns
# 2. Delete all lines that don't begin with 127.0.0.1
# 3. Delete any lines containing the word localhost because we'll obtain that from the original hosts file
# 4. Replace 127.0.0.1 with 0.0.0.0 because then we don't have to wait for the resolver to fail
# 5. Scrunch extraneous spaces separating address from name into a single tab
# 6. Delete any comments on lines
# 7. Clean up leftover trailing blanks
# Pass all this through sort with the unique flag to remove duplicates and save the result
echo "Parsing, cleaning, de-duplicating, sorting..."
sed -e 's/\r//' -e '/^127.0.0.1/!d' -e '/localhost/d' -e 's/127.0.0.1/0.0.0.0/' -e 's/ \+/\t/' -e 's/#.*$//' -e 's/[ \t]*$//' < "$temphosts1" | sort -u > "$temphosts2"

# Combine system hosts with adblocks
echo Merging with original system hosts...
echo -e "\n# Ad blocking hosts generated" "$date" | cat ~/.hosts-system - "$temphosts2" > ~/.hosts-block

# Clean up temp files and remind user to copy new file
echo "Cleaning up..."
rm "$temphosts1" "$temphosts2"
echo "Done."
echo
echo "Copy ad-blocking hosts file with this command:"
echo "sudo cp ~/.hosts-block /etc/hosts"
echo
echo "You can always restore your original hosts file with this command:"
echo "sudo cp ~/.hosts-system /etc/hosts"
echo "so don't delete that file! (It's saved read-only for your protection.)"

Cheers!!!

44
Scripts / MOC now playing lyrics script
« on: January 24, 2014, 10:38:55 AM »
I've this script that fetches lyrics of currently playing song in MOC and displays it in terminal,

Code: [Select]
#!/bin/sh
TITLE="`mocp -i | grep 'Title:' | sed -e 's/^.*: //'`";
if [ "$TITLE" != "" ]; then
ARTIST="`mocp -i | grep 'Artist:' | sed -e 's/^.*: //'`";
SONGTITLE="`mocp -i | grep 'SongTitle:' | sed -e 's/^.*: //'`";
ALBUM="`mocp -i | grep 'Album:' | sed -e 's/^.*: //'`";
if [ "$ARTIST" != "" ]; then ARTIST="$ARTIST"; fi
if [ "$ALBUM" != "" ]; then ALBUM="($ALBUM)"; fi
#echo $ARTIST $SONGTITLE $ALBUM
#else echo „MOC”
#fi
artist=`echo "$ARTIST" | perl -MURI::Escape -ne 'chomp;print uri_escape($_),"\n"'`
title=`echo "$SONGTITLE" | perl -MURI::Escape -ne 'chomp;print uri_escape($_),"\n"'`
song=`curl -s "http://makeitpersonal.co/lyrics?artist=$artist&title=$title"`
echo "$SONGTITLE - $ARTIST - $ALBUM\n$song" | less
else echo „MOC”
fi

It works fine most of the time but fails in some instances when a song tag or artist tag contains some extra characters.
Any ideas to parse tags more efficiently and make them more url friendly?
Cheers.

45
General Support / Choppy 720p video playback in Debian
« on: January 20, 2014, 11:01:03 AM »
I was a bit reluctant to post this as it is not exactly a VSIDO specific problem. But someone whispered in my ear to go ahead and post it so...
My main machine has modest specs. AMD Sempron 2800+ processor running at 1600 MHZ, 2 Gigs of RAM, Motherboard with VIA k8M800 chipset. Now VIA never released proper Linux graphics drivers for this chipset and the only functional drivers are provided by OpenChrome project. This is not a great system but it fulfills my modest needs.
Here is the problem part. I've a few 720p videos and when I play them the playback is choppy and slow. All necessary codecs like libav family, gstreamer family, w32codecs are installed. openchrome driver is installed. Now this choppy playback occurs on every Debian distro I have on this machine. VSIDO, Semplice, and a custom Sid install.
Here is the interesting part, I also have Bodhi Linux [based on Ubuntu Precise 12.04] and Salix 14.0 [based on slackware 14.0] installed on this machine and the 720p videos play fine there. There is no stutter in video playback.
I've tried different kernels ranging from 3.2 to liquorix 3.12.7. I've tried mplayer2 and the newer mpv. mplayer2 and mpv configs are identical across Bodhi-Salix and all Debian flavors.
So why the playback is choppy on Debian based distros and okay in Salix-Bodhi?
Here's my mplayer2 config,

Code: [Select]
ao=alsa
vo=xv
cache=8192
cache-min=20
cache-seek-min=50
double=yes
ontop=yes
stop-xscreensaver=yes
idx=yes
ass=yes
embeddedfonts=yes
sub-fuzziness=1
slang=en

And mpv config,
Code: [Select]
ao=alsa
vo=xv
cache-default=8192
cache=8192
cache-min=20
cache-seek-min=50
fs=no
osc=no
ontop=yes
softvol=no
slang=en
stop-screensaver=yes
user-agent="Mozilla/5.0"

Here is detailed info of a video file that stutters under Debian,
Code: [Select]
Format                                   : MPEG-4
Format profile                           : Base Media / Version 2
Codec ID                                 : mp42
File size                                : 87.5 MiB
Duration                                 : 5mn 28s
Overall bit rate mode                    : Variable
Overall bit rate                         : 2 232 Kbps
Encoded date                             : UTC 2011-05-05 19:43:07
Tagged date                              : UTC 2011-05-05 19:43:07
gsst                                     : 0
gstd                                     : 328771
gssd                                     : BADC23143HH1340962604252990
gshh                                     : o-o.preferred.sin01s10.v3.lscache7.c.youtube.com

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L3.1
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 1 frame
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 5mn 28s
Bit rate                                 : 2 076 Kbps
Maximum bit rate                         : 5 886 Kbps
Width                                    : 1 280 pixels
Height                                   : 720 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Variable
Frame rate                               : 23.976 fps
Minimum frame rate                       : 17.241 fps
Maximum frame rate                       : 24.390 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.094
Stream size                              : 81.4 MiB (93%)
Tagged date                              : UTC 2011-05-05 19:43:09

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : 40
Duration                                 : 5mn 28s
Bit rate mode                            : Variable
Bit rate                                 : 151 Kbps
Maximum bit rate                         : 204 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 44.1 KHz
Compression mode                         : Lossy
Stream size                              : 5.92 MiB (7%)
Title                                    : (C) 2007 Google Inc. v08.13.2007.
Encoded date                             : UTC 2011-05-05 19:43:08
Tagged date                              : UTC 2011-05-05 19:43:09

Any feedback is welcome.
Cheers.

Pages: 1 2 [3] 4