From dcac6199035a11f1bdc487cc663cfd032920c079 Mon Sep 17 00:00:00 2001
From: djdembeck
Date: Sat, 28 Aug 2021 16:50:29 -0500
Subject: [PATCH 1/4] Fix score calculation; Don't include pre-orders in
results; fix log spacing
---
Contents/Code/__init__.py | 22 +++++++++++++++++-----
Contents/Code/search_tools.py | 6 ++++++
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py
index 993324b..d9ab79e 100644
--- a/Contents/Code/__init__.py
+++ b/Contents/Code/__init__.py
@@ -235,8 +235,8 @@ def update(self, metadata, media, lang, force=False):
log.separator(
msg=(
- "UPDATING" + media.title + (
- "ID: " + metadata.id
+ "UPDATING: " + media.title + (
+ " ID: " + metadata.id
)
),
log_level="info"
@@ -473,20 +473,32 @@ def run_search(self, helper, media, result):
if date is not None:
year = date.year
+ # Make sure this isn't a pre-order listing
+ if helper.is_year_in_future(year):
+ continue
+
# Score the album name
scorebase1 = media.album
scorebase2 = title.encode('utf-8')
-
- score = INITIAL_SCORE - Util.LevenshteinDistance(
+ album_score = INITIAL_SCORE - Util.LevenshteinDistance(
scorebase1, scorebase2
)
+ log.debug("Score from album: " + str(album_score))
+ # Score the author name
if media.artist:
scorebase3 = media.artist
scorebase4 = author
- score = INITIAL_SCORE - Util.LevenshteinDistance(
+ author_score = INITIAL_SCORE - Util.LevenshteinDistance(
scorebase3, scorebase4
)
+ log.debug("Score from author: " + str(author_score))
+ # Find the difference in score between name and author
+ score = (
+ album_score + author_score
+ ) - INITIAL_SCORE
+ else:
+ score = album_score
log.info("Result #" + str(i + 1))
# Log basic metadata
diff --git a/Contents/Code/search_tools.py b/Contents/Code/search_tools.py
index 168fe28..4d6b240 100644
--- a/Contents/Code/search_tools.py
+++ b/Contents/Code/search_tools.py
@@ -1,3 +1,4 @@
+from datetime import date
import re
# Import internal tools
from logging import Logging
@@ -13,6 +14,11 @@ def __init__(self, lang, manual, media, results):
self.media = media
self.results = results
+ def is_year_in_future(self, year):
+ current_year = (date.today().year)
+ if year > current_year:
+ return True
+
def get_id_from_url(self, item):
url = item['url']
log.debug('URL For Breakdown: %s', url)
From 23ea98b292b86cb0d358693e7d751653cf61da34 Mon Sep 17 00:00:00 2001
From: djdembeck
Date: Sat, 28 Aug 2021 16:58:28 -0500
Subject: [PATCH 2/4] Handle special pages with single genre
---
Contents/Code/__init__.py | 12 ++++++++++--
Contents/Code/update_tools.py | 6 ++++++
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py
index d9ab79e..63aa4c7 100644
--- a/Contents/Code/__init__.py
+++ b/Contents/Code/__init__.py
@@ -288,6 +288,12 @@ def update(self, metadata, media, lang, force=False):
.replace("
", "\n")
)
+ # Handle single genre result
+ if update_helper.genre_child:
+ genre_string = update_helper.genre_parent + ', ' + update_helper.genre_child
+ else:
+ genre_string = update_helper.genre_parent
+
# Setup logging of all data in the array
data_to_log = [
{'date': update_helper.date},
@@ -295,7 +301,7 @@ def update(self, metadata, media, lang, force=False):
{'author': update_helper.author},
{'narrator': update_helper.narrator},
{'series': update_helper.series},
- {'genres': update_helper.genre_parent + ', ' + update_helper.genre_child},
+ {'genres': genre_string},
{'studio': update_helper.studio},
{'thumb': update_helper.thumb},
{'rating': update_helper.rating},
@@ -699,7 +705,9 @@ def compile_metadata(self, helper):
if not Prefs['no_overwrite_genre']:
helper.metadata.genres.clear()
helper.metadata.genres.add(helper.genre_parent)
- helper.metadata.genres.add(helper.genre_child)
+ # Not all books have 2 genres
+ if helper.genre_child:
+ helper.metadata.genres.add(helper.genre_child)
self.parse_author_narrator(helper)
diff --git a/Contents/Code/update_tools.py b/Contents/Code/update_tools.py
index 569849f..3ccbd8f 100644
--- a/Contents/Code/update_tools.py
+++ b/Contents/Code/update_tools.py
@@ -55,6 +55,12 @@ def re_parse_with_date_published(self, json_data):
)
except AttributeError:
continue
+ except IndexError:
+ log.info(
+ '"' + self.title + '", '
+ "only has one genre"
+ )
+ continue
# Writes metadata information to log.
def writeInfo(self):
From ee7ef3747ab9d6cf8f95d63af2159e5b6f37a114 Mon Sep 17 00:00:00 2001
From: djdembeck
Date: Sat, 28 Aug 2021 17:02:56 -0500
Subject: [PATCH 3/4] bump version
---
Contents/Code/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py
index 63aa4c7..bf63046 100644
--- a/Contents/Code/__init__.py
+++ b/Contents/Code/__init__.py
@@ -10,7 +10,7 @@
from update_tools import UpdateTool
from urls import SiteUrl
-VERSION_NO = '2021.08.27.1'
+VERSION_NO = '2021.08.28.1'
# Delay used when requesting HTML,
# may be good to have to prevent being banned from the site
From 7dd4251d56ba4bb98962f278569f85fd67b4e030 Mon Sep 17 00:00:00 2001
From: djdembeck
Date: Sat, 28 Aug 2021 18:17:13 -0500
Subject: [PATCH 4/4] Check entire date and not just year for preorder
---
Contents/Code/__init__.py | 2 +-
Contents/Code/search_tools.py | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py
index bf63046..5314459 100644
--- a/Contents/Code/__init__.py
+++ b/Contents/Code/__init__.py
@@ -480,7 +480,7 @@ def run_search(self, helper, media, result):
year = date.year
# Make sure this isn't a pre-order listing
- if helper.is_year_in_future(year):
+ if helper.check_if_preorder(date):
continue
# Score the album name
diff --git a/Contents/Code/search_tools.py b/Contents/Code/search_tools.py
index 4d6b240..0c5b704 100644
--- a/Contents/Code/search_tools.py
+++ b/Contents/Code/search_tools.py
@@ -14,9 +14,9 @@ def __init__(self, lang, manual, media, results):
self.media = media
self.results = results
- def is_year_in_future(self, year):
- current_year = (date.today().year)
- if year > current_year:
+ def check_if_preorder(self, book_date):
+ current_date = (date.today())
+ if book_date > current_date:
return True
def get_id_from_url(self, item):