Series sorting filtering (#200)
Because additional series results are now returned due to #143 the series selection window can with a large number of results that are not usually sorted in a useful way. I've created 3 settings that can help finding the corect series quickly use the publisher black list - can be toggled from the series selction screen, as well as a setting for is default behaviour a setting to make the result initially sorted by start year instead of the default no of issues a setting to initially put exact and near matches at the top of the list
This commit is contained in:
parent
ed16199940
commit
a66b5ea0e3
@ -79,7 +79,7 @@ class ComicTaggerSettings:
|
||||
# identifier settings
|
||||
self.id_length_delta_thresh = 5
|
||||
self.id_publisher_blacklist = "Panini Comics, Abril, Planeta DeAgostini, Editorial Televisa, Dino Comics"
|
||||
|
||||
|
||||
# Show/ask dialog flags
|
||||
self.ask_about_cbi_in_rar = True
|
||||
self.show_disclaimer = True
|
||||
@ -95,6 +95,10 @@ class ComicTaggerSettings:
|
||||
self.remove_html_tables = False
|
||||
self.cv_api_key = ""
|
||||
|
||||
self.sort_series_by_year = True
|
||||
self.exact_series_matches_first = True
|
||||
self.always_use_publisher_blacklist = False
|
||||
|
||||
# CBL Tranform settings
|
||||
|
||||
self.assume_lone_credit_is_primary = False
|
||||
@ -254,6 +258,17 @@ class ComicTaggerSettings:
|
||||
if self.config.has_option('comicvine', 'remove_html_tables'):
|
||||
self.remove_html_tables = self.config.getboolean(
|
||||
'comicvine', 'remove_html_tables')
|
||||
|
||||
if self.config.has_option('comicvine', 'sort_series_by_year'):
|
||||
self.sort_series_by_year = self.config.getboolean(
|
||||
'comicvine', 'sort_series_by_year')
|
||||
if self.config.has_option('comicvine', 'exact_series_matches_first'):
|
||||
self.exact_series_matches_first = self.config.getboolean(
|
||||
'comicvine', 'exact_series_matches_first')
|
||||
if self.config.has_option('comicvine', 'always_use_publisher_blacklist'):
|
||||
self.always_use_publisher_blacklist = self.config.getboolean(
|
||||
'comicvine', 'always_use_publisher_blacklist')
|
||||
|
||||
if self.config.has_option('comicvine', 'cv_api_key'):
|
||||
self.cv_api_key = self.config.get('comicvine', 'cv_api_key')
|
||||
|
||||
@ -408,6 +423,14 @@ class ComicTaggerSettings:
|
||||
self.clear_form_before_populating_from_cv)
|
||||
self.config.set(
|
||||
'comicvine', 'remove_html_tables', self.remove_html_tables)
|
||||
|
||||
self.config.set(
|
||||
'comicvine', 'sort_series_by_year', self.sort_series_by_year)
|
||||
self.config.set(
|
||||
'comicvine', 'exact_series_matches_first', self.exact_series_matches_first)
|
||||
self.config.set(
|
||||
'comicvine', 'always_use_publisher_blacklist', self.always_use_publisher_blacklist)
|
||||
|
||||
self.config.set('comicvine', 'cv_api_key', self.cv_api_key)
|
||||
|
||||
if not self.config.has_section('cbl_transform'):
|
||||
|
@ -135,6 +135,14 @@ class SettingsWindow(QtWidgets.QDialog):
|
||||
self.cbxClearFormBeforePopulating.setCheckState(QtCore.Qt.Checked)
|
||||
if self.settings.remove_html_tables:
|
||||
self.cbxRemoveHtmlTables.setCheckState(QtCore.Qt.Checked)
|
||||
|
||||
if self.settings.always_use_publisher_blacklist:
|
||||
self.cbxUseBlackFilter.setCheckState(QtCore.Qt.Checked)
|
||||
if self.settings.sort_series_by_year:
|
||||
self.cbxSortByYear.setCheckState(QtCore.Qt.Checked)
|
||||
if self.settings.exact_series_matches_first:
|
||||
self.cbxExactMatches.setCheckState(QtCore.Qt.Checked)
|
||||
|
||||
self.leKey.setText(str(self.settings.cv_api_key))
|
||||
|
||||
if self.settings.assume_lone_credit_is_primary:
|
||||
@ -193,6 +201,11 @@ class SettingsWindow(QtWidgets.QDialog):
|
||||
self.settings.use_series_start_as_volume = self.cbxUseSeriesStartAsVolume.isChecked()
|
||||
self.settings.clear_form_before_populating_from_cv = self.cbxClearFormBeforePopulating.isChecked()
|
||||
self.settings.remove_html_tables = self.cbxRemoveHtmlTables.isChecked()
|
||||
|
||||
self.settings.always_use_publisher_blacklist = self.cbxUseBlackFilter.isChecked()
|
||||
self.settings.sort_series_by_year = self.cbxSortByYear.isChecked()
|
||||
self.settings.exact_series_matches_first = self.cbxExactMatches.isChecked()
|
||||
|
||||
self.settings.cv_api_key = str(self.leKey.text())
|
||||
ComicVineTalker.api_key = self.settings.cv_api_key.strip()
|
||||
self.settings.assume_lone_credit_is_primary = self.cbxAssumeLoneCreditIsPrimary.isChecked()
|
||||
|
@ -263,6 +263,40 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbxUseBlackFilter">
|
||||
<property name="text">
|
||||
<string>Always use Publisher Blacklist on 'manual' searches</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbxSortByYear">
|
||||
<property name="text">
|
||||
<string>Initally sort Series search results by Starting Year instead of No. Issues</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbxExactMatches">
|
||||
<property name="text">
|
||||
<string>Initally show Series Name exact matches first</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -148,6 +148,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbxFilter">
|
||||
<property name="text">
|
||||
<string>Filter Publishers</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Filter the publishers based on the publisher blacklist.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
|
@ -32,9 +32,11 @@ from .settings import ComicTaggerSettings
|
||||
from .matchselectionwindow import MatchSelectionWindow
|
||||
from .coverimagewidget import CoverImageWidget
|
||||
from comictaggerlib.ui.qtutils import reduceWidgetFontSize, centerWindowOnParent
|
||||
#from imagefetcher import ImageFetcher
|
||||
#import utils
|
||||
|
||||
from comictaggerlib import settings
|
||||
#from imagefetcher import ImageFetcher
|
||||
|
||||
from . import utils
|
||||
|
||||
class SearchThread(QtCore.QThread):
|
||||
|
||||
@ -124,6 +126,8 @@ class VolumeSelectionWindow(QtWidgets.QDialog):
|
||||
self.cover_index_list = cover_index_list
|
||||
self.cv_search_results = None
|
||||
|
||||
self.use_blackList = self.settings.always_use_publisher_blacklist
|
||||
|
||||
self.twList.resizeColumnsToContents()
|
||||
self.twList.currentItemChanged.connect(self.currentItemChanged)
|
||||
self.twList.cellDoubleClicked.connect(self.cellDoubleClicked)
|
||||
@ -131,6 +135,9 @@ class VolumeSelectionWindow(QtWidgets.QDialog):
|
||||
self.btnIssues.clicked.connect(self.showIssues)
|
||||
self.btnAutoSelect.clicked.connect(self.autoSelect)
|
||||
|
||||
self.cbxFilter.setChecked(self.use_blackList)
|
||||
self.cbxFilter.toggled.connect(self.filterToggled)
|
||||
|
||||
self.updateButtons()
|
||||
self.performQuery()
|
||||
self.twList.selectRow(0)
|
||||
@ -150,6 +157,10 @@ class VolumeSelectionWindow(QtWidgets.QDialog):
|
||||
def requery(self,):
|
||||
self.performQuery(refresh=True)
|
||||
self.twList.selectRow(0)
|
||||
|
||||
def filterToggled(self):
|
||||
self.use_blackList = not self.use_blackList
|
||||
self.performQuery(refresh=False)
|
||||
|
||||
def autoSelect(self):
|
||||
|
||||
@ -334,6 +345,40 @@ class VolumeSelectionWindow(QtWidgets.QDialog):
|
||||
return
|
||||
|
||||
self.cv_search_results = self.search_thread.cv_search_results
|
||||
# filter the blacklisted publishers if setting set
|
||||
if self.use_blackList:
|
||||
try:
|
||||
publisher_blacklist = {s.strip().lower() for s in self.settings.id_publisher_blacklist.split(',')}
|
||||
# use '' as publisher name if None
|
||||
self.cv_search_results = list(filter(lambda d: ('' if d['publisher'] is None else str(d['publisher']['name']).lower()) not in publisher_blacklist, self.cv_search_results))
|
||||
except:
|
||||
print('bad data error filtering blacklist publishers')
|
||||
|
||||
# pre sort the data - so that we can put exact matches first afterwards
|
||||
# compare as str incase extra chars ie. '1976?'
|
||||
# - missing (none) values being converted to 'None' - consistant with prior behaviour in v1.2.3
|
||||
# sort by start_year if set
|
||||
if self.settings.sort_series_by_year:
|
||||
try:
|
||||
self.cv_search_results = sorted(self.cv_search_results, key = lambda i: (str(i['start_year']), str(i['count_of_issues'])), reverse=True)
|
||||
except:
|
||||
print('bad data error sorting results by start_year,count_of_issues')
|
||||
else:
|
||||
try:
|
||||
self.cv_search_results = sorted(self.cv_search_results, key = lambda i: str(i['count_of_issues']), reverse=True)
|
||||
except:
|
||||
print('bad data error sorting results by count_of_issues')
|
||||
|
||||
# move sanitized matches to the front
|
||||
if self.settings.exact_series_matches_first:
|
||||
try:
|
||||
sanitized = utils.sanitize_title(self.series_name)
|
||||
exactMatches = list(filter(lambda d: utils.sanitize_title(str(d['name'])) in sanitized, self.cv_search_results))
|
||||
nonMatches = list(filter(lambda d: utils.sanitize_title(str(d['name'])) not in sanitized, self.cv_search_results))
|
||||
self.cv_search_results = exactMatches + nonMatches
|
||||
except:
|
||||
print('bad data error filtering exact/near matches')
|
||||
|
||||
self.updateButtons()
|
||||
|
||||
self.twList.setSortingEnabled(False)
|
||||
@ -375,9 +420,7 @@ class VolumeSelectionWindow(QtWidgets.QDialog):
|
||||
|
||||
row += 1
|
||||
|
||||
self.twList.resizeColumnsToContents()
|
||||
self.twList.setSortingEnabled(True)
|
||||
self.twList.sortItems(2, QtCore.Qt.DescendingOrder)
|
||||
self.twList.selectRow(0)
|
||||
self.twList.resizeColumnsToContents()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user