Skip to content

Instantly share code, notes, and snippets.

@gatekeepr
Created October 27, 2020 13:05
Show Gist options
  • Save gatekeepr/6574aad0a472c4378773d52eba296e79 to your computer and use it in GitHub Desktop.
Save gatekeepr/6574aad0a472c4378773d52eba296e79 to your computer and use it in GitHub Desktop.
Discovers video files in a directory that are <Full HD Resolution
from pymediainfo import MediaInfo
from os import listdir
from os.path import isfile, join
import os
# adjust these
MOVIEPATH = r"M:\Movies"
WRITEFILE = True
if WRITEFILE:
f = open("nonehdmovies.txt", "a")
# function to check if a file has resolution below full hd
def get_title_prop(name):
media_info = MediaInfo.parse(name)
for track in media_info.tracks:
if track.track_type == 'Video':
if track.width < 1920:
help = f"{name} - {track.width} x {track.height}"
if WRITEFILE:
f.write(help)
else:
print(help)
# grab all video files in the movies directory
onlyfiles = [os.path.join(dp, f) for dp, dn, fn in os.walk(os.path.expanduser(MOVIEPATH)) for f in fn]
# iterate all files
for movie in onlyfiles:
get_title_prop(movie)
print("Done!")
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment