Brisppy / twitch-archiver

A simple, fast, platform-independent tool for downloading Twitch streams, videos, and chat logs.
GNU Affero General Public License v3.0
67 stars 6 forks source link

Merging video fails with a certain VOD #33

Closed rantos9 closed 5 months ago

rantos9 commented 5 months ago

Describe the bug Merging video fails with a certain VOD

Supplied arguments twitch-archiver -v 2152363893

Error log

2024-05-24 21:56:21 [   ERROR] Exception occurred inside DownloadHandler. ['  File "/usr/local/lib/python3.9/dist-packages/twitcharchiver/processing.py", line 287, in _start_download\n    _downloader.merge()\n', '  File "/usr/local/lib/python3.9/dist-packages/twitcharchiver/downloaders/video.py", line 499, in merge\n    raise VideoMergeError("Exception raised while merging VOD.") from exc\n']
2024-05-24 21:56:21 [   ERROR] Error archiving VOD {'vod_id': 2152363893, 'stream_id': 0, 'title': 'πŸ€‘ NOT ENDING STREAM UNTIL I MAKE $100 IN DOORDASH πŸš— | 100bits TTS !socials !discord', 'description': None, 'created_at': datetime.datetime(2024, 5, 22, 16, 21, 43), 'published_at': datetime.datetime(2024, 5, 22, 16, 21, 43), 'thumbnail_url': 'https://static-cdn.jtvnw.net/cf_vods/d2nvs31859zcd8/d08e34707dce4d3a6d86_juliakins_44233131003_1716394898//thumb/thumb0-90x60.jpg', 'duration': 27031, 'chat_archived': False, 'video_archived': True}.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/twitcharchiver/downloaders/video.py", line 490, in merge
    merger.merge()
  File "/usr/local/lib/python3.9/dist-packages/twitcharchiver/downloaders/video.py", line 567, in merge
    self._convert_vod()
  File "/usr/local/lib/python3.9/dist-packages/twitcharchiver/downloaders/video.py", line 677, in _convert_vod
    _dts_offset = self._get_dts_offset()
  File "/usr/local/lib/python3.9/dist-packages/twitcharchiver/downloaders/video.py", line 792, in _get_dts_offset
    float(json.loads(_ts_file_data)["format"]["start_time"])
KeyError: 'format'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/twitcharchiver/processing.py", line 287, in _start_download
    _downloader.merge()
  File "/usr/local/lib/python3.9/dist-packages/twitcharchiver/downloaders/video.py", line 499, in merge
    raise VideoMergeError("Exception raised while merging VOD.") from exc
twitcharchiver.exceptions.VideoMergeError: Exception raised while merging VOD.

[OPTIONAL] Applicable files https://www.twitch.tv/videos/2152363893

Operating system Linux/Docker (WSL2)

Additional context I tried both with Docker and in native WSL.. Tried with both twitch-archiver 4.0.8 and twitch-archiver 4.0.7

Brisppy commented 5 months ago

Hi, thanks for opening up a PR.

Hmm, VOD seems to download fine for me.

If you've been testing by downloading the VOD to the same directory could you try deleting the parts folder inside and see if re-downloading the VOD fixes the issue? I'm wondering if it could be due to a corrupt part.

rantos9 commented 5 months ago

I tried a few times and always end up with the same error. Will try on another machine just in case. Thanks for answering so quickly!

Brisppy commented 5 months ago

Aha I've managed to get it to trigger, let me look into it and I'll see what I can do.

rantos9 commented 5 months ago

On another machine, a MacBook M2, I encountered the same error, for what it’s worth.

Brisppy commented 5 months ago

Pushed an update to the #develop branch which should fix this if you want to give it a try, the problem was the exclamation marks which weren't being escaped on Linux.

rantos9 commented 5 months ago

That fixed it! Thank you very much Brisppy!

Brisppy commented 5 months ago

Not a problem, thanks for bringing it to my attention. I'll push this out with v4.0.9.

rantos9 commented 5 months ago

Found another VOD with the same error. ID: 2129490878

Brisppy commented 5 months ago

Should be fixed again now on the #develop branch. Didn't add ' to the disallowed characters which messed with the previous fix.

rantos9 commented 5 months ago

Perfect, that solved the problem.