[instagram] add 'previews' option (#2135)
This commit is contained in:
parent
8295bc6d97
commit
f8230dde43
@ -1392,6 +1392,16 @@ Description
|
|||||||
You can use ``"all"`` instead of listing all values separately.
|
You can use ``"all"`` instead of listing all values separately.
|
||||||
|
|
||||||
|
|
||||||
|
extractor.instagram.previews
|
||||||
|
----------------------------
|
||||||
|
Type
|
||||||
|
``bool``
|
||||||
|
Default
|
||||||
|
``false``
|
||||||
|
Description
|
||||||
|
Download video previews.
|
||||||
|
|
||||||
|
|
||||||
extractor.instagram.videos
|
extractor.instagram.videos
|
||||||
--------------------------
|
--------------------------
|
||||||
Type
|
Type
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2018-2020 Leonardo Taccari
|
# 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
|
# 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
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
@ -43,6 +43,7 @@ class InstagramExtractor(Extractor):
|
|||||||
self.login()
|
self.login()
|
||||||
data = self.metadata()
|
data = self.metadata()
|
||||||
videos = self.config("videos", True)
|
videos = self.config("videos", True)
|
||||||
|
previews = self.config("previews", False)
|
||||||
video_headers = {"User-Agent": "Mozilla/5.0"}
|
video_headers = {"User-Agent": "Mozilla/5.0"}
|
||||||
|
|
||||||
for post in self.posts():
|
for post in self.posts():
|
||||||
@ -56,14 +57,18 @@ class InstagramExtractor(Extractor):
|
|||||||
|
|
||||||
yield Message.Directory, post
|
yield Message.Directory, post
|
||||||
for file in files:
|
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)
|
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)
|
yield Message.Url, url, text.nameext_from_url(url, file)
|
||||||
|
|
||||||
def metadata(self):
|
def metadata(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user