Repository: yt-dlp/yt-dlp

Issue:
[TNAFlix] XML download stage fails due to incorrect URL (404)
### 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 broken site
- [X] I've verified that I'm running yt-dlp version **2023.01.06** ([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)
- [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

USA

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

All extractions from this site are failing for me. I took a look through the code, and it seems like maybe the XML delivery site has changed- I can see a request made to a different URL, and if I change the extractor to use that other URL, the extraction succeeds (albeit with `--no-check-certificate`).

### 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
[debug] Command-line config: ['-vU', '--', 'https://www.tnaflix.com/amateur-porn/Lesbians-Tribbing/video6007859']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version 2023.01.06 [6becd2508] (source)
[debug] Lazy loading extractors is disabled
[debug] Git HEAD: 59d7de0da
[debug] Python 3.10.9 (CPython x86_64 64bit) - macOS-12.3.1-x86_64-i386-64bit (OpenSSL 1.1.1s  1 Nov 2022)
[debug] exe versions: ffmpeg 5.1.2 (setts), ffprobe 5.1.2
[debug] Optional libraries: sqlite3-2.6.0
[debug] Proxy map: {}
[debug] Loaded 1761 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: 2023.01.06, Current version: 2023.01.06
yt-dlp is up to date (2023.01.06)
[TNAFlix] Extracting URL: https://www.tnaflix.com/amateur-porn/Lesbians-Tribbing/video6007859
[TNAFlix] Lesbians-Tribbing: Downloading webpage
[TNAFlix] Lesbians-Tribbing: Downloading metadata
ERROR: [TNAFlix] 6007859: Unable to download XML: HTTP Error 404: Not Found (caused by <HTTPError 404: 'Not Found'>); 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 "/Users/aroberts/Source/yt-dlp/yt_dlp/extractor/common.py", line 682, in extract
    ie_result = self._real_extract(url)
  File "/Users/aroberts/Source/yt-dlp/yt_dlp/extractor/tnaflix.py", line 109, in _real_extract
    cfg_xml = self._download_xml(
  File "/Users/aroberts/Source/yt-dlp/yt_dlp/extractor/common.py", line 1036, in download_content
    res = getattr(self, download_handle.__name__)(url_or_request, video_id, **kwargs)
  File "/Users/aroberts/Source/yt-dlp/yt_dlp/extractor/common.py", line 1000, in download_handle
    res = self._download_webpage_handle(
  File "/Users/aroberts/Source/yt-dlp/yt_dlp/extractor/common.py", line 870, in _download_webpage_handle
    urlh = self._request_webpage(url_or_request, video_id, note, errnote, fatal, data=data, headers=headers, query=query, expected_status=expected_status)
  File "/Users/aroberts/Source/yt-dlp/yt_dlp/extractor/common.py", line 827, in _request_webpage
    raise ExtractorError(errmsg, cause=err)

  File "/Users/aroberts/Source/yt-dlp/yt_dlp/extractor/common.py", line 809, in _request_webpage
    return self._downloader.urlopen(self._create_request(url_or_request, data, headers, query))
  File "/Users/aroberts/Source/yt-dlp/yt_dlp/YoutubeDL.py", line 3730, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/local/Cellar/python@3.10/3.10.9/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.9/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.9/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.9/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.9/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 404: Not Found
```
```



Discussion:

Resolving patch:
diff --git a/yt_dlp/extractor/tnaflix.py b/yt_dlp/extractor/tnaflix.py
--- a/yt_dlp/extractor/tnaflix.py
+++ b/yt_dlp/extractor/tnaflix.py
@@ -81,26 +81,27 @@ def _real_extract(self, url):
             display_id = video_id
 
         webpage = self._download_webpage(url, display_id)
+        inputs = self._hidden_inputs(webpage)
+        query = {}
 
         # check for MovieFap-style config
         cfg_url = self._proto_relative_url(self._html_search_regex(
             self._CONFIG_REGEX, webpage, 'flashvars.config', default=None,
             group='url'), 'http:')
-        query = {}
 
-        # check for TNAFlix-style config
         if not cfg_url:
-            inputs = self._hidden_inputs(webpage)
-            if inputs.get('vkey') and inputs.get('nkey'):
-                cfg_url = f'https://www.{host}.com/cdn/cdn.php'
-                query.update({
-                    'file': inputs['vkey'],
-                    'key': inputs['nkey'],
-                    'VID': video_id,
-                    'premium': '1',
-                    'vip': '1',
-                    'alpha': '',
-                })
+            cfg_url = inputs.get('config')
+
+        # check for TNAFlix-style config
+        if not cfg_url and inputs.get('vkey') and inputs.get('nkey'):
+            cfg_url = f'http://cdn-fck.{host}.com/{host}/{inputs["vkey"]}.fid'
+            query.update({
+                'key': inputs['nkey'],
+                'VID': video_id,
+                'premium': '1',
+                'vip': '1',
+                'alpha': '',
+            })
 
         formats, json_ld = [], {}
 


Test patch: