2016-06-15 12:42:08 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2016-06-26 09:43:02 +02:00
|
|
|
import re, json, datetime, shutil, os, time, random, sys, pickle, getpass
|
2016-06-21 19:37:14 +02:00
|
|
|
from io import BytesIO
|
2016-06-26 09:43:02 +02:00
|
|
|
from argparse import ArgumentParser
|
|
|
|
import requests
|
2016-06-15 12:42:08 +02:00
|
|
|
|
2016-07-15 15:52:21 +02:00
|
|
|
DEFAULTSESSIONFILE = "/tmp/.instaloadersession"
|
|
|
|
|
2016-06-17 21:38:21 +02:00
|
|
|
class DownloaderException(Exception):
|
|
|
|
pass
|
|
|
|
|
2016-07-12 21:04:40 +02:00
|
|
|
class ProfileNotExistsException(DownloaderException):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class ProfileHasNoPicsException(DownloaderException):
|
|
|
|
pass
|
|
|
|
|
2016-07-22 15:49:20 +02:00
|
|
|
class PrivateProfileNotFollowedException(DownloaderException):
|
|
|
|
pass
|
|
|
|
|
2016-07-15 15:54:35 +02:00
|
|
|
class LoginRequiredException(DownloaderException):
|
|
|
|
pass
|
|
|
|
|
2016-06-27 16:49:00 +02:00
|
|
|
def log(*msg, sep='', end='\n', flush=False, quiet=False):
|
2016-06-26 10:39:26 +02:00
|
|
|
if not quiet:
|
|
|
|
print(*msg, sep=sep, end=end, flush=flush)
|
|
|
|
|
2016-06-27 16:49:00 +02:00
|
|
|
def get_json(name, max_id = 0, session=None, sleep_min_max=[1,5]):
|
2016-06-21 19:37:14 +02:00
|
|
|
if session is None:
|
|
|
|
session = get_session(None, None, True)
|
2016-06-27 16:49:00 +02:00
|
|
|
resp = session.get('http://www.instagram.com/'+name, \
|
2016-06-26 09:43:02 +02:00
|
|
|
params={'max_id': max_id})
|
2016-06-27 16:49:00 +02:00
|
|
|
time.sleep(abs(sleep_min_max[1]-sleep_min_max[0])*random.random()+abs(sleep_min_max[0]))
|
|
|
|
match = re.search('window\._sharedData = .*<', resp.text)
|
|
|
|
if match is None:
|
2016-06-15 12:42:08 +02:00
|
|
|
return None
|
|
|
|
else:
|
2016-06-27 16:49:00 +02:00
|
|
|
return json.loads(match.group(0)[21:-2])
|
2016-06-15 12:42:08 +02:00
|
|
|
|
|
|
|
def get_last_id(data):
|
|
|
|
if len(data["entry_data"]) == 0 or \
|
|
|
|
len(data["entry_data"]["ProfilePage"][0]["user"]["media"]["nodes"]) == 0:
|
2016-06-26 09:43:02 +02:00
|
|
|
return None
|
2016-06-15 12:42:08 +02:00
|
|
|
else:
|
|
|
|
data = data["entry_data"]["ProfilePage"][0]["user"]["media"]["nodes"]
|
|
|
|
return int(data[len(data)-1]["id"])
|
|
|
|
|
2016-06-27 16:49:00 +02:00
|
|
|
def epoch_to_string(epoch):
|
2016-06-15 12:42:08 +02:00
|
|
|
return datetime.datetime.fromtimestamp(epoch).strftime('%Y-%m-%d_%H-%M-%S')
|
|
|
|
|
2016-06-27 16:49:00 +02:00
|
|
|
def get_file_extension(url):
|
|
|
|
match = re.search('\.[a-z]*\?', url)
|
|
|
|
if match is None:
|
2016-06-15 12:42:08 +02:00
|
|
|
return url[-3:]
|
|
|
|
else:
|
2016-06-27 16:49:00 +02:00
|
|
|
return match.group(0)[1:-1]
|
2016-06-15 12:42:08 +02:00
|
|
|
|
2016-06-27 16:49:00 +02:00
|
|
|
def download_pic(name, url, date_epoch, outputlabel=None, quiet=False):
|
2016-06-17 21:40:55 +02:00
|
|
|
# Returns true, if file was actually downloaded, i.e. updated
|
2016-06-15 12:42:08 +02:00
|
|
|
if outputlabel is None:
|
2016-06-27 16:49:00 +02:00
|
|
|
outputlabel = epoch_to_string(date_epoch)
|
|
|
|
filename = name.lower() + '/' + epoch_to_string(date_epoch) + '.' + get_file_extension(url)
|
2016-06-15 12:42:08 +02:00
|
|
|
if os.path.isfile(filename):
|
2016-06-27 16:49:00 +02:00
|
|
|
log(outputlabel + ' exists', end=' ', flush=True, quiet=quiet)
|
2016-06-17 21:40:55 +02:00
|
|
|
return False
|
2016-06-27 16:49:00 +02:00
|
|
|
resp = get_session(None, None, True).get(url, stream=True)
|
|
|
|
if resp.status_code == 200:
|
|
|
|
log(outputlabel, end=' ', flush=True, quiet=quiet)
|
2016-06-15 12:42:08 +02:00
|
|
|
os.makedirs(name.lower(), exist_ok=True)
|
2016-06-27 16:49:00 +02:00
|
|
|
with open(filename, 'wb') as file:
|
|
|
|
resp.raw.decode_content = True
|
|
|
|
shutil.copyfileobj(resp.raw, file)
|
2016-06-15 12:42:08 +02:00
|
|
|
os.utime(filename, (datetime.datetime.now().timestamp(), date_epoch))
|
2016-06-17 21:40:55 +02:00
|
|
|
return True
|
2016-06-15 12:42:08 +02:00
|
|
|
else:
|
2016-06-17 21:38:21 +02:00
|
|
|
raise DownloaderException("file \'" + url + "\' could not be downloaded")
|
2016-06-15 12:42:08 +02:00
|
|
|
|
2016-06-27 16:49:00 +02:00
|
|
|
def save_caption(name, date_epoch, caption, quiet=False):
|
|
|
|
filename = name.lower() + '/' + epoch_to_string(date_epoch) + '.txt'
|
2016-06-15 12:42:08 +02:00
|
|
|
if os.path.isfile(filename):
|
2016-06-27 16:49:00 +02:00
|
|
|
with open(filename, 'r') as file:
|
|
|
|
file_caption = file.read()
|
|
|
|
if file_caption == caption:
|
|
|
|
log('txt unchanged', end=' ', flush=True, quiet=quiet)
|
2016-06-15 12:42:08 +02:00
|
|
|
return None
|
|
|
|
else:
|
|
|
|
def get_filename(index):
|
|
|
|
return filename if index==0 else (filename[:-4] + '_old_' + \
|
|
|
|
(str(0) if index<10 else str()) + str(index) + filename[-4:])
|
|
|
|
i = 0
|
|
|
|
while os.path.isfile(get_filename(i)):
|
|
|
|
i = i + 1
|
|
|
|
for index in range(i, 0, -1):
|
2016-06-26 09:43:02 +02:00
|
|
|
os.rename(get_filename(index-1), get_filename(index))
|
2016-06-27 16:49:00 +02:00
|
|
|
log('txt updated', end=' ', flush=True, quiet=quiet)
|
|
|
|
log('txt', end=' ', flush=True, quiet=quiet)
|
2016-06-15 12:42:08 +02:00
|
|
|
os.makedirs(name.lower(), exist_ok=True)
|
|
|
|
with open(filename, 'w') as text_file:
|
|
|
|
text_file.write(caption)
|
|
|
|
os.utime(filename, (datetime.datetime.now().timestamp(), date_epoch))
|
|
|
|
|
2016-06-27 16:49:00 +02:00
|
|
|
def download_profilepic(name, url, quiet=False):
|
2016-06-15 12:42:08 +02:00
|
|
|
date_object = datetime.datetime.strptime(requests.head(url).headers["Last-Modified"], \
|
|
|
|
'%a, %d %b %Y %H:%M:%S GMT')
|
2016-06-27 16:49:00 +02:00
|
|
|
filename = name.lower() + '/' + epoch_to_string(date_object.timestamp()) + \
|
2016-06-15 12:42:08 +02:00
|
|
|
'_UTC_profile_pic.' + url[-3:]
|
|
|
|
if os.path.isfile(filename):
|
2016-06-27 16:49:00 +02:00
|
|
|
log(filename + ' already exists', quiet=quiet)
|
2016-06-15 12:42:08 +02:00
|
|
|
return None
|
2016-06-27 16:49:00 +02:00
|
|
|
match = re.search('http.*://.*instagram.*[^/]*\.(com|net)/[^/]+/.', url)
|
|
|
|
if match is None:
|
2016-06-22 14:00:22 +02:00
|
|
|
raise DownloaderException("url \'" + url + "\' could not be processed")
|
2016-06-27 16:49:00 +02:00
|
|
|
index = len(match.group(0))-1
|
|
|
|
offset = 8 if match.group(0)[-1:] == 's' else 0
|
2016-06-15 12:42:08 +02:00
|
|
|
url = url[:index] + 's2048x2048' + ('/' if offset == 0 else str()) + url[index+offset:]
|
2016-06-27 16:49:00 +02:00
|
|
|
resp = get_session(None, None, True).get(url, stream=True)
|
|
|
|
if resp.status_code == 200:
|
|
|
|
log(filename, quiet=quiet)
|
2016-06-15 12:42:08 +02:00
|
|
|
os.makedirs(name.lower(), exist_ok=True)
|
2016-06-27 16:49:00 +02:00
|
|
|
with open(filename, 'wb') as file:
|
|
|
|
resp.raw.decode_content = True
|
|
|
|
shutil.copyfileobj(resp.raw, file)
|
2016-06-15 12:42:08 +02:00
|
|
|
os.utime(filename, (datetime.datetime.now().timestamp(), date_object.timestamp()))
|
|
|
|
else:
|
2016-06-17 21:38:21 +02:00
|
|
|
raise DownloaderException("file \'" + url + "\' could not be downloaded")
|
2016-06-15 12:42:08 +02:00
|
|
|
|
2016-07-25 19:54:24 +02:00
|
|
|
def save_object(obj, filename, quiet=False):
|
2016-06-21 19:37:14 +02:00
|
|
|
if filename is None:
|
2016-07-15 15:52:21 +02:00
|
|
|
filename = DEFAULTSESSIONFILE
|
2016-06-27 16:49:00 +02:00
|
|
|
with open(filename, 'wb') as file:
|
2016-07-25 19:54:24 +02:00
|
|
|
log("Saved session to %s." % filename, quiet=quiet)
|
2016-07-15 15:52:21 +02:00
|
|
|
os.chmod(filename, 0o600)
|
2016-06-27 16:49:00 +02:00
|
|
|
shutil.copyfileobj(BytesIO(pickle.dumps(obj, -1)), file)
|
2016-06-21 19:37:14 +02:00
|
|
|
|
2016-07-25 19:54:24 +02:00
|
|
|
def load_object(filename, quiet=False):
|
2016-06-21 19:37:14 +02:00
|
|
|
if filename is None:
|
2016-07-15 15:52:21 +02:00
|
|
|
filename = DEFAULTSESSIONFILE
|
2016-06-21 19:37:14 +02:00
|
|
|
if os.path.isfile(filename):
|
2016-06-27 16:49:00 +02:00
|
|
|
with open(filename, 'rb') as sessionfile:
|
|
|
|
obj = pickle.load(sessionfile)
|
2016-07-25 19:54:24 +02:00
|
|
|
log("Loaded session from %s." % filename, quiet=quiet)
|
|
|
|
return obj
|
2016-06-21 19:37:14 +02:00
|
|
|
|
|
|
|
def test_login(user, session):
|
|
|
|
if user is None or session is None:
|
|
|
|
return False
|
2016-06-27 16:49:00 +02:00
|
|
|
resp = session.get('https://www.instagram.com/')
|
2016-06-21 19:37:14 +02:00
|
|
|
time.sleep(4 * random.random() + 1)
|
2016-06-27 16:49:00 +02:00
|
|
|
return resp.text.find(user.lower()) != -1
|
2016-06-21 19:37:14 +02:00
|
|
|
|
2016-06-27 16:49:00 +02:00
|
|
|
def get_session(user, passwd, empty_session_only=False, session=None):
|
2016-06-21 19:37:14 +02:00
|
|
|
def instaheader():
|
|
|
|
user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 ' \
|
|
|
|
'(KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36'
|
2016-06-22 14:00:22 +02:00
|
|
|
header = { 'Accept-Encoding' : 'gzip, deflate', \
|
|
|
|
'Accept-Language' : 'en-US,en;q=0.8', \
|
|
|
|
'Connection' : 'keep-alive', \
|
|
|
|
'Content-Length' : '0', \
|
|
|
|
'Host' : 'www.instagram.com', \
|
|
|
|
'Origin' : 'https://www.instagram.com', \
|
|
|
|
'Referer' : 'https://www.instagram.com/', \
|
|
|
|
'User-Agent' : user_agent, \
|
|
|
|
'X-Instagram-AJAX' : '1', \
|
|
|
|
'X-Requested-With' : 'XMLHttpRequest'}
|
2016-06-27 16:49:00 +02:00
|
|
|
if empty_session_only:
|
2016-06-22 14:00:22 +02:00
|
|
|
del header['Host']
|
|
|
|
del header['Origin']
|
|
|
|
del header['Referer']
|
|
|
|
del header['X-Instagram-AJAX']
|
|
|
|
del header['X-Requested-With']
|
|
|
|
return header
|
2016-06-21 19:37:14 +02:00
|
|
|
if session is None:
|
|
|
|
session = requests.Session()
|
|
|
|
session.cookies.update({'sessionid' : '', 'mid' : '', 'ig_pr' : '1', \
|
|
|
|
'ig_vw' : '1920', 'csrftoken' : '', \
|
|
|
|
's_network' : '', 'ds_user_id' : ''})
|
2016-06-22 14:00:22 +02:00
|
|
|
session.headers.update(instaheader())
|
2016-06-27 16:49:00 +02:00
|
|
|
if empty_session_only:
|
2016-06-21 19:37:14 +02:00
|
|
|
return session
|
2016-06-27 16:49:00 +02:00
|
|
|
resp = session.get('https://www.instagram.com/')
|
|
|
|
session.headers.update({'X-CSRFToken':resp.cookies['csrftoken']})
|
2016-06-21 19:37:14 +02:00
|
|
|
time.sleep(9 * random.random() + 3)
|
|
|
|
login = session.post('https://www.instagram.com/accounts/login/ajax/', \
|
|
|
|
data={'password':passwd,'username':user}, allow_redirects=True)
|
|
|
|
session.headers.update({'X-CSRFToken':login.cookies['csrftoken']})
|
|
|
|
time.sleep(5 * random.random())
|
|
|
|
if login.status_code == 200:
|
|
|
|
if test_login(user, session):
|
|
|
|
return session, True
|
|
|
|
else:
|
|
|
|
print('Login error! Check your credentials!', file=sys.stderr)
|
|
|
|
return session, False
|
|
|
|
else:
|
|
|
|
print('Login error! Connection error!', file=sys.stderr)
|
|
|
|
return session, False
|
|
|
|
|
|
|
|
def download(name, username = None, password = None, sessionfile = None, \
|
2016-06-27 16:49:00 +02:00
|
|
|
profile_pic_only = False, download_videos = True, fast_update = False, \
|
|
|
|
sleep_min_max=[0.25,2], quiet=False):
|
2016-06-26 13:13:59 +02:00
|
|
|
# pylint:disable=too-many-arguments,too-many-locals,too-many-nested-blocks,too-many-branches
|
2016-07-25 19:58:00 +02:00
|
|
|
# pylint:disable=too-many-statements
|
2016-06-26 13:13:59 +02:00
|
|
|
# We are aware that this function has many arguments, many local variables, many nested blocks
|
|
|
|
# and many branches. But we don't care.
|
2016-07-25 19:54:24 +02:00
|
|
|
session = load_object(sessionfile, quiet=quiet)
|
2016-06-21 19:37:14 +02:00
|
|
|
data = get_json(name, session=session)
|
2016-07-04 23:50:20 +02:00
|
|
|
if len(data["entry_data"]) == 0 or "ProfilePage" not in data["entry_data"]:
|
2016-07-12 21:04:40 +02:00
|
|
|
raise ProfileNotExistsException("user %s does not exist" % name)
|
2016-06-15 12:42:08 +02:00
|
|
|
else:
|
2016-06-27 16:49:00 +02:00
|
|
|
download_profilepic(name, data["entry_data"]["ProfilePage"][0]["user"]["profile_pic_url"],
|
|
|
|
quiet=quiet)
|
|
|
|
time.sleep(abs(sleep_min_max[1]-sleep_min_max[0])*random.random()+abs(sleep_min_max[0]))
|
|
|
|
if not profile_pic_only and data["entry_data"]["ProfilePage"][0]["user"]["is_private"]:
|
2016-06-21 19:37:14 +02:00
|
|
|
if not test_login(username, session):
|
|
|
|
if username is None or password is None:
|
2016-06-26 10:39:26 +02:00
|
|
|
if quiet:
|
2016-07-15 15:54:35 +02:00
|
|
|
raise LoginRequiredException("user %s requires login" % name)
|
2016-06-21 19:37:14 +02:00
|
|
|
while True:
|
|
|
|
if username is None:
|
|
|
|
username = input('Enter your Instagram username to login: ')
|
|
|
|
if password is None:
|
2016-06-22 14:00:22 +02:00
|
|
|
password = getpass.getpass(
|
|
|
|
prompt='Enter your corresponding Instagram password: ')
|
2016-06-21 19:37:14 +02:00
|
|
|
session, status = get_session(username, password, session=session)
|
|
|
|
if status:
|
|
|
|
break
|
2016-06-27 15:34:26 +02:00
|
|
|
username = None
|
|
|
|
password = None
|
2016-06-21 19:37:14 +02:00
|
|
|
else:
|
|
|
|
session, status = get_session(username, password, session=session)
|
|
|
|
if not status:
|
2016-06-22 14:00:22 +02:00
|
|
|
raise DownloaderException("aborting due to login error")
|
2016-07-15 15:30:35 +02:00
|
|
|
data = get_json(name, session=session)
|
2016-07-22 15:49:20 +02:00
|
|
|
if not data["entry_data"]["ProfilePage"][0]["user"]["followed_by_viewer"]:
|
|
|
|
raise PrivateProfileNotFollowedException("user %s: private but not followed" % name)
|
2016-06-26 13:13:59 +02:00
|
|
|
if ("nodes" not in data["entry_data"]["ProfilePage"][0]["user"]["media"] \
|
2016-06-22 14:00:22 +02:00
|
|
|
or len(data["entry_data"]["ProfilePage"][0]["user"]["media"]["nodes"]) == 0) \
|
2016-06-27 16:49:00 +02:00
|
|
|
and not profile_pic_only:
|
2016-07-12 21:04:40 +02:00
|
|
|
raise ProfileHasNoPicsException("user %s: no pics found" % name)
|
2016-06-21 19:37:14 +02:00
|
|
|
totalcount = data["entry_data"]["ProfilePage"][0]["user"]["media"]["count"]
|
2016-06-27 16:49:00 +02:00
|
|
|
if not profile_pic_only:
|
2016-06-15 12:42:08 +02:00
|
|
|
count = 1
|
2016-06-26 13:13:59 +02:00
|
|
|
while get_last_id(data) is not None:
|
2016-06-15 12:42:08 +02:00
|
|
|
for node in data["entry_data"]["ProfilePage"][0]["user"]["media"]["nodes"]:
|
2016-06-27 16:49:00 +02:00
|
|
|
log("[%3i/%3i] " % (count, totalcount), end="", flush=True, quiet=quiet)
|
2016-06-15 12:42:08 +02:00
|
|
|
count = count + 1
|
2016-06-27 16:49:00 +02:00
|
|
|
downloaded = download_pic(name, node["display_src"], node["date"], quiet=quiet)
|
|
|
|
time.sleep(abs(sleep_min_max[1]-sleep_min_max[0])*random.random() + \
|
|
|
|
abs(sleep_min_max[0]))
|
2016-06-15 12:42:08 +02:00
|
|
|
if "caption" in node:
|
2016-06-27 16:49:00 +02:00
|
|
|
save_caption(name, node["date"], node["caption"], quiet=quiet)
|
|
|
|
if node["is_video"] and download_videos:
|
2016-06-21 19:37:14 +02:00
|
|
|
video_data = get_json('p/' + node["code"], session=session)
|
2016-06-15 12:42:08 +02:00
|
|
|
download_pic(name, \
|
|
|
|
video_data['entry_data']['PostPage'][0]['media']['video_url'], \
|
2016-06-27 16:49:00 +02:00
|
|
|
node["date"], 'mp4', quiet=quiet)
|
|
|
|
log(quiet=quiet)
|
|
|
|
if fast_update and not downloaded:
|
2016-07-15 15:04:29 +02:00
|
|
|
if test_login(username, session):
|
2016-07-25 19:54:24 +02:00
|
|
|
save_object(session, sessionfile, quiet=quiet)
|
2016-07-11 21:25:44 +02:00
|
|
|
return username
|
2016-06-21 19:37:14 +02:00
|
|
|
data = get_json(name, get_last_id(data), session)
|
2016-06-27 16:49:00 +02:00
|
|
|
time.sleep(abs(sleep_min_max[1]-sleep_min_max[0])*random.random()+abs(sleep_min_max[0]))
|
2016-06-21 19:37:14 +02:00
|
|
|
if test_login(username, session):
|
2016-07-25 19:54:24 +02:00
|
|
|
save_object(session, sessionfile, quiet=quiet)
|
2016-07-04 23:44:14 +02:00
|
|
|
return username
|
2016-06-15 12:42:08 +02:00
|
|
|
|
2016-06-27 16:49:00 +02:00
|
|
|
def main():
|
2016-06-15 12:42:08 +02:00
|
|
|
parser = ArgumentParser(description='Simple downloader to fetch all Instagram pics and '\
|
2016-06-23 21:06:56 +02:00
|
|
|
'captions from a given profile')
|
2016-06-26 10:04:59 +02:00
|
|
|
parser.add_argument('targets', nargs='+', help='Names of profiles to download')
|
2016-06-27 15:34:26 +02:00
|
|
|
parser.add_argument('-l', '--login', metavar='login_name',
|
2016-06-21 19:37:14 +02:00
|
|
|
help='Provide login name for your Instagram account')
|
2016-06-27 15:34:26 +02:00
|
|
|
parser.add_argument('-p', '--password',
|
2016-06-21 19:37:14 +02:00
|
|
|
help='Provide password for your Instagram account')
|
2016-06-27 15:34:26 +02:00
|
|
|
parser.add_argument('-f', '--sessionfile',
|
2016-07-15 15:52:21 +02:00
|
|
|
help='File to store session key, defaults to '+DEFAULTSESSIONFILE)
|
2016-06-15 12:42:08 +02:00
|
|
|
parser.add_argument('-P', '--profile-pic-only', action='store_true',
|
|
|
|
help='Only download profile picture')
|
|
|
|
parser.add_argument('-V', '--skip-videos', action='store_true',
|
|
|
|
help='Do not download videos')
|
2016-06-17 21:40:55 +02:00
|
|
|
parser.add_argument('-F', '--fast-update', action='store_true',
|
|
|
|
help='Abort at encounter of first already-downloaded picture')
|
2016-06-21 19:37:14 +02:00
|
|
|
parser.add_argument('-S', '--no-sleep', action='store_true',
|
|
|
|
help='Do not sleep between actual downloads of pictures')
|
2016-06-26 10:39:26 +02:00
|
|
|
parser.add_argument('-q', '--quiet', action='store_true',
|
|
|
|
help='Disable user interaction, i.e. do not print messages (except errors) and fail ' \
|
|
|
|
'if login credentials are needed but not given.')
|
2016-06-15 12:42:08 +02:00
|
|
|
args = parser.parse_args()
|
2016-07-04 23:44:14 +02:00
|
|
|
username = args.login
|
2016-07-12 21:04:40 +02:00
|
|
|
failedtargets = []
|
2016-06-26 10:04:59 +02:00
|
|
|
for target in args.targets:
|
2016-07-12 21:04:40 +02:00
|
|
|
try:
|
|
|
|
username = download(target, username, args.password, args.sessionfile,
|
|
|
|
args.profile_pic_only, not args.skip_videos, args.fast_update,
|
|
|
|
[0,0] if args.no_sleep else [0.25,2], args.quiet)
|
2016-07-15 15:54:35 +02:00
|
|
|
except (ProfileNotExistsException, ProfileHasNoPicsException,
|
2016-07-22 15:49:20 +02:00
|
|
|
PrivateProfileNotFollowedException, LoginRequiredException) as err:
|
2016-07-12 21:04:40 +02:00
|
|
|
failedtargets.append(target)
|
2016-07-12 21:10:48 +02:00
|
|
|
print("%s" % err, file=sys.stderr)
|
2016-07-12 21:04:40 +02:00
|
|
|
if len(args.targets) > 1 and len(failedtargets) > 0:
|
2016-07-12 21:10:48 +02:00
|
|
|
print("Errors occured (see above) while downloading profiles: %s" %
|
2016-07-12 21:04:40 +02:00
|
|
|
", ".join(failedtargets), file=sys.stderr)
|
2016-06-27 16:49:00 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|