diff --git a/PDMameUpdate.py b/PDMameUpdate.py index 6b82975..eb48ad0 100755 --- a/PDMameUpdate.py +++ b/PDMameUpdate.py @@ -17,6 +17,10 @@ Basically what it does is: Supported Torrents: * MAME * HBMAME + * Demul + * Kawaks + * FBNeo + * Raine Work in progress… * TODO: implement some error handling @@ -26,6 +30,7 @@ Requirements: * A proper PDMameUpdate.json file (see PDMameUpdate.template.json) * Python3 with the libraries below - bs4 + - packaging - requests - transmission-clutch - tabulate @@ -53,6 +58,7 @@ from tabulate import tabulate from collections import defaultdict from pprint import pformat from urllib.parse import urlparse +from packaging import version def open_config_file(): @@ -93,16 +99,6 @@ def open_config_file(): return config -def get_magnet_link(link): - page = get(link) - html = bs(page.text, 'html.parser') - - for link in html.find_all('a'): - href = link.get('href') - if urlparse(href).scheme == 'magnet': - return link.string - - def fetch_local_torrents(): """Fetches local torrents versions""" @@ -129,7 +125,11 @@ def fetch_remote_torrents(): logging.info('Opening PleasureDome github feed') pdurls = [ 'https://pleasuredome.github.io/pleasuredome/mame/index.html', - 'https://pleasuredome.github.io/pleasuredome/hbmame/index.html' + 'https://pleasuredome.github.io/pleasuredome/nonmame/hbmame/index.html', + 'https://pleasuredome.github.io/pleasuredome/nonmame/demul/index.html', + 'https://pleasuredome.github.io/pleasuredome/nonmame/fbneo/index.html', + 'https://pleasuredome.github.io/pleasuredome/nonmame/kawaks/index.html', + 'https://pleasuredome.github.io/pleasuredome/nonmame/raine/index.html' ] for url in pdurls: page = get(url) @@ -139,7 +139,7 @@ def fetch_remote_torrents(): for regexp in regexps: match = regexp.search(link.string) if match: - if urlparse(link.get('href')).netloc == 'mgnet.me': + if urlparse(link.get('href')).scheme == 'magnet': matched_version = match.group(0) matched_torrent = torrents[regexp.sub('#', link.string)] remote_version = matched_torrent.get('remote-version', '') @@ -148,8 +148,8 @@ def fetch_remote_torrents(): matched_torrent['remote-link'] = link.get('href') matched_torrent['remote-name'] = link.string else: - logging.info("Skipping '{}' version '{}'".format( - match.group(0), + logging.debug("Skipping '{}' version '{}'".format( + link.string, matched_version )) logging.debug('Found the remote torrent versions: %s', pformat(torrents)) @@ -160,13 +160,11 @@ def filter_updatable_torrents(): for torrent, data in list(torrents.items()): keys_to_check = {'local-version', 'remote-version'} - if ( + if not ( keys_to_check.issubset(data.keys()) and - data['local-version'] < data['remote-version'] + version.parse(data['local-version']) < version.parse(data['remote-version']) ): - data['remote-link'] = get_magnet_link(data['remote-link']) - else: del torrents[torrent] logging.debug( @@ -314,6 +312,10 @@ if __name__ == '__main__': regexps = [ re.compile(r'(?<=MAME )[\d.]+'), re.compile(r'(?<=HBMAME )[\d.]+'), + re.compile(r'(?<=Demul )[\d.]+'), + re.compile(r'(?<=Kawaks )[\d.]+'), + re.compile(r'(?<=FBNeo )[\d.]+'), + re.compile(r'(?<=Raine )[\d.]+'), ] config = open_config_file() torrents = defaultdict(dict) diff --git a/README.md b/README.md index 41ad977..8c688d3 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Supported torrents: * MAME * HBMAME -![Sample output](https://djib.fr/djib/PDMameUpdate/raw/branch/master/screenshot.png) +![Sample output](https://djib.djib.fr/djib/PDMameUpdate/raw/branch/master/screenshot.png) ## Installation You need to rename `PDMameUpdate.template.json` to `PDMameUpdate.json` and modify it with the proper information.