From c609a3181bb9d52204782e008f77f637b3d6cb88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 3 Oct 2025 22:26:45 +0200 Subject: [PATCH] [instagram] support '/share/SHORTCODE' URLs (#8340) i.e. "bare" /share/ links --- gallery_dl/extractor/instagram.py | 11 +++++++---- gallery_dl/version.py | 2 +- test/results/instagram.py | 7 +++++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/gallery_dl/extractor/instagram.py b/gallery_dl/extractor/instagram.py index 0e6c4801..14a8ac42 100644 --- a/gallery_dl/extractor/instagram.py +++ b/gallery_dl/extractor/instagram.py @@ -436,7 +436,8 @@ class InstagramExtractor(Extractor): return cursor def _update_cursor(self, cursor): - self.log.debug("Cursor: %s", cursor) + if cursor: + self.log.debug("Cursor: %s", cursor) self._cursor = cursor return cursor @@ -461,16 +462,18 @@ class InstagramPostExtractor(InstagramExtractor): """Extractor for an Instagram post""" subcategory = "post" pattern = (r"(?:https?://)?(?:www\.)?instagram\.com" - r"/(?:share/()|[^/?#]+/)?(?:p|tv|reels?())/([^/?#]+)") + r"/(?:share()(?:/(?:p|tv|reels?()))?" + r"|(?:[^/?#]+/)?(?:p|tv|reels?()))" + r"/([^/?#]+)") example = "https://www.instagram.com/p/abcdefg/" def __init__(self, match): - if match[2] is not None: + if match[2] is not None or match[3] is not None: self.subcategory = "reel" InstagramExtractor.__init__(self, match) def posts(self): - share, reel, shortcode = self.groups + share, _, _, shortcode = self.groups if share is not None: url = text.ensure_http_scheme(self.url) headers = { diff --git a/gallery_dl/version.py b/gallery_dl/version.py index d3e02772..459eab97 100644 --- a/gallery_dl/version.py +++ b/gallery_dl/version.py @@ -6,5 +6,5 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. -__version__ = "1.30.9" +__version__ = "1.31.0-dev" __variant__ = None diff --git a/test/results/instagram.py b/test/results/instagram.py index f904896d..6d9166e4 100644 --- a/test/results/instagram.py +++ b/test/results/instagram.py @@ -288,6 +288,13 @@ __tests__ = ( "#class" : instagram.InstagramPostExtractor, }, +{ + "#url" : "https://www.instagram.com/share/BACiUUUYQV", + "#category": ("", "instagram", "post"), + "#class" : instagram.InstagramPostExtractor, + "shortcode" : "C6q-XdvsU5v", +}, + { "#url" : "https://www.instagram.com/share/p/BACiUUUYQV", "#category": ("", "instagram", "post"),