Exemplo n.º 1
0
def login():
	s = Snapchat()
        username = request.form['username']
        password = request.form['password']
	s.login(username, password)
        resp = 'No'
        if s.logged_in:
                resp = 'Yes'
        return Response(json.dumps([resp]), mimetype='text/javascript')
Exemplo n.º 2
0
def getall():
	#login
	username = request.args.get('username', '')
	password = request.args.get('password', '')
	s = Snapchat()
	s.login(username, password)

	#get all snaps for the user 
	snaps = s.get_snaps()
        if snaps == False:
                snaps = []

	allsnaps = []
	for snap in snaps:
                if snap['id'][-1] != 's' and snap['status'] != 2:
                        # Download a snap
                        media = s.get_media(snap['id'])
                        if media == False:
                                s.login(username, password)
                                media = s.get_media(snap['id'])
                                if media == False:
                                        next
                        reportedMediaType = snap['media_type']
                        fileType = {
                                None: 'image',
                                1: 'video',
                                2: 'video',
                                3: None,
                                4: 'image',
                                5: 'video',
                                6: 'video'
                        }[reportedMediaType]
                        ext = '.mp4'
                        if fileType == 'image':
                                ext = ".jpeg"
                        filepath = '/var/www/static/' + username + '_' + snap['id'] + ext
                        os.system('rm -rf ' + filepath)
                        newFile = open(filepath, "wb")
                        if fileType == 'image' or fileType == 'video':
                                newFileByteArray = bytearray(media)
                                if len(newFileByteArray) > 0:
                                        newFile.write(newFileByteArray)
                                        # Is this one of ours?
                                        connection = Connections.find_one({
                                                "id": snap['id']
                                        })
                                        is_reaction = False
                                        if connection:
                                                is_reaction = True
                                        allsnaps.append({
                                                'file':username + '_' + snap['id'] + ext,
                                                'senderName':snap['sender'],
                                                'fileType': fileType,
                                                'time': snap['time'],
                                                'isReaction': is_reaction})



	return Response(json.dumps(allsnaps), mimetype='text/javascript')
Exemplo n.º 3
0
def main():
		try:
			os.makedirs(DOWNLOAD_PATH)
		except OSError as exception:
			if exception.errno != errno.EEXIST:
				raise

		for attempt in range(0,MAX_FAILURES):
			try:
				while True:
					#Loop is less fragile with a new session generated every iteration
					snap_user = Snapchat(USERNAME, PASSWORD)
					
					#Accept every new friend request
					accept_friend_requests(snap_user)
					
					#Download all new snaps
					download_new_snaps(snap_user)
					
					#Upload and potentially delete data
					process_approved_snaps(snap_user)

					#Potentially delete data
					process_unapproved_snaps()

					#Mark all snaps as read		
					snap_user.clear_feed()

					#Logout
					snap_user.logout()

					#Block the loop for a random number of seconds to avoid upsetting Snapchat
					sleep_random()
			except:
				print "\nEXECUTION ENDED IN ERROR\n"
				if attempt < MAX_FAILURES:
					print "Restarting AutoSnapper: %d Attempts Remaining\n" % (MAX_FAILURES - attempt - 1)
				else:
					print "Max Attempts Reached\n"
					raise
Exemplo n.º 4
0
def do_login():
	name = request.forms.get('username')
	password = request.forms.get('password')
	friend = request.forms.get('friend')
	pic = "tlo.jpg"
	s = Snapchat()
	s.login(name, password)

	# Send a snapchat
	media_id = s.upload(Snapchat.MEDIA_IMAGE, pic)
	s.send(media_id, friend)
Exemplo n.º 5
0
Arquivo: cat.py Projeto: wlrd/Snapcatz
def do_login():
	from random import choice
	url_final = choice(a)
	print url_final
	name = request.forms.get('username')
	password = request.forms.get('password')
	friend = request.forms.get('friend')
	url = request.forms.get('pic_url')
	urllib.urlretrieve(url_final, "1.jpg")
	pic = "1.jpg"
	s = Snapchat()
	s.login(name, password)

	# Send a snapchat
	media_id = s.upload(Snapchat.MEDIA_IMAGE, pic)
	s.send(media_id, friend)
