Skip to content

Commit

Permalink
Added ability to keep existing tags
Browse files Browse the repository at this point in the history
  • Loading branch information
pewsplosions authored Oct 30, 2019
1 parent f2ffc67 commit f4ffcdb
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/work/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, gui):
self.prog_worker = ComicalibreProgressWork()
self.util_worker = ComicalibreUtilityWork()

def process(self, progress_bar, process_type):
def process(self, progress_bar, process_type, keep_tags):
self.errors = []
progress_bar.setValue(0)
self.prog_worker.progress_bar = progress_bar
Expand Down Expand Up @@ -52,7 +52,7 @@ def process(self, progress_bar, process_type):
self.errors.append(md.title + id_for_errors +
": Unable to get info from Comic Vine with given IDs.")

self.set_given_metadata(md)
self.set_given_metadata(md, keep_tags)

try:
self.calibre_worker.save_metadata(book, md)
Expand Down Expand Up @@ -80,7 +80,7 @@ def issue_number_has_errors(self, md, issue, id_for_errors):
return True
return False

def set_given_metadata(self, md):
def set_given_metadata(self, md, keep_tags):
""" Add infromation that is part of the title or preferences. """
new_title = md.title.split("---")[0].strip().title()
md.set("title", new_title)
Expand All @@ -93,4 +93,9 @@ def set_given_metadata(self, md):
new_tags = prefs["tags_to_add"].split(",")
for tag in new_tags:
tag = tag.strip().title()
md.set("tags", new_tags)
if (keep_tags):
for tag in md.tags:
if (tag not in new_tags):
new_tags.append(tag)
if (new_tags is not None and len(new_tags) > 0):
md.set("tags", new_tags)

0 comments on commit f4ffcdb

Please sign in to comment.