Save Snapchat files (Android) – Part 2

SnapchatTake the headache out of saving your Snapchat files from Part 1 by automating the entire process using Tasker.

Edit: This post is now obsolete! Snapchat have upgraded their app, and since the time of writing, many free apps have appeared on the Google Play and Apple App Stores.

In the previous instalment, we set up our rooted device to save Snapchat files using a handy little script. Although this works, it’s quite tedious to repeatedly have to call the script whenever you receive a snap. To save ourselves some time, we’re going to set up our script to run automatically using Tasker.

What you’ll need

Set up
I recommend reading through this guide before starting. The process is rather long but quite simple.

  1. Open up Tasker. Click “+” to create a new Task and select the “Application” context option. Find Snapchat from the list and tap to select it. Click “App selection” in the corner to go back to the main screen once that’s selected.
  2. Now that we have a context specified, we need to tell Tasker what to do when the app launches. Click “New Task” to open up the task creator, then click “+” to add an action.

  3. From the popup, select “Plugin” from the list of available actions, then choose Secure Settings.
  4. We now need to configure exactly what our Secure Settings action is doing. Click “Edit”, then find “Run Command”. On the “Run Command” configuration screen, enter the path of your script from part 1. In my example, this is /data/ Note: I’ve since updated the path due to some people having difficulties with /etc.

    DO NOT FORGET to check the box labelled “Use Root”, as this is responsible for ensuring that the script runs with the proper permissions (and actually does something). Also, I like to enable “Show Notification” so I know that the action is running.

    After naming the action, you can save your configuration by clicking the save icon (bottom left) or by tapping the “Run Command”/back header in the top corner and selecting the save option from the popup dialog.

  5. Click the headers in the corner to go back to the main screen. This will also serve to save your changes. Once this is done, you should be able to boot up Snapchat for a test run.

If you didn’t run into any trouble throughout the guide, Snapchat should now trigger your script, saving any downloaded snaps to your specified directory.

There is some weird behaviour that may pop up when using the script/Tasker combo. Here are some things I’ve encountered during my time with the script and how to work around them.

  • The script is not saving snaps
    This is either because 1) the script is faulty; or 2) Snapchat has not downloaded your files. As there is occasionally a delay, I like to load Snapchat, wait for the files to load, then check my gallery for the files. The usual culprit is poor phone reception.
  • The saved snaps are not showing in the gallery
    This is the most annoying “bug” that I encounter. Android caches the thumbnails for the gallery, and the script bypasses any media refresh hooks. You can manually refresh the gallery by rebooting the phone, taking a photo, or use an app. I used SD Card Rescan and it works amazingly. It can take a while to scan fully, depending on the size of your card, so bear that in mind.
    Due to the nature of the script, it is very indiscriminate when it comes to saving files. It will always attempt to save whatever it finds, duplicate or not. I just delete them.

These are the three main things I run into regularly. I’m happy to investigate any other weird things posted to the comments.

Hopefully this guide made sense, and you are now happily (read: sneakily) saving your incoming Snapchats. Feel free to leave a note below if this worked/did not work for you.

Happy snapping!

Save Snapchat files (Android) – Part 1

SnapchatIf you’re using Snapchat, chances are you want to save some of the pictures and/or videos you receive. Now you can.

Edit: This post is now obsolete! Snapchat have upgraded their app, and since the time of writing, many free apps have appeared on the Google Play and Apple App Stores.

I should start with a preface: You probably shouldn’t do this. Half the fun of Snapchat is knowing it’s a one-off, and there’s a sort of “honour among thieves” type of policy between users. That being said, I do like a challenge, even if a solution does make me look creepy.

What you’ll need

  1. I assume that if you’re reading this, you have Snapchat. If you don’t, you can grab it from one of the links on their website.
  2. An Android phone. So far, this solution only applies to Android. I’m currently playing around with a solution for Apple devices.
  3. A rooted phone. I probably haven’t thought hard enough about the problem, but from what I can tell, you need to have root access for this to work.
  4. The most useful tool of all – a Terminal Emulator. There are heaps of apps out there for changing permissions and fiddling with the filesystem, but nothing is better than the ol’ terminal.

The Script

Most of what does the work is inside this shell script:

When executed (before viewing anything), the script checks the two storage locations for Snapchat (images and video), loop through the list of files, and copies the data to a safe location (a place the app can’t touch). The unusual part of the script is the use of the cat command, which we need due to some filesystem limitations within Android. Also, keep in mind that the paths above are for my device (Samsung Galaxy SIII, running Jelly Bean 4.1). You may need to update them if the script is returning errors.

Setting up the script

If you are Unix-savvy, you probably already know how to do this. You can jump down to the “how-to” section below for some notes.

If you’re a little Unix-rusty, here’s what you need to do to get this script working.

  1. First, copy/paste the script above into a new text file. Save it as whatever you like and add the extension .sh. I called mine
  2. Transfer the script onto your phone using Android File Transfer (Mac) or just in Explorer (Windows). I usually just stick it in the sdcard’s “Downloads” folder. It actually doesn’t matter, as this location is temporary anyway.
  3. Open the Terminal Emulator. First switch to the root user by running the su command.

    Then, make the internal system writable by running:

    If this step isn’t working, you can try this app instead. It’s what I use, as it offers a one-click solution.

  4. Now that you’re root, we need to move the script to a place on the system to allow us to execute it without any permission errors. Thanks to an Android limitation, this will need to be done using cat. Note: Some people appeared to be having problems copying to /etc. I’m now using /data instead to avoid any difficulties. Everything except the path is the same.

    This outputs the contents of the script into a new copy located in /data. Feel free to change this location to basically anything on the phone’s internal storage.

  5. Remove the temporary copy of the script (not essential, just tidy):

  6. Once this is done, navigate to the folder you copied the script into (on the phone’s storage), and add execute permissions using chmod.

  7. All that’s left is a bit of cleanup:

    This will remount the internal storage as read-only (as it was before).

As far as set-up is concerned, that’s (thankfully) it!

How to

Now for the best part – saving files. You will need to use Terminal Emulator (or equivalent) to do this. Be aware that you need to use su, otherwise the script won’t find the files due to permission restrictions.

  1. “Snap received!”
  2. Open Snapchat and wait until your snaps are loaded. Do not open them. I can’t stress this enough. If you open them, the script will not find them.
  3. Jump to your Terminal Emulator and run:

    This will execute the script and tell you what it does (as it’s doing it).

  4. Once that’s complete (assuming no errors), you can view your snaps as normal. A copy should have been made in the location specified by the script (in my example, this is /storage/extSdCard/snapchat/)

And that’s all there is to it! Unfortunately, this process needs to be repeated every time new snaps come in. However, in part 2, we’ll be automating the whole process using Tasker, meaning that once you open the app, your files are saved. Very sneaky.

Update: Part 2 is now available!

Note: Feel free to add comments/suggestions or point out errors in the comments section below. I will be maintaining this post.