parent
41a50ffa5a
commit
75d9dda4ba
@ -34,6 +34,10 @@ it by its unique ID** and renames the folder likewise.
|
|||||||
|
|
||||||
Do not download videos.
|
Do not download videos.
|
||||||
|
|
||||||
|
.. option:: --no-video-thumbnails
|
||||||
|
|
||||||
|
Do not download thumbnails of videos.
|
||||||
|
|
||||||
.. option:: --geotags
|
.. option:: --geotags
|
||||||
|
|
||||||
**Download geotags** when available. Geotags are stored as a text file with
|
**Download geotags** when available. Geotags are stored as a text file with
|
||||||
|
@ -416,6 +416,7 @@ class Instaloader:
|
|||||||
dirname_pattern: Optional[str] = None,
|
dirname_pattern: Optional[str] = None,
|
||||||
filename_pattern: Optional[str] = None,
|
filename_pattern: Optional[str] = None,
|
||||||
download_videos: Tristate = Tristate.always,
|
download_videos: Tristate = Tristate.always,
|
||||||
|
download_video_thumbnails: Tristate = Tristate.always,
|
||||||
download_geotags: Tristate = Tristate.no_extra_query,
|
download_geotags: Tristate = Tristate.no_extra_query,
|
||||||
save_captions: Tristate = Tristate.no_extra_query,
|
save_captions: Tristate = Tristate.no_extra_query,
|
||||||
download_comments: Tristate = Tristate.no_extra_query,
|
download_comments: Tristate = Tristate.no_extra_query,
|
||||||
@ -432,6 +433,7 @@ class Instaloader:
|
|||||||
self.filename_pattern = filename_pattern.replace('{date}', '{date:%Y-%m-%d_%H-%M-%S}') \
|
self.filename_pattern = filename_pattern.replace('{date}', '{date:%Y-%m-%d_%H-%M-%S}') \
|
||||||
if filename_pattern is not None else '{date:%Y-%m-%d_%H-%M-%S}'
|
if filename_pattern is not None else '{date:%Y-%m-%d_%H-%M-%S}'
|
||||||
self.download_videos = download_videos
|
self.download_videos = download_videos
|
||||||
|
self.download_video_thumbnails = download_video_thumbnails
|
||||||
self.download_geotags = download_geotags
|
self.download_geotags = download_geotags
|
||||||
self.save_captions = save_captions
|
self.save_captions = save_captions
|
||||||
self.download_comments = download_comments
|
self.download_comments = download_comments
|
||||||
@ -454,7 +456,9 @@ class Instaloader:
|
|||||||
"""Yield an anonymous, otherwise equally-configured copy of an Instaloader instance; Then copy its error log."""
|
"""Yield an anonymous, otherwise equally-configured copy of an Instaloader instance; Then copy its error log."""
|
||||||
new_loader = Instaloader(self.sleep, self.quiet, self.user_agent,
|
new_loader = Instaloader(self.sleep, self.quiet, self.user_agent,
|
||||||
self.dirname_pattern, self.filename_pattern,
|
self.dirname_pattern, self.filename_pattern,
|
||||||
self.download_videos, self.download_geotags,
|
self.download_videos,
|
||||||
|
self.download_video_thumbnails,
|
||||||
|
self.download_geotags,
|
||||||
self.save_captions, self.download_comments,
|
self.save_captions, self.download_comments,
|
||||||
self.save_metadata, self.max_connection_attempts)
|
self.save_metadata, self.max_connection_attempts)
|
||||||
new_loader.previous_queries = self.previous_queries
|
new_loader.previous_queries = self.previous_queries
|
||||||
@ -908,27 +912,30 @@ class Instaloader:
|
|||||||
os.makedirs(os.path.dirname(filename), exist_ok=True)
|
os.makedirs(os.path.dirname(filename), exist_ok=True)
|
||||||
|
|
||||||
# Download the image(s) / video thumbnail and videos within sidecars if desired
|
# Download the image(s) / video thumbnail and videos within sidecars if desired
|
||||||
|
downloaded = False
|
||||||
if post.typename == 'GraphSidecar':
|
if post.typename == 'GraphSidecar':
|
||||||
edge_number = 1
|
edge_number = 1
|
||||||
downloaded = True
|
|
||||||
for edge in post.get_sidecar_edges():
|
for edge in post.get_sidecar_edges():
|
||||||
edge_downloaded = self.download_pic(filename=filename,
|
# Download picture or video thumbnail
|
||||||
|
if not edge['node']['is_video'] or self.download_video_thumbnails is Tristate.always:
|
||||||
|
downloaded |= self.download_pic(filename=filename,
|
||||||
url=edge['node']['display_url'],
|
url=edge['node']['display_url'],
|
||||||
mtime=post.date,
|
mtime=post.date,
|
||||||
filename_suffix=str(edge_number))
|
filename_suffix=str(edge_number))
|
||||||
# Additionally download video if available and desired
|
# Additionally download video if available and desired
|
||||||
if edge['node']['is_video'] and self.download_videos is Tristate.always:
|
if edge['node']['is_video'] and self.download_videos is Tristate.always:
|
||||||
self.download_pic(filename=filename,
|
downloaded |= self.download_pic(filename=filename,
|
||||||
url=edge['node']['video_url'],
|
url=edge['node']['video_url'],
|
||||||
mtime=post.date,
|
mtime=post.date,
|
||||||
filename_suffix=str(edge_number))
|
filename_suffix=str(edge_number))
|
||||||
downloaded = downloaded and edge_downloaded
|
|
||||||
edge_number += 1
|
edge_number += 1
|
||||||
elif post.typename in ['GraphImage', 'GraphVideo']:
|
elif post.typename == 'GraphImage':
|
||||||
|
downloaded = self.download_pic(filename=filename, url=post.url, mtime=post.date)
|
||||||
|
elif post.typename == 'GraphVideo':
|
||||||
|
if self.download_video_thumbnails is Tristate.always:
|
||||||
downloaded = self.download_pic(filename=filename, url=post.url, mtime=post.date)
|
downloaded = self.download_pic(filename=filename, url=post.url, mtime=post.date)
|
||||||
else:
|
else:
|
||||||
self.error("Warning: {0} has unknown typename: {1}".format(post, post.typename))
|
self.error("Warning: {0} has unknown typename: {1}".format(post, post.typename))
|
||||||
downloaded = False
|
|
||||||
|
|
||||||
# Save caption if desired
|
# Save caption if desired
|
||||||
if self.save_captions is not Tristate.never:
|
if self.save_captions is not Tristate.never:
|
||||||
@ -939,7 +946,7 @@ class Instaloader:
|
|||||||
|
|
||||||
# Download video if desired
|
# Download video if desired
|
||||||
if post.is_video and self.download_videos is Tristate.always:
|
if post.is_video and self.download_videos is Tristate.always:
|
||||||
self.download_pic(filename=filename, url=post.video_url, mtime=post.date)
|
downloaded |= self.download_pic(filename=filename, url=post.video_url, mtime=post.date)
|
||||||
|
|
||||||
# Download geotags if desired
|
# Download geotags if desired
|
||||||
if self.download_geotags is Tristate.always:
|
if self.download_geotags is Tristate.always:
|
||||||
@ -1046,14 +1053,15 @@ class Instaloader:
|
|||||||
date=date,
|
date=date,
|
||||||
shortcode=shortcode)
|
shortcode=shortcode)
|
||||||
os.makedirs(os.path.dirname(filename), exist_ok=True)
|
os.makedirs(os.path.dirname(filename), exist_ok=True)
|
||||||
|
downloaded = False
|
||||||
if "image_versions2" in item:
|
if "image_versions2" in item:
|
||||||
|
if "video_versions" not in item or self.download_video_thumbnails is Tristate.always:
|
||||||
url = item["image_versions2"]["candidates"][0]["url"]
|
url = item["image_versions2"]["candidates"][0]["url"]
|
||||||
downloaded = self.download_pic(filename=filename,
|
downloaded = self.download_pic(filename=filename,
|
||||||
url=url,
|
url=url,
|
||||||
mtime=date)
|
mtime=date)
|
||||||
else:
|
else:
|
||||||
self._log("Warning: Unable to find story image.")
|
self._log("Warning: Unable to find story image.")
|
||||||
downloaded = False
|
|
||||||
if "caption" in item and item["caption"] is not None and \
|
if "caption" in item and item["caption"] is not None and \
|
||||||
self.save_captions is not Tristate.never:
|
self.save_captions is not Tristate.never:
|
||||||
caption = item["caption"]
|
caption = item["caption"]
|
||||||
@ -1063,7 +1071,7 @@ class Instaloader:
|
|||||||
else:
|
else:
|
||||||
self._log("<no caption>", end=' ', flush=True)
|
self._log("<no caption>", end=' ', flush=True)
|
||||||
if "video_versions" in item and self.download_videos is Tristate.always:
|
if "video_versions" in item and self.download_videos is Tristate.always:
|
||||||
downloaded = self.download_pic(filename=filename,
|
downloaded |= self.download_pic(filename=filename,
|
||||||
url=item["video_versions"][0]["url"],
|
url=item["video_versions"][0]["url"],
|
||||||
mtime=date)
|
mtime=date)
|
||||||
if item["story_locations"] and self.download_geotags is not Tristate.never:
|
if item["story_locations"] and self.download_geotags is not Tristate.never:
|
||||||
@ -1445,6 +1453,8 @@ def main():
|
|||||||
help='Do not download profile picture.')
|
help='Do not download profile picture.')
|
||||||
g_what.add_argument('-V', '--no-videos', action='store_true',
|
g_what.add_argument('-V', '--no-videos', action='store_true',
|
||||||
help='Do not download videos.')
|
help='Do not download videos.')
|
||||||
|
g_what.add_argument('--no-video-thumbnails', action='store_true',
|
||||||
|
help='Do not download thumbnails of videos.')
|
||||||
g_what.add_argument('-G', '--geotags', action='store_true',
|
g_what.add_argument('-G', '--geotags', action='store_true',
|
||||||
help='Download geotags when available. Geotags are stored as a '
|
help='Download geotags when available. Geotags are stored as a '
|
||||||
'text file with the location\'s name and a Google Maps link. '
|
'text file with the location\'s name and a Google Maps link. '
|
||||||
@ -1538,6 +1548,7 @@ def main():
|
|||||||
"eventually --only-if=viewer_has_liked.")
|
"eventually --only-if=viewer_has_liked.")
|
||||||
|
|
||||||
download_videos = Tristate.always if not args.no_videos else Tristate.no_extra_query
|
download_videos = Tristate.always if not args.no_videos else Tristate.no_extra_query
|
||||||
|
download_video_thumbnails = Tristate.always if not args.no_video_thumbnails else Tristate.never
|
||||||
download_comments = Tristate.always if args.comments else Tristate.no_extra_query
|
download_comments = Tristate.always if args.comments else Tristate.no_extra_query
|
||||||
save_captions = Tristate.no_extra_query if not args.no_captions else Tristate.never
|
save_captions = Tristate.no_extra_query if not args.no_captions else Tristate.never
|
||||||
save_metadata = Tristate.always if args.metadata_json else Tristate.never
|
save_metadata = Tristate.always if args.metadata_json else Tristate.never
|
||||||
@ -1554,7 +1565,8 @@ def main():
|
|||||||
loader = Instaloader(sleep=not args.no_sleep, quiet=args.quiet,
|
loader = Instaloader(sleep=not args.no_sleep, quiet=args.quiet,
|
||||||
user_agent=args.user_agent,
|
user_agent=args.user_agent,
|
||||||
dirname_pattern=args.dirname_pattern, filename_pattern=args.filename_pattern,
|
dirname_pattern=args.dirname_pattern, filename_pattern=args.filename_pattern,
|
||||||
download_videos=download_videos, download_geotags=download_geotags,
|
download_videos=download_videos, download_video_thumbnails=download_video_thumbnails,
|
||||||
|
download_geotags=download_geotags,
|
||||||
save_captions=save_captions, download_comments=download_comments,
|
save_captions=save_captions, download_comments=download_comments,
|
||||||
save_metadata=save_metadata, max_connection_attempts=args.max_connection_attempts)
|
save_metadata=save_metadata, max_connection_attempts=args.max_connection_attempts)
|
||||||
loader.main(args.profile,
|
loader.main(args.profile,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user