Thursday, November 14, 2013

Python Android Script copy photos from Whats App Profiles

I think everybody reading this must be using WhatsApp by now. :-D
I am amazed by how much ignorance people have. I have been told by many people that it is secure to share profile photo on WhatsApp since the application doesnt allow to save other people profile photos. Well when I saw my one friend dying to get his friend's profile photos over whatsapp (offcourse it was a girl, Haaa hahaa.) I just checked the whats app folder location and showed him that the profile photos are temporary saved in this folder. For his phone it was "/storage/sdcard0/WhatsApp/Profile Pictures" path.
 Then one more issue came forward WhatsApp deletes the profile photos automatically after some couple of days. (No I didnt bothered to find out after how much time).
        So I told him to copy the files to other folder using some file manager. But as always I was thinking of automation in my mind. So I wrote a python script which can be run by using qpython for android (http://qpython.com/). This script copies the files in the default directory of WhatsApp to user specified directory. (You will have to specify the directory in the python script, its easy this way in Android instead of going for command line and etc.
      So again one small problem was there. Every time the WhatsApp profile photo is changes it is stored by using the mobile number as filename. So by default if you copy files it would overwrite them. So you cannot use filenames to identify if the file different from existing photo in the bkp directory. So I used the md5 library in python to check the md5 sum of the files in the backup directory and tally it with same phone number file in the WhatsApp directory. So now the script copies the filename and count the files with similar name in the backup directory and paste with the one added counter name.
E.g. +919887766554-0.jpg , +919887766554-1.jpg , +919887766554-2.jpg etc.

So there you go my friend. (and any one else who needed similar script)
Steps to use
1) Install qpython on your android phone from http://qpython.com/
2) download file WatsAppCp.py from  https://sites.google.com/site/neo1981/files/WatsAppCp.py?attredirects=0&d=1
3) copy file to the scripts directory of qpython.
4) Edit the file and pur your phones path to the WhatsApp profile pictures
--  Change following variables in py file
--- mysrc = "/storage/sdcard0/WhatsApp/Profile Pictures"
--- mydst = "/storage/sdcard0/.Wats App profile BKP"
--Here mysrc is the WhatsApp profile pictures folder
--and mydst is bkp folder which you can specify

5) Run the WatsAppCp.py file from qpython
6) File whill show copying message for every photo which is copied.


3 comments:

Fariz Muradov said...

there are only maim problem. from Application need to open all conact profile picutire, then you can find that picture in folder path.

sunil tatipelly said...

Do we need to run this script always to copy the images or make it run in background or once if we run it, will it run continuosly even if we close qpython

neo said...

@Sunil
When script is run it will copy photos at that time. Again if you want copy new updated photos you need to run again.