def set_TagonListwidget(self, videoName, Setting_Tags=True, Media_Tags=True): if Media_Tags: self.ListWidget_Tags_of_file.clear() if Setting_Tags: self.Setting.Edit_tag_Listwidget.clear() try: if videoName in self.allTag: sessionTag = self.allTag[videoName] # sorted tags by time sessionTag = { text: time for text, time in sorted( sessionTag.items(), key=lambda item: tc.to_second(item[1])) } for text in sessionTag: # setting part tags by qtreewidget if Setting_Tags: item = QTreeWidgetItem( self.Setting.Edit_tag_Listwidget, [text, sessionTag[text]]) # media part tags by qlistwidget if Media_Tags: self.ListWidget_Tags_of_file.addItem( f'{self.ListWidget_Tags_of_file.count()+1} . {text}' ) except: pass
def item_searchlist_Event(self, item): session, tag = re.split(" -> ", item.text()) # get all session to compare that is selected tag in playlist or user select tag wrong all_sessions = list(self.PlaylistW.Files.keys()) # there is bug here if mp3 and mp4 has same name all_sessions = [ ".".join(item.split(".")[:-1]) for item in all_sessions ] if session in all_sessions: if session != ".".join(self.windowTitle()[16:].split(".")[:-1]): # Show confirm window to get accept user for change video self.confirmWin = confrimWin( self, session=session, tag_Text=tag, Text= f"Are you sure to change video to {session} from search") self.confirmWin.show() else: try: # concert time format to second for using in change position time_second = tc.to_second(self.allTag[session][tag]) self.change_Position(time_second) except: # handle unexcepted error! pass else: Warning_user_wrongTags = confrimWin( self, Title="Warning", Text="You have opened wrong tag files") Warning_user_wrongTags.show()
def yes_Clicked(self): if self.Title == "Change video": self.MediaPlayer.change_Video(self.session) try: time_second = tc.to_second( self.MediaPlayer.allTag[self.session][self.tag_Text]) self.MediaPlayer.change_Position(time_second) except: pass if self.Title == "Delete tag": try: del self.MediaPlayer.allTag[self.session][self.tagPartText[0]] self.MediaPlayer.set_TagonListwidget(self.session) # delete bookmark edit_Tags( self.tagPartText[0] + "#" + self.tagPartText[1] + "#" + "\*", "", self.MediaPlayer.tag_Path) # delete tag edit_Tags(self.tagPartText[0] + "#" + self.tagPartText[1], "", self.MediaPlayer.tag_Path) self.MediaPlayer.Setting.comboBox_Tag.setEnabled(True) except: self.MediaPlayer.Setting.comboBox_Tag.setEnabled(True) # close curent tag if self.Title == "Close Tag": self.closeTag() # create new tag if self.Title == "Create Tag": self.close() self.closeTag() dialog = QFileDialog(self, 'File tag', directory=os.getcwd()) _path = dialog.getSaveFileName(filter="*.csv")[0] try: if _path: self.tag_Path = _path open(self.tag_Path, "w") except: pass self.MediaPlayer.actionCreate_Tag.setEnabled(True) try: self.MediaPlayer.actionClose_Tag.setEnabled(True) except: pass try: self.close() except: pass
def find_Closest_to(tags, word): suggest = __find__(tags, word) # tags = {text.lower(): val for text, val in tags.items()} # change all text to lower case for key in difflib.get_close_matches(word, tags.keys()): suggest = {**suggest, **(__find__(tags, key))} result = {} for key in suggest: # delete repeated if not key in result.keys(): result.update({key: suggest[key]}) # sort tags by time result = { text: time for text, time in sorted(result.items(), key=lambda item: tc.to_second(item[1])) } return result # dict
def GoToTagtime(self, item): spliter = len(str(self.ListWidget_Tags_of_file.currentRow() + 1)) + 3 tag_Text = item.text()[spliter:] # change time if clicked on tags that belong to playing session if self.windowTitle()[16:] == self.ComboBox_Tags_of_file.currentText(): session = ".".join(self.windowTitle()[16:].split(".")[:-1]) try: # convert time to seconds using tc mudole(write by own) time_second = tc.to_second(self.allTag[session][tag_Text]) # using change position function to handle sliders and time self.change_Position(time_second) except: pass else: session = ".".join( self.ComboBox_Tags_of_file.currentText().split(".")[:-1]) self.confirmWin = confrimWin( self, session=session, tag_Text=tag_Text, Text=f"Are you sure to change video to {session}") self.confirmWin.show()