From bef5ebb7782b11e063d9772e2e1d7afeb80f69a3 Mon Sep 17 00:00:00 2001 From: Marek Marecki Date: Sat, 10 Aug 2013 14:26:45 +0200 Subject: [PATCH] Added script for downloading pictures --- sensual_asa_cat.py | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 sensual_asa_cat.py diff --git a/sensual_asa_cat.py b/sensual_asa_cat.py new file mode 100644 index 0000000..ec685fc --- /dev/null +++ b/sensual_asa_cat.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 + +"""Script for downloading all user data. + +Named after SensualAsaCat user whose account was deleted after some +radikal transgender reported her to admins of joindiaspora.com for +posting *inappropriate* content. + +I disaggred with him. So, here it is get all SensualAsaCat's pictures. +""" + +import getpass +import urllib.request + +import diaspy + + +guid = "b1b7d3e76ec50c7d" + +pod = input('Your pod: ') +username = input ('Your username on pod \'{0}\': '.format(pod)) +password = getpass.getpass('Password for \'{0}@{1}\': '.format(username, pod)) + +connection = diaspy.connection.Connection(pod=pod, username=username, password=password) +connection.login() + + +user = diaspy.people.User(connection, guid=guid) + +oldstream = user.stream.copy() +user.stream.more() + +while len(oldstream) != len(user.stream): + try: + oldstream = user.stream.copy() + user.stream.more() + go = True + except KeyboardInterrupt: + go = False + finally: + if go: print('Working... ({0})'.format(len(oldstream))) + +print('Posts found:', len(user.stream)) +for i, p in enumerate(oldstream): + #print(repr(p), '\n(', p.data, ')', '\n\n----\n') + print(repr(p)) + if p.data['photos']: + print('Downloading photos...') + for n, photo in enumerate(p.data['photos']): + print('{0}/{1}'.format(n+1, len(p.data['photos'])), end='\t') + try: + urllib.request.urlretrieve(url=photo['sizes']['large'], filename=photo['guid']) + print('[ OK ]') + except Exception as e: + print('[ FAIL: {0}]'.format(e)) + finally: + pass + print('\n\n----\n') -- 2.25.1