Skip to content

Commit

Permalink
Fix score calculation; Don't include pre-orders in results; fix log s…
Browse files Browse the repository at this point in the history
…pacing
  • Loading branch information
djdembeck committed Aug 28, 2021
1 parent 3a52e14 commit dcac619
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
22 changes: 17 additions & 5 deletions Contents/Code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Contents/Code/search_tools.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import date
import re
# Import internal tools
from logging import Logging
Expand All @@ -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)
Expand Down

0 comments on commit dcac619

Please sign in to comment.