Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video fragments get downloaded, but concating aborts after about 68mb with a 404 error #43

Open
huzhasan opened this issue Jan 17, 2025 · 3 comments

Comments

@huzhasan
Copy link

Firstly, I looked through the other issues and I could not find anything similar happening so I am posting an issue. My setup is:

  • Windows 11
  • Python 3.13.1
  • Running the script from Windows Terminal
  • Tried with 1080p and 360p videos

I setup the url and referer correctly and the video is found correctly and all the fragments are downloaded. At this stage the progress shows 99% while ETA shows 2 seconds remaining. This is where I think the fragments are decrypted and joined to reconstruct the full video, coz the CPU usage suddenly shoots up and the *.fragxxx files start to disappear one after the other (assuming yt-dlp is doing all this), albeit very slowly.
After sometime, I get the below error:

Traceback (most recent call last):
  File "D:\Dev\Repos\Python\Media\yt_dlp\YoutubeDL.py", line 3489, in process_info
    success, real_download = self.dl(temp_filename, info_dict)
                             ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Dev\Repos\Python\Media\yt_dlp\YoutubeDL.py", line 3209, in dl
    return fd.download(name, new_info, subtitle)
           ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Dev\Repos\Python\Media\yt_dlp\downloader\common.py", line 464, in download
    ret = self.real_download(filename, info_dict)
  File "D:\Dev\Repos\Python\Media\yt_dlp\downloader\hls.py", line 381, in real_download
    return self.download_and_append_fragments(ctx, fragments, info_dict)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Dev\Repos\Python\Media\yt_dlp\downloader\fragment.py", line 500, in download_and_append_fragments
    if not append_fragment(decrypt_fragment(fragment, self._read_fragment(ctx)), frag_index, ctx):
                           ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Dev\Repos\Python\Media\yt_dlp\downloader\fragment.py", line 357, in decrypt_fragment
    or _get_key(traverse_obj(info_dict, ('hls_aes', 'uri')) or decrypt_info['URI']))
       ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Dev\Repos\Python\Media\yt_dlp\downloader\fragment.py", line 346, in _get_key
    _key_cache[url] = self.ydl.urlopen(self._prepare_url(info_dict, url)).read()
                      ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Dev\Repos\Python\Media\yt_dlp\YoutubeDL.py", line 4172, in urlopen
    return self._request_director.send(req)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "D:\Dev\Repos\Python\Media\yt_dlp\networking\common.py", line 117, in send
    response = handler.send(request)
  File "D:\Dev\Repos\Python\Media\yt_dlp\networking\_helper.py", line 208, in wrapper
    return func(self, *args, **kwargs)
  File "D:\Dev\Repos\Python\Media\yt_dlp\networking\common.py", line 340, in send
    return self._send(request)
           ~~~~~~~~~~^^^^^^^^^
  File "D:\Dev\Repos\Python\Media\yt_dlp\networking\_requests.py", line 365, in _send
    raise HTTPError(res, redirect_loop=max_redirects_exceeded)
yt_dlp.networking.exceptions.HTTPError: HTTP Error 404: Not Found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Dev\Repos\Python\Media\b-cdn-drm-vod-dl.py", line 188, in <module>
    # video.session.close()
  File "D:\Dev\Repos\Python\Media\b-cdn-drm-vod-dl.py", line 174, in download
    ydl.download(url)
    ~~~~~~~~~~~~^^^^^
  File "D:\Dev\Repos\Python\Media\yt_dlp\YoutubeDL.py", line 3615, in download
    self.__download_wrapper(self.extract_info)(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        url, force_generic_extractor=self.params.get('force_generic_extractor', False))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Dev\Repos\Python\Media\yt_dlp\YoutubeDL.py", line 3588, in wrapper
    res = func(*args, **kwargs)
  File "D:\Dev\Repos\Python\Media\yt_dlp\YoutubeDL.py", line 1623, in extract_info
    return self.__extract_info(url, self.get_info_extractor(key), download, extra_info, process)
           ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Dev\Repos\Python\Media\yt_dlp\YoutubeDL.py", line 1634, in wrapper
    return func(self, *args, **kwargs)
  File "D:\Dev\Repos\Python\Media\yt_dlp\YoutubeDL.py", line 1790, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Dev\Repos\Python\Media\yt_dlp\YoutubeDL.py", line 1849, in process_ie_result
    ie_result = self.process_video_result(ie_result, download=download)
  File "D:\Dev\Repos\Python\Media\yt_dlp\YoutubeDL.py", line 3021, in process_video_result
    self.process_info(new_info)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "D:\Dev\Repos\Python\Media\yt_dlp\YoutubeDL.py", line 177, in wrapper
    return func(self, *args, **kwargs)
  File "D:\Dev\Repos\Python\Media\yt_dlp\YoutubeDL.py", line 3498, in process_info
    self.report_error(f'unable to download video data: {err}')
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Dev\Repos\Python\Media\yt_dlp\YoutubeDL.py", line 1092, in report_error
    self.trouble(f'{self._format_err("ERROR:", self.Styles.ERROR)} {message}', *args, **kwargs)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Dev\Repos\Python\Media\yt_dlp\YoutubeDL.py", line 1031, in trouble
    raise DownloadError(message, exc_info)
yt_dlp.utils.DownloadError: ERROR: unable to download video data: HTTP Error 404: Not Found` 

When this happens, there is about 68MB of the reconstructed video in the download directory, which depending on the resolution, is 3 minutes to 13 minutes. It plays correctly so atleast it is working OK to begin with, but obviously it is not completing successfully. Tried with different videos and multiple resolutions, but fails everytime with the same error. Where could the issue be?

@huzhasan
Copy link
Author

Forgot to mention that videos, which would amount to less than 68MB when downloaded, work just fine with the script.

@Worz01
Copy link

Worz01 commented Jan 17, 2025

Forgot to mention that videos, which would amount to less than 68MB when downloaded, work just fine with the script.

Somewhat similar, or same. Since today I find the script only downloads resolutions that are < 70mb in file size. In my case it was a 240p version of a 30min clip.

@mal1k-me
Copy link
Owner

Hi. Thanks for reaching out.

This may be related to #11. Please try the fix mentioned in there and report back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants