mirror of
https://github.com/instaloader/instaloader.git
synced 2026-10-17 06:02:18 -07:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5304e9794b | ||
|
|
ee3106814e | ||
|
|
4c6d6e50af | ||
|
|
af287c3fdd | ||
|
|
0bc9ab55dd | ||
|
|
e64394fd25 | ||
|
|
43cc15d1b3 | ||
|
|
a263ec85a6 | ||
|
|
487d2c366d | ||
|
|
e493fa9c2d | ||
|
|
2e482b063a | ||
|
|
0bc91b722e | ||
|
|
4264d40f19 | ||
|
|
b15a595083 | ||
|
|
71ae32c85e | ||
|
|
f5134ff95e |
@@ -18,7 +18,7 @@ jobs:
|
||||
cache: 'pipenv'
|
||||
- name: "Install Dependencies"
|
||||
run: |
|
||||
python -m pip install pipenv==2024.2.0
|
||||
python -m pip install pipenv==2025.0.4
|
||||
pipenv --python `python --version | grep -Eo '3\.[0-9]+'` sync --dev
|
||||
- name: "Build Documentation"
|
||||
run: pipenv --python `python --version | grep -Eo '3\.[0-9]+'` run make -C docs html SPHINXOPTS="-W -n"
|
||||
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
cache: 'pipenv'
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
python -m pip install pipenv==2024.2.0
|
||||
python -m pip install pipenv==2025.0.4
|
||||
pipenv --python `python --version | grep -Eo '3\.[0-9]+'` sync --dev
|
||||
- name: PyLint
|
||||
run: pipenv --python `python --version | grep -Eo '3\.[0-9]+'` run pylint instaloader
|
||||
|
||||
@@ -23,11 +23,11 @@ jobs:
|
||||
run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
- name: "Install Dependencies"
|
||||
run: python -m pip install setuptools
|
||||
run: python -m pip install -U setuptools wheel build
|
||||
- name: "Generate Python Package"
|
||||
run: python setup.py sdist
|
||||
run: python -m build
|
||||
- name: "Publish Distribution to PyPI"
|
||||
uses: pypa/gh-action-pypi-publish@master
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
||||
with:
|
||||
password: ${{ secrets.PYPI_PASSWORD }}
|
||||
- name: "Publish Distribution to AUR"
|
||||
|
||||
@@ -12,7 +12,7 @@ jobs:
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
python-version: "3.13"
|
||||
cache: 'pipenv'
|
||||
architecture: x64
|
||||
- name: Get the tagged version
|
||||
|
||||
@@ -433,6 +433,7 @@ disable=bad-inline-option,
|
||||
too-many-instance-attributes,
|
||||
too-many-lines,
|
||||
too-many-locals,
|
||||
too-many-positional-arguments,
|
||||
too-many-public-methods,
|
||||
too-many-statements,
|
||||
unnecessary-lambda-assignment,
|
||||
|
||||
Generated
+627
-564
File diff suppressed because it is too large
Load Diff
@@ -5,9 +5,13 @@ pkgbase = instaloader
|
||||
url = https://instaloader.github.io/
|
||||
arch = any
|
||||
license = MIT
|
||||
makedepends = python-build
|
||||
makedepends = python-installer
|
||||
makedepends = python-setuptools
|
||||
depends = python>=3.8
|
||||
depends = python-requests>=2.4
|
||||
makedepends = python-wheel
|
||||
depends = python
|
||||
depends = python-requests
|
||||
optdepends = python-browser-cookie3: Import session cookies from browser
|
||||
options = !emptydirs
|
||||
source = instaloader-{{version}}.tar.gz::https://codeload.github.com/instaloader/instaloader/tar.gz/v{{version}}
|
||||
sha512sums = {{hash}}
|
||||
|
||||
@@ -8,20 +8,30 @@ arch=('any')
|
||||
url="https://instaloader.github.io/"
|
||||
license=('MIT')
|
||||
groups=()
|
||||
depends=('python>=3.8' 'python-requests>=2.4')
|
||||
makedepends=('python-setuptools')
|
||||
depends=(
|
||||
python
|
||||
python-requests
|
||||
)
|
||||
makedepends=(
|
||||
python-build
|
||||
python-installer
|
||||
python-setuptools
|
||||
python-wheel
|
||||
)
|
||||
optdepends=(
|
||||
'python-browser-cookie3: Import session cookies from browser'
|
||||
)
|
||||
options=('!emptydirs')
|
||||
source=($pkgname-$pkgver.tar.gz::https://codeload.github.com/instaloader/instaloader/tar.gz/v$pkgver)
|
||||
sha512sums=('{{hash}}')
|
||||
|
||||
build() {
|
||||
cd "$srcdir/$pkgname-$pkgver"
|
||||
python setup.py clean --all
|
||||
python setup.py build
|
||||
python -m build --wheel --no-isolation
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "$srcdir/$pkgname-$pkgver"
|
||||
install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
|
||||
python setup.py install --root "$pkgdir/" --skip-build
|
||||
python -m installer --destdir="$pkgdir" dist/*.whl
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ with open('__main__.py', 'w+') as f:
|
||||
f.writelines(lines)
|
||||
|
||||
# install dependencies and invoke PyInstaller
|
||||
commands = ["pip install pipenv==2024.2.0",
|
||||
commands = ["pip install pipenv==2025.0.4",
|
||||
f"pipenv --python {sys.version_info.major}.{sys.version_info.minor} sync --dev",
|
||||
"pipenv run pyinstaller --log-level=DEBUG instaloader.spec"]
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ Instaloader supports the following targets:
|
||||
to **download IGTV videos**.
|
||||
|
||||
- ``"#hashtag"``
|
||||
Posts with a certain **hashtag** (the quotes are usually necessary).
|
||||
Posts with a certain **hashtag** (the quotes are usually necessary). Requires :ref:`login<login>`.
|
||||
|
||||
- ``%location id``
|
||||
Posts tagged with a given location; the location ID is the numerical ID
|
||||
|
||||
+12
-10
@@ -208,22 +208,24 @@ Instead of :option:`--login`, it is possible to use
|
||||
|
||||
.. option:: --load-cookies BROWSER-NAME, -b BROWSER-NAME
|
||||
|
||||
Use Instagram cookie in your browser to login.
|
||||
This feature requires the browser_cookie3 library.
|
||||
Compatible with :option:`--cookiefile` if you want to load cookies from browser profiles.
|
||||
Incompatible with :option:`--login` due to potential username mismatch between user input and browser login.
|
||||
Supported browsers: Brave, Chrome, Chromium, Edge, Firefox, LibreWolf, Opera, Opera_GX, Safari and Vivaldi.
|
||||
Load Instagram session cookies from a browser instead of using Instaloader's own login mechanism.
|
||||
This method requires the `browser_cookie3 <https://github.com/borisbabic/browser_cookie3>`__ library.
|
||||
By default, cookies are loaded from the browser's main profile, but you can specify a custom cookie file using :option:`--cookiefile`.
|
||||
|
||||
In subsequent runs, you can just use :option:`--login` to reuse the
|
||||
same session, which is saved by Instaloader.
|
||||
Since :option:`--load-cookies` and :option:`--login` are alternative ways to acquire a session, they cannot be used together when initially acquiring a session.
|
||||
|
||||
Supported browsers: Arc, Brave, Chrome, Chromium, Edge, Firefox, LibreWolf, Opera, Opera_GX, Safari, and Vivaldi.
|
||||
|
||||
Once logged in via browser cookies, Instaloader saves the session, allowing you to use :option:`--login` in subsequent runs.
|
||||
|
||||
.. versionadded:: 4.11
|
||||
|
||||
.. option:: --cookiefile COOKIE-FILE, -B COOKIE-FILE
|
||||
|
||||
Cookie file path of a browser profile to load cookies from.
|
||||
Specifies a cookie file path for :option:`--load-cookies` to load cookies from a particular browser profile.
|
||||
This option must be used together with :option:`--load-cookies` and does not work on its own.
|
||||
|
||||
.. versionadded:: 4.11
|
||||
.. versionadded:: 4.11
|
||||
|
||||
.. option:: --sessionfile SESSIONFILE, -f SESSIONFILE
|
||||
|
||||
@@ -310,7 +312,7 @@ How to Download
|
||||
.. option:: --user-agent USER_AGENT
|
||||
|
||||
User Agent to use for HTTP requests. Per default, Instaloader pretends being
|
||||
Chrome/127 on Linux.
|
||||
Chrome/138 on Linux.
|
||||
|
||||
.. option:: --max-connection-attempts N
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Download pictures (or videos) along with their captions and other metadata from Instagram."""
|
||||
|
||||
|
||||
__version__ = '4.14'
|
||||
__version__ = '4.15a1'
|
||||
|
||||
|
||||
try:
|
||||
|
||||
@@ -112,7 +112,7 @@ def get_cookies_from_instagram(domain, browser, cookie_file='', cookie_name=''):
|
||||
print(f"Cookies loaded successfully from {browser}")
|
||||
else:
|
||||
raise LoginException(f"No cookies found for Instagram in {browser}, "
|
||||
f"Are you logged in succesfully in {browser}?")
|
||||
f"Are you logged in successfully in {browser}?")
|
||||
|
||||
if cookie_name:
|
||||
return cookies.get(cookie_name, {})
|
||||
|
||||
@@ -83,7 +83,7 @@ def _requires_login(func: Callable) -> Callable:
|
||||
|
||||
|
||||
def _retry_on_connection_error(func: Callable) -> Callable:
|
||||
"""Decorator to retry the function max_connection_attemps number of times.
|
||||
"""Decorator to retry the function max_connection_attempts number of times.
|
||||
|
||||
Herewith-decorated functions need an ``_attempt`` keyword argument.
|
||||
|
||||
@@ -737,19 +737,20 @@ class Instaloader:
|
||||
suffix: Optional[str] = str(edge_number)
|
||||
if '{filename}' in self.filename_pattern:
|
||||
suffix = None
|
||||
if self.download_pictures and (not sidecar_node.is_video or self.download_video_thumbnails):
|
||||
video_url = sidecar_node.video_url
|
||||
if self.download_pictures and (video_url is None or self.download_video_thumbnails):
|
||||
# pylint:disable=cell-var-from-loop
|
||||
sidecar_filename = self.__prepare_filename(filename_template,
|
||||
lambda: sidecar_node.display_url)
|
||||
# Download sidecar picture or video thumbnail (--no-pictures implies --no-video-thumbnails)
|
||||
downloaded &= self.download_pic(filename=sidecar_filename, url=sidecar_node.display_url,
|
||||
mtime=post.date_local, filename_suffix=suffix)
|
||||
if sidecar_node.is_video and self.download_videos:
|
||||
if video_url is not None and self.download_videos:
|
||||
# pylint:disable=cell-var-from-loop
|
||||
sidecar_filename = self.__prepare_filename(filename_template,
|
||||
lambda: sidecar_node.video_url)
|
||||
lambda: video_url)
|
||||
# Download sidecar video if desired
|
||||
downloaded &= self.download_pic(filename=sidecar_filename, url=sidecar_node.video_url,
|
||||
downloaded &= self.download_pic(filename=sidecar_filename, url=video_url,
|
||||
mtime=post.date_local, filename_suffix=suffix)
|
||||
else:
|
||||
downloaded = False
|
||||
@@ -1215,6 +1216,7 @@ class Instaloader:
|
||||
Use :meth:`Hashtag.get_posts_resumable`."""
|
||||
return Hashtag.from_name(self.context, hashtag).get_posts_resumable()
|
||||
|
||||
@_requires_login
|
||||
def download_hashtag(self, hashtag: Union[Hashtag, str],
|
||||
max_count: Optional[int] = None,
|
||||
post_filter: Optional[Callable[[Post], bool]] = None,
|
||||
@@ -1302,6 +1304,7 @@ class Instaloader:
|
||||
post_filter,
|
||||
owner_profile=profile,
|
||||
takewhile=posts_takewhile,
|
||||
possibly_pinned=3,
|
||||
)
|
||||
if latest_stamps is not None and reels.first_item is not None:
|
||||
latest_stamps.set_last_reels_timestamp(profile.username, reels.first_item.date_local)
|
||||
|
||||
@@ -32,15 +32,15 @@ def copy_session(session: requests.Session, request_timeout: Optional[float] = N
|
||||
|
||||
def default_user_agent() -> str:
|
||||
return ('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 '
|
||||
'(KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36')
|
||||
'(KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36')
|
||||
|
||||
|
||||
def default_iphone_headers() -> Dict[str, Any]:
|
||||
return {'User-Agent': 'Instagram 273.0.0.16.70 (iPad13,8; iOS 16_3; en_US; en-US; ' \
|
||||
'scale=2.00; 2048x2732; 452417278) AppleWebKit/420+',
|
||||
return {'User-Agent': 'Instagram 361.0.0.35.82 (iPad13,8; iOS 18_0; en_US; en-US; ' \
|
||||
'scale=2.00; 2048x2732; 674117118) AppleWebKit/420+',
|
||||
'x-ads-opt-out': '1',
|
||||
'x-bloks-is-panorama-enabled': 'true',
|
||||
'x-bloks-version-id': '01507c21540f73e2216b6f62a11a5b5e51aa85491b72475c080da35b1228ddd6',
|
||||
'x-bloks-version-id': '16b7bd25c6c06886d57c4d455265669345a2d96625385b8ee30026ac2dc5ed97',
|
||||
'x-fb-client-ip': 'True',
|
||||
'x-fb-connection-type': 'wifi',
|
||||
'x-fb-http-engine': 'Liger',
|
||||
@@ -102,7 +102,7 @@ class InstaloaderContext:
|
||||
|
||||
self._rate_controller = rate_controller(self) if rate_controller is not None else RateController(self)
|
||||
|
||||
# Can be set to True for testing, disables supression of InstaloaderContext._error_catcher
|
||||
# Can be set to True for testing, disables suppression of InstaloaderContext._error_catcher
|
||||
self.raise_all_errors = False
|
||||
|
||||
# HTTP status codes that should cause an AbortDownloadException
|
||||
|
||||
+16
-14
@@ -20,7 +20,7 @@ class PostSidecarNode(NamedTuple):
|
||||
"""Item of a Sidecar Post."""
|
||||
is_video: bool
|
||||
display_url: str
|
||||
video_url: str
|
||||
video_url: Optional[str]
|
||||
|
||||
|
||||
PostSidecarNode.is_video.__doc__ = "Whether this node is a video."
|
||||
@@ -180,7 +180,7 @@ class Post:
|
||||
This class unifies access to the properties associated with a post. It implements == and is
|
||||
hashable.
|
||||
|
||||
:param context: :attr:`Instaloader.context` used for additional queries if neccessary..
|
||||
:param context: :attr:`Instaloader.context` used for additional queries if necessary..
|
||||
:param node: Node structure, as returned by Instagram.
|
||||
:param owner_profile: The Profile of the owner, if already known at creation.
|
||||
"""
|
||||
@@ -512,14 +512,14 @@ class Post:
|
||||
|
||||
@property
|
||||
def caption_hashtags(self) -> List[str]:
|
||||
"""List of all lowercased hashtags (without preceeding #) that occur in the Post's caption."""
|
||||
"""List of all lowercased hashtags (without preceding #) that occur in the Post's caption."""
|
||||
if not self.caption:
|
||||
return []
|
||||
return _hashtag_regex.findall(self.caption.lower())
|
||||
|
||||
@property
|
||||
def caption_mentions(self) -> List[str]:
|
||||
"""List of all lowercased profiles that are mentioned in the Post's caption, without preceeding @."""
|
||||
"""List of all lowercased profiles that are mentioned in the Post's caption, without preceding @."""
|
||||
if not self.caption:
|
||||
return []
|
||||
return _mention_regex.findall(self.caption.lower())
|
||||
@@ -1079,7 +1079,7 @@ class Profile:
|
||||
@property
|
||||
def biography_hashtags(self) -> List[str]:
|
||||
"""
|
||||
List of all lowercased hashtags (without preceeding #) that occur in the Profile's biography.
|
||||
List of all lowercased hashtags (without preceding #) that occur in the Profile's biography.
|
||||
|
||||
.. versionadded:: 4.10
|
||||
"""
|
||||
@@ -1090,7 +1090,7 @@ class Profile:
|
||||
@property
|
||||
def biography_mentions(self) -> List[str]:
|
||||
"""
|
||||
List of all lowercased profiles that are mentioned in the Profile's biography, without preceeding @.
|
||||
List of all lowercased profiles that are mentioned in the Profile's biography, without preceding @.
|
||||
|
||||
.. versionadded:: 4.10
|
||||
"""
|
||||
@@ -1534,7 +1534,7 @@ class StoryItem:
|
||||
@property
|
||||
def caption_hashtags(self) -> List[str]:
|
||||
"""
|
||||
List of all lowercased hashtags (without preceeding #) that occur in the StoryItem's caption.
|
||||
List of all lowercased hashtags (without preceding #) that occur in the StoryItem's caption.
|
||||
|
||||
.. versionadded:: 4.10
|
||||
"""
|
||||
@@ -1545,7 +1545,7 @@ class StoryItem:
|
||||
@property
|
||||
def caption_mentions(self) -> List[str]:
|
||||
"""
|
||||
List of all lowercased profiles that are mentioned in the StoryItem's caption, without preceeding @.
|
||||
List of all lowercased profiles that are mentioned in the StoryItem's caption, without preceding @.
|
||||
|
||||
.. versionadded:: 4.10
|
||||
"""
|
||||
@@ -1844,11 +1844,11 @@ class Hashtag:
|
||||
@classmethod
|
||||
def from_name(cls, context: InstaloaderContext, name: str):
|
||||
"""
|
||||
Create a Hashtag instance from a given hashtag name, without preceeding '#'. Raises an Exception if there is no
|
||||
Create a Hashtag instance from a given hashtag name, without preceding '#'. Raises an Exception if there is no
|
||||
hashtag with the given name.
|
||||
|
||||
:param context: :attr:`Instaloader.context`
|
||||
:param name: Hashtag, without preceeding '#'
|
||||
:param name: Hashtag, without preceding '#'
|
||||
:raises: :class:`QueryReturnedNotFoundException`
|
||||
"""
|
||||
# pylint:disable=protected-access
|
||||
@@ -1858,11 +1858,13 @@ class Hashtag:
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Hashtag name lowercased, without preceeding '#'"""
|
||||
"""Hashtag name lowercased, without preceding '#'"""
|
||||
return self._node["name"].lower()
|
||||
|
||||
def _query(self, params):
|
||||
json_response = self._context.get_json("explore/tags/{0}/".format(self.name), params)
|
||||
json_response = self._context.get_iphone_json(
|
||||
"api/v1/tags/web_info/", {**params, "tag_name": self.name}
|
||||
)
|
||||
return json_response["graphql"]["hashtag"] if "graphql" in json_response else json_response["data"]
|
||||
|
||||
def _obtain_metadata(self):
|
||||
@@ -2185,7 +2187,7 @@ def load_structure(context: InstaloaderContext, json_structure: dict) -> JsonExp
|
||||
"""Loads a :class:`Post`, :class:`Profile`, :class:`StoryItem`, :class:`Hashtag` or :class:`FrozenNodeIterator` from
|
||||
a json structure.
|
||||
|
||||
:param context: :attr:`Instaloader.context` linked to the new object, used for additional queries if neccessary.
|
||||
:param context: :attr:`Instaloader.context` linked to the new object, used for additional queries if necessary.
|
||||
:param json_structure: Instaloader JSON structure
|
||||
|
||||
.. versionadded:: 4.8
|
||||
@@ -2215,7 +2217,7 @@ def load_structure_from_file(context: InstaloaderContext, filename: str) -> Json
|
||||
"""Loads a :class:`Post`, :class:`Profile`, :class:`StoryItem`, :class:`Hashtag` or :class:`FrozenNodeIterator` from
|
||||
a '.json' or '.json.xz' file that has been saved by :func:`save_structure_to_file`.
|
||||
|
||||
:param context: :attr:`Instaloader.context` linked to the new object, used for additional queries if neccessary.
|
||||
:param context: :attr:`Instaloader.context` linked to the new object, used for additional queries if necessary.
|
||||
:param filename: Filename, ends in '.json' or '.json.xz'
|
||||
"""
|
||||
compressed = filename.endswith('.xz')
|
||||
|
||||
Reference in New Issue
Block a user