Minor doc-related improvements

This commit is contained in:
Alexander Graf 2017-08-28 21:45:43 +02:00
parent fbbbfdf53c
commit d84136b2dd
3 changed files with 17 additions and 8 deletions

View File

@ -24,7 +24,7 @@ Alternatively, to get the most current version of Instaloader from our
(pass ``--upgrade`` to upgrade if Instaloader is already installed) (pass ``--upgrade`` to upgrade if Instaloader is already installed)
Instaloader requires Instaloader requires
`requests <https://pypi.python.org/pypi/requests>`__, which `requests <http://python-requests.org/>`__, which
will be installed automatically, if it is not already installed. will be installed automatically, if it is not already installed.
.. installation-end .. installation-end
@ -32,9 +32,6 @@ will be installed automatically, if it is not already installed.
How to Automatically Download Pictures from Instagram How to Automatically Download Pictures from Instagram
----------------------------------------------------- -----------------------------------------------------
(This file is only a summary of
`the complete Instaloader Documentation <https://instaloader.readthedocs.io/>`__)
.. basic-usage-start .. basic-usage-start
To **download all pictures and videos of a profile**, as well as the To **download all pictures and videos of a profile**, as well as the
@ -122,7 +119,8 @@ For example, encode the poster's profile name in the filenames with:
The pattern string is formatted with Python's string formatter. This The pattern string is formatted with Python's string formatter. This
gives additional flexibilty for pattern specification. For example, gives additional flexibilty for pattern specification. For example,
strptime-style formatting options are supported for the post's `strftime-style formatting options <https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior>`__
are supported for the post's
timestamp. The default for ``{date}`` is ``{date:%Y-%m-%d_%H-%M-%S}``. timestamp. The default for ``{date}`` is ``{date:%Y-%m-%d_%H-%M-%S}``.
Filter Posts Filter Posts
@ -343,7 +341,7 @@ get the current username of a profile, given this unique ID
.. as-module-intro-end .. as-module-intro-end
Refer to the Refer to the
`Instaloader Documentation <https://instaloader.readthedocs.io/>`__ for `Instaloader Documentation <https://instaloader.readthedocs.io/as-module.html>`__ for
more information. more information.
Disclaimer Disclaimer

View File

@ -14,10 +14,13 @@ With `Python <https://www.python.org/>`__ installed, do:
**Instaloader** **Instaloader**
- downloads **public and private profiles, hashtags, user stories, - downloads **public and private profiles, hashtags, user stories and
feeds**, feeds**,
- downloads **comments, geotags, captions** of each post, - downloads **comments, geotags and captions** of each post,
- automatically **detects profile name changes** and renames the target
directory accordingly,
- allows **fine-grained customization** of filters and where to store - allows **fine-grained customization** of filters and where to store
downloaded media, downloaded media,

View File

@ -197,6 +197,7 @@ class Post:
@property @property
def shortcode(self) -> str: def shortcode(self) -> str:
"""Media shortcode. URL of the post is instagram.com/p/<shortcode>/."""
return self._node['shortcode'] if 'shortcode' in self._node else self._node['code'] return self._node['shortcode'] if 'shortcode' in self._node else self._node['code']
def __repr__(self): def __repr__(self):
@ -247,10 +248,12 @@ class Post:
@property @property
def date(self) -> datetime: def date(self) -> datetime:
"""Timestamp when the post was created."""
return datetime.fromtimestamp(self._node["date"] if "date" in self._node else self._node["taken_at_timestamp"]) return datetime.fromtimestamp(self._node["date"] if "date" in self._node else self._node["taken_at_timestamp"])
@property @property
def url(self) -> str: def url(self) -> str:
"""URL of the picture / video thumbnail of the post"""
return self._node["display_url"] if "display_url" in self._node else self._node["display_src"] return self._node["display_url"] if "display_url" in self._node else self._node["display_src"]
@property @property
@ -266,6 +269,7 @@ class Post:
@property @property
def caption(self) -> Optional[str]: def caption(self) -> Optional[str]:
"""Caption."""
if "edge_media_to_caption" in self._node and self._node["edge_media_to_caption"]["edges"]: if "edge_media_to_caption" in self._node and self._node["edge_media_to_caption"]["edges"]:
return self._node["edge_media_to_caption"]["edges"][0]["node"]["text"] return self._node["edge_media_to_caption"]["edges"][0]["node"]["text"]
elif "caption" in self._node: elif "caption" in self._node:
@ -273,10 +277,12 @@ class Post:
@property @property
def is_video(self) -> bool: def is_video(self) -> bool:
"""True if the Post is a video."""
return self._node['is_video'] return self._node['is_video']
@property @property
def video_url(self) -> Optional[str]: def video_url(self) -> Optional[str]:
"""URL of the video, or None."""
if self.is_video: if self.is_video:
return self._field('video_url') return self._field('video_url')
@ -368,6 +374,7 @@ class Instaloader:
@property @property
def is_logged_in(self) -> bool: def is_logged_in(self) -> bool:
"""True, if this Instaloader instance is logged in."""
return bool(self.username) return bool(self.username)
@contextmanager @contextmanager
@ -589,6 +596,7 @@ class Instaloader:
def graphql_node_list(self, query_id: int, query_variables: Dict[str, Any], query_referer: Optional[str], def graphql_node_list(self, query_id: int, query_variables: Dict[str, Any], query_referer: Optional[str],
edge_extractor: Callable[[Dict[str, Any]], Dict[str, Any]]) -> Iterator[Dict[str, Any]]: edge_extractor: Callable[[Dict[str, Any]], Dict[str, Any]]) -> Iterator[Dict[str, Any]]:
"""Retrieve a list of GraphQL nodes."""
query_variables['first'] = 500 query_variables['first'] = 500
data = self.graphql_query(query_id, query_variables, query_referer) data = self.graphql_query(query_id, query_variables, query_referer)
while True: while True: