Fix some video download edge cases (#776)
Fixes unintended sidecar video skipping if --no-pictures is set. Fixes video download if video thumbnail access fails with 410 error.
This commit is contained in:
@@ -513,26 +513,27 @@ class Instaloader:
|
|||||||
|
|
||||||
# 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 = True
|
downloaded = True
|
||||||
if self.download_pictures:
|
if post.typename == 'GraphSidecar':
|
||||||
if post.typename == 'GraphSidecar':
|
for edge_number, sidecar_node in enumerate(post.get_sidecar_nodes(), start=1):
|
||||||
edge_number = 1
|
if self.download_pictures and (not sidecar_node.is_video or self.download_video_thumbnails):
|
||||||
for sidecar_node in post.get_sidecar_nodes():
|
# Download sidecar picture or video thumbnail (--no-pictures implies --no-video-thumbnails)
|
||||||
# Download picture or video thumbnail
|
downloaded &= self.download_pic(filename=filename, url=sidecar_node.display_url,
|
||||||
if not sidecar_node.is_video or self.download_video_thumbnails is True:
|
mtime=post.date_local, filename_suffix=str(edge_number))
|
||||||
downloaded &= self.download_pic(filename=filename, url=sidecar_node.display_url,
|
if sidecar_node.is_video and self.download_videos:
|
||||||
mtime=post.date_local, filename_suffix=str(edge_number))
|
# Download sidecar video if desired
|
||||||
# Additionally download video if available and desired
|
downloaded &= self.download_pic(filename=filename, url=sidecar_node.video_url,
|
||||||
if sidecar_node.is_video and self.download_videos is True:
|
mtime=post.date_local, filename_suffix=str(edge_number))
|
||||||
downloaded &= self.download_pic(filename=filename, url=sidecar_node.video_url,
|
elif post.typename == 'GraphImage':
|
||||||
mtime=post.date_local, filename_suffix=str(edge_number))
|
# Download picture
|
||||||
edge_number += 1
|
if self.download_pictures:
|
||||||
elif post.typename == 'GraphImage':
|
|
||||||
downloaded = self.download_pic(filename=filename, url=post.url, mtime=post.date_local)
|
downloaded = self.download_pic(filename=filename, url=post.url, mtime=post.date_local)
|
||||||
elif post.typename == 'GraphVideo':
|
elif post.typename == 'GraphVideo':
|
||||||
if self.download_video_thumbnails is True:
|
# Download video thumbnail (--no-pictures implies --no-video-thumbnails)
|
||||||
|
if self.download_pictures and self.download_video_thumbnails:
|
||||||
|
with self.context.error_catcher("Video thumbnail of {}".format(post)):
|
||||||
downloaded = self.download_pic(filename=filename, url=post.url, mtime=post.date_local)
|
downloaded = self.download_pic(filename=filename, url=post.url, mtime=post.date_local)
|
||||||
else:
|
else:
|
||||||
self.context.error("Warning: {0} has unknown typename: {1}".format(post, post.typename))
|
self.context.error("Warning: {0} has unknown typename: {1}".format(post, post.typename))
|
||||||
|
|
||||||
# Save caption if desired
|
# Save caption if desired
|
||||||
metadata_string = _ArbitraryItemFormatter(post).format(self.post_metadata_txt_pattern).strip()
|
metadata_string = _ArbitraryItemFormatter(post).format(self.post_metadata_txt_pattern).strip()
|
||||||
@@ -540,7 +541,7 @@ class Instaloader:
|
|||||||
self.save_caption(filename=filename, mtime=post.date_local, caption=metadata_string)
|
self.save_caption(filename=filename, mtime=post.date_local, caption=metadata_string)
|
||||||
|
|
||||||
# Download video if desired
|
# Download video if desired
|
||||||
if post.is_video and self.download_videos is True:
|
if post.is_video and self.download_videos:
|
||||||
downloaded &= self.download_pic(filename=filename, url=post.video_url, mtime=post.date_local)
|
downloaded &= self.download_pic(filename=filename, url=post.video_url, mtime=post.date_local)
|
||||||
|
|
||||||
# Download geotags if desired
|
# Download geotags if desired
|
||||||
@@ -548,11 +549,11 @@ class Instaloader:
|
|||||||
self.save_location(filename, post.location, post.date_local)
|
self.save_location(filename, post.location, post.date_local)
|
||||||
|
|
||||||
# Update comments if desired
|
# Update comments if desired
|
||||||
if self.download_comments is True:
|
if self.download_comments:
|
||||||
self.update_comments(filename=filename, post=post)
|
self.update_comments(filename=filename, post=post)
|
||||||
|
|
||||||
# Save metadata as JSON if desired.
|
# Save metadata as JSON if desired.
|
||||||
if self.save_metadata is not False:
|
if self.save_metadata:
|
||||||
self.save_metadata_json(filename, post)
|
self.save_metadata_json(filename, post)
|
||||||
|
|
||||||
self.context.log()
|
self.context.log()
|
||||||
|
Reference in New Issue
Block a user