initial commit

This commit is contained in:
2023-02-18 07:39:08 +01:00
commit e63ab7b77e
63 changed files with 7122 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env python3.9
from pathlib import Path
import subprocess
import sys
from ffmpeg import ffprobe
import logging
def get_resolution(video_path: Path) -> str:
try:
info = ffprobe(video_path)
except subprocess.CalledProcessError:
return None
if 700 <= info.height <= 800:
return "720p"
elif 1000 <= info.height <= 1200:
return "1080p"
elif info.height > 2000:
return "4K"
return None
def main():
for it in sys.argv[1:]:
video_path = Path(it)
if not video_path.is_file():
continue
resolution = get_resolution(video_path)
if resolution is None:
logging.info("unknown resolution: %s", video_path)
continue
if resolution in video_path.stem:
continue
logging.info("%s: %s", video_path.stem, resolution)
new_path = video_path.with_stem(f"{video_path.stem} [{resolution}]")
video_path.rename(new_path)
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
main()