diff --git a/.gitignore b/.gitignore index c0c219b..277aeb8 100644 --- a/.gitignore +++ b/.gitignore @@ -122,3 +122,5 @@ dmypy.json # Pyre type checker .pyre/ + +TODO diff --git a/README.md b/README.md index 029c107..1e27aa9 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# mediainfoSama +# mediaInfoSama diff --git a/file_cmds.py b/file_cmds.py index 1e93d2c..76b44d2 100644 --- a/file_cmds.py +++ b/file_cmds.py @@ -2,14 +2,14 @@ import os, subprocess, json from shlex import quote class FileCmds: - def __init__(self, filePath): + def __init__(self, file_path): super().__init__() - self.filePath = filePath - self.trackCount = self.track_count() - self.basicInfo = self.generate_basic() - self.advancedInfo = self.generate_advanced() - self.tabsList = self.generate_tabs_list() - self.tabsContent = self.generate_tabs_content() + self.file_path = file_path + self.track_count = self.track_count() + self.basic_info = self.generate_basic() + self.advanced_info = self.generate_advanced() + self.tabs_list = self.generate_tabs_list() + self.tabs_content = self.generate_tabs_content() def execute_bash(self, cmd): @@ -30,7 +30,7 @@ class FileCmds: :rtype: bool ''' - if os.path.exists(self.filePath): + if os.path.exists(self.file_path): return True else: print("The file doesn't exist") @@ -41,11 +41,11 @@ class FileCmds: ''' Execute mediainfo --Inform - :type inform: rstr + :type inform: str :rtype: str ''' - bashCommand = f"mediainfo --Inform={quote(inform)} {quote(self.filePath)}" - output = self.execute_bash(bashCommand).decode('utf-8') + bash_command = f"mediainfo --Inform={quote(inform)} {quote(self.file_path)}" + output = self.execute_bash(bash_command).decode('utf-8') return output @@ -55,7 +55,7 @@ class FileCmds: :rtype: dict[str,int] ''' - trackTypes = [ + track_types = [ "Video", "Audio", "Text", @@ -65,11 +65,11 @@ class FileCmds: output = {} - for trackType in trackTypes: - count = self.media_inform(f"General;%{trackType}Count%").replace('\n', '') + for track_type in track_types: + count = self.media_inform(f"General;%{track_type}Count%").replace('\n', '') if not count: count = 0 - output[trackType] = int(count) + output[track_type] = int(count) return output @@ -80,32 +80,32 @@ class FileCmds: :rtype: string ''' - informGeneral = r"General;G: %Format%, %FileSize_String%, %Duration_String%, %BitRate_String%\n" - informVideo = r"Video;V: %Format%, %Format_Profile%, %StreamSize_String%, %Width%x%Height%, %FrameRate% FPS, %BitRate_String%\n" - informAudio = r"Audio;A: %Language_String%, %Format%, %StreamSize_String%, %BitRate_String%, %Channel(s)_String%, %SamplingRate_String%\n" - informText = r"Text;T: %Language_String%, %Format%\n" + inform_general = r"General;G: %Format%, %FileSize_String%, %Duration_String%, %BitRate_String%\n" + inform_video = r"Video;V: %Format%, %Format_Profile%, %StreamSize_String%, %Width%x%Height%, %FrameRate% FPS, %BitRate_String%\n" + inform_audio = r"Audio;A: %Language_String%, %Format%, %StreamSize_String%, %BitRate_String%, %Channel(s)_String%, %SamplingRate_String%\n" + inform_text = r"Text;T: %Language_String%, %Format%\n" - informs = [informGeneral] + informs = [inform_general] - if not self.trackCount["Video"] == 0: - informs.append(informVideo) + if not self.track_count["Video"] == 0: + informs.append(inform_video) - if not self.trackCount["Audio"] == 0: - informs.append(informAudio) + if not self.track_count["Audio"] == 0: + informs.append(inform_audio) - if not self.trackCount["Text"] == 0: - informs.append(informText) + if not self.track_count["Text"] == 0: + informs.append(inform_text) output = "" for inform in informs: output += self.media_inform(inform) - if not self.trackCount["Menu"] == 0: + if not self.track_count["Menu"] == 0: output += "M: Menu\n\n" output += "\n" - output += self.execute_bash(f"mediainfo {quote(self.filePath)}").decode('utf-8') + output += self.execute_bash(f"mediainfo {quote(self.file_path)}").decode('utf-8') return(output) @@ -115,7 +115,7 @@ class FileCmds: :rtype: string ''' - output = self.execute_bash(f"mediainfo --Full {quote(self.filePath)}").decode('utf-8') + output = self.execute_bash(f"mediainfo --Full {quote(self.file_path)}").decode('utf-8') return output @@ -125,40 +125,40 @@ class FileCmds: :rtype: list ''' - tabsStr = "" + tab_str = "" tabs = ["Basic", "Advanced"] - informGeneral = r"General;General (%Format%)\n" + inform_general = r"General;General (%Format%)\n" - informs = [informGeneral] + informs = [inform_general] - if self.trackCount["Video"] == 1: - informVideo = r'Video;Video (%Format%)\n' - informs.append(informVideo) - elif self.trackCount["Video"] > 1: - informVideo = r'Video;Video #%StreamKindPos% (%Format%)\n' - informs.append(informVideo) + if self.track_count["Video"] == 1: + inform_video = r'Video;Video (%Format%)\n' + informs.append(inform_video) + elif self.track_count["Video"] > 1: + inform_video = r'Video;Video #%StreamKindPos% (%Format%)\n' + informs.append(inform_video) - if self.trackCount["Audio"] == 1: - informAudio = r'Audio;Audio (%Format%)\n' - informs.append(informAudio) - elif self.trackCount["Audio"] > 1: - informAudio = r'Audio;Audio #%StreamKindPos% (%Format%)\n' - informs.append(informAudio) + if self.track_count["Audio"] == 1: + inform_audio = r'Audio;Audio (%Format%)\n' + informs.append(inform_audio) + elif self.track_count["Audio"] > 1: + inform_audio = r'Audio;Audio #%StreamKindPos% (%Format%)\n' + informs.append(inform_audio) - if self.trackCount["Text"] == 1: - informText = r'Text;Text (%Format%)\n' - informs.append(informText) - elif self.trackCount["Text"] > 1: - informText = r'Text;Text #%StreamKindPos% (%Format%)\n' - informs.append(informText) + if self.track_count["Text"] == 1: + inform_text = r'Text;Text (%Format%)\n' + informs.append(inform_text) + elif self.track_count["Text"] > 1: + inform_text = r'Text;Text #%StreamKindPos% (%Format%)\n' + informs.append(inform_text) for inform in informs: - tabsStr += self.media_inform(inform) + tab_str += self.media_inform(inform) - if not self.trackCount["Menu"] == 0: - tabsStr += "Menu" + if not self.track_count["Menu"] == 0: + tab_str += "Menu" - tabs.extend(list(filter(None, tabsStr.split("\n")))) + tabs.extend(list(filter(None, tab_str.split("\n")))) return tabs @@ -168,15 +168,15 @@ class FileCmds: :rtype: dict[str:str] ''' - tracksList = self.advancedInfo.split("\n\n") - del tracksList[-1] + track_list = self.advanced_info.split("\n\n") + del track_list[-1] tabs = {} - tabs["Basic"] = self.basicInfo - tabs["Advanced"] = self.advancedInfo + tabs["Basic"] = self.basic_info + tabs["Advanced"] = self.advanced_info - for i in range(len(tracksList)): - tabs.update({self.tabsList[i+2]: tracksList[i]}) + for i in range(len(track_list)): + tabs.update({self.tabs_list[i+2]: track_list[i]}) return tabs \ No newline at end of file diff --git a/main_window.py b/main_window.py index 12beb7c..0c9e0d8 100644 --- a/main_window.py +++ b/main_window.py @@ -1,7 +1,6 @@ from PySide6.QtWidgets import QWidget from ui_main_window import Ui_MainWindow from file_cmds import FileCmds -from PySide6.QtGui import QFont from PySide6.QtCore import QSize @@ -9,8 +8,8 @@ class MainWindow(QWidget, Ui_MainWindow): def __init__(self): super().__init__() self.setupUi(self) - self.windowTitle = "mediainfoSama" - self.setWindowTitle(self.windowTitle) + self.window_title = "mediaInfoSama" + self.setWindowTitle(self.window_title) self.setAcceptDrops(True) self.setupConnections() @@ -31,20 +30,20 @@ class MainWindow(QWidget, Ui_MainWindow): def dropEvent(self, event): - self.filePath = event.mimeData().urls()[0].toLocalFile() - self.fileCmds = FileCmds(self.filePath) + self.file_path = event.mimeData().urls()[0].toLocalFile() + self.file_cmds = FileCmds(self.file_path) - if self.fileCmds.file_exist() == False: + if self.file_cmds.file_exist() == False: return - self.setWindowTitle(f"{self.filePath} - {self.windowTitle}") + self.setWindowTitle(f"{self.file_path} - {self.window_title}") self.populate_tabs() self.tracks_list_widget.item(0).setSelected(True) def populate_tabs(self): self.tracks_list_widget.clear() - self.tracks_list_widget.addItems(self.fileCmds.tabsList) + self.tracks_list_widget.addItems(self.file_cmds.tabs_list) for i in range(self.tracks_list_widget.count()): item = self.tracks_list_widget.item(i) @@ -53,7 +52,7 @@ class MainWindow(QWidget, Ui_MainWindow): def popuplate_content(self): - itemsSelected = self.tracks_list_widget.selectedItems() - if itemsSelected: - text = self.fileCmds.tabsContent[itemsSelected[0].text()] + item_selected = self.tracks_list_widget.selectedItems() + if item_selected: + text = self.file_cmds.tabs_content[item_selected[0].text()] self.detail_plain_text_edit.setPlainText(text) \ No newline at end of file