Saturday, November 9, 2013

Bulk Mp3 id3-tagger using Yad and Id3-tagger Python Module

I like doing most of things on Linux using CLI ,it is easy , time-saving and more effecient, but some times it is great to have alternative tools with nice GUI to do the same job, especially for the average user who are frightened to open the terminal and type anything
This is a little bash script built using Yad to edit id3-tags (Artist and Album Title for the time being) ,
Python2 , Id3-tagger Module 

  1. m=$(yad --file-selection --multiple --geometry=600x400+20+20 --file-filter="MP3 | *.mp3" --title="Bulk Mp3 ID3-Tagger Tool");FILE_ARRAY=(`echo $m | tr "|" "\n"`);
  2. Album_artist=$(yad --form --field='Album Title' --field='Artist');STR_ARRAY=(`echo $Album_artist | tr "|" "\n"`);
  3. for f in ${FILE_ARRAY[@]}
  4. do
  5. #echo "> [[$f]]"
  6. if [[ ! -z "${STR_ARRAY[0]}" ]] && [[ ! -z "${STR_ARRAY[1]}" ]];then
  7. python2 /usr/bin/ -a ${STR_ARRAY[1]} -A ${STR_ARRAY[0]} $f;
  8. yad --text="Artist changed to ${STR_ARRAY[1]} Album changed to ${STR_ARRAY[0]}" --title="Bulk Mp3 ID3-Tagger Tool"
  9. #if [[ ! -z "${STR_ARRAY[0]}" ]];then
  10. # python2 /usr/bin/ -A ${STR_ARRAY[[0]]} $f
  11. # yad --text="Album changed to ${STR_ARRAY[[0]]}"
  12. #if [[ ! -z "${STR_ARRAY[1]}" ]];then
  13. # python2 /usr/bin/ -a ${STR_ARRAY[1]} $f
  14. # yad --text="Artist changed to ${STR_ARRAY[1]}"
  15. else
  16. yad --text="nothing to be done.You have to fill both fileds" --title="Bulk Mp3 ID3-Tagger Tool";
  17. fi
  18. done
  19. screenshot:

Monday, September 2, 2013

Editing ID3 tags from command line using Python.

You can build a Python module from scratch just to edit ID3 tags, but there is no need to reinvent the wheel since there are many modules ready for this job.I have been using which is very straightforward , anyway, here is a little How-to
* Download the module and extract it to any directory you like
* Navigate to the directory where you extracted the module to
cd /ID3/id3-py-1.2
*Install the module
sudo python install
* If there is no errors , you are ready to go.
download this python script created by the same author ,
make it executable
chmod  a+x
 , you can copy the file to the home directory for an easier access
we are almost done,
here is an example on how to use the file
find ./ -d 1 -name '*.mp3' -exec ~/ -A 'soundcloud' {} \;

this command will search for any mp3 file in the directory [not recursively] , then will modify the Album tag to soundcloud , you can modify/add different tags to the command as you wish.

Wednesday, August 28, 2013

Bash Script To Extract Subtitles From MKV file.

well ,some times I prefer to do things using the command line ,especially when logging into my server remotely ,so I created a little bash script to help me extract subtitles from mkv files using mkvextract ( you have to install  mkvtoolnix-cli) , still , the file extension need to be added though.

 ###paste the following  
if [[ $filename ]]
 m=$(mkvinfo $filename|grep 'No EBML head found');
 if [[ $m ]];
  then echo "This is not a valid mkv file";
    echo "proceeding...";
    mm=$(mkvinfo $filename|grep -i -A 2 -B 2 subtitle);
    if [[ $mm ]];
      echo "subtitles found, proceeding...";
      mmm=$(echo $mm|grep -o 'mkvextract: [0-9]*'|grep -o '[0-9]*')
      arry1=$(echo $mmm|tr " " "\n ");
      for m in $arry1
       do mkvextract tracks $filename $mmm:${filename:0:-4}"_"$mmm; 
     echo "no subs";
 echo "no file name given";

Monday, August 12, 2013

How to assign a key shourtcut for 3rd level special characters [archlinux]

I use Arabic and English on daily basis,for switching layouts I use qxkb app which is really effecient and easy to use . some times i need to type special characters ( گ چ ڤ ) etc, and to my suprise this option was already there in qxkb , here is a little illustrative

if there is a poroblem with the graphical user interface , you can copy and paste this command in your terminal
setxkbmap -option -option grp:lalt_lshift_toggle,lv3:caps_switch
,press and hold caps and type the special character, that is =) .

Thursday, May 30, 2013

Arabic support on non-rooted Nook Simple Touch

Nook simple touch is the second generation of e-readers made by B&N, although it's released in 2011, it’s based on Android 2.1 (released in 2009!), and hence its native support for Arabic eBooks is very poor, combined with fact you can't change system fonts , all you will see is bunch of ? A square here is a sample of Arabic Epub book on NST:

So, is there any way to overcome this problem?
Rooting is the easy and the best way , once the device is rooted , you can replace certain files with patched ones +replacing DroidSansFallback.ttf with any Arabic font ( I use DroidSansNaskh (don't forget to rename it )  in /system/fonts to have proper support of Arabic, once done you will see Arabic texts  in most apps (ES file explorer, EzpdfReader , etc)

For Arabic Eups reading I highly recommend using moon reader+ pro 1.6 or any version that supports RTL (Right to left texts) .

 Even with this method B&N stock reader won't display Arabic texts properly  as its engine doesn't understand/support RTL . 

So, all mentioned above is for rooted devices, what about poor non-rooted NST users?
Well, here what I did
 [css font hack]
  1. first we are gonna use sigil as epub creator tool ...
  2. create a new epub file 
  3. add Droid Sans Naskh font to your Fonts folder
  4. edit the html source and add the following 

@namespace h "";
@font-face {  
 font-family: "Droid Sans Naskh"  
 font-weight: normal;  
 font-style: normal;  
 src: url('../Fonts/DroidSansNaskh.ttf');  

Now the hard part,
By default, as you can see above, NST reader displays the Arabic words reversed and with un-connected letters, so we need to modify the text in a form NST can display properly
They are different way to do it but the most accurate way is to use php class called PHP-AR
To use the script, I will assume you use Linux,
·         Install php on your system
·         Extract the file to any folder you like
·         Create 1.php file in the I18N folder and paste the following code

  include 'Arabic.php';  
 $lines = @file("1.txt");  
 $obj = new I18N_Arabic('Glyphs');  
 foreach($lines as $line ){  
 $text = $obj->utf8Glyphs($line);  
 echo "$text \n" ;  
Paste your Arabic text in a txt file named 1.txt
In your terminal cd to the I18N directory
cd /home/live/Downloads/Arabic-3.6.0/I18N
Execute the following command
php a.php >2.txt
The converted Arabic text will be saved in 2.txt
Open the file and copy the incomprehensible back to sigil, save your work.
This is how the file will be displayed using NST reader
The result is satisfying =) , thanks to the php-Ar class , diacritics handled and displayed properly on the NST., but alef-lam combinations needs some work from the developer.
You can download all the files needed from this link

If you have a question, or want a clarification, leave a comment