Fix error with updates no longer being detected

This commit is contained in:
2020-09-30 14:19:55 +02:00
parent e46b9c06e8
commit d0e0aa9888

View File

@ -106,8 +106,10 @@ def fetch_local_torrents():
for regexp in regexps: for regexp in regexps:
match = regexp.match(directory) match = regexp.match(directory)
if match: if match:
torrents[match.group('name')]['local-version'] = match.group('version') version = match.group('version')
torrents[match.group('name')]['local-name'] = directory name = match.group(0).replace(version, '#')
torrents[name]['local-version'] = version
torrents[name]['local-name'] = directory
logging.debug('Found the local torrent versions: %s', pformat(torrents)) logging.debug('Found the local torrent versions: %s', pformat(torrents))
@ -121,7 +123,7 @@ def fetch_remote_torrents():
match = regexp.match(post.title) match = regexp.match(post.title)
if match: if match:
matched_version = match.group('version') matched_version = match.group('version')
matched_torrent = torrents[match.group('name')] matched_torrent = torrents[match.group(0).replace(matched_version, '#')]
if matched_version > matched_torrent.get('remote-version', ''): if matched_version > matched_torrent.get('remote-version', ''):
matched_torrent['remote-version'] = matched_version matched_torrent['remote-version'] = matched_version
matched_torrent['remote-link'] = post.link matched_torrent['remote-link'] = post.link
@ -240,7 +242,7 @@ def fetch_transmission_torrents():
for regexp in regexps: for regexp in regexps:
match = regexp.match(torrent['name']) match = regexp.match(torrent['name'])
if match: if match:
torrents[match.group('name')]['transmission-id'] = torrent['id'] torrents[match.group(0).replace(match.group('version'), '#')]['transmission-id'] = torrent['id']
logging.debug('Found the Transmission torrent ids: %s', pformat(torrents)) logging.debug('Found the Transmission torrent ids: %s', pformat(torrents))
@ -326,8 +328,8 @@ if __name__ == '__main__':
time.sleep(1) time.sleep(1)
regexps = [ regexps = [
re.compile(r'(?P<name>(?:HB)?MAME (?P<version>[\d.]+) .*)'), re.compile(r'(?:HB)?MAME (?P<version>[\d.]+) .*'),
re.compile(r'(?P<name>No-Intro \((?P<version>[\d-]+)\) .*)') re.compile(r'No-Intro \((?P<version>[\d-]+)\) .*')
] ]
config = open_config_file() config = open_config_file()
torrents = defaultdict(dict) torrents = defaultdict(dict)