mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-19 22:46:20 -05:00
Checking for corruption in bytes to avoid unicode error.
This commit is contained in:
parent
df72735289
commit
c681c500e8
3 changed files with 10 additions and 8 deletions
3
main.py
3
main.py
|
|
@ -54,6 +54,9 @@ videos = list(videos)
|
|||
for video in videos:
|
||||
get_video_duration(video.video_path.path)
|
||||
|
||||
Check local variables:
|
||||
locals().keys()
|
||||
|
||||
'''
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -275,14 +275,13 @@ def check_for_video_corruption(video_path: Path) -> bool:
|
|||
return True # video is corrupt.
|
||||
|
||||
messages = (
|
||||
'Invalid NAL unit size',
|
||||
'Error splitting the input into NAL units',
|
||||
b'Invalid NAL unit size',
|
||||
b'Error splitting the input into NAL units',
|
||||
)
|
||||
stderr = proc.stderr.decode()
|
||||
corrupt = False
|
||||
for error in messages:
|
||||
if error in stderr:
|
||||
logger.warning(f'Possible video corruption ({error}): {video_path}')
|
||||
if error in proc.stderr:
|
||||
logger.warning(f'Possible video corruption ({error.decode()}): {video_path}')
|
||||
corrupt = True
|
||||
return corrupt
|
||||
|
||||
|
|
|
|||
|
|
@ -435,9 +435,9 @@ def test_check_for_video_corruption(video_file, test_directory):
|
|||
# Check for specific ffprobe errors.
|
||||
with mock.patch('modules.videos.common.subprocess') as mock_subprocess:
|
||||
# `video_file` is ignored for these calls.
|
||||
mock_subprocess.run().stderr.decode.return_value = 'Something\nInvalid NAL unit size'
|
||||
mock_subprocess.run().stderr = b'Something\nInvalid NAL unit size'
|
||||
assert common.check_for_video_corruption(video_file) is True
|
||||
mock_subprocess.run().stderr.decode.return_value = 'Something\nError splitting the input into NAL units'
|
||||
mock_subprocess.run().stderr = b'Something\nError splitting the input into NAL units'
|
||||
assert common.check_for_video_corruption(video_file) is True
|
||||
mock_subprocess.run().stderr.decode.return_value = 'Some stderr is fine'
|
||||
mock_subprocess.run().stderr = b'Some stderr is fine'
|
||||
assert common.check_for_video_corruption(video_file) is False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue