[instagram] use 'reel' subcategory for '/reel/CODE' URLs (#8274)

This commit is contained in:
Mike Fährmann
2025-10-01 10:05:22 +02:00
parent bcefcd5ae1
commit eb4c159f36
2 changed files with 10 additions and 4 deletions

View File

@@ -453,11 +453,16 @@ 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?())/([^/?#]+)")
example = "https://www.instagram.com/p/abcdefg/"
def __init__(self, match):
if match[2] is not None:
self.subcategory = "reel"
InstagramExtractor.__init__(self, match)
def posts(self):
share, shortcode = self.groups
share, reel, shortcode = self.groups
if share is not None:
url = text.ensure_http_scheme(self.url)
headers = {

View File

@@ -278,12 +278,13 @@ __tests__ = (
{
"#url" : "https://www.instagram.com/reel/CDg_6Y1pxWu/",
"#category": ("", "instagram", "post"),
"#category": ("", "instagram", "reel"),
"#class" : instagram.InstagramPostExtractor,
},
{
"#url" : "https://www.instagram.com/reels/CDg_6Y1pxWu/",
"#category": ("", "instagram", "reel"),
"#class" : instagram.InstagramPostExtractor,
},
@@ -296,7 +297,7 @@ __tests__ = (
{
"#url" : "https://www.instagram.com/share/reel/BARSSL4rTu",
"#category": ("", "instagram", "post"),
"#category": ("", "instagram", "reel"),
"#class" : instagram.InstagramPostExtractor,
"shortcode" : "DHbVbT4Jx0c",
}