Created
January 20, 2021 08:09
-
-
Save muyajil/6cb349491b17a8f080bdfa1977faf160 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pymediainfo import MediaInfo | |
| import os | |
| def get_absolute_paths(root_dir): | |
| for dirpath, _, filenames in os.walk(root_dir): | |
| for f in filenames: | |
| yield os.path.abspath(os.path.join(dirpath, f)) | |
| def get_relevant_file_paths(root_dir): | |
| file_paths = get_absolute_paths(root_dir) | |
| file_paths = filter(lambda f: "/movies/" in f or "/tv/" in f, file_paths) | |
| file_paths = filter(lambda f: "partial" not in f, file_paths) | |
| return file_paths | |
| if __name__ == "__main__": | |
| f = open('videos_with_no_audio.csv', 'w') | |
| f.write('Movie/Show;Season;File\n') | |
| for path in get_relevant_file_paths('/home/srv-user/media'): | |
| fileInfo = MediaInfo.parse(path) | |
| is_video = len(list(filter(lambda x: x.track_type == "Video", fileInfo.tracks))) > 0 | |
| has_audio = len(list(filter(lambda x: x.track_type == "Audio", fileInfo.tracks))) > 0 | |
| if is_video and not has_audio: | |
| try: | |
| parts = path.split('/') | |
| if len(parts) == 7: | |
| line = parts[5] + ';-;' + parts[6] | |
| else: | |
| line = parts[5] + ';' + parts[6] + ';' + parts[7] | |
| f.write(line + '\n') | |
| f.flush() | |
| print(line) | |
| except: | |
| print(path) | |
| exit() | |
| f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment