diff --git a/ArtNet/artnet_manager.py b/ArtNet/artnet_manager.py index 77f284f..6bd67f3 100644 --- a/ArtNet/artnet_manager.py +++ b/ArtNet/artnet_manager.py @@ -320,7 +320,8 @@ class ArtNetManager: #image_db_result = self.db_connection.get_art_by_path(self.all_images[self.curr_image_index]) s = self.all_images[self.curr_image_index].split(os.path.sep) if image_db_result is not None: - image_title = image_db_result["title"] if len(image_db_result["title"]) > 0 else "-Title Unknown-" + image_title = image_db_result["title"] if isinstance(image_db_result["title"], str) and \ + len(image_db_result["title"]) > 0 else self.window.UNKNOWN_TITLE image_author = self.db_connection.get_authors_of_art_by_ID(image_db_result["ID"]) image_link = image_db_result["link"] art_ID = image_db_result["ID"] diff --git a/ArtNet/db/db_adapter.py b/ArtNet/db/db_adapter.py index da2b96d..223635e 100644 --- a/ArtNet/db/db_adapter.py +++ b/ArtNet/db/db_adapter.py @@ -21,9 +21,9 @@ class DBAdapter: Updates or saves the given image data to the DB :param ID: :param title: - :param authors: + :param authors: list of presences List[Tuple[str, str]] :param path: - :param tags: + :param tags: list of tag names List[str] :param link: :param md5_hash: md5 hash as a hex digest :return: @@ -549,6 +549,7 @@ class DBAdapter: :return: """ name = name.strip().lower() + implications = [self.get_tag_ID(x) for x in implications] d = { "id": tag_id, "name": name, @@ -572,7 +573,7 @@ class DBAdapter: self.remove_alias_by_ID(tag_id, old_alias) if implications is not None: - old_implicants = self.get_tag_implications(name) + old_implicants = self.get_tag_implications_by_ID(tag_id) for implicant in implications: if implicant in old_implicants: # is this already set? continue diff --git a/ArtNet/gui/window.py b/ArtNet/gui/window.py index 71503ca..34e7973 100644 --- a/ArtNet/gui/window.py +++ b/ArtNet/gui/window.py @@ -19,6 +19,9 @@ from ArtNet.web.link_generator import LinkGenerator class Window(QtWidgets.QMainWindow): + UNKNOWN_TITLE = "-Title Unknown-" + UNKNOWN_PRESENCE = "(Not in Database)" + def __init__(self, main): super(Window, self).__init__() @@ -130,7 +133,7 @@ class Window(QtWidgets.QMainWindow): :return: """ new_title = self.curr_image_title - if new_title == self.curr_file_name or len(new_title) == 0: + if new_title == self.curr_file_name or len(new_title) == 0 or new_title == Window.UNKNOWN_TITLE: new_title = None image_data = { "ID": self.curr_art_id, @@ -143,7 +146,7 @@ class Window(QtWidgets.QMainWindow): } for presence in self.curr_presences: - if presence[-1] == "(Not in Database)": + if presence[-1] == Window.UNKNOWN_PRESENCE: msg = QtWidgets.QMessageBox() msg.setWindowTitle("Invalid Presence Domain") msg.setInformativeText("You've tried to save with a not working presence entry! " + @@ -302,10 +305,10 @@ class Window(QtWidgets.QMainWindow): """ if len(presences) > 1: for name, domain in presences: - if domain == "(Not in Database)": + if domain == Window.UNKNOWN_PRESENCE: presences.remove((name, domain)) elif len(presences) == 0: - presences = [(self.curr_art_path.split("/")[0], "(Not in Database)")] + presences = [(self.curr_art_path.split("/")[0], Window.UNKNOWN_PRESENCE)] self.curr_presences = presences if self.curr_presences is not None: @@ -529,7 +532,7 @@ class Window(QtWidgets.QMainWindow): self.ui.image_label.setMovie(self.__pixmap) self.__pixmap.start() self.__pixmap.frameChanged.connect(self.on_movie_frame_changed) - elif file_ending in ["webm"]: + elif file_ending in ["webm", "mp4", "mov"]: self.__showing_video = True self.__video = QVideoWidget() self.__player = QtMultimedia.QMediaPlayer(None, QtMultimedia.QMediaPlayer.VideoSurface)