Merge branch 'master' of ssh://djib.fr:2311/djib/PDMameUpdate
This commit is contained in:
@ -17,6 +17,10 @@ Basically what it does is:
|
|||||||
Supported Torrents:
|
Supported Torrents:
|
||||||
* MAME
|
* MAME
|
||||||
* HBMAME
|
* HBMAME
|
||||||
|
* Demul
|
||||||
|
* Kawaks
|
||||||
|
* FBNeo
|
||||||
|
* Raine
|
||||||
|
|
||||||
Work in progress…
|
Work in progress…
|
||||||
* TODO: implement some error handling
|
* TODO: implement some error handling
|
||||||
@ -26,6 +30,7 @@ Requirements:
|
|||||||
* A proper PDMameUpdate.json file (see PDMameUpdate.template.json)
|
* A proper PDMameUpdate.json file (see PDMameUpdate.template.json)
|
||||||
* Python3 with the libraries below
|
* Python3 with the libraries below
|
||||||
- bs4
|
- bs4
|
||||||
|
- packaging
|
||||||
- requests
|
- requests
|
||||||
- transmission-clutch
|
- transmission-clutch
|
||||||
- tabulate
|
- tabulate
|
||||||
@ -53,6 +58,7 @@ from tabulate import tabulate
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
from packaging import version
|
||||||
|
|
||||||
|
|
||||||
def open_config_file():
|
def open_config_file():
|
||||||
@ -93,16 +99,6 @@ def open_config_file():
|
|||||||
return config
|
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():
|
def fetch_local_torrents():
|
||||||
"""Fetches local torrents versions"""
|
"""Fetches local torrents versions"""
|
||||||
|
|
||||||
@ -129,7 +125,11 @@ def fetch_remote_torrents():
|
|||||||
logging.info('Opening PleasureDome github feed')
|
logging.info('Opening PleasureDome github feed')
|
||||||
pdurls = [
|
pdurls = [
|
||||||
'https://pleasuredome.github.io/pleasuredome/mame/index.html',
|
'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:
|
for url in pdurls:
|
||||||
page = get(url)
|
page = get(url)
|
||||||
@ -139,7 +139,7 @@ def fetch_remote_torrents():
|
|||||||
for regexp in regexps:
|
for regexp in regexps:
|
||||||
match = regexp.search(link.string)
|
match = regexp.search(link.string)
|
||||||
if match:
|
if match:
|
||||||
if urlparse(link.get('href')).netloc == 'mgnet.me':
|
if urlparse(link.get('href')).scheme == 'magnet':
|
||||||
matched_version = match.group(0)
|
matched_version = match.group(0)
|
||||||
matched_torrent = torrents[regexp.sub('#', link.string)]
|
matched_torrent = torrents[regexp.sub('#', link.string)]
|
||||||
remote_version = matched_torrent.get('remote-version', '')
|
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-link'] = link.get('href')
|
||||||
matched_torrent['remote-name'] = link.string
|
matched_torrent['remote-name'] = link.string
|
||||||
else:
|
else:
|
||||||
logging.info("Skipping '{}' version '{}'".format(
|
logging.debug("Skipping '{}' version '{}'".format(
|
||||||
match.group(0),
|
link.string,
|
||||||
matched_version
|
matched_version
|
||||||
))
|
))
|
||||||
logging.debug('Found the remote torrent versions: %s', pformat(torrents))
|
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()):
|
for torrent, data in list(torrents.items()):
|
||||||
keys_to_check = {'local-version', 'remote-version'}
|
keys_to_check = {'local-version', 'remote-version'}
|
||||||
if (
|
if not (
|
||||||
keys_to_check.issubset(data.keys())
|
keys_to_check.issubset(data.keys())
|
||||||
and
|
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]
|
del torrents[torrent]
|
||||||
|
|
||||||
logging.debug(
|
logging.debug(
|
||||||
@ -314,6 +312,10 @@ if __name__ == '__main__':
|
|||||||
regexps = [
|
regexps = [
|
||||||
re.compile(r'(?<=MAME )[\d.]+'),
|
re.compile(r'(?<=MAME )[\d.]+'),
|
||||||
re.compile(r'(?<=HBMAME )[\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()
|
config = open_config_file()
|
||||||
torrents = defaultdict(dict)
|
torrents = defaultdict(dict)
|
||||||
|
@ -8,7 +8,7 @@ Supported torrents:
|
|||||||
* MAME
|
* MAME
|
||||||
* HBMAME
|
* HBMAME
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
You need to rename `PDMameUpdate.template.json` to `PDMameUpdate.json` and modify it with the proper information.
|
You need to rename `PDMameUpdate.template.json` to `PDMameUpdate.json` and modify it with the proper information.
|
||||||
|
Reference in New Issue
Block a user