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 menuBarCloseTag(self):
     # close current tags
     if self.tag_Path:
         self.confirmCloseTag = confrimWin(
             self,
             Title="Close Tag",
             Text="Are you sure to close current tag")
         self.confirmCloseTag.show()
         self.actionClose_Tag.setEnabled(False)
     else:
         self.confirmCloseTag = confrimWin(self,
                                           Title="Warning",
                                           Text="There is no tag to close")
         self.confirmCloseTag.show()
         self.actionClose_Tag.setEnabled(False)
 def menuBarCreateTag(self):
     # create new Tag file
     if self.tag_Path:
         self.confirmCloseTag = confrimWin(
             self,
             Title="Create Tag",
             Text="Are you sure to close current tag and create new one")
         self.actionCreate_Tag.setEnabled(False)
         self.confirmCloseTag.show()
     else:
         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
Exemple #4
0
 def del_Tag(self):
     self.comboBox_Tag.setEnabled(False)
     try:  # handle error of not selected item
         item = [
             self.Edit_tag_Listwidget.currentItem().text(0),
             self.Edit_tag_Listwidget.currentItem().text(1)
         ]
         session = ".".join(self.comboBox_Tag.currentText().split(".")[:-1])
         if session in self.MediaPlayer.allTag:
             # show window to get accept from user
             self.confirmWin = confrimWin(
                 self.MediaPlayer,
                 session=session,
                 Text=f"are you sure to delete ({item[0]}) tag",
                 tagPartText=item,
                 Title="Delete tag")
             self.confirmWin.show()
     except:
         pass
    def save_Bookmarks(self):
        if not self.tag_Path:
            error_addBookmark = confrimWin(
                self,
                Title="Warning",
                Text="First select or create a tag file and try again")
            error_addBookmark.show()
            return False
        try:
            # use add bookmark function to add bookmarks in tag part
            add_Bookmark(
                self.lineEdit_Bookmark.text() + "#" +
                tc.millis_to_format(self.player.position()),
                ".".join(self.windowTitle()[16:].split(".")[:-1]),
                self.tag_Path)
            # there isn't any tags for movie we want to add bookmark it
            if not ".".join(
                    self.windowTitle()[16:].split(".")[:-1]) in self.allTag:
                self.allTag.update(
                    {".".join(self.windowTitle()[16:].split(".")[:-1]): {}})
            self.allTag[".".join(
                self.windowTitle()[16:].split(".")[:-1])].update({
                    self.lineEdit_Bookmark.text():
                    tc.millis_to_format(self.player.position())
                })
            self.set_TagonListwidget(
                self.windowTitle()[16:].split(".")[0])  # update tag listwidget
            # update combo box of edit and Main window
            self.pushButton_Start.setFocus(True)
            index = self.ComboBox_Tags_of_file.findText(
                self.windowTitle()[16:])
            self.ComboBox_Tags_of_file.setCurrentIndex(index)
            index = self.Setting.comboBox_Tag.findText(self.windowTitle()[16:])
            self.Setting.comboBox_Tag.setCurrentIndex(index)
            # ****

        except:
            pass

        self.lineEdit_Bookmark.clear()
        self.lineEdit_Bookmark.setVisible(False)
 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()
 def error_TimeFormat(self):
     _Warning = confrimWin(self,
                           Title="Warning",
                           Text="Please enter current format for time")
     _Warning.show()