From afa7bf3d8ca26a0848650407a7cf938072179504 Mon Sep 17 00:00:00 2001 From: neingeist Date: Sun, 23 May 2021 14:05:53 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20check-resolution-tags:=20Check=20me?= =?UTF-8?q?dia=20file=20names=20for=20resolution=20tags=20(.720p.=20etc.)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- check-resolution-tags | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 check-resolution-tags diff --git a/check-resolution-tags b/check-resolution-tags new file mode 100755 index 0000000..5517626 --- /dev/null +++ b/check-resolution-tags @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +"""Check media file names for resolution tags (.720p. etc.)""" + +from pymediainfo import MediaInfo +import argparse + + +parser = argparse.ArgumentParser(description='Check media file names for resolution tags') +parser.add_argument('filename', nargs='+', help='media file name(s)') +args = parser.parse_args() + + +for fn in args.filename: + try: + media_info = MediaInfo.parse(fn) + tracks = (track for track in media_info.tracks if track.track_type == 'Video') + for track in tracks: + if track.height in [720, 1080, 2160]: + desired_tag = '.%dp.' % track.height + elif track.width == 1280 and 576 < track.height <= 720: + desired_tag = '.%dp.' % 720 + elif track.width == 1920 and 720 < track.height <= 1080: + desired_tag = '.%dp.' % 1080 + elif track.height > 576: + print('{} has strange dimensions of {}x{}'.format(fn, track.width, track.height)) + continue + else: + continue + + if desired_tag not in fn: + print('{} should have "{}" resolution tag'.format(fn, desired_tag)) + except FileNotFoundError as e: + print("File not found: {}".format(fn)) + +# vim:tw=120: