Repository: yt-dlp/yt-dlp
Issue category: Bug Report

[instagram] Support /share/ URLs
### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I *intentionally* remove or skip any mandatory\* field

### Checklist

- [X] I'm reporting that yt-dlp is broken on a **supported** site
- [X] I've verified that I have **updated yt-dlp to nightly or master** ([update instructions](https://github.com/yt-dlp/yt-dlp#update-channels))
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#video-url-contains-an-ampersand--and-im-getting-some-strange-output-1-2839-or-v-is-not-recognized-as-an-internal-or-external-command)
- [X] I've searched [known issues](https://github.com/yt-dlp/yt-dlp/issues/3766) and the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues **including closed ones**. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)
- [X] I've read about [sharing account credentials](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#are-you-willing-to-share-account-details-if-needed) and I'm willing to share it if required

### Region

Indonesian 

### Provide a description that is worded well enough to be understood

The issue occurs when trying to extract a video from Instagram using yt-dlp in the Seal app, where the tool fails to retrieve the video URL due to a problem in the extraction process, possibly caused by changes in the Instagram API or webpage structure, and I’ve made sure I’m using the latest version.

### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [ ] If using API, add `'verbose': True` to `YoutubeDL` params instead
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
Latest version: nightly@2024.11.24.232931 from yt-dlp/yt-dlp-nightly-builds
yt-dlp is up to date (nightly@2024.11.24.232931 from yt-dlp/yt-dlp-nightly-builds)
[Instagram] Extracting URL: https://www.instagram.com/share/reel/_69O6RoGd
[Instagram] _69O6RoGd: Setting up session
[Instagram] _69O6RoGd: Downloading JSON metadata

[debug] Command-line config: ['-P', '/storage/emulated/0/Download/Seal', '--newline', '--config-locations', '/data/user/0/com.junkfood.seal/cache/config.txt', '--no-cache-dir', '--ffmpeg-location', '/data/app/~~A2GvDkNiduFYW1kU1Oy9Fg==/com.junkfood.seal-iKQxGY5uYwqmCWT7tKicWA==/lib/arm64/libffmpeg.so', 'https://www.instagram.com/share/reel/_69O6RoGd']
[debug] | Config "/data/user/0/com.junkfood.seal/cache/config.txt": ['-vU']
[debug] Encodings: locale utf-8, fs utf-8, pref utf-8, out utf-8 (No ANSI), error utf-8 (No ANSI), screen utf-8 (No ANSI)
[debug] yt-dlp version nightly@2024.11.24.232931 from yt-dlp/yt-dlp-nightly-builds [4b5eec0aa] (zip)
[debug] Python 3.11.10 (CPython aarch64 64bit) - Linux-4.19.191-g65cea2ea204b-dirty-aarch64-with-libc (OpenSSL 3.3.2 3 Sep 2024, libc)
[debug] exe versions: ffmpeg 7.0.1 (setts), ffprobe 7.0.1
[debug] Optional libraries: Cryptodome-3.20.0, mutagen-1.47.0, sqlite3-3.46.1
[debug] Proxy map: {}
[debug] Request Handlers: urllib
[debug] Loaded 1837 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp-nightly-builds/releases/latest
WARNING: [Instagram] _69O6RoGd: Instagram API is not granting access
WARNING: [Instagram] unable to extract username; please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
ERROR: [Instagram] _69O6RoGd: Unable to extract video url; please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U
  File "/data/user/0/com.junkfood.seal/no_backup/youtubedl-android/yt-dlp/yt-dlp/yt_dlp/extractor/common.py", line 742, in extract
    ie_result = self._real_extract(url)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/user/0/com.junkfood.seal/no_backup/youtubedl-android/yt-dlp/yt-dlp/yt_dlp/extractor/instagram.py", line 489, in _real_extract
    video_url = self._og_search_video_url(webpage, secure=False)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/user/0/com.junkfood.seal/no_backup/youtubedl-android/yt-dlp/yt-dlp/yt_dlp/extractor/common.py", line 1499, in _og_search_video_url
    return self._html_search_regex(regexes, html, name, **kargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/user/0/com.junkfood.seal/no_backup/youtubedl-android/yt-dlp/yt-dlp/yt_dlp/extractor/common.py", line 1382, in _html_search_regex
    res = self._search_regex(pattern, string, name, default, fatal, flags, group)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/user/0/com.junkfood.seal/no_backup/youtubedl-android/yt-dlp/yt-dlp/yt_dlp/extractor/common.py", line 1346, in _search_regex
    raise RegexNotFoundError(f'Unable to extract {_name}')
```



Functions to edit:
yt_dlp/extractor/instagram.py:InstagramIE
Functions added: yt_dlp/extractor/instagram.py:InstagramIE

Patch:
diff --git a/yt_dlp/extractor/instagram.py b/yt_dlp/extractor/instagram.py
index dee8cb85d529..55086d0b29c7 100644
--- a/yt_dlp/extractor/instagram.py
+++ b/yt_dlp/extractor/instagram.py
@@ -254,7 +254,7 @@ def _real_extract(self, url):
 
 
 class InstagramIE(InstagramBaseIE):
-    _VALID_URL = r'(?P<url>https?://(?:www\.)?instagram\.com(?:/[^/]+)?/(?:p|tv|reels?(?!/audio/))/(?P<id>[^/?#&]+))'
+    _VALID_URL = r'(?P<url>https?://(?:www\.)?instagram\.com(?:/(?!share/)[^/?#]+)?/(?:p|tv|reels?(?!/audio/))/(?P<id>[^/?#&]+))'
     _EMBED_REGEX = [r'<iframe[^>]+src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?instagram\.com/p/[^/]+/embed.*?)\1']
     _TESTS = [{
         'url': 'https://instagram.com/p/aye83DjauH/?foo=bar#abc',