forked from djib/PDMameUpdate
Initial work on multible torrent formats (untested)
This commit is contained in:
@ -103,10 +103,11 @@ def fetch_local_torrents():
|
||||
logging.info('Fetching current MAME versions')
|
||||
directories = os.listdir(config['mame-directory'])
|
||||
for directory in directories:
|
||||
match = re_mame_version.match(directory)
|
||||
if match:
|
||||
torrents[match.group(2)]['local-version'] = int(match.group(1))
|
||||
torrents[match.group(2)]['local-name'] = directory
|
||||
for regexp in regexps:
|
||||
match = regexp.match(directory)
|
||||
if match:
|
||||
torrents[match.group('name')]['local-version'] = match.group('version')
|
||||
torrents[match.group('name')]['local-name'] = directory
|
||||
logging.debug('Found the local torrent versions: %s', pformat(torrents))
|
||||
|
||||
|
||||
@ -116,19 +117,20 @@ def fetch_remote_torrents():
|
||||
logging.info('Opening PleasureDome RSS feed')
|
||||
d = feedparser.parse('http://www.pleasuredome.org.uk/rss.xml')
|
||||
for post in d.entries:
|
||||
match = re_mame_version.match(post.title)
|
||||
if match:
|
||||
matched_version = int(match.group(1))
|
||||
matched_torrent = torrents[match.group(2)]
|
||||
if matched_version > matched_torrent.get('remote-version', 0):
|
||||
matched_torrent['remote-version'] = matched_version
|
||||
matched_torrent['remote-link'] = post.link
|
||||
matched_torrent['remote-name'] = post.title
|
||||
else:
|
||||
logging.info("Skipping '{}' version '{}'".format(
|
||||
match.group(0),
|
||||
matched_version
|
||||
))
|
||||
for regexp in regexps:
|
||||
match = regexp.match(post.title)
|
||||
if match:
|
||||
matched_version = match.group('version')
|
||||
matched_torrent = torrents[match.group('name')]
|
||||
if matched_version > matched_torrent.get('remote-version', ''):
|
||||
matched_torrent['remote-version'] = matched_version
|
||||
matched_torrent['remote-link'] = post.link
|
||||
matched_torrent['remote-name'] = post.title
|
||||
else:
|
||||
logging.info("Skipping '{}' version '{}'".format(
|
||||
match.group(0),
|
||||
matched_version
|
||||
))
|
||||
logging.debug('Found the remote torrent versions: %s', pformat(torrents))
|
||||
|
||||
|
||||
@ -235,9 +237,10 @@ def fetch_transmission_torrents():
|
||||
|
||||
logging.info('Listing Transmission torrents')
|
||||
for torrent in client.list().values():
|
||||
match = re_mame_version.match(torrent['name'])
|
||||
if match:
|
||||
torrents[match.group(2)]['transmission-id'] = torrent['id']
|
||||
for regexp in regexps:
|
||||
match = regexp.match(torrent['name'])
|
||||
if match:
|
||||
torrents[match.group('name')]['transmission-id'] = torrent['id']
|
||||
logging.debug('Found the Transmission torrent ids: %s', pformat(torrents))
|
||||
|
||||
|
||||
@ -322,7 +325,10 @@ if __name__ == '__main__':
|
||||
print('{}\r'.format(i), end=''),
|
||||
time.sleep(1)
|
||||
|
||||
re_mame_version = re.compile(r'MAME 0.(\d+) (.*)')
|
||||
regexps = [
|
||||
re.compile(r'(?P<name>(?:HB)?MAME (?P<version>[\d.]+) .*)'),
|
||||
re.compile(r'(?P<name>No-Intro \((?P<version>[\d-]+)\) .*)')
|
||||
]
|
||||
config = open_config_file()
|
||||
torrents = defaultdict(dict)
|
||||
|
||||
|
Reference in New Issue
Block a user