Wednesday, February 28, 2007

unpacker

Made an unpacker following a discussion on irc://irc.freenode.net/#fedora (or was it #kde?) that there's no good automatic unpacking tool for the CLI. Sure, you have ark etc. for the GUI, but you dont have an all-in-one utility for the CLI. So, here's the code for the thing. Just put it in your .bashrc and run it as

$ unpack file1.tbz2 file2.tZ file3.zip ...
unpack() {
  if shopt nocasematch | grep off >/dev/null 2>&1; then prevcasematch=0; fi
  shopt -s nocasematch
  while [ $# -gt 0 ]; do
    if ! [ -f $1 ]; then echo "File \"$i\" does not exist"; shift; continue; fi
    case $1 in
      *.tar.gz | *.tgz )            echo "Extracting $1 (gzipped tar archive):"; tar -xzvf $1 ;;
      *.tar.bz2 | *.tbz2 )          echo "Extracting $1 (bzipped tar archive):"; tar -xjvf $1 ;;
      *.tar.z | *.tz )              echo "Extracting $1 (compressed tar archive):"; tar -xZvf $1 ;;
      *.zip ) a=${1%%.[zZ][iI][pP]} echo "Extracting $1 (zip archive):"; mkdir $a; cd $a; unzip ../$1; cd - ;;
      *.rar ) a=${1%%.[rR][aA][rR]} echo "Extracting $1 (rar archive):"; mkdir $a; cd $a; unrar x ../$1; cd - ;;
    esac
    shift
  done
  if [ x$prevcasematch = x0 ]; then shopt -u nocasematch; fi
  }

Update: Just checked, it was neither #kde nor #fedora, it was #bash >.>

Saturday, February 17, 2007

ampsig submission script for amaroK

These days you will find dynamic signatures in almost every forum. There are many sites which allow you to generate dynamic sigs. One of them is ampsig. The difference between ampsig and others is that it can display live statistics about the song you're listening to. For example, here's a sample of mine (there are many different themes available, too. one of them has been randomly selected for you):

I've made a script which submits data to the ampsig server. It's avaialble for XMMS2, Noatun and amaroK. Noatun and XMMS2 scripts are a bit too buggy because I was half asleep while working on them (I personally wouldn't have used them had I not made them), but amaroK script is much better. Supports colour, verbose mode, GUI among other stuff. Read more about it here. Get it here

Wednesday, February 14, 2007

MangaSpot manga downloader

MangaSpot is probably the best archive for translated manga. Even thought it is not really big, it does have most of the mangas that you'd probably want. The most annoying thing is that you cant batch-download the mangs. This becomes a problem if the mangas are stretched over hundreds of chapters. So, I made a small script to automatically download manga from MangaSpot. It also overcomes MangaSpot's annoying sid-check (which ensures that you are not using a script to download manga). It requires the prefix assigned to the manga by manga spot and the number of the initial and final chapter (initial so that you can resume from where you stopped, final because, well... ).
For example, for Chobits, if you point your mouse on a chapter, the link looks like this: http://www.mangaspot.com/download.php?series=chobits&file=chobits010. Here, the series code is "chobits". The first and last chapters can be found out from the page itself. For this manga, the script would be run as:

./mangaspot.sh chobits 1 87

In another example, let's consider a series split into volumes instead of chapters. Let's take Ah! My Goddess!. The link for a volume looks something like this: http://www.mangaspot.com/download.php?series=amg&file=amg-v04. For this, the script will be run as:
./mangaspot.sh amg-v 1 22
Get the script here.