1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 10:42:34 +01:00

[instagram] add 'previews' option (#2135)

This commit is contained in:
Mike Fährmann 2022-03-19 15:22:13 +01:00
parent 8295bc6d97
commit f8230dde43
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 23 additions and 8 deletions

View File

@ -1392,6 +1392,16 @@ Description
You can use ``"all"`` instead of listing all values separately.
extractor.instagram.previews
----------------------------
Type
``bool``
Default
``false``
Description
Download video previews.
extractor.instagram.videos
--------------------------
Type

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Copyright 2018-2020 Leonardo Taccari
# Copyright 2018-2021 Mike Fährmann
# Copyright 2018-2022 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@ -43,6 +43,7 @@ class InstagramExtractor(Extractor):
self.login()
data = self.metadata()
videos = self.config("videos", True)
previews = self.config("previews", False)
video_headers = {"User-Agent": "Mozilla/5.0"}
for post in self.posts():
@ -56,14 +57,18 @@ class InstagramExtractor(Extractor):
yield Message.Directory, post
for file in files:
url = file.get("video_url")
if not url:
url = file["display_url"]
elif not videos:
continue
else:
file["_http_headers"] = video_headers
file.update(post)
url = file.get("video_url")
if url:
if videos:
file["_http_headers"] = video_headers
text.nameext_from_url(url, file)
yield Message.Url, url, file
if not previews:
continue
url = file["display_url"]
yield Message.Url, url, text.nameext_from_url(url, file)
def metadata(self):