Repository: youtube-dl
Issue: Resources parsed from MPD files dont contain signature for request resulting in a HTTP 403 (DiscoveryPlus)
Labels: broken-IE

### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I remove or skip any mandatory\* field

### Checklist

- [X] I'm reporting a bug unrelated to a specific site
- [X] I've verified that I'm running yt-dlp version **2022.11.11** ([update instructions](https://github.com/yt-dlp/yt-dlp#update)) or later (specify commit)
- [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 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)

### Provide a description that is worded well enough to be understood

```
➜  2021.12.17 git:(stable) ./bin/youtube-dl -Uv --no-geo-bypass --cookies discoveryplus.com_cookies.txt https://www.discoveryplus.com/video/homestead-rescue/hardcore-homesteading
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-Uv', '--no-geo-bypass', '--cookies', 'discoveryplus.com_cookies.txt', 'https://www.discoveryplus.com/video/homestead-rescue/hardcore-homesteading']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2021.12.17
[debug] Git HEAD: 3748bed37
[debug] Proxy map: {}
It looks like you installed youtube-dl with a package manager, pip, setup.py or a tarball. Please use that to update.
yoooo im here using common downloader
[DiscoveryPlus] homestead-rescue/hardcore-homesteading: Downloading JSON metadata
[DiscoveryPlus] 846793: Downloading JSON metadata
hello there: ext: mpd format_id: dash
[DiscoveryPlus] homestead-rescue/hardcore-homesteading: Downloading MPD manifest
urlh.geturl:https://dplus-northamerica.media-edge.prod-vod.h264.io/82a6a9c8-8581-42f8-b83d-f7aec5daccf5/dash_clear_fmp4/edge-cache-token=Expires=9999999999&KeyName=media-edge-key-prod-northamerica-200d417&Signature=[REDACTED]/master.mpd
Traceback (most recent call last):
  File "/youtube-dl/2021.12.17/./bin/youtube-dl", line 33, in <module>
    sys.exit(load_entry_point('youtube-dl==2021.12.17', 'console_scripts', 'youtube-dl')())
  File "__init__.py", line 475, in main
    _real_main(argv)
  File "__init__.py", line 465, in _real_main
    retcode = ydl.download(all_urls)
  File "YoutubeDL.py", line 2070, in download
    res = self.extract_info(
  File "YoutubeDL.py", line 810, in extract_info
    return self.__extract_info(url, ie, download, extra_info, process)
  File "YoutubeDL.py", line 817, in wrapper
    return func(self, *args, **kwargs)
  File "YoutubeDL.py", line 838, in __extract_info
```
This bug is related to #4147 but that fix didnt quite resolve the issue.  The signature and expiration from the .mpd file is getting dropped when parsing the xml and appending the resources to the base_url.  I'm not sure what the proper fix is, but I was able to fix it with this kludge of a hack:

```python
    def _extract_mpd_formats(self, mpd_url, video_id, mpd_id=None, note=None, errnote=None, fatal=True, data=None, headers={}, query={}):

[...]
        mpd_base_url = base_url(urlh.geturl())


        mpd_base_url = urlh.geturl().replace("master.mpd", "")
```


### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
➜  2021.12.17 git:(stable) ./bin/youtube-dl -Uv --no-geo-bypass --cookies discoveryplus.com_cookies.txt https://www.discoveryplus.com/video/homestead-rescue/hardcore-homesteading
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-Uv', '--no-geo-bypass', '--cookies', 'discoveryplus.com_cookies.txt', 'https://www.discoveryplus.com/video/homestead-rescue/hardcore-homesteading']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2021.12.17
[debug] Git HEAD: 3748bed37
[debug] Proxy map: {}
It looks like you installed youtube-dl with a package manager, pip, setup.py or a tarball. Please use that to update.
yoooo im here using common downloader
[DiscoveryPlus] homestead-rescue/hardcore-homesteading: Downloading JSON metadata
[DiscoveryPlus] 846793: Downloading JSON metadata
hello there: ext: mpd format_id: dash
[DiscoveryPlus] homestead-rescue/hardcore-homesteading: Downloading MPD manifest
urlh.geturl:https://dplus-northamerica.media-edge.prod-vod.h264.io/82a6a9c8-8581-42f8-b83d-f7aec5daccf5/dash_clear_fmp4/edge-cache-token=Expires=9999999999&KeyName=media-edge-key-prod-northamerica-200d417&Signature=[REDACTED]/master.mpd
Traceback (most recent call last):
  File "/youtube-dl/2021.12.17/./bin/youtube-dl", line 33, in <module>
    sys.exit(load_entry_point('youtube-dl==2021.12.17', 'console_scripts', 'youtube-dl')())
  File "__init__.py", line 475, in main
    _real_main(argv)
  File "__init__.py", line 465, in _real_main
    retcode = ydl.download(all_urls)
  File "YoutubeDL.py", line 2070, in download
    res = self.extract_info(
  File "YoutubeDL.py", line 810, in extract_info
    return self.__extract_info(url, ie, download, extra_info, process)
  File "YoutubeDL.py", line 817, in wrapper
    return func(self, *args, **kwargs)
  File "YoutubeDL.py", line 838, in __extract_info
```