-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbasic-usage.html
521 lines (502 loc) · 37.4 KB
/
basic-usage.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
<!DOCTYPE html>
<html lang="en" data-content_root="./">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta content="How to download pictures from Instagram. Description of basic usage of Instaloader, free tool to download photos from public and private profiles, hashtags, stories, feeds, saved media, and their metadata, comments and captions." name="description" />
<title>Download Pictures from Instagram — Instaloader documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=377f2d93" />
<link rel="stylesheet" type="text/css" href="_static/basic.css?v=fb9458d3" />
<link rel="stylesheet" type="text/css" href="_static/instaloaderdoc.css?v=d1e01417" />
<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=5929fcd5"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/instaloaderdoc.js?v=d3bfff1a"></script>
<script src="_static/instaloaderdoc.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Command Line Options" href="cli-options.html" />
<link rel="prev" title="Install Instaloader" href="installation.html" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="google-site-verification" content="FNUsDdkOJM9obm9QEdrNBVd9AtAzHzA-aaSMCUrS6C8"/>
<link rel="canonical" href="https://instaloader.github.io/basic-usage.html"/>
</head><body>
<nav class="navbar navbar-light navbar-expand bg-light border-bottom">
<a class="navbar-brand" href="index.html">
<img src="_static/logo.png" width="30" height="30" class="d-inline-block align-top" alt="logo">
<span class="ml-3">Instaloader</span>
</a>
<ul class="navbar-nav mr-auto">
<li class="nav-item ml-0 ml-sm-2">
<a class="nav-link"
href="https://github.com/instaloader/instaloader/releases/tag/v4.14.1"
title="Released on 24 Jan 2025" data-toggle="tooltip">
v<b>4.14.1</b>
</a>
</li>
</ul>
<ul class="navbar-nav ml-auto d-none d-sm-flex">
<li class="nav-item">
<a class="nav-link" href="https://github.com/instaloader/instaloader/issues">
Issues
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/instaloader/instaloader/releases">
Releases
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/instaloader/instaloader">
GitHub
</a>
</li>
</ul>
<button class="d-inline-block d-md-none btn btn-outline-primary btn-sm" type="button"
data-toggle="collapse" data-target="#instaloaderdocSidebar" aria-controls="instaloaderdocSidebar"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</nav>
<div class="container-fluid">
<div class="row">
<div class="instaloaderdoc-sidebar collapse d-md-block col-md-3 col-xl-2 bg-light"
id="instaloaderdocSidebar">
<nav role="navigation" aria-label="Table of Contents">
<form action="search.html" method="get" role="search" class="border-bottom mr-2 pb-2 mb-2 px-1">
<label class="sr-only" for="searchQueryInput">Search</label>
<input type="search" name="q" id="searchQueryInput" class="form-control my-2"
placeholder="Search..." aria-label="Search">
</form>
<h4>Contents</h4>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="installation.html">Install Instaloader</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Download Pictures from Instagram</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#basic-usage">Basic Usage</a></li>
<li class="toctree-l2"><a class="reference internal" href="#what-to-download">What to Download</a></li>
<li class="toctree-l2"><a class="reference internal" href="#filename-specification">Filename Specification</a></li>
<li class="toctree-l2"><a class="reference internal" href="#filter-posts">Filter Posts</a></li>
<li class="toctree-l2"><a class="reference internal" href="#metadata-text-files">Metadata Text Files</a></li>
<li class="toctree-l2"><a class="reference internal" href="#exit-codes">Exit codes</a></li>
<li class="toctree-l2"><a class="reference internal" href="#instaloader-as-cronjob">Instaloader as Cronjob</a></li>
<li class="toctree-l2"><a class="reference internal" href="#programming-instaloader">Programming Instaloader</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="cli-options.html">Command Line Options</a></li>
<li class="toctree-l1"><a class="reference internal" href="as-module.html">Python Module <code class="xref py py-mod docutils literal notranslate"><span class="pre">instaloader</span></code></a></li>
<li class="toctree-l1"><a class="reference internal" href="codesnippets.html">Advanced Instaloader Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="troubleshooting.html">Troubleshooting</a></li>
<li class="toctree-l1"><a class="reference internal" href="contributing.html">Contributing to Instaloader</a></li>
</ul>
</nav>
</div>
<main class="col-12 col-md-9 col-xl-10 pt-2" role="main">
<section id="download-pictures-from-instagram">
<span id="id1"></span><h1>Download Pictures from Instagram<a class="headerlink" href="#download-pictures-from-instagram" title="Link to this heading">¶</a></h1>
<p>Here we describe how to use Instaloader to download pictures from Instagram. If
you do not have Instaloader installed yet, see <a class="reference internal" href="installation.html#install"><span class="std std-ref">Install Instaloader</span></a>.</p>
<section id="basic-usage">
<h2>Basic Usage<a class="headerlink" href="#basic-usage" title="Link to this heading">¶</a></h2>
<p>To <strong>download all pictures and videos of a profile</strong>, as well as the
<strong>profile picture</strong>, do</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>instaloader profile [profile ...]
</pre></div>
</div>
<p>where <code class="docutils literal notranslate"><span class="pre">profile</span></code> is the name of a profile you want to download. Instead
of only one profile, you may also specify a list of profiles.</p>
<p>To later <strong>update your local copy</strong> of that profiles, you may run</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>instaloader --fast-update profile [profile ...]
</pre></div>
</div>
<p>If <a class="reference internal" href="cli-options.html#cmdoption-fast-update"><code class="xref std std-option docutils literal notranslate"><span class="pre">--fast-update</span></code></a> is given, Instaloader stops when arriving at the
first already-downloaded picture.</p>
<p>Alternatively, you can use <a class="reference internal" href="cli-options.html#cmdoption-latest-stamps"><code class="xref std std-option docutils literal notranslate"><span class="pre">--latest-stamps</span></code></a> to have Instaloader store
the time each profile was last downloaded and only download newer media:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>instaloader --latest-stamps -- profile [profile ...]
</pre></div>
</div>
<p>With this option it’s possible to move or delete downloaded media and still keep
the archive updated.</p>
<p>When updating profiles, Instaloader
automatically <strong>detects profile name changes</strong> and renames the target directory
accordingly.</p>
<p>Instaloader can also be used to <strong>download private profiles</strong>. To do so,
invoke it with</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>instaloader --login=your_username profile [profile ...]
</pre></div>
</div>
<p>When logging in, Instaloader <strong>stores the session cookies</strong> in a file in your
home directory, which will be reused later the next time <a class="reference internal" href="cli-options.html#cmdoption-login"><code class="xref std std-option docutils literal notranslate"><span class="pre">--login</span></code></a>
is given. So you can download private profiles <strong>non-interactively</strong> when you
already have a valid session cookie file.</p>
</section>
<section id="what-to-download">
<span id="id2"></span><h2>What to Download<a class="headerlink" href="#what-to-download" title="Link to this heading">¶</a></h2>
<p>Instaloader supports the following targets:</p>
<ul>
<li><dl>
<dt><code class="docutils literal notranslate"><span class="pre">profile</span></code></dt><dd><p>Public profile, or private profile with <a class="reference internal" href="cli-options.html#login"><span class="std std-ref">login</span></a>.</p>
<p>If an already-downloaded profile has been renamed, Instaloader automatically
finds it by its unique ID and renames the folder accordingly.</p>
<p>Besides the profile’s posts, its current profile picture is downloaded. For
each profile you download,</p>
<ul class="simple">
<li><dl class="simple">
<dt><a class="reference internal" href="cli-options.html#cmdoption-stories"><code class="xref std std-option docutils literal notranslate"><span class="pre">--stories</span></code></a></dt><dd><p>instructs Instaloader to also <strong>download the user’s stories</strong>,</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="cli-options.html#cmdoption-highlights"><code class="xref std std-option docutils literal notranslate"><span class="pre">--highlights</span></code></a></dt><dd><p>to <strong>download the highlights of that profile</strong>,</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="cli-options.html#cmdoption-tagged"><code class="xref std std-option docutils literal notranslate"><span class="pre">--tagged</span></code></a></dt><dd><p>to <strong>download posts where the user is tagged</strong>, and</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="cli-options.html#cmdoption-reels"><code class="xref std std-option docutils literal notranslate"><span class="pre">--reels</span></code></a></dt><dd><p>to <strong>download Reels videos</strong>.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="cli-options.html#cmdoption-igtv"><code class="xref std std-option docutils literal notranslate"><span class="pre">--igtv</span></code></a></dt><dd><p>to <strong>download IGTV videos</strong>.</p>
</dd>
</dl>
</li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">"#hashtag"</span></code></dt><dd><p>Posts with a certain <strong>hashtag</strong> (the quotes are usually necessary). Requires <a class="reference internal" href="cli-options.html#login"><span class="std std-ref">login</span></a>.</p>
</dd>
</dl>
</li>
<li><dl>
<dt><code class="docutils literal notranslate"><span class="pre">%location</span> <span class="pre">id</span></code></dt><dd><p>Posts tagged with a given location; the location ID is the numerical ID
Instagram labels a location with (e.g.
https://www.instagram.com/explore/locations/<strong>362629379</strong>/plymouth-naval-memorial/).
Requires <a class="reference internal" href="cli-options.html#login"><span class="std std-ref">login</span></a>.</p>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 4.2.</span></p>
</div>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">:stories</span></code></dt><dd><p>The currently-visible <strong>stories</strong> of your followees (requires
<a class="reference internal" href="cli-options.html#login"><span class="std std-ref">login</span></a>).</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">:feed</span></code></dt><dd><p>Your <strong>feed</strong> (requires <a class="reference internal" href="cli-options.html#login"><span class="std std-ref">login</span></a>).</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">:saved</span></code></dt><dd><p>Posts which are marked as <strong>saved</strong> (requires <a class="reference internal" href="cli-options.html#login"><span class="std std-ref">login</span></a>).</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">@profile</span></code></dt><dd><p>All profiles that are followed by <code class="docutils literal notranslate"><span class="pre">profile</span></code>, i.e. the <em>followees</em> of
<code class="docutils literal notranslate"><span class="pre">profile</span></code> (requires <a class="reference internal" href="cli-options.html#login"><span class="std std-ref">login</span></a>).</p>
</dd>
</dl>
</li>
<li><dl>
<dt><code class="docutils literal notranslate"><span class="pre">-post</span></code></dt><dd><p>Replace <strong>post</strong> with the post’s shortcode to download single post. Must be preceded by <code class="docutils literal notranslate"><span class="pre">--</span></code> in
the argument list to not be mistaken as an option flag. For example, to download the post
<a class="reference external" href="https://www.instagram.com/p/">https://www.instagram.com/p/</a><strong>B_K4CykAOtf</strong>, run the command:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>instaloader -- -B_K4CykAOtf
</pre></div>
</div>
<div class="versionadded">
<p><span class="versionmodified added">Added in version 4.1.</span></p>
</div>
</dd>
</dl>
</li>
</ul>
<p>Instaloader goes through all media matching the specified targets and
downloads the pictures and videos and their captions. You can specify</p>
<ul class="simple">
<li><dl class="simple">
<dt><a class="reference internal" href="cli-options.html#cmdoption-comments"><code class="xref std std-option docutils literal notranslate"><span class="pre">--comments</span></code></a></dt><dd><p>also <strong>download comments</strong> of each post,</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="cli-options.html#cmdoption-geotags"><code class="xref std std-option docutils literal notranslate"><span class="pre">--geotags</span></code></a></dt><dd><p><strong>download geotags</strong> of each post and save them as
Google Maps link (requires <a class="reference internal" href="cli-options.html#login"><span class="std std-ref">login</span></a>),</p>
</dd>
</dl>
</li>
</ul>
<p>For a reference of all supported command line options, see
<a class="reference internal" href="cli-options.html#command-line-options"><span class="std std-ref">Command Line Options</span></a>.</p>
</section>
<section id="filename-specification">
<span id="id3"></span><h2>Filename Specification<a class="headerlink" href="#filename-specification" title="Link to this heading">¶</a></h2>
<p>For each target, Instaloader creates a directory named after the target,
i.e. <code class="docutils literal notranslate"><span class="pre">profile</span></code>, <code class="docutils literal notranslate"><span class="pre">#hashtag</span></code>, <code class="docutils literal notranslate"><span class="pre">%location</span> <span class="pre">id</span></code>, <code class="docutils literal notranslate"><span class="pre">:feed</span></code>, etc. and therein saves the
posts in files named after the post’s timestamp.</p>
<p><a class="reference internal" href="cli-options.html#cmdoption-dirname-pattern"><code class="xref std std-option docutils literal notranslate"><span class="pre">--dirname-pattern</span></code></a> allows to configure the directory name of each
target. The default is <code class="docutils literal notranslate"><span class="pre">--dirname-pattern={target}</span></code>. In the dirname
pattern, the token <code class="docutils literal notranslate"><span class="pre">{target}</span></code> is replaced by the target name, and
<code class="docutils literal notranslate"><span class="pre">{profile}</span></code> is replaced by the owner of the post which is downloaded.</p>
<p><a class="reference internal" href="cli-options.html#cmdoption-filename-pattern"><code class="xref std std-option docutils literal notranslate"><span class="pre">--filename-pattern</span></code></a> configures the path of the post and story’s files relative
to the target directory that is specified with <a class="reference internal" href="cli-options.html#cmdoption-dirname-pattern"><code class="xref std std-option docutils literal notranslate"><span class="pre">--dirname-pattern</span></code></a>.
The default is <code class="docutils literal notranslate"><span class="pre">--filename-pattern={date_utc}_UTC</span></code>.
The tokens <code class="docutils literal notranslate"><span class="pre">{target}</span></code> and <code class="docutils literal notranslate"><span class="pre">{profile}</span></code> are replaced like in the
dirname pattern.</p>
<p><a class="reference internal" href="cli-options.html#cmdoption-title-pattern"><code class="xref std std-option docutils literal notranslate"><span class="pre">--title-pattern</span></code></a> is similar to <a class="reference internal" href="cli-options.html#cmdoption-filename-pattern"><code class="xref std std-option docutils literal notranslate"><span class="pre">--filename-pattern</span></code></a>, but for profile
pics, hashtag profile pics, and highlight covers. The default is
<code class="docutils literal notranslate"><span class="pre">{date_utc}_UTC_{typename}</span></code> if <a class="reference internal" href="cli-options.html#cmdoption-dirname-pattern"><code class="xref std std-option docutils literal notranslate"><span class="pre">--dirname-pattern</span></code></a> contains <code class="docutils literal notranslate"><span class="pre">{target}</span></code> or
<code class="docutils literal notranslate"><span class="pre">{profile}</span></code>, or <code class="docutils literal notranslate"><span class="pre">{target}_{date_utc}_UTC_{typename}</span></code> if it does not. Some tokens
are not supported for this option, see below for details.</p>
<p>The following tokens are defined for usage with
<a class="reference internal" href="cli-options.html#cmdoption-filename-pattern"><code class="xref std std-option docutils literal notranslate"><span class="pre">--filename-pattern</span></code></a> and <a class="reference internal" href="cli-options.html#cmdoption-title-pattern"><code class="xref std std-option docutils literal notranslate"><span class="pre">--title-pattern</span></code></a>:</p>
<ul>
<li><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">{target}</span></code></dt><dd><p>Target name (as given in Instaloader command line)</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">{profile}</span></code> (same as <code class="docutils literal notranslate"><span class="pre">{owner_username}</span></code>)</dt><dd><p>Owner of the Post / StoryItem / ProfilePic. For hashtag profile pics and
highlight covers, equivalent to <code class="docutils literal notranslate"><span class="pre">{target}</span></code>.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">{owner_id}</span></code></dt><dd><p>Unique integer ID of owner profile. For hashtag profile pics, equivalent to
<code class="docutils literal notranslate"><span class="pre">{target}</span></code>.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">{shortcode}</span></code></dt><dd><p>Shortcode (identifier string). Not available for <a class="reference internal" href="cli-options.html#cmdoption-title-pattern"><code class="xref std std-option docutils literal notranslate"><span class="pre">--title-pattern</span></code></a>.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">{mediaid}</span></code></dt><dd><p>Integer representation of shortcode. Not available for <a class="reference internal" href="cli-options.html#cmdoption-title-pattern"><code class="xref std std-option docutils literal notranslate"><span class="pre">--title-pattern</span></code></a>.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">{filename}</span></code></dt><dd><p>Instagram’s internal filename.</p>
</dd>
</dl>
</li>
<li><dl>
<dt><code class="docutils literal notranslate"><span class="pre">{date_utc}</span></code> (same as <code class="docutils literal notranslate"><span class="pre">{date}</span></code>)</dt><dd><p>Creation time in UTC timezone.
<a class="reference external" href="https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior">strftime()-style formatting options</a>
are supported as format specifier. The default date format specifier used by
Instaloader is:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>{date_utc:%Y-%m-%d_%H-%M-%S}
</pre></div>
</div>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">{typename}</span></code></dt><dd><p>Type of media being saved, such as GraphImage, GraphStoryVideo, profile_pic,
etc.</p>
</dd>
</dl>
</li>
</ul>
<p>For example, encode the poster’s profile name in the filenames with:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>instaloader --filename-pattern={date_utc}_UTC_{profile} "#hashtag"
</pre></div>
</div>
<p>As another example, you may instruct Instaloader to store posts in a
<code class="docutils literal notranslate"><span class="pre">PROFILE/YEAR/SHORTCODE.jpg</span></code> directory structure:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>instaloader --dirname-pattern={profile} --filename-pattern={date_utc:%Y}/{shortcode} <target> ...
</pre></div>
</div>
</section>
<section id="filter-posts">
<span id="id4"></span><h2>Filter Posts<a class="headerlink" href="#filter-posts" title="Link to this heading">¶</a></h2>
<p>The options <a class="reference internal" href="cli-options.html#cmdoption-post-filter"><code class="xref std std-option docutils literal notranslate"><span class="pre">--post-filter</span></code></a> and <a class="reference internal" href="cli-options.html#cmdoption-storyitem-filter"><code class="xref std std-option docutils literal notranslate"><span class="pre">--storyitem-filter</span></code></a>
allow to specify criteria that posts or story items have to
meet to be downloaded. If not given, all posts are downloaded.</p>
<p>The filter string must be a
<a class="reference external" href="https://docs.python.org/3/reference/expressions.html#boolean-operations">Python boolean expression</a>
where the attributes from <a class="reference internal" href="module/structures.html#instaloader.Post" title="instaloader.Post"><code class="xref py py-class docutils literal notranslate"><span class="pre">Post</span></code></a> or
<a class="reference internal" href="module/structures.html#instaloader.StoryItem" title="instaloader.StoryItem"><code class="xref py py-class docutils literal notranslate"><span class="pre">StoryItem</span></code></a> respectively are defined.</p>
<p>The following attributes can be used with both
<a class="reference internal" href="cli-options.html#cmdoption-post-filter"><code class="xref std std-option docutils literal notranslate"><span class="pre">--post-filter</span></code></a> and <a class="reference internal" href="cli-options.html#cmdoption-storyitem-filter"><code class="xref std std-option docutils literal notranslate"><span class="pre">--storyitem-filter</span></code></a>:</p>
<ul>
<li><dl class="simple">
<dt><a class="reference internal" href="module/structures.html#instaloader.Post.owner_username" title="instaloader.Post.owner_username"><code class="xref py py-attr docutils literal notranslate"><span class="pre">owner_username</span></code></a> (str), <a class="reference internal" href="module/structures.html#instaloader.Post.owner_id" title="instaloader.Post.owner_id"><code class="xref py py-attr docutils literal notranslate"><span class="pre">owner_id</span></code></a> (int)</dt><dd><p>Owner profile username / user ID.</p>
</dd>
</dl>
</li>
<li><dl>
<dt><a class="reference internal" href="module/structures.html#instaloader.Post.date_utc" title="instaloader.Post.date_utc"><code class="xref py py-attr docutils literal notranslate"><span class="pre">date_utc</span></code></a> (datetime), <a class="reference internal" href="module/structures.html#instaloader.Post.date_local" title="instaloader.Post.date_local"><code class="xref py py-attr docutils literal notranslate"><span class="pre">date_local</span></code></a> (datetime)</dt><dd><p>Creation timestamp. Since <a class="reference external" href="https://docs.python.org/3/library/datetime.html#datetime.datetime" title="(in Python v3.13)"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime</span></code></a> objects can be created
inside filter strings, this easily allows filtering by creation date. E.g.:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>instaloader --post-filter="date_utc <= datetime(2018, 5, 31)" target
</pre></div>
</div>
</dd>
</dl>
</li>
<li><dl>
<dt><a class="reference internal" href="module/structures.html#instaloader.Post.is_video" title="instaloader.Post.is_video"><code class="xref py py-attr docutils literal notranslate"><span class="pre">is_video</span></code></a> (bool)</dt><dd><p>Whether Post/StoryItem is a video. For example, you may skip videos:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>instaloader --post-filter="not is_video" target
</pre></div>
</div>
<p>This is not the same as <a class="reference internal" href="cli-options.html#cmdoption-no-videos"><code class="xref std std-option docutils literal notranslate"><span class="pre">--no-videos</span></code></a> and
<a class="reference internal" href="cli-options.html#cmdoption-no-video-thumbnails"><code class="xref std std-option docutils literal notranslate"><span class="pre">--no-video-thumbnails</span></code></a>, since sidecar posts (posts that contain
multiple pictures/videos in one post) have this attribute set to False.</p>
</dd>
</dl>
</li>
</ul>
<p>As <a class="reference internal" href="cli-options.html#cmdoption-post-filter"><code class="xref std std-option docutils literal notranslate"><span class="pre">--post-filter</span></code></a>, the following attributes can be used additionally:</p>
<ul>
<li><dl>
<dt><a class="reference internal" href="module/structures.html#instaloader.Post.viewer_has_liked" title="instaloader.Post.viewer_has_liked"><code class="xref py py-attr docutils literal notranslate"><span class="pre">viewer_has_liked</span></code></a> (bool)</dt><dd><p>Whether user (with <a class="reference internal" href="cli-options.html#login"><span class="std std-ref">login</span></a>) has liked given post. To download the
pictures from your feed that you have liked:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>instaloader --login=your_username --post-filter=viewer_has_liked :feed
</pre></div>
</div>
</dd>
</dl>
</li>
<li><dl>
<dt><a class="reference internal" href="module/structures.html#instaloader.Post.likes" title="instaloader.Post.likes"><code class="xref py py-attr docutils literal notranslate"><span class="pre">likes</span></code></a> (int), <a class="reference internal" href="module/structures.html#instaloader.Post.comments" title="instaloader.Post.comments"><code class="xref py py-attr docutils literal notranslate"><span class="pre">comments</span></code></a> (int)</dt><dd><p>Likes count / comments count. You might only want to download posts that
were either liked by yourself or by many others:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>instaloader --login=your_username --post-filter="likes>100 or viewer_has_liked" profile
</pre></div>
</div>
</dd>
</dl>
</li>
<li><dl>
<dt><a class="reference internal" href="module/structures.html#instaloader.Post.caption_hashtags" title="instaloader.Post.caption_hashtags"><code class="xref py py-attr docutils literal notranslate"><span class="pre">caption_hashtags</span></code></a> (list of str) / <a class="reference internal" href="module/structures.html#instaloader.Post.caption_mentions" title="instaloader.Post.caption_mentions"><code class="xref py py-attr docutils literal notranslate"><span class="pre">caption_mentions</span></code></a> (list of str)</dt><dd><p><code class="docutils literal notranslate"><span class="pre">#hashtags</span></code> or <code class="docutils literal notranslate"><span class="pre">@mentions</span></code> (lowercased) in the Post’s caption. For example, to
download posts of kittens that are cute:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>instaloader --post-filter="'cute' in caption_hashtags" "#kitten"
</pre></div>
</div>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="module/structures.html#instaloader.Post.tagged_users" title="instaloader.Post.tagged_users"><code class="xref py py-attr docutils literal notranslate"><span class="pre">tagged_users</span></code></a> (list of str)</dt><dd><p>Lowercased usernames that are tagged in the Post.</p>
</dd>
</dl>
</li>
</ul>
<p>For <a class="reference internal" href="cli-options.html#cmdoption-storyitem-filter"><code class="xref std std-option docutils literal notranslate"><span class="pre">--storyitem-filter</span></code></a>, the following additional attributes are
defined:</p>
<ul class="simple">
<li><dl class="simple">
<dt><a class="reference internal" href="module/structures.html#instaloader.StoryItem.expiring_utc" title="instaloader.StoryItem.expiring_utc"><code class="xref py py-attr docutils literal notranslate"><span class="pre">expiring_utc</span></code></a> (datetime) / <a class="reference internal" href="module/structures.html#instaloader.StoryItem.expiring_local" title="instaloader.StoryItem.expiring_local"><code class="xref py py-attr docutils literal notranslate"><span class="pre">expiring_local</span></code></a> (datetime)</dt><dd><p>Timestamp when StoryItem will get unavailable.</p>
</dd>
</dl>
</li>
</ul>
</section>
<section id="metadata-text-files">
<span id="id5"></span><h2>Metadata Text Files<a class="headerlink" href="#metadata-text-files" title="Link to this heading">¶</a></h2>
<p>Unless <a class="reference internal" href="cli-options.html#cmdoption-no-captions"><code class="xref std std-option docutils literal notranslate"><span class="pre">--no-captions</span></code></a> is given, Instaloader creates a <code class="docutils literal notranslate"><span class="pre">.txt</span></code> file
along with each post where the Post’s caption is saved.</p>
<p>You can customize what metadata to save for each Post or StoryItem with
<a class="reference internal" href="cli-options.html#cmdoption-post-metadata-txt"><code class="xref std std-option docutils literal notranslate"><span class="pre">--post-metadata-txt</span></code></a> and <a class="reference internal" href="cli-options.html#cmdoption-storyitem-metadata-txt"><code class="xref std std-option docutils literal notranslate"><span class="pre">--storyitem-metadata-txt</span></code></a>. The
default is <code class="docutils literal notranslate"><span class="pre">--post-metadata-txt={caption}</span></code> and no storyitem metadata txt.
These strings are formatted similar as the path patterns described in <a class="reference internal" href="#filename-specification"><span class="std std-ref">Filename Specification</span></a> and
the result is saved in text files, unless it is empty.</p>
<p>Specifying these options multiple times results in output having multiple lines,
in the order they were given to Instaloader.</p>
<p>The field names are evaluated to <a class="reference internal" href="module/structures.html#instaloader.Post" title="instaloader.Post"><code class="xref py py-class docutils literal notranslate"><span class="pre">Post</span></code></a> or <a class="reference internal" href="module/structures.html#instaloader.StoryItem" title="instaloader.StoryItem"><code class="xref py py-class docutils literal notranslate"><span class="pre">StoryItem</span></code></a> attributes,
and as such, the same fields are supported as in <a class="reference internal" href="#filename-specification"><span class="std std-ref">Filename Specification</span></a>
and <a class="reference internal" href="#filter-posts"><span class="std std-ref">Filter Posts</span></a>.</p>
<p>For example, to save the current number of likes for each post, rather than
the post’s caption:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>instaloader --post-metadata-txt="{likes} likes." <target>
</pre></div>
</div>
<p>Note that with this feature, it is possible to easily and quickly extract
additional metadata of already-downloaded posts, by reimporting their JSON
files. Say, you now also want to export the number of comments the Posts had
when they were downloaded:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>instaloader --post-metadata-txt="{likes} likes, {comments} comments." <target>/*.json.xz
</pre></div>
</div>
</section>
<section id="exit-codes">
<span id="id6"></span><h2>Exit codes<a class="headerlink" href="#exit-codes" title="Link to this heading">¶</a></h2>
<p>Different exit codes are used to indicate different kinds of error:</p>
<dl class="simple">
<dt>0</dt><dd><p>No error, all downloads were successful.</p>
</dd>
<dt>1</dt><dd><p>A non-fatal error happened. One or more posts, or even one or more
profiles could not be downloaded, but execution was not stopped. The
errors are repeated at the end of the log for easy access.</p>
</dd>
<dt>2</dt><dd><p>Command-line error. An unrecognized option was passed, or an invalid
combination of options, for example. No interaction with Instagram
was made.</p>
</dd>
<dt>3</dt><dd><p>Login error. It was not possible to login. Downloads were not
attempted.</p>
</dd>
<dt>4</dt><dd><p>Fatal download error. Downloads were interrupted and no further
attempts were made. Happens when a response with one of the status
codes in the <a class="reference internal" href="cli-options.html#cmdoption-abort-on"><code class="xref std std-option docutils literal notranslate"><span class="pre">--abort-on</span></code></a> option were passed, or when
Instagram logs the user out during downloads.</p>
</dd>
<dt>5</dt><dd><p>Interrupted by the user. Happens when the user presses Control-C or
sends SIGINT to the process.</p>
</dd>
</dl>
</section>
<section id="instaloader-as-cronjob">
<span id="id7"></span><h2>Instaloader as Cronjob<a class="headerlink" href="#instaloader-as-cronjob" title="Link to this heading">¶</a></h2>
<p>Instaloader is suitable for running as a cronjob to periodically update your
personal Instagram archive. The <a class="reference internal" href="cli-options.html#cmdoption-quiet"><code class="xref std std-option docutils literal notranslate"><span class="pre">--quiet</span></code></a> option disables user
interactions and logging of non-error messages. To non-interactively use
Instaloader logged-in, create a session file:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>instaloader --login=your_username
</pre></div>
</div>
<p>Then use the same username in your cronjob to load the session and download
the given targets:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>instaloader --login=your_username --quiet target [...]
</pre></div>
</div>
<p>Instaloader saves the session file to
<code class="docutils literal notranslate"><span class="pre">~/.config/instaloader/session-YOUR-USERNAME</span></code>. See
<a class="reference internal" href="cli-options.html#cmdoption-sessionfile"><code class="xref std std-option docutils literal notranslate"><span class="pre">--sessionfile</span></code></a> option for how to override this path.</p>
</section>
<section id="programming-instaloader">
<h2>Programming Instaloader<a class="headerlink" href="#programming-instaloader" title="Link to this heading">¶</a></h2>
<p>If your task cannot be done with the command line interface of Instaloader,
consider taking a look at the <a class="reference internal" href="as-module.html#python-module-instaloader"><span class="std std-ref">Python Module instaloader</span></a>.
Instaloader exposes its internally used methods and structures, making it a
powerful and intuitive Python API for Instagram, allowing to further customize
obtaining media and metadata.</p>
<p>Also see <a class="reference internal" href="codesnippets.html#codesnippets"><span class="std std-ref">Advanced Instaloader Examples</span></a>, where we collect a few example scripts that use
Instaloader for simple tasks that cannot be done with the command line
interface.</p>
</section>
</section>
<h2>Next Section</h2>
<p>
<a class="reference internal" href="cli-options.html">Command Line Options</a>
</p>
</main>
</div>
</div>
</body>
</html>