[instagram] support '/share/SHORTCODE' URLs (#8340)

i.e. "bare" /share/ links
This commit is contained in:
Mike Fährmann
2025-10-03 22:26:45 +02:00
parent 4d9b30bcb0
commit c609a3181b
3 changed files with 15 additions and 5 deletions

View File

@@ -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 = {