Skip to content

Commit

Permalink
Refactor Instaloader's methods into a class
Browse files Browse the repository at this point in the history
  • Loading branch information
aandergr committed Jun 24, 2017
1 parent 5249245 commit caf75a8
Show file tree
Hide file tree
Showing 3 changed files with 717 additions and 724 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ python:
install:
- pip install pylint requests
script:
- python3 -m pylint -r n -d bad-whitespace,bad-continuation,missing-docstring,multiple-imports,too-many-arguments,locally-disabled,line-too-long instaloader
- python3 -m pylint -r n -d bad-whitespace,missing-docstring,too-many-arguments,locally-disabled,line-too-long,too-many-public-methods instaloader
23 changes: 13 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,14 @@ their follower count, do
import instaloader
# login
session = instaloader.get_logged_in_session(USERNAME)
# Get instance
loader = instaloader.Instaloader()
# get followees
followees = instaloader.get_followees(PROFILE, session)
# Login
loader.interactive_login(USERNAME)
# Retrieve followees
followees = loader.get_followees(PROFILE)
for f in followees:
print("%i\t%s\t%s" % (f['follower_count'], f['username'], f['full_name']))
Expand All @@ -150,36 +153,36 @@ Then, you may download all pictures of all followees with
for f in followees:
try:
instaloader.download(f['username'], session)
loader.download(f['username'])
except instaloader.NonfatalException:
pass
You could also download your last 20 liked pics with

.. code:: python
instaloader.download_feed_pics(session, max_count=20, fast_update=True,
filter_func=lambda node:
oader.download_feed_pics(max_count=20, fast_update=True,
filter_func=lambda node:
not node["likes"]["viewer_has_liked"] if "likes" in node else not node["viewer_has_liked"])
To download the last 20 pictures with hashtag #cat, do

.. code:: python
instaloader.download_hashtag('cat', session=instaloader.get_anonymous_session(), max_count=20)
loader.download_hashtag('cat', max_count=20)
Each Instagram profile has its own unique ID which stays unmodified even
if a user changes his/her username. To get said ID, given the profile's
name, you may call

.. code:: python
instaloader.get_id_by_username(PROFILE_NAME)
loader.get_id_by_username(PROFILE_NAME)
``get_followees()`` also returns unique IDs for all loaded followees. To
get the current username of a profile, given this unique ID
``get_username_by_id()`` can be used. For example:

.. code:: python
instaloader.get_username_by_id(session, followees[0]['id'])
loader.get_username_by_id(followees[0]['id'])

0 comments on commit caf75a8

Please sign in to comment.