mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-21 22:03:13 -07:00
Use pathlib.Path for is_video_good
This commit is contained in:
parent
fc3d6a5744
commit
b907d76bba
1 changed files with 9 additions and 9 deletions
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
||||||
import errno
|
import errno
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import pathlib
|
||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -19,9 +20,8 @@ from core.utils.paths import make_dir
|
||||||
__author__ = 'Justin'
|
__author__ = 'Justin'
|
||||||
|
|
||||||
|
|
||||||
def is_video_good(videofile, status, require_lan=None):
|
def is_video_good(video: pathlib.Path, status, require_lan=None):
|
||||||
file_name_ext = os.path.basename(videofile)
|
file_ext = video.suffix
|
||||||
file_name, file_ext = os.path.splitext(file_name_ext)
|
|
||||||
disable = False
|
disable = False
|
||||||
if (
|
if (
|
||||||
file_ext not in core.MEDIA_CONTAINER
|
file_ext not in core.MEDIA_CONTAINER
|
||||||
|
@ -65,18 +65,18 @@ def is_video_good(videofile, status, require_lan=None):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f'Checking [{file_name_ext}] for corruption, please stand by ...',
|
f'Checking [{video.name}] for corruption, please stand by ...',
|
||||||
'TRANSCODER',
|
'TRANSCODER',
|
||||||
)
|
)
|
||||||
video_details, result = get_video_details(videofile)
|
video_details, result = get_video_details(video)
|
||||||
|
|
||||||
if result != 0:
|
if result != 0:
|
||||||
logger.error(f'FAILED: [{file_name_ext}] is corrupted!', 'TRANSCODER')
|
logger.error(f'FAILED: [{video.name}] is corrupted!', 'TRANSCODER')
|
||||||
return False
|
return False
|
||||||
if video_details.get('error'):
|
if video_details.get('error'):
|
||||||
error_details = video_details.get('error')
|
error_details = video_details.get('error')
|
||||||
logger.info(
|
logger.info(
|
||||||
f'FAILED: [{file_name_ext}] returned error [{error_details}].',
|
f'FAILED: [{video.name}] returned error [{error_details}].',
|
||||||
'TRANSCODER',
|
'TRANSCODER',
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
@ -103,12 +103,12 @@ def is_video_good(videofile, status, require_lan=None):
|
||||||
valid_audio = audio_streams
|
valid_audio = audio_streams
|
||||||
if len(video_streams) > 0 and len(valid_audio) > 0:
|
if len(video_streams) > 0 and len(valid_audio) > 0:
|
||||||
logger.info(
|
logger.info(
|
||||||
f'SUCCESS: [{file_name_ext}] has no corruption.', 'TRANSCODER',
|
f'SUCCESS: [{video.name}] has no corruption.', 'TRANSCODER',
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
logger.info(
|
logger.info(
|
||||||
f'FAILED: [{file_name_ext}] has {len(video_streams)} video streams and {len(audio_streams)} audio streams. Assume corruption.',
|
f'FAILED: [{video.name}] has {len(video_streams)} video streams and {len(audio_streams)} audio streams. Assume corruption.',
|
||||||
'TRANSCODER',
|
'TRANSCODER',
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue