yt-dlp: CeskaTelevize broken

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • I understand that I will be blocked if I intentionally remove or skip any mandatory* field

Checklist

Region

Should be available everywhere

Provide a description that is worded well enough to be understood

Looks like something has been changed in this web today.

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • If using API, add 'verbose': True to YoutubeDL params instead
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

[debug] Command-line config: ['-vU', 'https://www.ceskatelevize.cz/porady/10078945173-kouzlo-afriky/205552110600001/']
[debug] User config "C:\Users\jiri\yt-dlp.conf": ['--user-agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36', '--no-check-certificate', '--sponsorblock-remove', 'all', '-o', 'D:\\Downloads\\yt-dlp\\%(autonumber)03d_%(title)s.%(ext)s', '--no-mtime', '--format', 'bestvideo[ext=mp4][height<=1080][fps<=30]+bestaudio[ext=m4a]/best[ext=mp4][height<=1080][fps<=30]/best[height<=1080][fps<=30]/best', '--merge-output-format', 'mkv', '--ffmpeg-location', 'C:\\Apps\\ffmpeg\\bin\\ffmpeg.exe', '--all-subs', '-i', '--compat-options', 'multistreams', '--remux-video', 'mkv', '--add-header', 'accept-language: cs,fi;q=0.9,en-US;q=0.8,en;q=0.7,en-GB;q=0.6', '--add-header', 'sec-ch-ua: "Chromium";v="94", "Google Chrome";v="94", ";Not A Brand";v="99"', '--add-header', 'sec-ch-ua-arch: "x86"', '--add-header', 'sec-ch-ua-bitness: "64"', '--add-header', 'sec-ch-ua-full-version: "94.0.4606.71"', '--add-header', 'sec-ch-ua-mobile: ?0', '--add-header', 'sec-ch-ua-model: ""', '--add-header', 'sec-ch-ua-platform: "Windows"', '--add-header', 'sec-ch-ua-platform-version: "10.0.0"', '--add-header', 'sec-fetch-dest: document', '--add-header', 'sec-fetch-mode: navigate', '--add-header', 'sec-fetch-site: none', '--add-header', 'sec-fetch-user: ?1', '--add-header', 'service-worker-navigation-preload: true', '--add-header', 'upgrade-insecure-requests: 1', '--add-header', 'alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"', '--add-header', 'cache-control: no-cache, no-store, max-age=0, must-revalidate']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2023.03.04 [392389b7d] (win_exe)
[debug] Compatibility options: multistreams
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-10-10.0.19045-SP0 (OpenSSL 1.1.1k  25 Mar 2021)
[debug] exe versions: ffmpeg 4.4-full_build-www.gyan.dev (setts), ffprobe 4.4-full_build-www.gyan.dev, phantomjs 2.1.1

[debug] Optional libraries: Cryptodome-3.17, brotli-1.0.9, certifi-2022.12.07, mutagen-1.46.0, sqlite3-2.6.0, websockets-10.4
[debug] Proxy map: {}
[debug] Loaded 1786 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Available version: stable@2023.03.04, Current version: stable@2023.03.04
Current Build Hash: 5590c57bd0433ed239a2deaaf92e2ad6f37fe50f53664c821575cafe106a9421
yt-dlp is up to date (stable@2023.03.04)
[CeskaTelevize] Extracting URL: https://www.ceskatelevize.cz/porady/10078945173-kouzlo-afriky/205552110600001/
[CeskaTelevize] 205552110600001: Downloading webpage
[CeskaTelevize] 205552110600001: Getting IFRAME hash
ERROR: [CeskaTelevize] 205552110600001: Unable to download webpage: 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 "yt_dlp\extractor\common.py", line 694, in extract
  File "yt_dlp\extractor\ceskatelevize.py", line 122, in _real_extract
  File "yt_dlp\extractor\common.py", line 1097, in _download_webpage
  File "yt_dlp\extractor\common.py", line 1048, in download_content
  File "yt_dlp\extractor\common.py", line 882, in _download_webpage_handle
  File "yt_dlp\extractor\common.py", line 839, in _request_webpage

  File "yt_dlp\extractor\common.py", line 821, in _request_webpage
  File "yt_dlp\YoutubeDL.py", line 3742, in urlopen
  File "urllib\request.py", line 531, in open
  File "urllib\request.py", line 640, in http_response
  File "urllib\request.py", line 569, in error
  File "urllib\request.py", line 502, in _call_chain
  File "urllib\request.py", line 649, in http_error_default
urllib.error.HTTPError: HTTP Error 404: Not Found

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 14
  • Comments: 131 (30 by maintainers)

Commits related to this issue

Most upvoted comments

Is a merge into yt-dlp/yt-dlp planned or is there something that prevents it?

Hello, i just tried to download from this link: https://www.ceskatelevize.cz/porady/901363-chalupari/275320075140001/ , and it doesn’t work. It gives “Error 404”. What have to be done, in order to download from Ceska Televize? Thank you very much!

P.S. By the way, i can’t even watch the videos on the website, because it always gives errors… I have tried a lot of things, but nothing worked. I use Mozilla Firefox with uBlock Origin.

Hi @User4516150 your link can be download with this build https://github.com/bashonly/yt-dlp/releases/tag/ceskatelevize enjoy

https://github.com/bashonly/yt-dlp/releases/tag/ceskatelevize

yt-dlp --update-to bashonly/yt-dlp@ceskatelevize

@asd123-007 @dirkf @bluenitepk

Hello. Now works this pre-release build of yt-dlp : https://github.com/bashonly/yt-dlp/releases/tag/ceskatelevize

You can change your yt-dlp version to this by using yt-dlp --update-to bashonly/yt-dlp@ceskatelevize

Then you can return back to last official stable version of yt-dlp by using yt-dlp --update-to yt-dlp/yt-dlp

I managed to change the extractor so, that I am able to download at least an item of “porady”. Not tested much. Just the first attempt. Definitely not ready for production. Feel free to improve. It manages to download Czech subtitles as well. However, it does not choose the right format if “bestaudio+bestvideo” is not used (and I do not know why).

I tried to run it for:

import re
import urllib.parse

from .common import InfoExtractor

from ..utils import (
    ExtractorError,
    float_or_none,
    traverse_obj,
)

STREAM_DATA_MEDIA_API_URL_PREFIX = "https://api.ceskatelevize.cz/video/v1/playlist-vod/v1/stream-data/media/external/"
STREAM_DATA_API_URL_POSTFIX = "?canPlayDrm=true"
STREAM_DATA_BONUS_API_URL_PREFIX = "https://api.ceskatelevize.cz/video/v1/playlist-vod/v1/stream-data/bonus/BO-"
STREAM_DATA_INDEX_API_URL_PREFIX = "https://api.ceskatelevize.cz/video/v1/playlist-vod/v1/stream-data/index/"


class CeskaTelevizeIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?ceskatelevize\.cz/porady/(?:[^/?#&]+/)*(?P<id>[^/#?]+)'

    def _real_extract(self, url):
        playlist_id = self._match_id(url)
        webpage, urlh = self._download_webpage_handle(url, playlist_id)
        parsed_url = urllib.parse.urlparse(urlh.url)
        site_name = self._og_search_property('site_name', webpage, fatal=False, default='Česká televize')
        playlist_title = self._og_search_title(webpage, default=None)
        if site_name and playlist_title:
            playlist_title = re.split(rf'\s*[—|]\s*{site_name}', playlist_title, maxsplit=1)[0]
        playlist_description = self._og_search_description(webpage, default=None)
        if playlist_description:
            playlist_description = playlist_description.replace('\xa0', ' ')

        if not '/porady/' in parsed_url.path:
            raise ExtractorError('Only "porady" supported.')

        next_data = self._search_nextjs_data(webpage, playlist_id)
        idec = traverse_obj(next_data, ('props', 'pageProps', 'data', ('show', 'mediaMeta'), 'idec'), get_all=False)
        _type = "idec"

        if "/cast/" in traverse_obj(next_data, ('page')):
            indexId = traverse_obj(next_data, ('query', 'indexId'))
            _type = "index"
        if not idec:
            idec = traverse_obj(next_data, ('props', 'pageProps', 'data', 'videobonusDetail', 'bonusId'), get_all=False)
            _type = "bonus"
        if not idec:
            raise ExtractorError('Failed to find IDEC id')

        try:
            if _type == "idec":
                api_response = self._download_json(
                    STREAM_DATA_MEDIA_API_URL_PREFIX + idec + STREAM_DATA_API_URL_POSTFIX,
                    idec, note='Getting stream data media api json')
            elif _type == "bonus":
                api_response = self._download_json(
                    STREAM_DATA_BONUS_API_URL_PREFIX + idec + STREAM_DATA_API_URL_POSTFIX,
                    "BO-" + idec, note='Getting stream data bonus api json')
            elif _type == "index":
                api_response = self._download_json(
                    STREAM_DATA_INDEX_API_URL_PREFIX + indexId + STREAM_DATA_API_URL_POSTFIX,
                    idec + '/' + indexId, note='Getting stream data bonus api json')
        except ExtractorError as ex:
            self.to_screen("Error: %s" % ex.msg)
            NOT_AVAILABLE_STRING = 'This content is not available. Possibly georestricted or license expired.'
            raise ExtractorError(NOT_AVAILABLE_STRING, expected=True)

        entries = []
        for stream_index, stream in enumerate(api_response['streams']):
            stream_formats = self._extract_mpd_formats(
                stream['url'], idec,
                # mpd_id=f'dash-{format_id}', fatal=False)
                fatal=False)
            if 'drmOnly=true' in stream['url']:
                for f in stream_formats:
                    f['has_drm'] = True

            title = api_response['title']

            duration = float_or_none(stream.get('duration'))
            thumbnail = api_response.get('previewImageUrl')

            subtitles = {}
            subs = stream.get('subtitles')
            if subs:
                subtitles = self.extract_subtitles(playlist_id, subs)

            final_title = playlist_title or title
            if len(api_response['streams']) > 1:
                final_title = "%s %d" % (final_title, stream_index+1)

            entries.append({
                'id': playlist_id,
                'title': final_title,
                'description': playlist_description,
                'thumbnail': thumbnail,
                'duration': duration,
                'formats': stream_formats,
                'subtitles': subtitles,
                'is_live': 0,
            })

        if len(entries) == 1:
            return entries[0]
        return self.playlist_result(entries, playlist_id, playlist_title, playlist_description)

    def _get_subtitles(self, episode_id, subs):
        url = None
        for sub in subs:
            if sub['language'] == 'ces':
                for file in sub['files']:
                    if file['format'] == 'vtt':
                        url = file['url']
                        break
                break
        if url is None:
            return {}

        original_subtitles = self._download_webpage(
            url, episode_id, 'Downloading subtitles')
        srt_subs = self._fix_subtitles(original_subtitles)
        return {
            'cs': [{
                'ext': 'srt',
                'data': srt_subs,
            }],
        }

    @staticmethod
    def _fix_subtitles(subtitles):
        """ Convert millisecond-based subtitles to SRT """

        def _msectotimecode(msec):
            """ Helper utility to convert milliseconds to timecode """
            components = []
            for divider in [1000, 60, 60, 100]:
                components.append(msec % divider)
                msec //= divider
            return '{3:02}:{2:02}:{1:02},{0:03}'.format(*components)

        def _fix_subtitle(subtitle):
            for line in subtitle.splitlines():
                m = re.match(r'^\s*([0-9]+);\s*([0-9]+)\s+([0-9]+)\s*$', line)
                if m:
                    yield m.group(1)
                    start, stop = (_msectotimecode(int(t)) for t in m.groups()[1:])
                    yield f'{start} --> {stop}'
                else:
                    yield line

        return '\r\n'.join(_fix_subtitle(subtitles))

There were some objections to the pull request which make perfect sense from project’s point of view but are kind of pain for someone unfamiliar with the yt-dlp code and even python. I tried to address them but things kept getting more and more complicated as I would also have to address unrelated issues which have existed before my pull request. At some point I gave up.

Right now I keep updating my mk/cz branch by merging master once in a while and as long as it works well enough for my needs, I’m fine with it. Of course it would be much better to have the extractor fixed in mainline but I don’t think I’m the right person for such task. Anyone who is (unlike me) familiar with python and (unlike me) has time to do all the cleanups necessary for the pull request to be acceptable by the project is very much welcome to take over.

G:>yt-dlp.exe https://www.ceskatelevize.cz/porady/898901-dobrodruzstvi-kriminalistiky/200353910560004/ [CeskaTelevize] Extracting URL: https://www.ceskatelevize.cz/porady/898901-dobrodruzstvi-kriminalistiky/200353910560004/ [CeskaTelevize] 200353910560004: Downloading webpage [CeskaTelevize] 200353910560004: Getting IFRAME hash ERROR: [CeskaTelevize] 200353910560004: Unable to download webpage: 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

G:>yt-dlp -U Latest version: stable@2023.12.30 from yt-dlp/yt-dlp yt-dlp is up to date (stable@2023.12.30 from yt-dlp/yt-dlp)

I have used the following temporary workaround to download a movie and an episode of a TV show.

https://github.com/std-move/yt-dlp/commit/7692c2d0ce82771b9866796d68efefb88c878cb9

It is not a proper fix, but should work for most things until such is made. Hope someone finds it useful.

I’ve found a workaround how to download video from CT . You’ll need a browser and its network monitor to catch .mpd file from source. For example here is source and from browser’s network monitor you’ll catch the link to .mpd file here.

The link to .mpd file is the URL for the yt-dlp.exe command line.

You can even use normal yt-dlp release 😉.

EDIT: It seems that .mpd file is valid only for some period of time.

@cimenta try yt-dlp --update-to bashonly/yt-dlp@ceskatelevize with your working installation

I plan to tak a look at it again this weekend to see what should be kept and what can go and then submit a pull request.

I’ve found a workaround how to download video from CT . You’ll need a browser and its network monitor to catch .mpd file from source…

I confirm the workaround functionality (yt-dlp stable@2025.04.30) and the temporariness of the .mpd file addres. In my case, for example:

https://ivys-st37-5.o2tv.cz/atip/003b3f34afb1f0607357c2280b69b186/1747516901412/subscru/5b9a5d19-d6f4-4f78-beb5-5f73b96a32aa/61924494878398917-1080p_5-0-3773.mpd
https://ivys-st37-5.o2tv.cz/atip/e2ebab0fe7038a92bcc04379a3cd5306/1747521670594/subscru/fd64510f-2f77-477f-85da-6b372348dc9f/61924494878398917-1080p_5-0-3773.mpd

Thanks for sharing 👍

(Finally, a masterpiece that makes Vogon poetry sound like Shakespeare! 🙈🙉🙊)

Open issue = Not resolved

@jirih Regarding your comment - I would add following 2 changes:

  1. indicate to API that DRM content is supported - without it the API fails with misleading error about geoblocking
  2. add chapters
diff --git a/yt_dlp/extractor/ceskatelevize.py b/yt_dlp/extractor/ceskatelevize.py
index fd035f4cd..b985be6ef 100644
--- a/yt_dlp/extractor/ceskatelevize.py
+++ b/yt_dlp/extractor/ceskatelevize.py
@@ -47,11 +47,14 @@ def _real_extract(self, url):
         if not idec:
             raise ExtractorError('Failed to find IDEC id')
 
+        # indicate to API that DRM content is supported
+        query = { "canPlayDrm": "true" }
+
         try:
             if _type == "idec":
                 api_response = self._download_json(
                     STREAM_DATA_MEDIA_API_URL_PREFIX + idec,
-                    idec, note='Getting stream data media api json')
+                    idec, note='Getting stream data media api json', query=query)
             elif _type == "bonus":
                 api_response = self._download_json(
                     STREAM_DATA_BONUS_API_URL_PREFIX + idec,
@@ -93,6 +96,15 @@ def _real_extract(self, url):
             if subs:
                 subtitles = self.extract_subtitles(playlist_id, subs)
 
+            chapters = []
+            if stream.get('indexes'):
+                chapters = self._extract_chapters_helper(
+                    stream.get('indexes'),
+                    start_function=lambda x: x.get('time'),
+                    title_function=lambda x: x.get('title'),
+                    duration=duration
+                )
+
             final_title = playlist_title or title
             if len(api_response['streams']) > 1:
                 final_title = "%s %d" % (final_title, stream_index+1)
@@ -105,6 +117,7 @@ def _real_extract(self, url):
                 'duration': duration,
                 'formats': stream_formats,
                 'subtitles': subtitles,
+                'chapters': chapters,
                 'is_live': 0,
             })
 

Hi, thanks @JakubSvestka for hints and API.

I managed to create a wrapper around yt-dlp, which extracts idec number (this is the key information) from a webpage and pass it to CT API, output is processed by jq and yt-dlp manages the rest. Works for series (as previous mentioned commands) and also movies. It is a simple bash script (so no windows compatibility) depending on:

Save it to a file (add execution privilege) and run it with URL as first parameter.

#!/bin/bash

# downloader from czech tv (ivysilani.cz)
# $1: url of video page
# dependencies: jq, grep, awk, yt-dlp

# debugging
set -o xtrace

base_url="$1"

# IDEC is a code of video file
streamid="$(curl $1 | grep -o -e '"idec":"[0-9]*"' | head -n1 | awk -F\" '{print $4}')"

# get info from CT API
fileinfo="$(curl --location "https://api.ceskatelevize.cz/video/v1/playlist-vod/v1/stream-data/media/external/$streamid")"

# extract name of video
name="$(jq -r '.title' <<< "$fileinfo" | sed -e "s/|/-/g")"

# extract URL of playable file
url=$(jq -r '.streams.[].url' <<< "$fileinfo" | sed -e "s/\"//g")

# passing to yt-dlp ; linux only
yt-dlp -o "$name.%(ext)s" $url

Examples of usage:

./script.sh https://www.ceskatelevize.cz/porady/15184414585-alpy/223382576600002/
./script.sh https://www.ceskatelevize.cz/porady/11934992498-babovky/

Naming convention of resulting file is not so beautiful (regarding series, because number of episode is at the end), but maybe it will be useful for others 😃

@huh02 @JakubSvestka

Success! Thanks for cooperation.

w:\YT-DLP>yt-dlp.exe "https://ivys-nw-cdn.o2tv.cz/cdn/uri/get/?token=9741c0f2108ca80fe87243460c05641dcec2be79&userId=20625083-fcc0-4145-bfda-6f0cd32e4155&contentId=61924494878395426&streamType=dash&quality=1080p&contentType=vod&region=1&expiry=1736638236&drmOnly=false&startOffset=0&endOffset=1557&qualityCount=5"
[generic] Extracting URL: https://ivys-nw-cdn.o2tv.cz/cdn/uri/get/?token=9741c0f2108ca80fe87243460c05641dcec2be79&userId=20...=1557&qualityCount=5
[generic] ?token=9741c0f2108ca80fe87243460c05641dcec2be79&userId=20625083-fcc0-4145-bfda-6f0cd32e4155&contentId=61924494878395426&streamType=dash&quality=1080p&contentType=vod&region=1&expiry=1736638236&drmOnly=false&startOffset=0&endOffset=1557&qualityCount=5: Downloading webpage
[redirect] Following redirect to https://ivys-st32-5.o2tv.cz/atip/ca8bec2980f4e42f8ef3a8fe527aefd7/1736634707473/subscru/20625083-fcc0-4145-bfda-6f0cd32e4155/61924494878395426-1080p_5-0-1557.mpd
[generic] Extracting URL: https://ivys-st32-5.o2tv.cz/atip/ca8bec2980f4e42f8ef3a8fe527aefd7/1736634707473/subscru/20625083-...6-1080p_5-0-1557.mpd
[generic] 61924494878395426-1080p_5-0-1557: Downloading webpage
WARNING: [generic] Falling back on generic information extractor
[generic] 61924494878395426-1080p_5-0-1557: Extracting information
[info] 61924494878395426-1080p_5-0-1557: Downloading 1 format(s): 1001-1506+1002-1502
[dashsegments] Total fragments: 780
[download] Destination: 61924494878395426-1080p_5-0-1557 [61924494878395426-1080p_5-0-1557].f1001-1506.mp4
[download] 100% of    1.09GiB in 00:01:07 at 16.56MiB/s
[dashsegments] Total fragments: 780
[download] Destination: 61924494878395426-1080p_5-0-1557 [61924494878395426-1080p_5-0-1557].f1002-1502.m4a
[download] 100% of   24.46MiB in 00:00:16 at 1.50MiB/s
[Merger] Merging formats into "61924494878395426-1080p_5-0-1557 [61924494878395426-1080p_5-0-1557].mp4"
Deleting original file 61924494878395426-1080p_5-0-1557 [61924494878395426-1080p_5-0-1557].f1002-1502.m4a (pass -k to keep)
Deleting original file 61924494878395426-1080p_5-0-1557 [61924494878395426-1080p_5-0-1557].f1001-1506.mp4 (pass -k to keep)

@dirkf @bashonly @mkubecek @mtrakal @Radek-Bastar

I tried to download video from here https://www.ceskatelevize.cz/porady/10116288585-archiv-ct24/224411058210005/ but without success. I tried official version “stable@2024.12.23” and version “bashonly/yt-dlp@ceskatelevize build 2024.12.13.144700” and version from “mkubecek”. With the second and third version was downloaded short video with static picture containing text “Je nám líto, ale Vaše verze aplikace již není podporována, doporučujeme aktualizaci/We’re sorry, but your version of the app is no longer supported, we recommend updating”. You can see it here https://imgur.com/y9tFOGE

@cimenta if that build doesn’t work, then the PR no longer does either, and there is no version available that works

@bashonly sorry my bad. I deleted my last post when I realized it did not work because the movie was just on TV. Once it finished I was able to download. At the time I tried there was a play button but later on the button disappeared. So I realized my mistake.

@barth11 if it’s DRM-protected there is nothing we can do. yt-dlp does not support downloading DRM content and no help will be provided on this tracker for it.

@pschonmann Unfortunately the fix hasn’t been merged into the master branch yet, so it’s not part of regular releases. As of now, you’d need to run from source and cherry-pick the fix or use custom builds with it included.

IMHO the key question is if this used to work the way you expect before the March changes. (In other words, if it is actually related to my pull request.) To be honest, I do not really have ambition to take over maintaining this extractor, all I wanted was to make it work again after recent site rework. Unfortunately this got out of hand quickly with a series of follow-up requests to address issues I believe already existed before. I’m not really familiar with the yt-dlp codebase - or even python, actually - and fixing every issue that has accumulated over years is definitely not something I would like to invest my time into.

@mufak76 Here is compiled version which should not depend on anything.