instaloader

Aus Foxwiki
Version vom 12. November 2024, 18:36 Uhr von Dirkwagner (Diskussion | Beiträge) (Textersetzung - „== Syntax ==“ durch „== Aufruf ==“)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)

instaloader - instagram automatic photo downloader

Beschreibung

Mit instaloader können Sie öffentliche und private Profile, Hashtags, User Stories, Feeds und gespeicherte Medien herunterladen. Außerdem können Sie Kommentare, Geotags und Bildunterschriften für jeden Beitrag herunterladen.

Installation

# apt install instaloader

Anwendung

Profilnamen

Kodieren Sie zum Beispiel den Profilnamen des Posters in den Dateinamen mit:

instaloader --login=your_username
instaloader --dirname-pattern={profile}
instaloader --login=your_username --quiet target [...]
instaloader --filename-pattern={date_utc}_UTC_{profile} "#hashtag"
instaloader --post-filter="date_utc <= datetime(2018, 5, 31)" target
instaloader --post-filter="not is_video" target
instaloader --login=your_username --post-filter=viewer_has_liked :feed
Verzeichnisstruktur

Beiträge in einer Verzeichnisstruktur PROFILE/YEAR/SHORTCODE.jpg speichern:

instaloader --login=your_username --post-filter="likes>100 or viewer_has_liked" profile
instaloader --filename-pattern={date_utc:%Y}/{shortcode} <target> ...
instaloader --post-filter="'cute' in caption_hashtags" "#kitten"
instaloader --post-metadata-txt="{likes} likes." <target>
instaloader --post-metadata-txt="{likes} likes, {comments} comments." <target>/*.json.xz

Aufruf

instaloader profile [profile ...]
instaloader --fast-update profile [profile ...]
instaloader --latest-stamps -- profile [profile ...]

Optionen

Was soll heruntergeladen werden?
Option Beschreibung Anmerkungen
profile Public profile, or private profile
option: --login public/private.
option: --stories instructs Instaloader to also download the user's stories.
option: --highlights to download the highlights of that profile.
option: --tagged to download posts where the user is tagged.
option: --igtv to download IGTV videos.
#hashtag Posts with a certain hashtag the quotes are usually necessary
%location id 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 /362629379/ ply‐mouth-naval-memorial/). Requires :option:`--login`.
stories The currently-visible stories of your followees requires :option:--login
feed Your feed requires :option:--login
saved Posts which are marked as saved requires :option:--login
@profile All profiles that are followed by profile i.e. the followees of profile (requires :option:`--login`)
post Replace post with the post's shortcode to download single post Must be preceded by -- in the argument list to not be mistaken as an option flag: instaloader -- -B_K4CykAOtf .. versionadded :: 4.1 Instaloader goes through all media matching the specified targets and downloads the pictures and videos and their captions. You can specify
option:--comments also download comments of each post
option:--geotags download geotags of each post and save them as Google Maps link (requires :option:`--login`)
Angabe des Dateinamens

For each target, Instaloader creates a directory named after the target, i.e. profile, #hashtag,%location id, :feed, etc. and therein saves the posts in files named after the post's timestamp.

option:`--dirname-pattern` allow one to configure the directory name of each target. The default is --dirname-pattern={target}. In the dirname pattern, the token{target} is replaced by the target name, and {profile} is replaced by the owner of the post which is downloaded.
option:`--filename-pattern` configures the path of the post and story's files relative to the target directory that is specified with option: The default is `--filename-pat‐tern`={date_utc}_utc. The tokens {target} and {profile} are replaced like in the dirname pattern.
option:`--title-pattern` is similar to option:`--filename-pattern`, but for profile pics, hashtag profile pics, and highlight covers. The default is {date_utc}_UTC_{typename} if :op‐tion:`--dirname-pattern` contains {target} or {profile}, or {target}_{date_utc}_UTC_{typename} if it does not. Some tokens are not supported for this option, see below for details.

The following tokens are defined for usage with :option:`--filename-pattern` and :option:`--title-pattern`:

2.1 {target} Target name (as given in Instaloader command line)
2.2 {profile} (same as {owner_username}) Owner of the Post / StoryItem / ProfilePic. For hashtag profile pics and highlight covers, equivalent to {target}.
2.3 {owner_id} Unique integer ID of owner profile. For hashtag profile pics, equivalent to {tar‐get}.
2.4 {shortcode} Shortcode (identifier string). Not available for :option:`--title-pattern`
2.5 {mediaid} Integer representation of shortcode. Not available for :option:`--title-pattern`.
2.6 {filename} Instagram's internal filename.
2.7 {date_utc} (same as {date}) Creation time in UTC timezone. strftime ()-style formatting options are supported as format specifier. The default date format specifier used by Instaloader is: {date_utc:%Y-%m-%d_%H-%M-%S}
2.8 {typename} Type of media being saved, such as GraphImage, GraphStoryVideo, profile_pic, etc.

FILTER POSTS

The options :option:`--post-filter` and :option:`--storyitem-filter` allow one to specify crite‐ria that posts or story items have to meet to be downloaded. If not given, all posts are down‐ loaded.

The filter string must be a Python boolean expression where the attribute from :class:`Post` or :class:`StoryItem` respectively are defined.

the following attributes can be used with both option:`--post-filter` and option:`--storyitem- filter`:

3.1 attr
`~Post.owner_username` (str), attr:`~Post.owner_id` (int) Owner profile username/user ID.
3.2
attr:`~Post.date_utc` (datetime), :attr:`~Post.date_local` (datetime) Creation timestamp.

Since :class:`~datetime.datetime` objects can be created inside filter strings, this easily allows filtering by creation date.

3.3
attr:`~Post.is_video` (bool) Whether Post/StoryItem is a video. For example, you may skip videos: instaloader --post-filter="not is_video" target

This is not the same as :option:`--no-videos` and :option:`--no-video-thumbnails`, since sidecar posts (posts that contain multiple pictures/videos in one post) have this attribute set to False.

As :option:`--post-filter`, the following attributes can be used additionally:

3.4
attr:`~Post.viewer_has_liked` (bool) Whether user (with :option:`--login`) has liked given post. To download the pictures from your feed that you have liked:
3.5
attr:`~Post.likes` (int), :attr:`~Post.comments` (int) Likes count / comments count. You might only want to download posts that were either liked by yourself or by many others.
3.6
attr:`~Post.caption_hashtags` (list of str) /:attr:`~Post.caption_mentions` (list of str)
  1. hashtags or @mentions (lowercased) in the Post's caption. For example, to download posts of kittens that are cute: instaloader --post-filter="'cute' in caption_hashtags" "#kitten"
3.7
attr:`~Post.tagged_users` (list of str) Lowercased usernames that are tagged in the Post.

For :option:`--storyitem-filter`, the following additional attributes are defined:

3.8
attr:`~StoryItem.expiring_utc` (datetime) /:attr:`~StoryItem.expiring_local` (date‐time).Timestamp when StoryItem will get unavailable.

METADATA TEXT FILES

Unless :option:`--no-captions` is given, Instaloader creates a .txt file along with each post where the Post's caption is saved.

You can customize what metadata to save for each Post or StoryItem with :option: `--post-meta‐ data-txt` and :option:`--storyitem-metadata-txt`. The default is --post-metadata-txt={caption} and no storyitem metadata txt. These strings are formatted similar as the path patterns described in :ref:`filename-specification and the result is saved in text files, unless it is empty.

Specifying these options multiple times results in output having multiple lines, in the order they were given to Instaloader. The field names are evaluated to :class: `Post` or :class:`Sto‐ ryItem` attributes, and as such, the same fields are supported as in :ref:`filename-specifica‐ tion` and :ref:`filter-posts`.

For example, to save the current number of likes for each post, rather than the post's caption:

4.1 instaloader --post-metadata-txt="{likes} likes." <target>

Note that with this feature, it is possible to easily and fastly 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:

4.2 instaloader --post-metadata-txt="{likes} likes, {comments} comments." <target>/*.json.xz

Parameter

Umgebung

Rückgabewert

Konfiguration

Dateien

Anhang

Siehe auch

Dokumentation

Man-Page
  1. INSTALOADER(1)

Links

Projekt
Weblinks