Have setuptools setup.py for serious distribution

This is a) cooler and b) a requirement for deploying it on PyPI.

It removes need of __all__ shit (which is hard to keep updated), and
allows installing instaloader easily as a global module and executable.
Additionally it removes __init__.py.
This commit is contained in:
Alexander Graf 2016-09-18 14:38:58 +02:00
parent 70c91e000e
commit c2957e389f
5 changed files with 65 additions and 28 deletions

4
.gitignore vendored
View File

@ -1,2 +1,4 @@
__pycache__/
.idea
build/
dist/
instaloader.egg-info/

View File

@ -4,30 +4,39 @@ Simple downloader to fetch all Instagram pictures and captions from a given prof
## Usage
Ensure having [Python](https://www.python.org/) (at least version 3.3) and
[python3-requests](https://pypi.python.org/pypi/requests/) installed.
instaloader is written in Python, thus ensure having
[Python](https://www.python.org/) (at least version 3.3) installed.
If you intend to use this tool under Windows, it is highly recommended to first install
[win-unicode-console](https://github.com/Drekin/win-unicode-console).
After having [downloaded instaloader.py](https://github.com/Thammus/instaloader/releases), you
invoke it with
After having [downloaded instaloader](https://github.com/Thammus/instaloader/releases), unzip it and
invoke bundled `setup.py` (requiring [setuptools](https://pypi.python.org/pypi/setuptools)) to
install it:
```
./instaloader.py profile [profile ...]
./setup.py install [--user]
```
(pass `--user` to install it for your user only instead of globally)
instaloader requires [python3-requests](https://pypi.python.org/pypi/requests/), which will be
installed automatically by setup.py, if not already installed.
Now, to download a set of profiles, do
```
instaloader profile [profile ...]
```
where `profile` is the name of a profile you want to download. Instead of only one profile, you may
also specify a list of profiles.
To later update your local copy of that profile, you may run
```
./instaloader.py --fast-update profile [profile ...]
instaloader --fast-update profile [profile ...]
```
When `--fast-update` is given, instaloder terminates when arriving at the first already-downloaded
picture.
Instaloader can also be used to **download private profiles**. To do so, invoke it with
```
./instaloader.py --login=your_username profile [profile ...]
instaloader --login=your_username profile [profile ...]
```
When invoked like this, it also **stores the session cookies** in a file in `/tmp`, which will be
reused later when `--login` is given. So you can download private profiles **non-interactively**
@ -35,17 +44,17 @@ when you already have a valid session cookies file.
If you want to **download all followees of a given profile**, call
```
./instaloader.py --login=your_username @profile
instaloader --login=your_username @profile
```
To **download all the pictures which you have liked**, call
```
./instaloader.py --login=your_username :feed-liked
instaloader --login=your_username :feed-liked
```
The `--quiet` option makes it also **suitable as a cron job**.
To get a list of other helpful flags, run `./instaloader.py --help`.
To get a list of other helpful flags, run `instaloader --help`.
## Usage as library

View File

@ -1,4 +0,0 @@
"""Simple downloader to fetch all Instagram pics and captions from a given profile"""
# pylint:disable=wildcard-import
from .instaloader import *

View File

@ -1,11 +1,22 @@
#!/usr/bin/env python3
"""Download pictures and captions from Instagram"""
import re, json, datetime, shutil, os, time, random, sys, pickle, getpass, tempfile
from argparse import ArgumentParser
from io import BytesIO
import requests, requests.utils
# To get version from setup.py for instaloader --version
import pkg_resources
try:
# pylint:disable=no-member
__version__ = pkg_resources.get_distribution('instaloader').version
except pkg_resources.DistributionNotFound:
__version__ = 'Run ./setup.py --version'
try:
# pylint:disable=wrong-import-position
import win_unicode_console
except ImportError:
WINUNICODE = False
@ -13,16 +24,6 @@ else:
win_unicode_console.enable()
WINUNICODE = True
# List of public objects which are provided by `import instaloader`.
__all__ = ['BadCredentialsException', 'ConnectionException', 'InstaloaderException',
'LoginRequiredException', 'NonfatalException', 'PrivateProfileNotFollowedException',
'ProfileHasNoPicsException', 'ProfileNotExistsException', 'check_id', 'copy_session',
'default_http_header', 'download', 'download_pic', 'download_profilepic',
'download_profiles', 'get_feed_json', 'download_feed_pics', 'epoch_to_string',
'get_anonymous_session',
'get_default_session_filename', 'get_file_extension', 'get_followees', 'get_id_by_username',
'get_json', 'get_last_id', 'get_logged_in_session', 'get_session', 'get_username_by_id',
'load_session', 'log', 'main', 'save_caption', 'save_session', 'test_login']
class InstaloaderException(Exception):
"""Base exception for this script"""
@ -598,15 +599,14 @@ def download_profiles(profilelist, username=None, password=None, sessionfile=Non
save_session(session, username, sessionfile, quiet=quiet)
def main():
parser = ArgumentParser(description='Simple downloader to fetch all Instagram pics and '\
'captions from a given profile')
parser = ArgumentParser(description=__doc__)
parser.add_argument('profile', nargs='*',
help='Name of profile to download; @<profile> to download all followees of '
'<profile>; or the special targets :feed-all or :feed-liked to '
'download pictures from your feed if --login is given (using '
'--fast-update is recommended).')
parser.add_argument('--version', action='version',
version='1.0.1')
version=__version__)
parser.add_argument('-l', '--login', metavar='YOUR-USERNAME',
help='Login name for your Instagram account. Not needed to download public '\
'profiles, but if you want to download private profiles or all followees of '\

30
setup.py Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env python3
from setuptools import setup
setup(
name='instaloader',
version='1.0.1',
py_modules=['instaloader'],
url='https://github.com/Thammus/instaloader',
license='MIT',
author='Alexander Graf, André Koch-Kramer',
author_email='mail@agraf.me, koch-kramer@web.de',
description='Download pictures and captions from Instagram',
install_requires=['requests>=2.4'],
python_requires='>=3.3',
entry_points={'console_scripts': ['instaloader=instaloader:main']},
zip_safe=True,
keywords='instagram downloader',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6'
'Topic :: Internet'
]
)