List possible updates and prompt if the user wants to update
This commit is contained in:
@ -32,23 +32,34 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
logging.info('Fetching current MAME versions')
|
logging.info('Fetching current MAME versions')
|
||||||
files = os.listdir(config['mame_directory'])
|
files = os.listdir(config['mame_directory'])
|
||||||
torrent_versions = {}
|
local_torrents = {}
|
||||||
for file in files:
|
for file in files:
|
||||||
match = re_mame_version.match(file)
|
match = re_mame_version.match(file)
|
||||||
if match:
|
if match:
|
||||||
torrent_versions[match[2]] = match[1]
|
local_torrents[match[2]] = int(match[1])
|
||||||
logging.info('Found the following Torrent version on disk: %s', torrent_versions)
|
logging.info('Found the following Torrent version on disk: %s', local_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')
|
||||||
|
remote_torrents = {}
|
||||||
for post in d.entries:
|
for post in d.entries:
|
||||||
match = re_mame_version.match(post.title)
|
match = re_mame_version.match(post.title)
|
||||||
if match:
|
if match:
|
||||||
print('Torrent {} is available with version {}.'.format(match[2], match[1]))
|
remote_torrents[match[2]] = int(match[1])
|
||||||
if match[2] in torrent_versions:
|
logging.info('Found the following Torrent version on PleasureDome: %s', remote_torrents)
|
||||||
print('You have version {}'.format(torrent_versions[match[2]]))
|
|
||||||
|
for torrent, version in local_torrents.items():
|
||||||
|
if torrent in remote_torrents:
|
||||||
|
if version < remote_torrents[torrent]:
|
||||||
|
print('Torrent {}: {} -> {}'.format(torrent, version, remote_torrents[torrent]))
|
||||||
|
|
||||||
|
print('Should I update the torrents listed above? (y/N)')
|
||||||
|
answer = input()
|
||||||
|
if answer.lower() == 'y':
|
||||||
|
logging.info('Updating…')
|
||||||
|
else:
|
||||||
|
logging.info('Quitting: user cancelled update.')
|
||||||
|
|
||||||
# TODO: use user input to decide whether the torrent should be updated
|
|
||||||
# TODO: connect to PleasureDome
|
# TODO: connect to PleasureDome
|
||||||
# TODO: remove local torrent from Transmission
|
# TODO: remove local torrent from Transmission
|
||||||
# TODO: rename local folder
|
# TODO: rename local folder
|
||||||
|
Reference in New Issue
Block a user