From b00bcb9834b5809fc2d8b1aad8f68ac69fbc9048 Mon Sep 17 00:00:00 2001 From: djib Date: Wed, 4 Sep 2019 00:17:18 +0200 Subject: [PATCH] Initial commit. Currently recovers remote versions and local versions. No comparison or automation is implemented yet. --- .gitignore | 3 +++ PDMameUpdate.py | 56 ++++++++++++++++++++++++++++++++++++++++++++ config.template.json | 3 +++ 3 files changed, 62 insertions(+) create mode 100644 .gitignore create mode 100644 PDMameUpdate.py create mode 100644 config.template.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..59855f4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +config.json +.project +.pydevproject diff --git a/PDMameUpdate.py b/PDMameUpdate.py new file mode 100644 index 0000000..09ad5c7 --- /dev/null +++ b/PDMameUpdate.py @@ -0,0 +1,56 @@ +#!/usr/bin/python3 +''' +Checks available MAME Torrents on PleasureDome +and updates the local versions if more recent +versions are detected + +Work in progress… + +Requirements: + * Python3 with the libraries below + * Transmission for Bitorrent + * A PleasureDome account + +/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\ +/!\ Provided with no warranty whatsoever. /!\ +/!\ Use with caution. /!\ +/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\ +''' +import feedparser +import json +import logging +import os +import re + +if __name__ == '__main__': + logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s - %(message)s') + re_mame_version = re.compile('MAME 0.(\d+) (.*)') + + logging.info('Opening config file: config.json') + with open('config.json') as config_file: + config = json.load(config_file) + + logging.info('Fetching current MAME versions') + files = os.listdir(config['mame_directory']) + torrent_versions = {} + for file in files: + match = re_mame_version.match(file) + if match: + torrent_versions[match[2]] = match[1] + logging.info('Found the following Torrent version on disk: %s', torrent_versions) + + 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: + print('Torrent {} is available with version {}.'.format(match[2], match[1])) + if match[2] in torrent_versions: + print('You have version {}'.format(torrent_versions[match[2]])) + + # TODO: use user input to decide whether the torrent should be updated + # TODO: connect to PleasureDome + # TODO: remove local torrent from Transmission + # TODO: rename local folder + # TODO: add new torrent to Transmission + # TODO: implement some error handling \ No newline at end of file diff --git a/config.template.json b/config.template.json new file mode 100644 index 0000000..acf448f --- /dev/null +++ b/config.template.json @@ -0,0 +1,3 @@ +{ + "mame_directory":"/path/to/your/locol/mame/torrent/target/folders" +} \ No newline at end of file