Skip to main content

Download images and videos from Instagram

Project description

BasketCase

Download images and videos from Instagram.

Notable features:

  • Stories can be downloaded without triggering the "seen" flag.
  • Downloads a high quality version of a profile picture.

https://www.youtube.com/watch?v=NUTGr5t3MoY ;)

Requirements

  • Python 3.8^

Installation

Install it from PyPI as a user install.

pip install --user basketcase

This should put the executable basketcase on your PATH.

Alternatively, you could install it in a virtual environment. I keep mine at ~/venv, and I have a shell alias to quickly activate it.

Also, a pre-built executable for Linux is provided with the releases.

Command-line usage

basketcase -u "https://instagram.com/p/<post_id>"

Downloaded resources will be stored in the current working directory (i.e. $PWD/basketcase_downloads).

To download from multiple URLs, create a text file (e.g. urls.txt) and populate it with resource URLs:

https://instagram.com/p/<post_id>
https://instagram.com/reel/<reel_id>
https://instagram.com/<username>
basketcase -f ./urls.txt

See --help for more info.

Supported URLs

Supported URL Description
https://instagram.com/<username> User profile. Downloads stories from the past 24 hours, and the profile picture.
https://instagram.com/p/<post_id> Standard publication.
https://instagram.com/reel/<reel_id> Reels movie
https://www.instagram.com/stories/highlights/<highlight_id>/ A collection of stories, or "highlights"
https://www.instagram.com/s/<random_characters> A shorter type of URL

Authentication

  1. Add a session cookie
basketcase --cookie <session_cookie_id> --cookie-name "my session"
# Added session id: 1
  1. Specify its identifier when downloading
basketcase -s 1

List all available sessions with basketcase -l. To disable sessions, use --no-session. If only one exists, it is treated as the default.

User data

Cookies and other application data are kept in your home directory (i.e. ~/.basketcase).

Development setup

See Packaging Python Projects.

  1. cd to the project root and create a virtual environment in a directory named venv, which is conveniently ignored in version control.
  2. Install the dependencies.
pip install -r requirements.txt
  1. Install this package in editable mode.
pip install -e .

Package build and upload

  1. Update the requirements list.
pip freeze --exclude-editable > requirements.txt
  1. Increment the version on pyproject.toml.
  2. Build the package.
python -m build
  1. Commit and push the changes (and a new version tag) to the git repository.
  2. Publish it.
python -m twine upload dist/*

Build an executable

With the zipapp module we can build the whole package as an executable file for Linux. The only runtime requirement is Python 3.

python -m zipapp ./basketcase \
    --main="basketcase.__main__:main" \
    --python="/usr/bin/env python3" \
    --output="basketcase" \
    --compress

Explanation:

  • In zipapp ./basketcase, the argument is the path to the project folder
  • --main="basketcase.__main__:main" is the package entrypoint script, as defined in pyproject.toml

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

basketcase-7.0.0.tar.gz (46.9 kB view details)

Uploaded Source

Built Distribution

basketcase-7.0.0-py3-none-any.whl (35.2 kB view details)

Uploaded Python 3

File details

Details for the file basketcase-7.0.0.tar.gz.

File metadata

  • Download URL: basketcase-7.0.0.tar.gz
  • Upload date:
  • Size: 46.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for basketcase-7.0.0.tar.gz
Algorithm Hash digest
SHA256 cb7183e7a69d5912a67e04776ce2a915eba5f2dc89c87f7851b9804c5bc7c153
MD5 86552ffb9478f17b94ac5c99117cc041
BLAKE2b-256 bad5b73137fec8f33f8a6e0119155083067b51c71785b9dfc0643946b11cf029

See more details on using hashes here.

File details

Details for the file basketcase-7.0.0-py3-none-any.whl.

File metadata

  • Download URL: basketcase-7.0.0-py3-none-any.whl
  • Upload date:
  • Size: 35.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for basketcase-7.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e84f603992aadd6b60786f9dc785657bb5ef6c247b1ca4bcfa00ee9a7a2ac6b3
MD5 eb628893b1b6d85ea3c22e544e7198b2
BLAKE2b-256 dcff0d61bf1fc175bd3be02532b893326927dcbb74a29c520c05b355cfa12d84

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page