From d680623db369bc4acaa82f7118f81607937394e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Thu, 18 May 2023 22:34:33 +0200 Subject: [PATCH] [instagram] add 'order-files' option (#4017, #3993) --- docs/configuration.rst | 17 +++++++++++++++++ gallery_dl/extractor/instagram.py | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/docs/configuration.rst b/docs/configuration.rst index bb89b7c1..1ce75cb7 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -1817,6 +1817,23 @@ Description It is possible to use ``"all"`` instead of listing all values separately. +extractor.instagram.order-files +------------------------------- +Type + ``string`` +Default + ``"asc"`` +Description + Controls the order in which files of each post are returned. + + * ``"asc"``: Same order as displayed in a post + * ``"desc"``: Reverse order as displayed in a post + * ``"reverse"``: Same as ``"desc"`` + + Note: This option does *not* affect ``{num}``. + To enumerate files in reverse order, use ``count - num + 1``. + + extractor.instagram.previews ---------------------------- Type diff --git a/gallery_dl/extractor/instagram.py b/gallery_dl/extractor/instagram.py index 4c1be0fb..3f760ebb 100644 --- a/gallery_dl/extractor/instagram.py +++ b/gallery_dl/extractor/instagram.py @@ -55,6 +55,9 @@ class InstagramExtractor(Extractor): previews = self.config("previews", False) video_headers = {"User-Agent": "Mozilla/5.0"} + order = self.config("order-files") + reverse = order[0] in ("r", "d") if order else False + for post in self.posts(): if "__typename" in post: @@ -71,6 +74,8 @@ class InstagramExtractor(Extractor): if "date" in post: del post["date"] + if reverse: + files.reverse() for file in files: file.update(post)