youtube-dl: ARDMediathek HTTP Error 412: Precondition Failed for some videos

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/

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15

Most upvoted comments

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.

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.

@dstftw , please reopen this issue as it appears to be affecting multiple users (including myself on https://www.ardmediathek.de/video/feuer-und-flamme/schwerer-verkehrsunfall-oder-mit-gifttieren-ueben-fuer-den-ernstfall-s04-e02/wdr-fernsehen/Y3JpZDovL3dkci5kZS9CZWl0cmFnLWViOTVkN2ExLTY4ODctNDIwMy1iYjMwLTY1MDU1NTljYmYyZg/)

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--verbose', 'https://www.ardmediathek.de/video/feuer-und-flamme/schwerer-verkehrsunfall-oder-mit-gifttieren-ueben-fuer-den-ernstfall-s04-e02/wdr-fernsehen/Y3JpZDovL3dkci5kZS9CZWl0cmFnLWViOTVkN2ExLTY4ODctNDIwMy1iYjMwLTY1MDU1NTljYmYyZg/']
[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.7.5 (CPython) - Linux-5.3.0-64-generic-x86_64-with-Ubuntu-19.10-eoan
[debug] exe versions: ffmpeg 4.1.4-1build2, ffprobe 4.1.4-1build2
[debug] Proxy map: {}
[debug] Using fake IP 53.23.236.143 (DE) as X-Forwarded-For.
[ARDBetaMediathek] Y3JpZDovL3dkci5kZS9CZWl0cmFnLWViOTVkN2ExLTY4ODctNDIwMy1iYjMwLTY1MDU1NTljYmYyZg: 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 "/home/tobias/.local/lib/python3.7/site-packages/youtube_dl/extractor/common.py", line 634, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/home/tobias/.local/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 2279, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/usr/lib/python3.7/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)

And I can confirm that @yawkat fix solves the issue for the above video.

I can confirm that @yawkat 's fix works also for https://www.ardmediathek.de/video/Y3JpZDovL2Rhc2Vyc3RlLmRlL3RhdG9ydC8wNTQxYTQwZS1iNzcxLTRhYmYtYWUzYi02MDRhOTdlMDkzOTk/ , which failed before. Please reopen @dstftw , thanks!