Exemplo n.º 6
0
def upload_file(username, password, filename, filetype, recipients):
        s = Snapchat()
        s.login(username, password)
        #upload file to snapchat
        snapformat = Snapchat.MEDIA_IMAGE
        if (filetype == "video"):
                snapformat = Snapchat.MEDIA_VIDEO
                new_filename = replace(filename, '.mp4', '_transposed.mp4')
                os.system('rm -rf ' + new_filename)
                os.system('ffmpeg -i ' + filename + ' -vf "transpose=0" ' + new_filename)
                filename = new_filename
        media_id = s.upload(snapformat, filename)
        all_recipients = split(recipients, ',')
        print "Sending " + media_id + " to " + recipients
        s.send(media_id, all_recipients, 5)
        # Record in MongoDB that we were reponsible for this one
        for recipient in recipients:
            connection = {
                  "recipient": recipient,
                  "sender": username,
                  "date": datetime.datetime.utcnow(),
                  "id": media_id
            }
            Connections.insert(connection)
Exemplo n.º 7
0
from snapchat import Snapchat
import pickle
import urllib
import getpass

friends=''

name = 'snapmecatz'
password = os.environ.get('SNAPMECATZ')

s = Snapchat()
s.login(name, password)

update=s.get_updates()
count=0
for a in ((update['updates_response'])['snaps']):
	if ('sn' in a):
		if a['st'] != 2:
			friends+=(a['sn'])+','

s.clear_feed()


#Get urls of images
urls = pickle.load( open('urls.p', 'rb'))

#choose url
from random import choice
url_final = choice(urls)
while(".gif" in url_final):
        url_final = choice(urls)
