44
loading...
This website collects cookies to deliver better user experience
pkg install python
. After running this command, enter python
on the terminal to see if a python interpreter will pop up. You should see something like the image below ⬇️ statuses
folder inside your WhatsApp directory.statuses
folder.pip install watchgod
. /data/data/com.termux/files/home
, you need to change it to your phone's home directory. You can do so by entering cd /storage/emulated/0
. This command should take you straight to your phone's home directory.mkdir "Status Saver"
. We then change to that directory with cd "Status Saver"
. nano main.py
in your terminal and this should open a new empty file where we will write our code.from watchgod import watch #Imports the watcher
import re # Imports python regex module for extracting data out of the event
from shutil import copy
from os import makedirs
EVENT_REGEX = r"{\(<Change\.([\w]+):\s\d>,\s'([\w\W]+)'\)}" # The regex which will extract the data
WHATSAPP_STATUSES_DIRECTORY = "/storage/emulated/0/WhatsApp/Media/.Statuses/" #The WhatsApp status directory
STATUS_SAVER_DIRECTORY = "/storage/emulated/0/DCIM/Status Saver" #Where the statuses will be saves
def main():
for changes in watch(WHATSAPP_STATUSES_DIRECTORY):
match = re.match(EVENT_REGEX, str(changes)) #We try to use the regex to extract the data
event = match.group(1) # We extract the event type
file = match.group(2) #We extract the file name
if event == "added": #It checks if a file was added
copy(file,STATUS_SAVER_DIRECTORY)
def create_directory_if_not_exits():
#This function just creates the STATUS_SAVER_DIRECTORY
try:
makedirs(STATUS_SAVER_DIRECTORY)
except FileExistsError:
pass
if __name__ == "__main__":
create_directory_if_not_exits()
main()
watchgod
for directory watching, re
for regex, shutil.copy
for copying files and os.makedirs
for making folders.EVENT_REGEX
contains the regular expression which we will use to extract data from the event. watchgod does not provide an efficient way to extract data from the events it reports so this is the best we can do, anyways, it works.WHATSAPP_STATUSES_DIRECTORY
directory contains the default path to the WhatsApp status directory, this is the default path on almost all android phones, you can change it if your phone's WhatsApp status folder is stored in a different locationSTATUS_SAVER_DIRECTORY
is a default path where your statuses will be saved. The reason why I chose to save it in DCIM
is that, it gets to appear inside your gallery. Isn't that cool?😎main()
is the function which does all the work. We iterate through the watch method and wait for it's event to report. We then use the regex to extract the event type and the file which was affected. Then we try to see if the event type was adding a file, modifying it or deleting it. If it adds a file, we then copy that file to your STATUS_SAVER_DIRECTORY
. STATUS_SAVER_DIRECTORY
. Well, the reason is that, it will just be a waste of resources overwriting files over and over again. create_directory_if_not_exits()
just creates the STATUS_SAVER_DIRECTORY
directory if it does not exists.__name__ == "__main__"
condition means, if the code is being run directly, it should run the two functions. It's nothing special, just fun to add it.😆 python main.py
where main.py
is the name of the python file you just created