Repository: yt-dlp/yt-dlp

Issue:
http 403 instagram reels
### Checklist

- [X] I'm reporting a bug unrelated to a specific site
- [X] I've verified that I'm running yt-dlp version **2021.12.01**. ([update instructions](https://github.com/yt-dlp/yt-dlp#update))
- [X] I've checked that all provided URLs are alive and playable in a browser
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/ytdl-org/youtube-dl#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 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)

### Description

http error 403 while trying to download reels from instragram (already logged using cookies) latest version
verbose log below

![image](https://user-images.githubusercontent.com/8607299/145111774-f0761c7b-812b-416f-ac44-e54996e199f5.png)


### Verbose log

```shell
arthur@blackpower ~ % yt-dlp "https://www.instagram.com/marvelskies.fc/reel/CWqAgUZgCku/" --cookies "~/instagram.com_cookies.txt" --verbose
[debug] Command-line config: ['https://www.instagram.com/marvelskies.fc/reel/CWqAgUZgCku/', '--cookies', '~/instagram.com_cookies.txt', '--verbose']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, err utf-8, pref UTF-8
[debug] yt-dlp version 2021.12.01 [91f071af6]
[debug] Python version 3.10.0 (CPython 64bit) - macOS-11.3-x86_64-i386-64bit
[debug] exe versions: ffmpeg 4.4.1 (setts), ffprobe 4.4.1, rtmpdump 2.4
[debug] Optional libraries: Cryptodome, mutagen, sqlite, websockets
[debug] Proxy map: {}
[debug] [generic] Extracting URL: https://www.instagram.com/marvelskies.fc/reel/CWqAgUZgCku/
[generic] CWqAgUZgCku: Requesting header
WARNING: [generic] Could not send HEAD request to https://www.instagram.com/marvelskies.fc/reel/CWqAgUZgCku/: HTTP Error 405: Method Not Allowed
[generic] CWqAgUZgCku: Downloading webpage
WARNING: [generic] Falling back on generic information extractor.
[generic] CWqAgUZgCku: Extracting information
[debug] Looking for video embeds
[debug] Identified a JW Player JS loader
[debug] Default format spec: bestvideo*+bestaudio/best
[info] 259945183_634763724195677_1967405584202529129_n.mp4?_nc_ht=instagram.fgyn3-1.fna.fbcdn: Downloading 1 format(s): 0
[debug] Invoking downloader on "https://instagram.fgyn3-1.fna.fbcdn.net/v/t50.2886-16/259945183_634763724195677_1967405584202529129_n.mp4?_nc_ht=instagram.fgyn3-1.fna.fbcdn.net\u0026_nc_cat=105\u0026_nc_ohc=pIfmkouO64cAX-mzjZh\u0026edm=APfKNqwBAAAA\u0026ccb=7-4\u0026oe=61B1C916\u0026oh=9c99e1bc5cbb455c9b5a2ac528d429de\u0026_nc_sid=74f7ba"
ERROR: unable to download video data: HTTP Error 403: Forbidden
Traceback (most recent call last):
  File "/usr/local/Cellar/yt-dlp/2021.12.1/libexec/lib/python3.10/site-packages/yt_dlp/YoutubeDL.py", line 2933, in process_info
    success, real_download = self.dl(temp_filename, info_dict)
  File "/usr/local/Cellar/yt-dlp/2021.12.1/libexec/lib/python3.10/site-packages/yt_dlp/YoutubeDL.py", line 2654, in dl
    return fd.download(name, new_info, subtitle)
  File "/usr/local/Cellar/yt-dlp/2021.12.1/libexec/lib/python3.10/site-packages/yt_dlp/downloader/common.py", line 421, in download
    ret = self.real_download(filename, info_dict)
  File "/usr/local/Cellar/yt-dlp/2021.12.1/libexec/lib/python3.10/site-packages/yt_dlp/downloader/http.py", line 372, in real_download
    establish_connection()
  File "/usr/local/Cellar/yt-dlp/2021.12.1/libexec/lib/python3.10/site-packages/yt_dlp/downloader/http.py", line 120, in establish_connection
    raise err
  File "/usr/local/Cellar/yt-dlp/2021.12.1/libexec/lib/python3.10/site-packages/yt_dlp/downloader/http.py", line 114, in establish_connection
    ctx.data = self.ydl.urlopen(request)
  File "/usr/local/Cellar/yt-dlp/2021.12.1/libexec/lib/python3.10/site-packages/yt_dlp/YoutubeDL.py", line 3385, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 525, in open
    response = meth(req, response)
  File "/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 634, in http_response
    response = self.parent.error(
  File "/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 557, in error
    result = self._call_chain(*args)
  File "/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 749, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 525, in open
    response = meth(req, response)
  File "/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 634, in http_response
    response = self.parent.error(
  File "/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 563, in error
    return self._call_chain(*args)
  File "/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden
```



Discussion:
> I have a solution for this. If you would just do what I asked on the other repo, then I would share it. But since you want to do things the hard way, suit yourself.

if you have a solution then waste your time solving it and post a pull request
@89z I have already warned you not to start drama and then keep deleting your comments
@tucomel Check if https://www.instagram.com/reel/CWqAgUZgCku/ works for you

Resolving patch:
diff --git a/yt_dlp/extractor/instagram.py b/yt_dlp/extractor/instagram.py
--- a/yt_dlp/extractor/instagram.py
+++ b/yt_dlp/extractor/instagram.py
@@ -170,7 +170,7 @@ def _real_extract(self, url):
 
 
 class InstagramIE(InstagramBaseIE):
-    _VALID_URL = r'(?P<url>https?://(?:www\.)?instagram\.com/(?:p|tv|reel)/(?P<id>[^/?#&]+))'
+    _VALID_URL = r'(?P<url>https?://(?:www\.)?instagram\.com(?:/[^/]+)?/(?:p|tv|reel)/(?P<id>[^/?#&]+))'
     _TESTS = [{
         'url': 'https://instagram.com/p/aye83DjauH/?foo=bar#abc',
         'md5': '0d2da106a9d2631273e192b372806516',
@@ -266,6 +266,9 @@ class InstagramIE(InstagramBaseIE):
     }, {
         'url': 'https://www.instagram.com/reel/CDUMkliABpa/',
         'only_matching': True,
+    }, {
+        'url': 'https://www.instagram.com/marvelskies.fc/reel/CWqAgUZgCku/',
+        'only_matching': True,
     }]
 
     @staticmethod


Test patch: