mirror of
https://github.com/instaloader/instaloader.git
synced 2026-10-16 21:52:17 -07:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
edd1fbe49c | ||
|
|
dae18a05c6 | ||
|
|
c5b60b8a12 | ||
|
|
40a87761c9 | ||
|
|
d9b5c77e3a | ||
|
|
5b6e8f1a31 | ||
|
|
d533c60824 | ||
|
|
539273b963 | ||
|
|
71331d37e4 | ||
|
|
36110c8727 | ||
|
|
4a944fbbdb | ||
|
|
6764cd961f | ||
|
|
a125b367e3 | ||
|
|
07b30d6ebd | ||
|
|
3640e9c056 | ||
|
|
90a1b73d21 | ||
|
|
a7f89e4327 | ||
|
|
af1ec22d41 | ||
|
|
f55334cd5b | ||
|
|
b2f31e7782 | ||
|
|
68d8f65cb9 | ||
|
|
e97e4ecdc8 | ||
|
|
e77c998a94 | ||
|
|
861d7b92f1 |
@@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Alexander Graf and André Koch-Kramer.
|
||||
Copyright (c) 2016-2018 Alexander Graf and André Koch-Kramer.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
Instaloader
|
||||
===========
|
||||
.. image:: https://raw.githubusercontent.com/instaloader/instaloader/master/docs/logo_heading.png
|
||||
|
||||
::
|
||||
|
||||
|
||||
+7
-1
@@ -50,7 +50,7 @@ clean:
|
||||
|
||||
.PHONY: html
|
||||
html:
|
||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||
LC_ALL=C $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||
|
||||
@@ -223,3 +223,9 @@ dummy:
|
||||
$(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy
|
||||
@echo
|
||||
@echo "Build finished. Dummy builder generates no files."
|
||||
|
||||
favicon.ico: logo.svg
|
||||
convert -density 384 -background transparent -define icon:auto-resize -colors 256 logo.svg favicon.ico
|
||||
|
||||
logo.png: logo.svg
|
||||
inkscape -z -e logo.png -w 100 -h 100 logo.svg
|
||||
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
code {
|
||||
color: #222;
|
||||
}
|
||||
Vendored
-2
@@ -1,2 +0,0 @@
|
||||
<h2><a href="index.html">Instaloader</a></h2>
|
||||
<p>Download pictures (or videos) along with their captions and other metadata from Instagram.</p>
|
||||
Vendored
+8
-2
@@ -1,5 +1,11 @@
|
||||
{% extends "!layout.html" %}
|
||||
{% block extrahead %}
|
||||
<meta name="google-site-verification" content="FNUsDdkOJM9obm9QEdrNBVd9AtAzHzA-aaSMCUrS6C8" />
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
{{ super() }}
|
||||
<meta name="google-site-verification" content="FNUsDdkOJM9obm9QEdrNBVd9AtAzHzA-aaSMCUrS6C8" />
|
||||
{% if pagename == "index" %}
|
||||
<link rel="canonical" href="https://instaloader.github.io/" />
|
||||
{% else %}
|
||||
<link rel="canonical" href="https://instaloader.github.io/{{ pagename }}.html" />
|
||||
{% endif %}
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
Vendored
-23
@@ -1,23 +0,0 @@
|
||||
{% if next %}
|
||||
<h3>Next</h3>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="{{ next.link|e }}">{{ next.title }}</a></li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
<h3>Current Release</h3>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a href="https://github.com/instaloader/instaloader/releases/tag/v{{current_release}}">Version <b>{{current_release}}</b></a></li>
|
||||
<li>Released on <b>{{current_release_date}}</b>.</li>
|
||||
</ul>
|
||||
<h3>Links</h3>
|
||||
<ul>
|
||||
<li><a href="https://github.com/instaloader/instaloader/issues">Issue Tracker</a></li>
|
||||
<li><a href="https://github.com/instaloader/instaloader/releases">Version History</a></li>
|
||||
<li><a href="https://pypi.python.org/pypi/instaloader">Instaloader on PyPI</a></li>
|
||||
<li><a href="https://github.com/instaloader/instaloader">Instaloader on GitHub</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>
|
||||
<a class="github-button" href="https://github.com/instaloader/Instaloader" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star instaloader/Instaloader on GitHub">Star</a>
|
||||
</li>
|
||||
</ul>
|
||||
Vendored
+58
@@ -0,0 +1,58 @@
|
||||
<div id="navbar" class="{{ theme_navbar_class }} navbar-default {% if theme_navbar_fixed_top|tobool -%} navbar-fixed-top{%- endif -%}">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="{{ pathto(master_doc) }}">
|
||||
{%- block sidebarlogo %}
|
||||
{%- if logo %}<span><img src="{{ pathto('_static/' + logo, 1) }}"></span>{%- endif %}
|
||||
{%- endblock %}
|
||||
{% if theme_navbar_title -%}{{ theme_navbar_title|e }}{%- else -%}{{ project|e }}{%- endif -%}
|
||||
</a>
|
||||
<span class="navbar-text navbar-version pull-left">
|
||||
<a href="https://github.com/instaloader/instaloader/releases/tag/v{{current_release}}" title="Released on {{current_release_date}}.">v<b>{{current_release}}</b></a>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="collapse navbar-collapse nav-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
{% if theme_navbar_links %}
|
||||
{%- for link in theme_navbar_links %}
|
||||
<li><a href="{{ pathto(*link[1:]) }}">{{ link[0] }}</a></li>
|
||||
{%- endfor %}
|
||||
{% endif %}
|
||||
{% block navbartoc %}
|
||||
{% include "globaltoc.html" %}
|
||||
{% if theme_navbar_pagenav %}
|
||||
{% include "navbartoc.html" %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% if theme_navbar_sidebarrel %}
|
||||
{% block sidebarrel %}
|
||||
{% include "relations.html" %}
|
||||
{% endblock %}
|
||||
{% endif %}
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a role="button" id="dLabelUsefulLinks" data-toggle="dropdown" data-target="#" href="#">
|
||||
Useful Links
|
||||
<b class="caret"></b>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabelUsefulLinks">
|
||||
<li><a href="https://github.com/instaloader/instaloader/issues">Issue Tracker</a></li>
|
||||
<li><a href="https://github.com/instaloader/instaloader/releases">Version History</a></li>
|
||||
<li><a href="https://pypi.python.org/pypi/instaloader">Instaloader on PyPI</a></li>
|
||||
<li><a href="https://github.com/instaloader/instaloader">Instaloader on GitHub</a></li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li style="padding-left: 20px;"><a class="github-button" href="https://github.com/instaloader/instaloader" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star Instaloader on GitHub">Star</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
<h3>New Documentation URL</h3>
|
||||
<div class="danger"><p style="margin-left: 1em"><b>Instaloader's Documentation has been moved to
|
||||
<a class="reference external" href="https://instaloader.github.io/">https://instaloader.github.io</a>.</b></p></div>
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
.. meta::
|
||||
:description:
|
||||
Instaloader can also be used as a powerful and easy-to-use
|
||||
Python API for Instagram, allowing to download media and metadata.
|
||||
Documentation of Instaloader module, a powerful and easy-to-use
|
||||
Python library to download Instagram media and metadata.
|
||||
|
||||
Python Module :mod:`instaloader`
|
||||
--------------------------------
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
.. meta::
|
||||
:description:
|
||||
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.
|
||||
|
||||
Download Pictures from Instagram
|
||||
---------------------------------
|
||||
|
||||
|
||||
+18
-10
@@ -20,6 +20,9 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import sphinx_bootstrap_theme
|
||||
|
||||
sys.path.insert(0, os.path.abspath('..'))
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
@@ -133,16 +136,20 @@ todo_include_todos = False
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
html_theme = 'alabaster'
|
||||
html_theme = 'bootstrap'
|
||||
html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#
|
||||
html_theme_options = {
|
||||
'show_powered_by': False,
|
||||
'sidebar_width': '290px',
|
||||
'page_width': '935px' }
|
||||
'navbar_site_name': 'Site Contents',
|
||||
'navbar_pagenav_name': 'Page Contents',
|
||||
'navbar_pagenav': True,
|
||||
'navbar_sidebarrel': True,
|
||||
'nosidebar': True,
|
||||
}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
# html_theme_path = []
|
||||
@@ -159,13 +166,13 @@ html_theme_options = {
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#
|
||||
# html_logo = None
|
||||
html_logo = "logo.png"
|
||||
|
||||
# The name of an image file (relative to this directory) to use as a favicon of
|
||||
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#
|
||||
# html_favicon = None
|
||||
html_favicon = "favicon.ico"
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
@@ -191,10 +198,8 @@ html_static_path = ['_static']
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#
|
||||
if not os.environ.get("READTHEDOCS"):
|
||||
html_sidebars = {'**': ["caption.html", "globaltoc.html", "relations.html", "links.html"] }
|
||||
else:
|
||||
html_sidebars = {'**': ["caption.html", "rtdmessage.html", "globaltoc.html", "relations.html", "links.html"] }
|
||||
#html_sidebars = {'**': ["relations.html", "links.html"] }
|
||||
html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
@@ -362,3 +367,6 @@ current_release = subprocess.check_output(["git", "describe", "--abbrev=0"]).dec
|
||||
current_release_date = subprocess.check_output(["git", "log", "-1", "--tags", "--format=%ad", "--date=format:%e %b %Y"]).decode("ascii")[:-1]
|
||||
|
||||
html_context = {'current_release': current_release, 'current_release_date': current_release_date}
|
||||
|
||||
def setup(app):
|
||||
app.add_stylesheet("style.css")
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 330 KiB |
+4
-3
@@ -1,8 +1,9 @@
|
||||
.. meta::
|
||||
:description:
|
||||
Command line tool to download pictures (and videos) from Instagram.
|
||||
Instaloader downloads public and private profiles, hashtags, user stories,
|
||||
feeds, saved media, comments, geotags, captions and other metadata of each post.
|
||||
Free command line tool to download photos from Instagram.
|
||||
Scrapes public and private profiles, hashtags, stories, feeds,
|
||||
saved media, and their metadata, comments and captions.
|
||||
Written in Python.
|
||||
|
||||
Instaloader
|
||||
===========
|
||||
|
||||
@@ -28,7 +28,7 @@ will be installed automatically, if it is not already installed.
|
||||
|
||||
- If you do not want to use pip, even though it is highly recommended,
|
||||
and prefer to **install Instaloader manually**,
|
||||
`Download the Source <https://github.com/instaloader/instaloader/releases>`__,
|
||||
`Download the Source <https://github.com/instaloader/instaloader/releases/latest>`__,
|
||||
extract the Zip or Tarball and execute ``instaloader.py`` from there.
|
||||
|
||||
- On **Arch Linux**, you may install Instaloader using the
|
||||
@@ -36,3 +36,6 @@ will be installed automatically, if it is not already installed.
|
||||
|
||||
- On **Gentoo Linux**, you may install Instaloader using the
|
||||
`Instaloader Ebuild <https://bugs.gentoo.org/642100>`__.
|
||||
|
||||
- On **Windows 10**, you may download the standalone executable from the
|
||||
`current release page <https://github.com/instaloader/instaloader/releases/latest>`__.
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
+117
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 18 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.3 KiB |
@@ -1,3 +1,4 @@
|
||||
requests
|
||||
sphinx
|
||||
sphinx-autodoc-typehints
|
||||
sphinx-bootstrap-theme
|
||||
|
||||
+66
-47
@@ -6,6 +6,7 @@ import getpass
|
||||
import json
|
||||
import os
|
||||
import pickle
|
||||
import platform
|
||||
import random
|
||||
import re
|
||||
import shutil
|
||||
@@ -29,8 +30,14 @@ import requests.utils
|
||||
import urllib3
|
||||
|
||||
|
||||
__version__ = '3.3.1'
|
||||
__version__ = '3.3.4'
|
||||
|
||||
# NOTE: duplicated in README.rst and docs/index.rst
|
||||
USAGE_STRING = """
|
||||
{0} [--comments] [--geotags] [--stories]
|
||||
{2:{1}} [--login YOUR-USERNAME] [--fast-update]
|
||||
{2:{1}} profile | "#hashtag" | :stories | :feed | :saved
|
||||
{0} --help""".format(sys.argv[0], len(sys.argv[0]), '')
|
||||
|
||||
try:
|
||||
# pylint:disable=wrong-import-position
|
||||
@@ -127,10 +134,10 @@ def mediaid_to_shortcode(mediaid: int) -> str:
|
||||
return b64encode(mediaid.to_bytes(9, 'big'), b'-_').decode().replace('A', ' ').lstrip().replace(' ','A')
|
||||
|
||||
|
||||
def format_string_contains_key(format_string: str, key: str) -> bool:
|
||||
def format_string_contains_key(format_string: '_PathPattern', key: str) -> bool:
|
||||
# pylint:disable=unused-variable
|
||||
for literal_text, field_name, format_spec, conversion in string.Formatter().parse(format_string):
|
||||
if field_name == key or field_name.startswith(key + '.'):
|
||||
if field_name and (field_name == key or field_name.startswith(key + '.')):
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -404,7 +411,7 @@ class Post:
|
||||
if loc_dict is not None:
|
||||
location_json = self._instaloader.get_json("explore/locations/{0}/".format(loc_dict["id"]),
|
||||
params={'__a': 1})
|
||||
return location_json["location"]
|
||||
return location_json["location"] if "location" in location_json else location_json['graphql']['location']
|
||||
|
||||
@staticmethod
|
||||
def json_encoder(obj) -> Dict[str, Any]:
|
||||
@@ -440,6 +447,14 @@ class Tristate(Enum):
|
||||
always = 2
|
||||
|
||||
|
||||
class _PathPattern(str):
|
||||
"""Class overriding :meth:`str.format` for character substitution in paths for Windows, see issue #84."""
|
||||
|
||||
def format(self, *args: Any, **kwargs: Any) -> str:
|
||||
ret = super().format(*args, **kwargs)
|
||||
return ret.replace(':', '\ua789') if platform.system() == 'Windows' else ret
|
||||
|
||||
|
||||
class Instaloader:
|
||||
GRAPHQL_PAGE_LENGTH = 200
|
||||
|
||||
@@ -462,18 +477,19 @@ class Instaloader:
|
||||
self.username = None
|
||||
self.sleep = sleep
|
||||
self.quiet = quiet
|
||||
self.dirname_pattern = dirname_pattern if dirname_pattern is not None else '{target}'
|
||||
self.dirname_pattern = _PathPattern(dirname_pattern if dirname_pattern is not None else '{target}')
|
||||
if filename_pattern is not None:
|
||||
filename_pattern = re.sub(r"({(?:post\.)?date)([:}])", r"\1_utc\2", filename_pattern)
|
||||
self.filename_pattern_old = filename_pattern.replace('{date_utc}', '{date_utc:%Y-%m-%d_%H-%M-%S}')
|
||||
self.filename_pattern_old = re.sub(r"(?i)({(?:post\.)?date_utc:[^}]*?)_UTC",
|
||||
r"\1", self.filename_pattern_old)
|
||||
self.filename_pattern_old = _PathPattern(re.sub(r"(?i)({(?:post\.)?date_utc:[^}]*?)_UTC",
|
||||
r"\1", self.filename_pattern_old))
|
||||
filename_pattern = re.sub(r"(?i)({(date_utc|post\.date_utc):(?![^}]*UTC[^}]*).*?)}",
|
||||
r"\1_UTC}", filename_pattern)
|
||||
self.filename_pattern = filename_pattern.replace('{date_utc}', '{date_utc:%Y-%m-%d_%H-%M-%S_UTC}')
|
||||
self.filename_pattern = _PathPattern(filename_pattern.replace('{date_utc}',
|
||||
'{date_utc:%Y-%m-%d_%H-%M-%S_UTC}'))
|
||||
else:
|
||||
self.filename_pattern = '{date_utc:%Y-%m-%d_%H-%M-%S_UTC}'
|
||||
self.filename_pattern_old = '{date_utc:%Y-%m-%d_%H-%M-%S}'
|
||||
self.filename_pattern = _PathPattern('{date_utc:%Y-%m-%d_%H-%M-%S_UTC}')
|
||||
self.filename_pattern_old = _PathPattern('{date_utc:%Y-%m-%d_%H-%M-%S}')
|
||||
self.download_videos = download_videos
|
||||
self.download_video_thumbnails = download_video_thumbnails
|
||||
self.download_geotags = download_geotags
|
||||
@@ -572,12 +588,13 @@ class Instaloader:
|
||||
self.error("[skipped by user]", repeat_at_end=False)
|
||||
raise ConnectionException(error_string)
|
||||
|
||||
def get_json(self, url: str, params: Dict[str, Any],
|
||||
def get_json(self, path: str, params: Dict[str, Any], host: str = 'www.instagram.com',
|
||||
session: Optional[requests.Session] = None, _attempt = 1) -> Dict[str, Any]:
|
||||
"""JSON request to Instagram.
|
||||
|
||||
:param url: URL, relative to www.instagram.com/
|
||||
:param path: URL, relative to the given domain which defaults to www.instagram.com/
|
||||
:param params: GET parameters
|
||||
:param host: Domain part of the URL from where to download the requested JSON; defaults to www.instagram.com
|
||||
:param session: Session to use, or None to use self.session
|
||||
:return: Decoded response dictionary
|
||||
:raises QueryReturnedNotFoundException: When the server responds with a 404.
|
||||
@@ -594,7 +611,7 @@ class Instaloader:
|
||||
if len(timestamps) < 100 and not untracked_queries:
|
||||
return 0
|
||||
return round(min(timestamps) + sliding_window - current_time) + 6
|
||||
is_graphql_query = 'query_id' in params and 'graphql/query' in url
|
||||
is_graphql_query = 'query_id' in params and 'graphql/query' in path
|
||||
if is_graphql_query:
|
||||
query_id = params['query_id']
|
||||
waittime = graphql_query_waittime(query_id)
|
||||
@@ -609,7 +626,7 @@ class Instaloader:
|
||||
sess = session if session else self.session
|
||||
try:
|
||||
self._sleep()
|
||||
resp = sess.get('https://www.instagram.com/' + url, params=params)
|
||||
resp = sess.get('https://{0}/{1}'.format(host, path), params=params)
|
||||
if resp.status_code == 404:
|
||||
raise QueryReturnedNotFoundException("404")
|
||||
if resp.status_code == 429:
|
||||
@@ -625,7 +642,7 @@ class Instaloader:
|
||||
raise ConnectionException("Returned \"{}\" status.".format(resp_json['status']))
|
||||
return resp_json
|
||||
except (ConnectionException, json.decoder.JSONDecodeError, requests.exceptions.RequestException) as err:
|
||||
error_string = "JSON Query to {}: {}".format(url, err)
|
||||
error_string = "JSON Query to {}: {}".format(path, err)
|
||||
if _attempt == self.max_connection_attempts:
|
||||
raise ConnectionException(error_string)
|
||||
self.error(error_string + " [retrying; skip with ^C]", repeat_at_end=False)
|
||||
@@ -641,7 +658,7 @@ class Instaloader:
|
||||
self._log('The request will be retried in {} seconds.'.format(waittime))
|
||||
time.sleep(waittime)
|
||||
self._sleep()
|
||||
return self.get_json(url, params, sess, _attempt + 1)
|
||||
return self.get_json(path=path, params=params, host=host, session=sess, _attempt=_attempt + 1)
|
||||
except KeyboardInterrupt:
|
||||
self.error("[skipped by user]", repeat_at_end=False)
|
||||
raise ConnectionException(error_string)
|
||||
@@ -884,8 +901,14 @@ class Instaloader:
|
||||
def download_profilepic(self, name: str, profile_metadata: Dict[str, Any]) -> None:
|
||||
"""Downloads and saves profile pic."""
|
||||
|
||||
url = profile_metadata["user"]["profile_pic_url_hd"] if "profile_pic_url_hd" in profile_metadata["user"] \
|
||||
else profile_metadata["user"]["profile_pic_url"]
|
||||
try:
|
||||
data = self.get_json(path='api/v1/users/{0}/info/'.format(profile_metadata["user"]["id"]), params={},
|
||||
host='i.instagram.com', session=self._get_anonymous_session())
|
||||
url = data["user"]["hd_profile_pic_url_info"]["url"]
|
||||
except (InstaloaderException, KeyError) as err:
|
||||
self.error('{} Unable to fetch high quality profile pic.'.format(err))
|
||||
url = profile_metadata["user"]["profile_pic_url_hd"] if "profile_pic_url_hd" in profile_metadata["user"] \
|
||||
else profile_metadata["user"]["profile_pic_url"]
|
||||
|
||||
def _epoch_to_string(epoch: datetime) -> str:
|
||||
return epoch.strftime('%Y-%m-%d_%H-%M-%S')
|
||||
@@ -903,13 +926,7 @@ class Instaloader:
|
||||
if os.path.isfile(filename):
|
||||
self._log(filename + ' already exists')
|
||||
return None
|
||||
url_best = re.sub(r'/s([1-9][0-9]{2})x\1/', '/s2048x2048/', url)
|
||||
url_best = re.sub(r'/vp/[a-f0-9]{32}/[A-F0-9]{8}/', '/', url_best) # remove signature
|
||||
try:
|
||||
self._get_and_write_raw(url_best, filename)
|
||||
except (QueryReturnedForbiddenException, QueryReturnedNotFoundException) as err:
|
||||
self.error('{} Retrying with lower quality version.'.format(err))
|
||||
self._get_and_write_raw(url, filename)
|
||||
self._get_and_write_raw(url, filename)
|
||||
os.utime(filename, (datetime.now().timestamp(), date_object.timestamp()))
|
||||
self._log('') # log output of _get_and_write_raw() does not produce \n
|
||||
|
||||
@@ -947,7 +964,7 @@ class Instaloader:
|
||||
def test_login(self) -> Optional[str]:
|
||||
"""Returns the Instagram username to which given :class:`requests.Session` object belongs, or None."""
|
||||
data = self.graphql_query("d6f4427fbe92d846298cf93df0b937d3", {})
|
||||
return data["data"]["user"]["username"] if "username" in data["data"]["user"] else None
|
||||
return data["data"]["user"]["username"] if data["data"]["user"] is not None else None
|
||||
|
||||
def login(self, user: str, passwd: str) -> None:
|
||||
"""Log in to instagram with given username and password and internally store session object"""
|
||||
@@ -1185,30 +1202,22 @@ class Instaloader:
|
||||
def get_feed_posts(self) -> Iterator[Post]:
|
||||
"""Get Posts of the user's feed."""
|
||||
|
||||
data = self.get_json('', params={'__a': 1})
|
||||
if not self.is_logged_in:
|
||||
return
|
||||
data = self.graphql_query("d6f4427fbe92d846298cf93df0b937d3", {})["data"]
|
||||
|
||||
while True:
|
||||
if "graphql" in data:
|
||||
is_edge = True
|
||||
feed = data["graphql"]["user"]["edge_web_feed_timeline"]
|
||||
elif "data" in data:
|
||||
is_edge = True
|
||||
feed = data["data"]["user"]["edge_web_feed_timeline"]
|
||||
else:
|
||||
is_edge = False
|
||||
feed = data["feed"]["media"]
|
||||
|
||||
if is_edge:
|
||||
yield from (Post(self, edge["node"]) for edge in feed["edges"])
|
||||
else:
|
||||
yield from (Post(self, node) for node in feed["nodes"])
|
||||
|
||||
feed = data["user"]["edge_web_feed_timeline"]
|
||||
yield from (Post(self, edge["node"]) for edge in feed["edges"]
|
||||
if not edge["node"]["__typename"] == "GraphSuggestedUserFeedUnit")
|
||||
if not feed["page_info"]["has_next_page"]:
|
||||
break
|
||||
data = self.graphql_query(17863003771166879, {'fetch_media_item_count': 12,
|
||||
'fetch_media_item_cursor': feed["page_info"]["end_cursor"],
|
||||
'fetch_comment_count': 4,
|
||||
'fetch_like': 10})
|
||||
data = self.graphql_query("d6f4427fbe92d846298cf93df0b937d3",
|
||||
{'fetch_media_item_count': 12,
|
||||
'fetch_media_item_cursor': feed["page_info"]["end_cursor"],
|
||||
'fetch_comment_count': 4,
|
||||
'fetch_like': 10,
|
||||
'has_stories': False})["data"]
|
||||
|
||||
def download_feed_posts(self, max_count: int = None, fast_update: bool = False,
|
||||
filter_func: Optional[Callable[[Post], bool]] = None) -> None:
|
||||
@@ -1244,6 +1253,8 @@ class Instaloader:
|
||||
def get_saved_posts(self) -> Iterator[Post]:
|
||||
"""Get Posts that are marked as saved by the user."""
|
||||
|
||||
if not self.is_logged_in:
|
||||
return
|
||||
data = self.get_profile_metadata(self.username)
|
||||
user_id = data["user"]["id"]
|
||||
|
||||
@@ -1587,6 +1598,14 @@ class Instaloader:
|
||||
# Save session if it is useful
|
||||
if username is not None:
|
||||
self.save_session_to_file(sessionfile)
|
||||
# User might be confused if Instaloader does nothing
|
||||
if not profilelist:
|
||||
if self.is_logged_in:
|
||||
# Instaloader did at least save a session file
|
||||
self._log("No targets were specified, thus nothing has been downloaded.")
|
||||
else:
|
||||
# Instloader did not do anything
|
||||
self._log("usage:"+USAGE_STRING)
|
||||
if self.error_log:
|
||||
print("\nErrors occured:", file=sys.stderr)
|
||||
for err in self.error_log:
|
||||
@@ -1594,7 +1613,7 @@ class Instaloader:
|
||||
|
||||
|
||||
def main():
|
||||
parser = ArgumentParser(description=__doc__, add_help=False,
|
||||
parser = ArgumentParser(description=__doc__, add_help=False, usage=USAGE_STRING,
|
||||
epilog="Report issues at https://github.com/instaloader/instaloader/issues. "
|
||||
"The complete documentation can be found at "
|
||||
"https://instaloader.github.io/.")
|
||||
|
||||
Reference in New Issue
Block a user