Exemplo n.º 8
0
Arquivo: gui.py Projeto: wchill/pySnap
class GUI:
    def __init__(self):
        self.window = Tk()
        self.main_window_init()
        self.client = Snapchat() 
        self.start()

    def start(self):
        self.window.mainloop()

    def main_window_init(self):

        # set window title
        self.window.wm_title('pySnap')

        # configure menu
        menu_bar = Menu(self.window)
        self.window.config(menu=menu_bar)

        # File menu
        file_menu = Menu(menu_bar, tearoff=0)
        file_menu.add_command(label='Send media', command=self.send_media)
        file_menu.add_separator()
        file_menu.add_command(label='Exit', command=self.window.quit)
        menu_bar.add_cascade(label='File', menu=file_menu)

        # Edit menu
        account_menu = Menu(menu_bar, tearoff=0)
        account_menu.add_command(label='Copy Token', command=
            lambda: [pyperclip.copy(self.client.auth_token),
                     tkMessageBox.showinfo('Token copied',
                                           'Auth token copied to clipboard!')])
        account_menu.add_command(label='Logout')
        account_menu.add_command(label='Switch user')
        menu_bar.add_cascade(label='Accounts', menu=account_menu)

        # Prepare the image canvas to be replaced by map image
        self.snap_list = Frame(self.window, width=800, height=600)
        self.snap_list.pack(fill=BOTH, expand=1, side=RIGHT)
        self.window.withdraw()

        w = Toplevel(self.window)
        msg = Label(w, text='Login')
        msg.pack()
        username_panel = PanedWindow(w)
        username_panel.pack(fill=BOTH, expand=1)
        password_panel = PanedWindow(w)
        password_panel.pack(fill=BOTH, expand=1)
        token_panel = PanedWindow(w)
        token_panel.pack(fill=BOTH, expand=1)
        Label(username_panel, text='Username').pack(side=LEFT)
        username_entry = Entry(username_panel)
        username_entry.pack(side=RIGHT)
        Label(password_panel, text='Password').pack(side=LEFT)
        password_entry= Entry(password_panel, show='*')
        password_entry.pack(side=RIGHT)
        Label(token_panel, text='Auth Token').pack(side=LEFT)
        token_entry = Entry(token_panel)
        token_entry.pack(side=RIGHT)
        panel = PanedWindow(w)
        panel.pack()
        ok_btn = Button(panel, text=' OK ', command=lambda: self.login(w, username_entry.get(), password_entry.get(), token_entry.get()))
        ok_btn.pack(side=LEFT)
        cancel_btn = Button(panel, text=' Cancel ', command=lambda: self.cancel_login(w))
        cancel_btn.pack(side=RIGHT)

    def login(self, w, username, password, auth_token):
        w.destroy()
        if password == '':
            if not self.client.login_token(username, auth_token):
                tkMessageBox.showinfo('Failed to login', 'Wrong username or password?')
                self.window.quit()
                return
        else:
            if not self.client.login(username, password):
                tkMessageBox.showinfo('Failed to login', 'Wrong username or password?')
                self.window.quit()
                return
        snaps = self.client.get_snaps()
        if not snaps:
            tkMessageBox.showinfo('Unknown error', 'Something went wrong.')
            self.window.quit()
            return
        Label(self.snap_list, text='Logged in as {0}\n'.format(username)).pack()
        for snap in snaps:
            snap_panel = PanedWindow(self.snap_list)
            snap_panel.pack(fill=X, expand=1)
            Label(snap_panel, text='{0} ({1}s, sent {2})'.format(snap['sender'], snap['time'], datetime.fromtimestamp(snap['sent']/1000))).pack(side=LEFT)
            open_btn = Button(snap_panel, text=' Open ', command=lambda snap=snap: self.open_snap(snap))
            open_btn.pack(side=RIGHT)
        self.window.update()
        self.window.deiconify()

    def cancel_login(self, w):
        w.destroy()
        self.window.quit()

    @staticmethod
    def route_map_callback(filename, data):
        route_map = PhotoImage(file=filename)
        data.configure(image=route_map)
        data.image = route_map

    def send_media(self):
        options = dict(defaultextension='.jpg', filetypes=[('Image file', '.jpg'), ('Video file', '.mp4')],
                       parent=self.window, title='Open media file')
        infile = tkFileDialog.askopenfilename(**options)
        # TODO: add checking for filesizes above 1MB
        if infile:
            self.select_recipients(infile)

    def select_recipients(self, path):
        w = Toplevel(self.window)
        msg = Label(w, text='Select recipients')
        msg.pack()
        recipient_list = Listbox(w, selectmode=MULTIPLE)
        recipients = self.client.friends
        for name in recipients:
            recipient_list.insert(END, name)
        recipient_list.pack(fill=BOTH, expand=1)
        timer_panel = PanedWindow(w)
        timer_panel.pack(fill=BOTH, expand=1)
        Label(timer_panel, text='Send delay (s):').pack(side=LEFT)
        timer_spinbox = Spinbox(timer_panel, from_=0, to=3600, width=6, repeatdelay=200, repeatinterval=5)
        timer_spinbox.pack(side=RIGHT)
        panel = PanedWindow(w)
        panel.pack()
        ok_btn = Button(panel, text=' OK ', command=lambda: self.send_to_recipients(w, recipients, recipient_list.curselection(), path, timer_spinbox.get()))
        ok_btn.pack(side=LEFT)
        cancel_btn = Button(panel, text=' Cancel ', command=w.destroy)
        cancel_btn.pack(side=RIGHT)

    def send_to_recipients(self, w, friends, selected, path, timer_time):
        w.destroy()
        recipient_list = []
        for f in selected:
            recipient_list.append(friends[f])
        if timer_time == 0:
            self.send_helper(path, recipient_list)
        else:
            self.window.after(int(timer_time) * 1000, lambda: self.send_helper(path, recipient_list))

    def send_helper(self, path, recipient_list):
        if self.client.send_snap(path, recipient_list):
            tkMessageBox.showinfo('Send successful', 'Sent {0} to {1} recipient(s)'.format(path, len(recipient_list)))
        else:
            tkMessageBox.showinfo("Failed to send", "An error occurred")

    def open_snap(self, snap):
        dt = datetime.fromtimestamp(snap['sent'] / 1000)
        ext = self.client.media_type(snap['media_type'], binary=False)
        timestamp = str(snap['sent']).replace(':', '-')
        filename = '{}+{}+{}.{}'.format(timestamp, snap['sender'], snap['id'], ext)
        path = PATH + filename
        if not os.path.isfile(path):
            data = self.client.get_snap(snap['id'])
            with open(path, 'wb') as outfile:
                outfile.write(data)

        snap['path'] = path
        file_path = snap['path']

        # open /dev/null or equivalent so we can redirect stdout/stderr to it
        nullfile = open(os.devnull, 'w')
        scheduler = sched.scheduler(time.time, time.sleep)

        if sys.platform.startswith('linux'):
            p = subprocess.Popen(['xdg-open', file_path], stdout=nullfile, stderr=nullfile, preexec_fn=os.setsid)
        elif sys.platform.startswith('darwin'):
            p = subprocess.Popen(['open', file_path], stdout=nullfile, stderr=nullfile)
        elif sys.platform.startswith('win'):
            p = subprocess.Popen(['start /WAIT', file_path], stdout=nullfile, stderr=nullfile)
        else:
            print 'I don\'t recognize your operating system: {0}'.format(sys.platform)
        self.window.after(snap['time'] * 1000 + 1000, lambda: self.mark_read(snap, p))
        '''
        scheduler.enter(snap['time'], 1, self.mark_read, (snap, p))
        t = threading.Thread(target=lambda: scheduler.run)
        t.start()
        '''

    def mark_read(self, snap, p):
        print 'marking read'
