|
|
|
@ -26,6 +26,7 @@ Requirements:
|
|
|
|
|
* A proper PDMameUpdate.json file (see PDMameUpdate.template.json)
|
|
|
|
|
* Python3 with the libraries below
|
|
|
|
|
- bs4
|
|
|
|
|
- packaging
|
|
|
|
|
- requests
|
|
|
|
|
- transmission-clutch
|
|
|
|
|
- tabulate
|
|
|
|
@ -53,6 +54,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 +95,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"""
|
|
|
|
|
|
|
|
|
@ -139,7 +131,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 +140,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 +152,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(
|
|
|
|
|