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')
|
logging.info('Fetching current MAME versions')
|
||||||
directories = os.listdir(config['mame-directory'])
|
directories = os.listdir(config['mame-directory'])
|
||||||
for directory in directories:
|
for directory in directories:
|
||||||
match = re_mame_version.match(directory)
|
for regexp in regexps:
|
||||||
|
match = regexp.match(directory)
|
||||||
if match:
|
if match:
|
||||||
torrents[match.group(2)]['local-version'] = int(match.group(1))
|
torrents[match.group('name')]['local-version'] = match.group('version')
|
||||||
torrents[match.group(2)]['local-name'] = directory
|
torrents[match.group('name')]['local-name'] = directory
|
||||||
logging.debug('Found the local torrent versions: %s', pformat(torrents))
|
logging.debug('Found the local torrent versions: %s', pformat(torrents))
|
||||||
|
|
||||||
|
|
||||||
@ -116,11 +117,12 @@ def fetch_remote_torrents():
|
|||||||
logging.info('Opening PleasureDome RSS feed')
|
logging.info('Opening PleasureDome RSS feed')
|
||||||
d = feedparser.parse('http://www.pleasuredome.org.uk/rss.xml')
|
d = feedparser.parse('http://www.pleasuredome.org.uk/rss.xml')
|
||||||
for post in d.entries:
|
for post in d.entries:
|
||||||
match = re_mame_version.match(post.title)
|
for regexp in regexps:
|
||||||
|
match = regexp.match(post.title)
|
||||||
if match:
|
if match:
|
||||||
matched_version = int(match.group(1))
|
matched_version = match.group('version')
|
||||||
matched_torrent = torrents[match.group(2)]
|
matched_torrent = torrents[match.group('name')]
|
||||||
if matched_version > matched_torrent.get('remote-version', 0):
|
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
|
||||||
matched_torrent['remote-name'] = post.title
|
matched_torrent['remote-name'] = post.title
|
||||||
@ -235,9 +237,10 @@ def fetch_transmission_torrents():
|
|||||||
|
|
||||||
logging.info('Listing Transmission torrents')
|
logging.info('Listing Transmission torrents')
|
||||||
for torrent in client.list().values():
|
for torrent in client.list().values():
|
||||||
match = re_mame_version.match(torrent['name'])
|
for regexp in regexps:
|
||||||
|
match = regexp.match(torrent['name'])
|
||||||
if match:
|
if match:
|
||||||
torrents[match.group(2)]['transmission-id'] = torrent['id']
|
torrents[match.group('name')]['transmission-id'] = torrent['id']
|
||||||
logging.debug('Found the Transmission torrent ids: %s', pformat(torrents))
|
logging.debug('Found the Transmission torrent ids: %s', pformat(torrents))
|
||||||
|
|
||||||
|
|
||||||
@ -322,7 +325,10 @@ if __name__ == '__main__':
|
|||||||
print('{}\r'.format(i), end=''),
|
print('{}\r'.format(i), end=''),
|
||||||
time.sleep(1)
|
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()
|
config = open_config_file()
|
||||||
torrents = defaultdict(dict)
|
torrents = defaultdict(dict)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user