Skip to content

Commit

Permalink
(#432) Fixes search & post-processing related issues when a result wo…
Browse files Browse the repository at this point in the history
…uld contain a matching title of another watchlisted series (ie. wrong matches)
  • Loading branch information
evilhero authored and barbequesauce committed Sep 2, 2020
1 parent 5dc44e6 commit 8cbf578
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 10 deletions.
38 changes: 35 additions & 3 deletions mylar/PostProcessor.py
Expand Up @@ -964,6 +964,7 @@ def Process(self):
logger.error('%s No Story Arcs in Watchlist that contain that particular series - aborting Manual Post Processing. Maybe you should be running Import?' % module)
return
else:
tmp_arclist = []
arcvals = []
for av in arc_series:
arcvals.append({"ComicName": av['ComicName'],
Expand Down Expand Up @@ -1163,9 +1164,9 @@ def Process(self):
else:
logger.info('%s Found matching issue # %s for ComicID: %s / IssueID: %s' % (module, fcdigit, v[i]['WatchValues']['ComicID'], isc['IssueID']))

logger.fdebug('datematch: %s' % datematch)
logger.fdebug('temploc: %s' % helpers.issuedigits(temploc))
logger.fdebug('arcissue: %s' % helpers.issuedigits(v[i]['ArcValues']['IssueNumber']))
#logger.fdebug('datematch: %s' % datematch)
#logger.fdebug('temploc: %s' % helpers.issuedigits(temploc))
#logger.fdebug('arcissue: %s' % helpers.issuedigits(v[i]['ArcValues']['IssueNumber']))
if datematch == "True": # and helpers.issuedigits(temploc) == helpers.issuedigits(v[i]['ArcValues']['IssueNumber']):
#reset datematch here so it doesn't carry the value down and avoid year checks
datematch = "False"
Expand Down Expand Up @@ -1258,13 +1259,44 @@ def Process(self):
"Publisher": arcpublisher,
"ReadingOrder": v[i]['ArcValues']['ReadingOrder'],
"ComicName": k})
tmp_arclist.append({"ComicName": k,
"ComicID": v[i]['WatchValues']['ComicID'],
"IssueID": v[i]['ArcValues']['IssueID']})

logger.info('%s[SUCCESSFUL MATCH: %s-%s] Match verified for %s' % (module, k, v[i]['WatchValues']['ComicID'], arcmatch['comicfilename']))
self.matched = True
break
else:
logger.fdebug('%s[NON-MATCH: %s-%s] Incorrect series - not populating..continuing post-processing' % (module, k, v[i]['WatchValues']['ComicID']))

i+=1
if len(tmp_arclist) > 1:
logger.info('[STORY-ARC VERIFICATION] %s matches to storyarcs - probably due to invalid name matching above. Let\'s try to correct this.' % len(tmp_arclist))
keep_match = []
drop_match = []
for x in tmp_arclist:
xmld = filechecker.FileChecker()
xmld1 = xmld.dynamic_replace(x['ComicName']) #helpers.conversion(cs['ComicName']))
xseries = xmld1['mod_seriesname'].lower()
xmld2 = xmld.dynamic_replace(arcmatch['series_name']) #helpers.conversion(watchmatch['series_name']))
xfile = xmld2['mod_seriesname'].lower()
if re.sub('\|', '', xseries) == re.sub('\|', '', xfile):
logger.fdebug('%s[DEFINITIVE-NAME MATCH] Definitive name match exactly to : %s [%s]' % (module, arcmatch['series_name'], x['ComicID']))
keep_match.append(x['IssueID'])
self.matched = True
else:
logger.fdebug('INVALID MATCH DETECTED: %s' % x['ComicName'])
drop_match.append(x['IssueID'])

tmp_list = []
for xy in manual_arclist:
if [True for dm in drop_match if xy['IssueID'] == dm]:
continue
else:
tmp_list.append(xy)
manual_arclist = tmp_list
#logger.fdebug('new_manualarclist: %s' % (manual_arclist,))

if self.matched is False:
#one-off manual pp'd of torrents
if all(['0-Day Week' in self.nzb_name, mylar.CONFIG.PACK_0DAY_WATCHLIST_ONLY is True]):
Expand Down
8 changes: 7 additions & 1 deletion mylar/filechecker.py
Expand Up @@ -1276,6 +1276,7 @@ def parseit(self, path, filename, subpath=None):
return self.matchIT(series_info)

def matchIT(self, series_info):
qmatch_chk = None
series_name = series_info['series_name']
alt_series = series_info['alt_series']
filename = series_info['comicfilename']
Expand Down Expand Up @@ -1339,7 +1340,12 @@ def matchIT(self, series_info):
if nspace_altseriesname is not None:
if re.sub('\|','', nspace_altseriesname.lower()).strip() == re.sub('\|', '', nspace_watchcomic.lower()).strip():
seriesalt = True
qmatch_chk = 'alt_match'

if any([seriesalt is True, re.sub('\|','', nspace_seriesname.lower()).strip() == re.sub('\|', '', nspace_watchcomic.lower()).strip(), re.sub('\|','', nspace_seriesname_decoded.lower()).strip() == re.sub('\|', '', nspace_watchname_decoded.lower()).strip()]) or any(re.sub('[\|\s]','', x.lower()).strip() == re.sub('[\|\s]','', nspace_seriesname.lower()).strip() for x in self.AS_Alt):
if qmatch_chk is None:
qmatch_chk = 'match'
if qmatch_chk is not None:
#logger.fdebug('[MATCH: ' + series_info['series_name'] + '] ' + filename)
enable_annual = False
annual_comicid = None
Expand Down Expand Up @@ -1416,7 +1422,7 @@ def matchIT(self, series_info):
elif 'special' in nspace_watchcomic.lower():
justthedigits = 'Special %s' % justthedigits

return {'process_status': 'match',
return {'process_status': qmatch_chk,
'sub': series_info['sub'],
'volume': series_info['series_volume'],
'match_type': None, #match_type - will eventually pass if it wasa folder vs. filename match,
Expand Down
28 changes: 22 additions & 6 deletions mylar/search.py
Expand Up @@ -573,6 +573,7 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, Publisher, IssueDa
foundc['status'] = False
done = False
seperatealpha = "no"
hold_the_matches = []
#---issue problem
# if issue is '011' instead of '11' in nzb search results, will not have same
# results. '011' will return different than '11', as will '009' and '09'.
Expand Down Expand Up @@ -838,6 +839,7 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, Publisher, IssueDa
pack_warning = False
if not bb == "no results":
for entry in bb['entries']:
alt_match = False
#logger.fdebug('entry: %s' % entry) #<--- uncomment this to see what the search result(s) are
#brief match here against 32p since it returns the direct issue number
if nzbprov == '32P' and entry['title'][:17] == '0-Day Comics Pack':
Expand Down Expand Up @@ -1151,6 +1153,12 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, Publisher, IssueDa
if filecomic['process_status'] == 'fail':
logger.fdebug('%s was not a match to %s (%s)' % (cleantitle, ComicName, SeriesYear))
continue
elif filecomic['process_status'] == 'alt_match':
#if it's an alternate series match, we'll retain each value until the search has compeletely run, compiling matches.
#if at any point it's a standard match (ie. non-alternate series) that will be accepted as the one match and ignore the alts
#once all search options have been exhausted and no matches aside from alternate series then we go get the best result from that list
logger.fdebug('%s was a match due to alternate matching. Continuing to search, but retaining this result just in case.' % ComicTitle)
alt_match = True
elif booktype != parsed_comic['booktype'] and ignore_booktype is False:
logger.fdebug('Booktypes do not match. Looking for %s, this is a %s. Ignoring this result.' % (booktype, parsed_comic['booktype']))
continue
Expand Down Expand Up @@ -1359,7 +1367,7 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, Publisher, IssueDa
nzbid = entry['id']
else:
nzbid = generate_id(nzbprov, entry['link'])
if manual is not True:
if all([manual is not True, alt_match is False]):
downloadit = True
else:
for x in mylar.COMICINFO:
Expand All @@ -1378,7 +1386,8 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, Publisher, IssueDa
kind = 'torrent'
if torznab_host is not None:
tprov = torznab_host[0]
mylar.COMICINFO.append({"ComicName": ComicName,

search_values = {"ComicName": ComicName,
"ComicID": ComicID,
"IssueID": IssueID,
"ComicVolume": ComicVersion,
Expand All @@ -1401,8 +1410,11 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, Publisher, IssueDa
"SARC": SARC,
"IssueArcID": IssueArcID,
"newznab": newznab_host,
"torznab": torznab_host})
"torznab": torznab_host}

mylar.COMICINFO.append(search_values)

hold_the_matches.append(search_values)

else:
if filecomic['process_status'] == 'match':
Expand Down Expand Up @@ -1442,7 +1454,7 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, Publisher, IssueDa
entry['title'] = entry['filename']
else:
nzbid = generate_id(nzbprov, entry['link'])
if manual is not True:
if all([manual is not True, alt_match is False]):
downloadit = True
else:
for x in mylar.COMICINFO:
Expand Down Expand Up @@ -1475,7 +1487,7 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, Publisher, IssueDa
if torznab_host is not None:
tprov = torznab_host[0]

mylar.COMICINFO.append({"ComicName": ComicName,
search_values = {"ComicName": ComicName,
"ComicID": ComicID,
"IssueID": IssueID,
"ComicVolume": ComicVersion,
Expand All @@ -1498,7 +1510,11 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, Publisher, IssueDa
"SARC": SARC,
"IssueArcID": IssueArcID,
"newznab": newznab_host,
"torznab": torznab_host})
"torznab": torznab_host}

mylar.COMICINFO.append(search_values)

hold_the_matches.append(search_values)
else:
log2file = log2file + "issues don't match.." + "\n"
downloadit = False
Expand Down

0 comments on commit 8cbf578

Please sign in to comment.