question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ARDMediathek HTTP Error 412: Precondition Failed for some videos

See original GitHub issue

Checklist

  • I’m reporting a broken site support
  • I’ve verified that I’m running youtube-dl version 2021.04.26
  • I’ve checked that all provided URLs are alive and playable in a browser
  • I’ve checked that all URLs and arguments with special characters are properly quoted or escaped
  • I’ve searched the bugtracker for similar issues including closed ones

Verbose log

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--ignore-config', '-v', 'https://ardmediathek.de/video/feuer-und-flamme/feuer-und-flamme-s01-e01/wdr-fernsehen/Y3JpZDovL3dkci5kZS9CZWl0cmFnLTM1Y2IwM2VkLTNkOTgtNDBkZC1iZjIxLTU1ZjFjODE4MmFlNw/']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2021.04.26
[debug] Python version 3.9.4 (CPython) - Linux-5.12.0-1-MANJARO-x86_64-with-glibc2.33
[debug] exe versions: ffmpeg 4.3.2, ffprobe 4.3.2, rtmpdump 2.4
[debug] Proxy map: {}
[debug] Using fake IP 53.50.219.112 (DE) as X-Forwarded-For.
[ARDBetaMediathek] Y3JpZDovL3dkci5kZS9CZWl0cmFnLTM1Y2IwM2VkLTNkOTgtNDBkZC1iZjIxLTU1ZjFjODE4MmFlNw: Downloading JSON metadata
ERROR: Unable to download JSON metadata: HTTP Error 412: Precondition Failed (caused by <HTTPError 412: 'Precondition Failed'>); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
  File "/usr/lib/python3.9/site-packages/youtube_dl/extractor/common.py", line 634, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/usr/lib/python3.9/site-packages/youtube_dl/YoutubeDL.py", line 2279, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/usr/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.9/urllib/request.py", line 561, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.9/urllib/request.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)

Description

Youtube-dl fails for some videos of the ARDMediathek. An example video is https://ardmediathek.de/video/feuer-und-flamme/feuer-und-flamme-s01-e01/wdr-fernsehen/Y3JpZDovL3dkci5kZS9CZWl0cmFnLTM1Y2IwM2VkLTNkOTgtNDBkZC1iZjIxLTU1ZjFjODE4MmFlNw/

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15

github_iconTop GitHub Comments

8reactions
yawkatcommented, May 4, 2021

This issue is caused by the player_page graphql query ( https://github.com/ytdl-org/youtube-dl/blob/master/youtube_dl/extractor/ard.py#L379 ). Removing the tracking block from the query appears to fix the issue in my local testing:

===================================================================
diff --git a/youtube_dl/extractor/ard.py b/youtube_dl/extractor/ard.py
--- a/youtube_dl/extractor/ard.py	(revision a0df8a06178e530a1097f177a1faf1d2c609ac99)
+++ b/youtube_dl/extractor/ard.py	(date 1620143870131)
@@ -404,11 +404,6 @@
     }
     synopsis
     title
-    tracking {
-      atiCustomVars {
-        contentId
-      }
-    }
   }
 }''' % video_id,
             }).encode(), headers={

I don’t know if this fix works for all videos that have this issue, or why it works, so I am not going to PR this.

3reactions
burk-castlehardcommented, May 7, 2021

definetly a problem depending on your own IP or provider. Just checked the exactly same download from two different systems with two different providers. one gives the error (deutsche telekom) , the other (versatel) runs fine. (for ONE time only. then the download fails exactly the same way, so maybe just try the download twice fore reproducing) So that geoblocking somehow seems to be the problem. If that @yawkat workaround works with everything it should be implemented for all the others and published, please.

Read more comments on GitHub >

github_iconTop Results From Across the Web

412 Precondition Failed - HTTP - MDN Web Docs
The HyperText Transfer Protocol (HTTP) 412 Precondition Failed client error response code indicates that access to the target resource has been denied.
Read more >
How to fix 412 (Precondition Failed) Error HTML5 Video Tag
I got a temporary solution which helped me to make it working. Here is my code in which I am appending milli-seconds to...
Read more >
412 Precondition Failed error on setting v3 in the Maven ...
If the build fails during the deploy stage with a status code of 412 (Precondition Failed), then <goal>exchange-pre-deploy</goal> was not executed. SOLUTION
Read more >
412 Precondition Failed - HTTP Status Code Glossary - WebFX
HTTP Status Code 412: One or more conditions given in the request header fields evaluated to false when tested on the server.
Read more >
Error "412 Precondition Failed" (mod_security2) - Online manual
When this happens, the error message returned by the server is 412 Request Blocked (Precondition failed). You can disable certain blocking rules, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found