Created
January 31, 2015 20:57
-
-
Save cmcewen/ce281c8327cef1bc8f2c to your computer and use it in GitHub Desktop.
Snapchat group stories hack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#using the awesome pysnap library: https://github.com/martinp/pysnap | |
from __future__ import print_function | |
import os.path | |
import sys | |
from getpass import getpass | |
from zipfile import is_zipfile, ZipFile | |
from pysnap import get_file_extension, Snapchat | |
def process_snap(s, snap, path): | |
filename = '{0}_{1}.{2}'.format(snap['sender'], snap['id'], | |
get_file_extension(snap['media_type'])) | |
abspath = os.path.abspath(os.path.join(path, filename)) | |
if os.path.isfile(abspath): | |
return | |
data = s.get_blob(snap['id']) | |
if data is None: | |
return | |
with open(abspath, 'wb') as f: | |
f.write(data) | |
print('Saved: {0}'.format(abspath)) | |
return abspath | |
if is_zipfile(abspath): | |
zipped_snap = ZipFile(abspath) | |
unzip_dir = os.path.join(path, '{0}_{1}'.format(snap['sender'], | |
snap['id'])) | |
zipped_snap.extractall(unzip_dir) | |
print('Unzipped {0} to {1}'.format(filename, unzip_dir)) | |
return abspath | |
def upload_story(s, snap_path): | |
media_id = s.upload(snap_path) | |
if media_id: | |
s.send_to_story(media_id, time=5) | |
def main(): | |
username = # Your username goes here | |
password = # Your password goes here | |
path = 'Documents/snaps' #where you download the snaps to | |
s = Snapchat() | |
if not s.login(username, password).get('logged'): | |
print('Invalid username or password') | |
sys.exit(1) | |
new_snaps = [] | |
for snap in s.get_snaps(): | |
result = process_snap(s, snap, path) | |
if result: | |
new_snaps.append(result) | |
for snap_path in new_snaps: | |
upload_story(s, snap_path) | |
if __name__ == '__main__': | |
main() |
Can someone confirm what this hack does?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great hack. Would love to see some form of permissions that only allows snaps from certain Snapchat users to be published on the account, rather than everyone with this account added being able to publish.