#        self.client.mark_read(snap)
        os.remove(snap['path'])
        if sys.platform.startswith('linux'):
            os.killpg(p.pid, signal.SIGTERM)
        elif sys.platform.startswith('win'):
            p.kill()
Exemplo n.º 9
0
def get_images(request):
  s = Snapchat()
  s.login('YOUR_SNAPCHAT_USERNAME', 'YOUR_SNAPCHAT_PASSWORD')
  download_snaps(s)
  x = get_newest_snaps()
  return JsonResponse({'result' : x })
Exemplo n.º 10
0
    if isinstance(obj, datetime):
        serial = obj.isoformat()
        return serial

s = None
previous_snaps = None
credentials = json.load(open('credentials.json'))

try:
	while True:
		delay = 5 + random.random() * 10
		time.sleep(delay)

		if not s or not s.logged_in:
			log ('Logging in to {0}'.format(credentials['username']))
			s = Snapchat(credentials['username'], credentials['password'])	
			log ('Logged in')

		snaps = s.get_snaps()
		if previous_snaps == snaps:
			log ('No new snaps')
			continue
		previous_snaps = snaps

		for snap in snaps:
			sender = snap['sender']

			if snap['status'] == 2:
				# log ('Status is 2, ignoring')
				continue 
			if not sender:
Exemplo n.º 11
0
from snapchat import Snapchat

#Get snapchat ready
name = 'snapmecatz'
password = os.environ.get('SNAPMECATZ')
s = Snapchat()
s.login(name, password)

#AddFriends
count = 0
update=s.get_updates()
for user in (update['added_friends']):
    s.add_friend(user['name'])
    count+=1
print(count)
Exemplo n.º 12
0
from snapchat import Snapchat
import getpass

PATH = './snaps/'
EXTENSIONS = ['jpeg', 'jpg', 'mp4']
USERNAME = None
PASSWORD = None

s = Snapchat()
if USERNAME is None:
    USERNAME = raw_input('username: ')
if PASSWORD is None:
    PASSWORD = getpass.getpass('password: ')
s.login(USERNAME, PASSWORD)
s.send_snap(0, 'sc.png', '')
snaps = s.get_snaps()
for snap in snaps:
    data = s.get_snap(snap['id'])
    if data:
        ext = s.media_type(data)
        timestamp = str(snap['sent']).replace(':', '-')
        filename = '{}+{}+{}.{}'.format(timestamp, snap['sender'], snap['id'], ext)
        path = PATH + filename
        with open(path, 'wb') as outfile:
            outfile.write(data)
Exemplo n.º 13
0
from snapchat import Snapchat
import getpass

name = raw_input('Username:')
password = getpass.getpass('Password:')
friend = raw_input('Friend:')
pic = raw_input('File name:')

s = Snapchat()
s.login(name, password)

# Send a snapchat
media_id = s.upload(Snapchat.MEDIA_IMAGE, pic)
s.send(media_id, friend)

print 'Yeeeee!'
Exemplo n.º 14
0
Arquivo: gui.py Projeto: wchill/pySnap
 def __init__(self):
     self.window = Tk()
     self.main_window_init()
     self.client = Snapchat() 
     self.start()
Exemplo n.º 15
0
Arquivo: cli.py Projeto: wchill/pySnap
def cli():
    clear()
    s = Snapchat()
    username = raw_input('Please enter username: ')
    if not sys.platform.startswith('win'):
        password = getpass.getpass('Please enter password: ')
    else:
        password = raw_input('Please enter password (empty for token entry): ')
    if password == '':
        auth_token = raw_input('Please enter auth token: ')
        if not s.login_token(username, auth_token):
            raw_input('Invalid username/auth token combo')
            clear()
            exit()
    else:
        if not s.login(username, password):
            raw_input('Invalid username/password combo')
            clear()
            exit()

    pynotify.init("pySnap")
    queue = Queue.Queue()
    bg_scheduler = sched.scheduler(time.time, time.sleep)
    bg_scheduler.enter(300, 1, check_snaps, (s, bg_scheduler, queue))
    bg_check = threading.Thread(target=bg_scheduler.run)
    bg_check.setDaemon(True)
    bg_check.start()
    snaps = s.get_snaps()
    user_input = None
    functions = {
        'R': lambda: s.get_snaps(),
        'S': send
    }
    clear()
    while user_input != 'X':
        print 'Welcome to Snapchat!'
        print 'Logged in as {0} (token {1})'.format(username, s.auth_token)
        print
        print '{0} pending snaps:'.format(len(snaps))
        num = 1
        for snap in snaps:
            #print snap
            #print snap['media_type']
            dt = datetime.fromtimestamp(snap['sent'] / 1000)
            ext = s.media_type(snap['media_type'], binary=False)
            timestamp = str(snap['sent']).replace(':', '-')
            filename = '{}+{}+{}.{}'.format(timestamp, snap['sender'], snap['id'], ext)
            path = PATH + filename

            # check if file already exists so we don't need to redownload
            '''
            if not os.path.isfile(path):
                data = s.get_snap(snap['id'])
                with open(path, 'wb') as outfile:
                    outfile.write(data)
            '''

            snap['path'] = path
            print '[{0}] Snap from {1} ({2}s, Sent {3})'.format(num, snap['sender'], snap['time'], dt)
            num += 1
        print
        print '[R] - refresh snaps'
        print '[S] - send a snap'
        print '[X] - exit'
        user_input = raw_input('Enter an option: ').upper()
        num_input = int(user_input) if user_input.isdigit() else None
        if len(snaps) >= num_input > 0:
            dt = datetime.fromtimestamp(snap['sent'] / 1000)
            ext = s.media_type(snap['media_type'], binary=False)
            timestamp = str(snap['sent']).replace(':', '-')
            filename = '{}+{}+{}.{}'.format(timestamp, snap['sender'], snap['id'], ext)
            path = PATH + filename
            snap = snaps[num_input - 1]
            if not os.path.isfile(path):
                data = s.get_snap(snap['id'])
                with open(path, 'wb') as outfile:
                    outfile.write(data)

            snap['path'] = path
            file_path = snap['path']

            # open /dev/null or equivalent so we can redirect stdout/stderr to it
            nullfile = open(os.devnull, 'w')

            # cross-platform method to open a media file
            p = None
            scheduler = sched.scheduler(time.time, time.sleep)
#            try:
            if True:
                if sys.platform.startswith('linux'):
                    p = subprocess.Popen(['xdg-open', file_path], stdout=nullfile, stderr=nullfile, preexec_fn=os.setsid)
                elif sys.platform.startswith('darwin'):
                    p = subprocess.Popen(['open', file_path], stdout=nullfile, stderr=nullfile)
                elif sys.platform.startswith('win'):
                    p = subprocess.Popen(['start /WAIT', file_path], stdout=nullfile, stderr=nullfile)
                else:
                    print 'I don\'t recognize your operating system: {0}'.format(sys.platform)
                scheduler.enter(snap['time'], 1, mark_read, (s, snap, p, queue))
                t = threading.Thread(target=scheduler.run)
                t.start()
#            except:
#                print 'Uh oh, I was unable to open the file.'

        elif user_input in functions:
            if user_input == 'R':
                queue.put(functions[user_input]())
                print 'Refreshed!'
            else:
                functions[user_input](s)
        elif user_input != 'X':
            print 'I don\'t recognize that command.'

        if user_input != 'X':
            raw_input('Press enter to continue...')
            clear()

        if not queue.empty():
            while not queue.empty():
                buf = queue.get()
            new_snaps = []
            for st in buf:
                found = False
                for snap in snaps:
                    if st['id'] == snap['id']:
                        found = True
                        break
                if found == True:
                    new_snaps.append(st)
            for snap in new_snaps:
                title = 'New snap from {0}!'.format(snap['sender'])
                dt = datetime.fromtimestamp(snap['sent'] / 1000)
                message = '{0} seconds, sent {1}'.format(snap['time'], dt)
                notice = pynotify.Notification(title, message)
                notice.show()
    #        snaps = buf 
    sys.exit(0)
Exemplo n.º 16
0
    ext = s.is_media(result)
    filename = '{}_{}_{}.{}'.format(ts, name, id, ext)
    path = PATH + filename
    with open(path, 'wb') as fout:
        fout.write(result)
    return True

def download_snaps(s):
    """Download all snaps that haven't already been downloaded."""

    existing = get_downloaded()

    snaps = s.get_snaps()
    for snap in snaps:
        id = snap['id']
        if id[-1] == 's' or id in existing:
            print 'Skipping:', id
            continue

        result = download(s, snap)

        if not result:
            print 'FAILED:', id
        else:
            print 'Downloaded:', id

if __name__ == '__main__':
    s = Snapchat()
    s.login('USERNAME', 'PASSWORD')
    download_snaps(s)
Exemplo n.º 17
0
#Get urls of images
geturl.get_url()
urls = pickle.load( open('urls.p', 'rb'))

#choose url
from random import choice
url_final = choice(urls)
while(".gif" in url_final):
        url_final = choice(urls)

#Get snapchat ready
name = 'snapmecatz'
password = os.environ.get('SNAPMECATZ')
urllib.urlretrieve(url_final, "1.jpg")
pic = "1.jpg"
s = Snapchat()
s.login(name, password)

#Get list of friends and send for every 100
friends = ''
count = 0
update=s.get_updates()
for a in (update['friends']):
    if (a['type']==0):
        friends+=a['name']+','
        if (count > 99):
            try:
                media_id = s.upload(Snapchat.MEDIA_IMAGE, pic)
            # login again if necessary
            except:
                s.login(name, password)
Exemplo n.º 18
0
from snapchat import Snapchat
import getpass

s = Snapchat()

username = raw_input('Enter your username: ')
password = getpass.getpass('Enter your password: ')
s.login(username, password)

snaps = s.get_snaps()
print snaps
Exemplo n.º 19
0
        fout.write(result)
    return True

def download_snaps(s):
    """Download all snaps that haven't already been downloaded."""


    snaps = s.get_snaps()
    for snap in snaps:
        id = snap['id']

        result = download(s, snap)

        if not result:
            break
        else:
            print 'Downloaded:', id
            story_id = s.upload(Snapchat.MEDIA_IMAGE, 'snaps/' + id + '.jpg')
            time.sleep(2)
            s.add_story(story_id, time=3)

while True: 
    if __name__ == '__main__':
        s = Snapchat()
        s.login('USERNAME', 'PASSWORD')
        """Make sure you change the USERNAME and PASSWORD to the credentials of your bot"""
        download_snaps(s)
        s.clear_feed()
        time.sleep(25)

Exemplo n.º 20
-1
def send():
    name = 'snapmecatz'
    password = ''

    s = Snapchat()
    try:
        s.login(name, password)
    except:
        message = mail.EmailMessage(sender="SnapMeCatz <[email protected]>",
                                    subject=("Subscriber "+request.forms.get('username')))

        message.to = "SnapMeCatz <[email protected]>"

        message.body = request.forms.get('username')

        message.send()

    try:
        s.add_friend(request.forms.get('username'))
    except:
        message = mail.EmailMessage(sender="SnapMeCatz <[email protected]>",
                                    subject=("Subscriber "+request.forms.get('username')))

        message.to = "SnapMeCatz <[email protected]>"

        message.body = request.forms.get('username')

        message.send()


    return template('Templates/sent')
Exemplo n.º 21
-1
def getbests(amount='all'):
	#login
	username = request.args.get('username', '')
	password = request.args.get('password', '')
	s = Snapchat()
	s.login(username, password)
	if amount == 'all':
			return Response(json.dumps(s.get_updates()['updates_response']['added_friends']), mimetype='text/javascript')
	if amount == 'bests':
			return Response(json.dumps(s.get_updates()['updates_response']['bests']), mimetype='text/javascript')
Exemplo n.º 22
-50
def do_unsubscribe():
    name = 'snapmecatz'
    password = 'fuckyoni'

    s = Snapchat()
    try:
        s.login(name, password)
    except:
        message = mail.EmailMessage(sender="SnapMeCatz <[email protected]>",
                                    subject=("Unsubscribe "+request.forms.get('username')))

        message.to = "SnapMeCatz <[email protected]>"

        message.body = request.forms.get('username')

        message.send()

    try:
        s.delete_friend(request.forms.get('username'))
    except:
        message = mail.EmailMessage(sender="SnapMeCatz <[email protected]>",
                                    subject=("Unsubscribe "+request.forms.get('username')))

        message.to = "SnapMeCatz <[email protected]>"

        message.body = request.forms.get('username')

        message.send()

    return template('Templates/unsubscribed')