merge #7241: [instagram] handle '/share/' URLs
generated by the mobile app
This commit is contained in:
@@ -707,11 +707,21 @@ class InstagramPostExtractor(InstagramExtractor):
|
||||
"""Extractor for an Instagram post"""
|
||||
subcategory = "post"
|
||||
pattern = (r"(?:https?://)?(?:www\.)?instagram\.com"
|
||||
r"/(?:[^/?#]+/)?(?:p|tv|reel)/([^/?#]+)")
|
||||
r"/(?:share/()|[^/?#]+/)?(?:p|tv|reel)/([^/?#]+)")
|
||||
example = "https://www.instagram.com/p/abcdefg/"
|
||||
|
||||
def posts(self):
|
||||
return self.api.media(self.item)
|
||||
share, shortcode = self.groups
|
||||
if share is not None:
|
||||
url = text.ensure_http_scheme(self.url)
|
||||
headers = {
|
||||
"Sec-Fetch-Dest": "empty",
|
||||
"Sec-Fetch-Mode": "navigate",
|
||||
"Sec-Fetch-Site": "same-origin",
|
||||
}
|
||||
location = self.request_location(url, headers=headers)
|
||||
shortcode = location.split("/")[-2]
|
||||
return self.api.media(shortcode)
|
||||
|
||||
|
||||
class InstagramRestAPI():
|
||||
|
||||
@@ -277,4 +277,18 @@ __tests__ = (
|
||||
"#class" : instagram.InstagramPostExtractor,
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://www.instagram.com/share/p/BACiUUUYQV",
|
||||
"#category": ("", "instagram", "post"),
|
||||
"#class" : instagram.InstagramPostExtractor,
|
||||
"shortcode" : "C6q-XdvsU5v",
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://www.instagram.com/share/reel/BARSSL4rTu",
|
||||
"#category": ("", "instagram", "post"),
|
||||
"#class" : instagram.InstagramPostExtractor,
|
||||
"shortcode" : "DHbVbT4Jx0c",
|
||||
}
|
||||
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user