Skip to content

Commit

Permalink
Options --dirname-pattern and --filename-pattern
Browse files Browse the repository at this point in the history
Instaloader downloads all posts in

  <DIRNAME>/<FILENAME>+(suffix and extension)

which are now generated by the templates given with --dirname-pattern
and --filename-pattern. These templates may contain specifiers such as
'{target}', '{profile}', '{date}' and '{shortcode}'.

Default for --dirname-pattern is '{target}', default for
--filename-pattern is '{date:%Y-%m-%d_%H-%M-%S}'

The former options --no-profile-subdir and --hashtag-username were
removed, because their behavior can now be achieved like this:

--no-profile-subdir and --hashtag-username:
--dirname-pattern='.' --filename-pattern='{profile}__{date:%Y-%m-%d_%H-%M-%S}'

--no-profile-subdir, but not --hashtag-username:
--dirname-pattern='.' --filename-pattern='{target}__{date:%Y-%m-%d_%H-%M-%S}'

--hashtag-username but not --no-profile-subdir:
--dirname-pattern='{profile}'

This adds the option proposed in #23, to encode both the hashtag and the
profile name in the file's path when downloading by hashtag, e.g.:
--dirname-pattern='{target}' --filename-pattern='{profile}_{date:%Y-%m-%d_%H-%M-%S}'

(Closes #23)
  • Loading branch information
aandergr committed Jul 25, 2017
1 parent 5068c94 commit 8572e52
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 100 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,missing-docstring,too-many-arguments,locally-disabled,line-too-long,too-many-public-methods,too-many-lines instaloader
- python3 -m pylint -r n -d bad-whitespace,missing-docstring,too-many-arguments,locally-disabled,line-too-long,too-many-public-methods,too-many-lines,too-many-instance-attributes instaloader
22 changes: 13 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,19 @@ Instaloader to login.
How to Download
^^^^^^^^^^^^^^^

--no-profile-subdir Instead of creating a subdirectory for each profile
and storing pictures there, store pictures in files
named ``PROFILE__DATE_TIME.jpg``.
--hashtag-username Lookup username of pictures when downloading by
#hashtag and encode it in the downlaoded file's path
or filename (if ``--no-profile-subdir``). Without this
option, the #hashtag is used instead. This requires an
additional request to the Instagram server for each
picture, which is why it is disabled by default.
--dirname-pattern DIRNAME_PATTERN
Name of directory where to store posts. {profile}
is replaced by the profile name, {target} is replaced
by the target you specified, i.e. either :feed,
#hashtag or the profile name. Defaults to '{target}'.
--filename-pattern FILENAME_PATTERN
Prefix of filenames. Posts are stored in the
directory whose pattern is given with --dirname-pattern.
{profile} is replaced by the profile name,
{target} is replaced by the target you specified, i.e.
either :feed, #hashtag or the profile name. Also, the
fields date and shortcode can be specified. Defaults
to '{date:%Y-%m-%d_%H-%M-%S}'.
--user-agent USER_AGENT User Agent to use for HTTP requests. Per default,
Instaloader pretends being Chrome/51.
--no-sleep Do not sleep between requests to Instagram's servers.
Expand Down

0 comments on commit 8572e52

Please sign in to comment.