### Install InstaLooter from PyPI (with admin rights) Source: https://github.com/althonos/instalooter/blob/master/docs/source/install.md Use this command to install InstaLooter globally if you have super user rights. ```bash # pip install instaLooter ``` -------------------------------- ### Install InstaLooter Source: https://github.com/althonos/instalooter/blob/master/README.rst Installs InstaLooter using pip. The --user flag installs it for the current user. ```bash pip install --user instalooter --pre ``` -------------------------------- ### Install InstaLooter with metadata extras Source: https://github.com/althonos/instalooter/blob/master/docs/source/install.md Install InstaLooter with the 'metadata' extras to enable exif metadata features. This command is for installing for the current user. ```bash $ pip install instaLooter[metadata] --user ``` -------------------------------- ### Instalooter Template Examples Source: https://github.com/althonos/instalooter/blob/master/docs/source/usage.md Examples demonstrating how to use the -T argument to specify a filename template for downloaded media. These templates can include variables like username, datetime, likescount, width, height, and id. ```console $ instaLooter -T {username}.{datetime} ``` ```console $ instaLooter -T {username}-{likescount}-{width}x{height}.{id} ``` ```console $ instaLooter -T {username}.{code}.something_constant ``` -------------------------------- ### Install InstaLooter from PyPI (current user) Source: https://github.com/althonos/instalooter/blob/master/docs/source/install.md Use this command to install InstaLooter for the current user if you do not have admin rights. ```bash $ pip install instaLooter --user ``` -------------------------------- ### Install InstaLooter from local source Source: https://github.com/althonos/instalooter/blob/master/docs/source/install.md After cloning the repository, use pip to install the local version of InstaLooter and its dependencies. ```bash # pip install . ``` -------------------------------- ### Install development dependencies for InstaLooter Source: https://github.com/althonos/instalooter/blob/master/docs/source/install.md Install specific development dependencies for testing or documentation building using pip. These commands install for the current user. ```bash $ pip install --user ".[test]" # install only test dependencies $ pip install --user ".[doc]" # install only doc dependencies $ pip install --user ".[dev]" # install all dev dependencies ``` -------------------------------- ### Batch Download Configuration with Parameters Source: https://github.com/althonos/instalooter/blob/master/docs/source/batch.md Example of a batch configuration section specifying parameters like downloading only videos, only new media, and setting the number of downloads. ```ini [Vids] videos-only = true new = true num-to-dl = 3 hashtags = funny: ~/Videos nsfw: ~/Videos ``` -------------------------------- ### SystemD: Start and Enable Timer (System-wide) Source: https://github.com/althonos/instalooter/blob/master/docs/source/cron.md Commands to start and enable a SystemD timer for system-wide jobs. This ensures the timer is active and will run according to its schedule. ```bash systemctl start looter.timer && systemctl enable looter.timer ``` -------------------------------- ### SystemD: Start and Enable Timer (User) Source: https://github.com/althonos/instalooter/blob/master/docs/source/cron.md Commands to start and enable a SystemD timer for user-specific jobs. This allows running scheduled tasks under a specific user's context. ```bash systemctl --user start looter.timer && systemctl --user enable looter.timer ``` -------------------------------- ### Example CLI Command for Reproducing Errors Source: https://github.com/althonos/instalooter/blob/master/docs/ISSUE_TEMPLATE.md When encountering runtime errors with the CLI, provide a command that can reproduce the issue. This helps in debugging. ```bash instalooter ... ``` -------------------------------- ### Check Instalooter Version Source: https://github.com/althonos/instalooter/blob/master/docs/ISSUE_TEMPLATE.md Use this command to check the installed version of the Instalooter library. ```bash instalooter --version ``` -------------------------------- ### Example API Snippet for Reproducing Errors Source: https://github.com/althonos/instalooter/blob/master/docs/ISSUE_TEMPLATE.md If an error occurs when using the Instalooter API, include a small Python snippet that demonstrates how to reproduce the error. ```python from instalooter.looters import ... ``` -------------------------------- ### SystemD Timer File Configuration Source: https://github.com/althonos/instalooter/blob/master/docs/source/cron.md Configure a SystemD timer to schedule the execution of an InstaLooter service. This example sets the timer to run the associated service 10 minutes after boot and then every hour. ```ini [Unit] Description=run my custom periodic instagram looter hourly [Timer] # Time to wait after booting before we run first time OnBootSec=10min # Time between running each consecutive time OnUnitActiveSec=1h Unit=looter.service ``` -------------------------------- ### Download by Time Range Source: https://github.com/althonos/instalooter/blob/master/docs/source/usage.md Filter downloads using a start and stop date in ISO format. Edges are included. Supports partial date ranges like 'YYYY-MM-DD:' or ':YYYY-MM-DD'. ```console --time 2016-12-21:2016-12-18 --time 2015-03-07: --time :2016-08-02 ``` -------------------------------- ### SystemD Service File Configuration Source: https://github.com/althonos/instalooter/blob/master/docs/source/cron.md Define a SystemD service to run InstaLooter. This configuration specifies the command to execute for periodic Instagram downloads. Ensure the instaLooter module is installed in a location accessible by the systemd manager. ```ini [Unit] Description=my custom periodic instagram looter [Service] Type=oneshot ExecStart=/usr/bin/env python -m instaLooter ``` -------------------------------- ### get_post_info Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Get media information from a given post code. ```APIDOC ## get_post_info(code: str) -> dict ### Description Get media information from a given post code. ### Parameters: * **code** (*str*) – the code of the post (can be obtained either from the `shortcode` attribute of media dictionaries, or from a post URL: `https://www.instagram.com/p//`) ### Returns: a media dictionaries, in the format used by Instagram. ### Return type: dict ``` -------------------------------- ### HashtagLooter.get_post_info Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Get media information from a given post code. This is useful for retrieving details about a specific Instagram post. ```APIDOC #### get_post_info(code: str) -> dict Get media information from a given post code. * **Parameters:** **code** (*str*) – the code of the post (can be obtained either from the `shortcode` attribute of media dictionaries, or from a post URL: `https://www.instagram.com/p//`) * **Returns:** a media dictionaries, in the format used by Instagram. * **Return type:** dict ``` -------------------------------- ### Extract Users from Mentions in Posts Source: https://github.com/althonos/instalooter/blob/master/docs/source/examples.md Gathers usernames of users mentioned in the tagged users section of posts from a given Instagram profile. This example iterates through media and extracts tagged user information. ```python from instalooter.looters import ProfileLooter looter = ProfileLooter("mandodiaomusic") users = set() for media in looter.medias(): info = looter.get_post_info(media['shortcode']) for comment in post_info['edge_media_to_tagged_user']['edges']: user = comment['node']['user']['username'] users.add(user) ``` -------------------------------- ### instalooter.cli.main Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/cli.md Executes the Instalooter program from the command line interface. It accepts positional arguments and can direct error messages to a specified stream. ```APIDOC ## instalooter.cli.main(argv=None, stream=None) ### Description Run from the command line interface. ### Parameters #### Path Parameters * **argv** (list) - Optional - The positional arguments to read. Defaults to `sys.argv` to use CLI arguments. * **stream** (IOBase) - Optional - A file where to write error messages. Leave to `None` to use the `StandardErrorHandler` for logs, and `sys.stderr` for error messages. ### Returns An error code, or 0 if the program executed successfully. ### Return type int ``` -------------------------------- ### InstaLooter Initialization Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Instantiate the InstaLooter class with various configuration options. ```APIDOC ## InstaLooter(add_metadata: bool = False, get_videos: bool = False, videos_only: bool = False, jobs: int = 16, template: Text = '{id}', dump_json: bool = False, dump_only: bool = False, extended_dump: bool = False, session: Session | None = None) ### Description A brutal Instagram looter that raids without API tokens. Create a new looter instance. ### Parameters: * **add_metadata** (*bool*) – Add date and comment metadata to the downloaded pictures. * **get_videos** (*bool*) – Also get the videos from the given target. * **videos_only** (*bool*) – Only download videos (implies `get_videos=True`). * **jobs** (*int*) – the number of parallel threads to use to download media (12 or more is advised to have a true parallel download of media files). * **template** (*str*) – a filename format, in Python new-style-formatting format. See the the [Template](../usage.md#template) page of the documentation for available keys. * **dump_json** (*bool*) – Save each resource metadata to a JSON file next to the actual image/video. * **dump_only** (*bool*) – Only save metadata and discard the actual resource. * **extended_dump** (*bool*) – Attempt to fetch as much metadata as possible, at the cost of more time. Set to `True` if, for instance, you always want the top comments to be downloaded in the dump. * **session** (*Session* *or* *None*) – a `requests` session, or `None` to create a new one. ``` -------------------------------- ### InstaLooter Core Methods Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Core methods for managing sessions and retrieving media iterators. ```APIDOC ## login(username: str, password: str) -> None ### Description Log the instance in using the given credentials. ### Parameters #### Path Parameters * **username** (str) - Required - the username to log in with. * **password** (str) - Required - the password to log in with. ``` ```APIDOC ## logout() -> None ### Description Log the instance out from the currently opened session. ``` ```APIDOC ## medias(timeframe: _Timeframe | None = None) -> Iterator[Dict[Text, Any]] ### Description Obtain an iterator over the Instagram medias. Wraps the iterator returned by `InstaLooter.pages` to seamlessly iterate over the medias of all the pages. ### Returns an iterator over the medias in every pages. ### Return type [MediasIterator](medias.md#instalooter.medias.MediasIterator) ``` ```APIDOC ## pages() -> Iterator[Dict[Text, Any]] ### Description Obtain an iterator over Instagram post pages. ### Returns an iterator over the instagram post pages. ### Return type [PageIterator](pages.md#instalooter.pages.PageIterator) ``` ```APIDOC ## logged_in() -> bool ### Description Check if there’s an open Instagram session. ``` -------------------------------- ### Running InstaLooter in Batch Mode Source: https://github.com/althonos/instalooter/blob/master/docs/source/batch.md Command to execute InstaLooter in batch mode, pointing to the specified configuration file. ```console instaLooter batch /path/to/your/batch.ini ``` -------------------------------- ### Batch Download with Configuration Source: https://github.com/althonos/instalooter/blob/master/README.rst Uses a configuration file to download content from multiple accounts with custom parameters. Refer to the Batch mode documentation for details. ```bash $ instalooter batch /path/to/a/config/file.ini ``` -------------------------------- ### Download in Batch Mode Source: https://github.com/althonos/instalooter/blob/master/docs/source/usage.md This command initiates a batch download process using instructions from a specified batch file. Refer to the batch mode documentation for file format details. ```console $ instaLooter batch ``` -------------------------------- ### Specifying Users and Hashtags in Batch Config Source: https://github.com/althonos/instalooter/blob/master/docs/source/batch.md Define users and hashtags to download from, mapping them to specific local directories. Each user or hashtag is listed with its corresponding download path. ```ini [Video Games] users = borderlands: /tmp/borderlands ffxv: /tmp/ffxv hashtags = nierautomata: /tmp/nier [Music] users = perm36 : ~/Music/Perm36 ``` -------------------------------- ### ProfileLooter Constructor Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Initializes a ProfileLooter instance to target media on a specific user profile. ```APIDOC ## Class ProfileLooter(username: str, **kwargs: Any) ### Description A looter targeting medias on a user profile. ### Parameters * **username** (str) - The username of the profile. ``` -------------------------------- ### Clone InstaLooter repository Source: https://github.com/althonos/instalooter/blob/master/docs/source/install.md Clone the InstaLooter repository from GitHub using git and navigate into the cloned directory. ```bash $ git clone https://github.com/althonos/InstaLooter $ cd InstaLooter ``` -------------------------------- ### SystemD: Journalctl for Service Logs Source: https://github.com/althonos/instalooter/blob/master/docs/source/cron.md Command to view logs for a SystemD service. Use this to diagnose issues with your InstaLooter service. ```console journalctl looter.service ``` -------------------------------- ### Basic INI Section Format Source: https://github.com/althonos/instalooter/blob/master/docs/source/batch.md A configuration file section is defined by a header in square brackets, followed by key-value pairs on separate lines. ```ini [my section header] key = value other_key = other_value ``` -------------------------------- ### Cron: Batch download using a configuration file weekly Source: https://github.com/althonos/instalooter/blob/master/docs/source/cron.md Schedule a weekly batch download using a configuration file. This cron job runs every Sunday at midnight, processing downloads defined in the specified INI file. ```default @weekly /usr/bin/env python -m instaLooter batch ~/myLooter.ini ``` -------------------------------- ### Download by Hashtag Source: https://github.com/althonos/instalooter/blob/master/docs/source/usage.md This command downloads pictures and videos associated with a given hashtag. You must specify the hashtag and the directory where the files will be saved. ```console $ instaLooter hashtag [options] ``` -------------------------------- ### Download by Special Time Values Source: https://github.com/althonos/instalooter/blob/master/docs/source/usage.md Filter downloads using predefined time frames: 'thisday', 'thisweek', 'thismonth', 'thisyear'. ```console --time thisday --time thisweek --time thismonth --time thisyear ``` -------------------------------- ### download_videos Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Downloads all videos from the profile to the provided destination. This is a shortcut for the `download` method with a condition set to accept only videos. ```APIDOC ## download_videos(destination: str | fs.base.FS, media_count: int | None = None, timeframe: _Timeframe | None = None, new_only: bool = False, pgpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None, dlpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None) -> int ### Description Download all videos to the provided destination. ### Parameters * **destination** (FS or str) - The filesystem where to store the downloaded files. * **media_count** (int or None) - The maximum number of medias to download. * **timeframe** (tuple or None) - A tuple of two `datetime` objects to enforce a time frame. * **new_only** (bool) - Stop media discovery when already downloaded medias are encountered. * **pgpbar_cls** (type or None) - An optional `ProgressBar` subclass to use to display page scraping progress. * **dlpbar_cls** (type or None) - An optional `ProgressBar` subclass to use to display file download progress. ### Returns The number of queued medias. * **Return type:** int ``` -------------------------------- ### HashtagLooter.download_videos Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Download all videos to the provided destination. This is a shortcut for the `download` method with a condition set to accept only videos. ```APIDOC #### download_videos(destination: str | fs.base.FS, media_count: int | None = None, timeframe: _Timeframe | None = None, new_only: bool = False, pgpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None, dlpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None) -> int Download all videos to the provided destination. Actually a shortcut for [`download`](#instalooter.looters.HashtagLooter.download) with `condition` set to accept only videos. ``` -------------------------------- ### TqdmProgressBar Class Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/pbar.md A concrete implementation of the ProgressBar class that utilizes the `tqdm` library for displaying progress bars in the command-line interface. ```APIDOC ## class instalooter.pbar.TqdmProgressBar(*_, **__) A progress bar using the `tqdm` library. ### Methods #### finish() Notify the progress bar the operation is finished. #### set_maximum(maximum) Set the maximum number of steps of the operation. ``` -------------------------------- ### BatchRunner Class Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/batch.md The BatchRunner class facilitates running InstaLooter in batch mode by utilizing a configuration file to manage multiple downloading jobs. ```APIDOC ## Class instalooter.batch.BatchRunner ### Description Run `InstaLooter` in batch mode, using a configuration file. ### Methods #### get_targets(raw_string: Text | None) -> Dict[Text, Text] Extract targets from a string in ‘key: value’ format. #### run_all() -> None Run all the jobs specified in the configuration file. #### run_job(section_id: Text, session: Session | None = None) -> None Run a job as described in the section named `section_id`. * **Raises:** **KeyError** – when the section could not be found. ``` -------------------------------- ### download Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Download all medias passing a condition to the specified destination. ```APIDOC ## download(destination: str | fs.base.FS, condition: Callable[[dict], bool] | None = None, media_count: int | None = None, timeframe: _Timeframe | None = None, new_only: bool = False, pgpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None, dlpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None) -> int ### Description Download all medias passing `condition` to destination. ### Parameters: * **destination** (*FS* *or* *str*) – the filesystem where to store the downloaded files, as a filesystem instance or FS URL. * **condition** (*function*) – the condition to filter the medias with. If `None` is given, a function is created using the `get_videos` and `videos_only` passed at object initialisation. * **media_count** (*int* *or* *None*) – the maximum number of medias to download. Leave to `None` to download everything from the target. *Note that more files can be downloaded, since a post with multiple images/videos is considered to be a single media*. * **timeframe** (*tuple* *or* *None*) – a tuple of two `datetime` objects to enforce a time frame (the first item must be more recent). Leave to `None` to ignore times. * **new_only** (*bool*) – stop media discovery when already downloaded medias are encountered. * **pgpbar_cls** (*type* *or* *None*) – an optional [`ProgressBar`](pbar.md#instalooter.pbar.ProgressBar) subclass to use to display page scraping progress. * **dlpbar_cls** (*type* *or* *None*) – an optional [`ProgressBar`](pbar.md#instalooter.pbar.ProgressBar) subclass to use to display file download progress. ### Returns: the number of queued medias. May not be equal to the number of downloaded medias if some errors occurred during background download. ### Return type: int ``` -------------------------------- ### download Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Downloads all media from the profile that satisfy the given condition to the specified destination. ```APIDOC ## download(destination: str | fs.base.FS, condition: Callable[[dict], bool] | None = None, media_count: int | None = None, timeframe: _Timeframe | None = None, new_only: bool = False, pgpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None, dlpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None) -> int ### Description Download all medias passing `condition` to destination. ### Parameters * **destination** (FS or str) - The filesystem where to store the downloaded files. * **condition** (function or None) - The condition to filter the medias with. If None, a function is created using `get_videos` and `videos_only` passed at object initialisation. * **media_count** (int or None) - The maximum number of medias to download. Leave to None to download everything. * **timeframe** (tuple or None) - A tuple of two `datetime` objects to enforce a time frame. * **new_only** (bool) - Stop media discovery when already downloaded medias are encountered. * **pgpbar_cls** (type or None) - An optional `ProgressBar` subclass to use to display page scraping progress. * **dlpbar_cls** (type or None) - An optional `ProgressBar` subclass to use to display file download progress. ### Returns The number of queued medias. May not be equal to the number of downloaded medias if some errors occurred during background download. * **Return type:** int ``` -------------------------------- ### download_pictures Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Downloads all pictures from the profile to the provided destination. This is a shortcut for the `download` method with a condition set to accept only images. ```APIDOC ## download_pictures(destination: str | fs.base.FS, media_count: int | None = None, timeframe: _Timeframe | None = None, new_only: bool = False, pgpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None, dlpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None) -> int ### Description Download all the pictures to the provided destination. ### Parameters * **destination** (FS or str) - The filesystem where to store the downloaded files. * **media_count** (int or None) - The maximum number of medias to download. * **timeframe** (tuple or None) - A tuple of two `datetime` objects to enforce a time frame. * **new_only** (bool) - Stop media discovery when already downloaded medias are encountered. * **pgpbar_cls** (type or None) - An optional `ProgressBar` subclass to use to display page scraping progress. * **dlpbar_cls** (type or None) - An optional `ProgressBar` subclass to use to display file download progress. ### Returns The number of queued medias. * **Return type:** int ``` -------------------------------- ### Download Hashtagged Media Source: https://github.com/althonos/instalooter/blob/master/README.rst Downloads the latest 20 pictures or videos tagged with 'python' to the '/tmp' directory. Requires login credentials. ```bash $ instalooter hashtag python /tmp -n 20 --get-videos -c MYLOGIN ``` -------------------------------- ### Authentication Options Source: https://github.com/althonos/instalooter/blob/master/docs/source/usage.md These options allow you to provide credentials for connecting to Instagram. If only the username is provided, the password will be prompted for in the shell. ```console -u USER, --username USER ``` ```console -p PASS, --password PASS ``` -------------------------------- ### download_videos Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Download all videos to the provided destination. ```APIDOC ## download_videos(destination: str | fs.base.FS, media_count: int | None = None, timeframe: _Timeframe | None = None, new_only: bool = False, pgpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None, dlpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None) -> int ### Description Download all videos to the provided destination. Actually a shortcut for [`download`](#instalooter.looters.InstaLooter.download) with `condition` set to accept only videos. ``` -------------------------------- ### SystemD: Journalctl for User Service Logs Source: https://github.com/althonos/instalooter/blob/master/docs/source/cron.md Command to view logs for a user-specific SystemD service. This is useful for debugging scheduled tasks running under a user's account. ```console journalctl --user --user-unit looter.service ``` -------------------------------- ### Cron: Download new #funny videos hourly Source: https://github.com/althonos/instalooter/blob/master/docs/source/cron.md Use this cron job to download a maximum of 3 new videos tagged as '#funny' to a specified directory every hour. Ensure the python interpreter and instaLooter are accessible in the cron environment. ```default @hourly /usr/bin/env python -m instaLooter hashtag funny ~/Videos -N -n 3 -V ``` -------------------------------- ### HashtagLooter.download_pictures Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Download all the pictures to the provided destination. This is a shortcut for the `download` method with a condition set to accept only images. ```APIDOC #### download_pictures(destination: str | fs.base.FS, media_count: int | None = None, timeframe: _Timeframe | None = None, new_only: bool = False, pgpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None, dlpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None) -> int Download all the pictures to the provided destination. Actually a shortcut for [`download`](#instalooter.looters.HashtagLooter.download) with `condition` set to accept only images. ``` -------------------------------- ### Download from User Profile Source: https://github.com/althonos/instalooter/blob/master/docs/source/usage.md Use this command to download all pictures and videos from a specific Instagram user's profile. The directory is optional and defaults to the current directory if not specified. ```console $ instaLooter user [] [options] ``` -------------------------------- ### HashtagLooter.login Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Log the instance in using the given username and password. This establishes an active session for subsequent operations. ```APIDOC #### login(username: str, password: str) -> None Log the instance in using the given credentials. * **Parameters:** * **username** (*str*) – the username to log in with. * **password** (*str*) – the password to log in with. ``` -------------------------------- ### download_pictures Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Download all the pictures to the provided destination. ```APIDOC ## download_pictures(destination: str | fs.base.FS, media_count: int | None = None, timeframe: _Timeframe | None = None, new_only: bool = False, pgpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None, dlpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None) -> int ### Description Download all the pictures to the provided destination. Actually a shortcut for [`download`](#instalooter.looters.InstaLooter.download) with `condition` set to accept only images. ``` -------------------------------- ### PostLooter Class Methods Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Methods specific to the PostLooter class for targeting and downloading a specific post. ```APIDOC ## PostLooter(code: str, **kwargs: Any) ### Description A looter targeting a specific post. Create a new hashtag looter. ### Parameters * **code** (str) - the code of the post to get. See `InstaLooter.__init__` for more details about accepted keyword arguments. ``` ```APIDOC ## download(destination: str | fs.base.FS, condition: Callable[[dict], bool] | None = None, media_count: int | None = None, timeframe: _Timeframe | None = None, new_only: bool = False, pgpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None, dlpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None) -> int ### Description Download the refered post to the destination. See [`InstaLooter.download`](#instalooter.looters.InstaLooter.download) for argument reference. NOTE This function, opposed to other *looter* implementations, will not spawn new threads, but simply use the main thread to download the files. Since a worker is in charge of downloading a *media* at a time (and not a *file*), there would be no point in spawning more. ``` ```APIDOC ## download_pictures(destination: str | fs.base.FS, media_count: int | None = None, timeframe: _Timeframe | None = None, new_only: bool = False, pgpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None, dlpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None) -> int ### Description Download all the pictures to the provided destination. Actually a shortcut for [`download`](#instalooter.looters.PostLooter.download) with `condition` set to accept only images. ``` ```APIDOC ## download_videos(destination: str | fs.base.FS, media_count: int | None = None, timeframe: _Timeframe | None = None, new_only: bool = False, pgpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None, dlpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None) -> int ### Description Download all videos to the provided destination. Actually a shortcut for [`download`](#instalooter.looters.PostLooter.download) with `condition` set to accept only videos. ``` ```APIDOC ## get_post_info(code: str) -> dict ### Description Get media information from a given post code. ### Parameters #### Path Parameters * **code** (str) - Required - the code of the post (can be obtained either from the `shortcode` attribute of media dictionaries, or from a post URL: `https://www.instagram.com/p//`). ### Returns a media dictionaries, in the format used by Instagram. ### Return type dict ``` ```APIDOC ## medias(timeframe=None) ### Description Return a generator that yields only the refered post. ### Yields *dict* – a media dictionary obtained from the given post. ### Raises **StopIteration** – if the post does not fit the timeframe. ``` ```APIDOC ## pages() -> Iterator[Dict[Text, Any]] ### Description Return a generator that yields a page with only the refered post. ### Yields *dict* – a page dictionary with only a single media. ``` -------------------------------- ### Download Single Post Source: https://github.com/althonos/instalooter/blob/master/docs/source/usage.md Use this command to download media from a specific Instagram post. Provide the post's token (URL or code) and the target directory. ```console $ instaLooter post [options] ``` -------------------------------- ### get_post_info Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Retrieves information about a specific media post using its code. ```APIDOC ## get_post_info(code: str) -> dict ### Description Get media information from a given post code. ### Parameters * **code** (str) - The code of the post (can be obtained either from the `shortcode` attribute of media dictionaries, or from a post URL: `https://www.instagram.com/p//`). ### Returns A media dictionary, in the format used by Instagram. * **Return type:** dict ``` -------------------------------- ### HashtagLooter.download Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Download all medias passing a given condition to a specified destination. This method allows for flexible filtering and media count limitations. ```APIDOC #### download(destination: str | fs.base.FS, condition: Callable[[dict], bool] | None = None, media_count: int | None = None, timeframe: _Timeframe | None = None, new_only: bool = False, pgpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None, dlpbar_cls: Type[[ProgressBar](pbar.md#instalooter.pbar.ProgressBar)] | None = None) -> int Download all medias passing `condition` to destination. * **Parameters:** * **destination** (*FS* *or* *str*) – the filesystem where to store the downloaded files, as a filesystem instance or FS URL. * **condition** (*function*) – the condition to filter the medias with. If `None` is given, a function is created using the `get_videos` and `videos_only` passed at object initialisation. * **media_count** (*int* *or* *None*) – the maximum number of medias to download. Leave to `None` to download everything from the target. *Note that more files can be downloaded, since a post with multiple images/videos is considered to be a single media*. * **timeframe** (*tuple* *or* *None*) – a tuple of two `datetime` objects to enforce a time frame (the first item must be more recent). Leave to `None` to ignore times. * **new_only** (*bool*) – stop media discovery when already downloaded medias are encountered. * **pgpbar_cls** (*type* *or* *None*) – an optional [`ProgressBar`](pbar.md#instalooter.pbar.ProgressBar) subclass to use to display page scraping progress. * **dlpbar_cls** (*type* *or* *None*) – an optional [`ProgressBar`](pbar.md#instalooter.pbar.ProgressBar) subclass to use to display file download progress. * **Returns:** the number of queued medias. May not be equal to the number of downloaded medias if some errors occurred during background download. * **Return type:** int ``` -------------------------------- ### Cron: Download new pictures with metadata at reboot Source: https://github.com/althonos/instalooter/blob/master/docs/source/cron.md This cron job downloads new pictures along with their metadata from the 'instagram' account every time the system reboots. The downloaded files will be saved to the specified directory. ```default @reboot /usr/bin/env python -m instaLooter instagram ~/Pictures/instagram -Nm ``` -------------------------------- ### ProgressBar Class Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/pbar.md The abstract base class for progress bars. It defines the interface for reporting progress and can be subclassed to implement custom progress display logic. ```APIDOC ## class instalooter.pbar.ProgressBar(it, *args, **kwargs) An abstract progess bar used to report interal progress. ### Methods #### finish() -> None Notify the progress bar the operation is finished. #### get_lock() -> Lock | RLock Obtain the progress bar lock. #### set_lock(lock: Lock | RLock) -> None Set a lock to be used by parallel workers. #### set_maximum(maximum: int) -> None Set the maximum number of steps of the operation. #### update() -> None Update the progress bar by one step. ``` -------------------------------- ### MediasIterator Class Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/medias.md An iterator over the medias obtained from a page iterator. It yields individual media dictionaries. ```APIDOC ## class instalooter.medias.MediasIterator(page_iterator: Iterable[Dict[Text, Any]]) Bases: `Iterator`[`Dict`[`str`, `Any`]] An iterator over the medias obtained from a page iterator. ### __next__() → Dict[Text, Any] Return the next item from the iterator. When exhausted, raise StopIteration ``` -------------------------------- ### Authenticate with Username and Password Source: https://github.com/althonos/instalooter/blob/master/docs/source/usage.md Log in to Instagram using username and password to download from private profiles. Password can be provided directly or entered interactively. ```console $ instaLooter ... --username USERNAME --password PASSWORD $ instaLooter ... --username USERNAME Password: # type PASSWORD privately here ``` -------------------------------- ### Extract Media Links from Hashtag Source: https://github.com/althonos/instalooter/blob/master/docs/source/examples.md Generates a list of direct links to media files (pictures and videos) associated with a given hashtag and saves them to a text file. Handles both single media posts and sidecar posts. ```python def links(media, looter): if media.get('__typename') == "GraphSidecar": media = looter.get_post_info(media['shortcode']) nodes = [e['node'] for e in media['edge_sidecar_to_children']['edges']] return [n.get('video_url') or n.get('display_url') for n in nodes] elif media['is_video']: media = looter.get_post_info(media['shortcode']) return [media['video_url']] else: return [media['display_url']] from instalooter.looters import HashtagLooter looter = HashtagLooter("ramones") with open("ramones.txt", "w") as f: for media in looter.medias(): for link in links(media, looter): f.write("{}\n".format(link)) ``` -------------------------------- ### pages Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Obtains an iterator over the Instagram post pages for the profile. ```APIDOC ## pages() -> ProfileIterator ### Description Obtain an iterator over Instagram post pages. ### Returns An iterator over the instagram post pages. * **Return type:** ProfileIterator ### Raises * **ValueError** - when the requested user does not exist. * **RuntimeError** - when the user is a private account and there is no logged user (or the logged user does not follow that account). ``` -------------------------------- ### HashtagLooter.medias Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Obtain an iterator over the Instagram medias. This method wraps the iterator from `InstaLooter.pages` to provide a seamless iteration over medias across all pages. ```APIDOC #### medias(timeframe: _Timeframe | None = None) -> Iterator[Dict[Text, Any]] Obtain an iterator over the Instagram medias. Wraps the iterator returned by [`InstaLooter.pages`](#instalooter.looters.InstaLooter.pages) to seamlessly iterate over the medias of all the pages. * **Returns:** an iterator over the medias in every pages. * **Return type:** [MediasIterator](medias.md#instalooter.medias.MediasIterator) ``` -------------------------------- ### Download Posts from a Profile Source: https://github.com/althonos/instalooter/blob/master/docs/source/examples.md Downloads a specified number of posts from an Instagram profile to a local directory. Ensure the target directory exists. ```python from instalooter.looters import ProfileLooter looter = ProfileLooter("dreamwifetheband") looter.download('~/Pictures', media_count=50) ``` -------------------------------- ### login Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Logs into an Instagram session using the provided username and password. ```APIDOC ## login(username: str, password: str) -> None ### Description Log the instance in using the given credentials. ### Parameters * **username** (str) - The username to log in with. * **password** (str) - The password to log in with. ``` -------------------------------- ### logged_in Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Check if there’s an open Instagram session. ```APIDOC ## logged_in() -> bool ### Description Check if there’s an open Instagram session. ``` -------------------------------- ### Download User Pictures Source: https://github.com/althonos/instalooter/blob/master/README.rst Downloads all pictures from the 'instagram' profile into the current directory. ```bash $ instalooter user instagram ``` -------------------------------- ### Download Single Post Source: https://github.com/althonos/instalooter/blob/master/README.rst Downloads a single Instagram post from a given URL into the specified directory. ```bash $ instalooter post "https://www.instagram.com/p/BFB6znLg5s1/" ~/Pictures ``` -------------------------------- ### TimedMediasIterator Class Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/medias.md An iterator over medias within a specific timeframe. It inherits from MediasIterator and filters medias by time. ```APIDOC ## class instalooter.medias.TimedMediasIterator(page_iterator, timeframe=None) Bases: [`MediasIterator`](#instalooter.medias.MediasIterator) An iterator over the medias within a specific timeframe. ### __next__() Return the next item from the iterator. When exhausted, raise StopIteration ``` -------------------------------- ### HashtagLooter Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md A looter targeting medias tagged with a specific hashtag. It inherits from InstaLooter and provides methods to download media based on hashtags. ```APIDOC ## class instalooter.looters.HashtagLooter(hashtag: str, **kwargs: Any) Bases: [`InstaLooter`](#instalooter.looters.InstaLooter) A looter targeting medias tagged with a hashtag. Create a new hashtag looter. * **Parameters:** **username** (*str*) – the hashtag to search for. See `InstaLooter.__init__` for more details about accepted keyword arguments. ``` -------------------------------- ### PageIterator Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/pages.md An abstract Instagram page iterator. This is the base class for other page iterators. ```APIDOC ## class instalooter.pages.PageIterator(session: Session, rhx: Text) Bases: `Iterator`[`Dict`[`str`, `Any`]] An abstract Instagram page iterator. ### __next__() Return the next item from the iterator. When exhausted, raise StopIteration ``` -------------------------------- ### HashtagLooter.logout Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Log the instance out from the currently opened session. This terminates the active session. ```APIDOC #### logout() -> None Log the instance out from the currently opened session. ``` -------------------------------- ### medias Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Obtains an iterator over all Instagram medias from the profile, optionally filtered by timeframe. ```APIDOC ## medias(timeframe: _Timeframe | None = None) -> Iterator[Dict[Text, Any]] ### Description Obtain an iterator over the Instagram medias. ### Parameters * **timeframe** (tuple or None) - A tuple of two `datetime` objects to enforce a time frame. ### Returns An iterator over the medias in every pages. * **Return type:** MediasIterator ``` -------------------------------- ### ProfileIterator Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/pages.md An iterator over the pages of a user profile. It inherits from `PageIterator`. ```APIDOC ## class instalooter.pages.ProfileIterator(owner_id, session, rhx) Bases: [`PageIterator`](#instalooter.pages.PageIterator) An iterator over the pages of a user profile. ### __next__() Return the next item from the iterator. When exhausted, raise StopIteration ``` -------------------------------- ### logged_in Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Checks if there is an active Instagram session. ```APIDOC ## logged_in() -> bool ### Description Check if there’s an open Instagram session. ### Returns True if logged in, False otherwise. * **Return type:** bool ``` -------------------------------- ### HashtagLooter.logged_in Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Check if there’s an open Instagram session. Returns a boolean indicating the login status. ```APIDOC #### logged_in() -> bool Check if there’s an open Instagram session. ``` -------------------------------- ### HashtagIterator Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/pages.md An iterator over the pages referring to a specific hashtag. It inherits from `PageIterator`. ```APIDOC ## class instalooter.pages.HashtagIterator(hashtag, session, rhx) Bases: [`PageIterator`](#instalooter.pages.PageIterator) An iterator over the pages refering to a specific hashtag. ### __next__() Return the next item from the iterator. When exhausted, raise StopIteration ``` -------------------------------- ### logout Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Logs out of the current Instagram session. ```APIDOC ## logout() -> None ### Description Log the instance out from the currently opened session. ``` -------------------------------- ### HashtagLooter.pages Source: https://github.com/althonos/instalooter/blob/master/docs/source/instalooter/looters.md Obtain an iterator over Instagram post pages. This method provides access to the raw page data. ```APIDOC #### pages() -> [HashtagIterator](pages.md#instalooter.pages.HashtagIterator) Obtain an iterator over Instagram post pages. * **Returns:** an iterator over the instagram post pages. * **Return type:** [PageIterator](pages.md#instalooter.pages.PageIterator) ``` -------------------------------- ### Extract Users from Comments on Posts Source: https://github.com/althonos/instalooter/blob/master/docs/source/examples.md Retrieves usernames of users who commented on posts from a specific Instagram profile. Requires fetching post information for each media item. ```python from instalooter.looters import ProfileLooter looter = ProfileLooter("franz_ferdinand") users = set() for media in looter.medias(): info = looter.get_post_info(media['shortcode']) for comment in post_info['edge_media_to_comment']['edges']: user = comment['node']['owner']['username'] users.add(user) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.