forked from djib/PDMameUpdate
Merge pull request 'Add HBMAME github site, add support for multiple download directories' (#9) from sebastian404/PDMameUpdate:master into master
Reviewed-on: https://djib.fr/djib/PDMameUpdate/pulls/9
This commit is contained in:
@ -66,7 +66,7 @@ def open_config_file():
|
|||||||
)
|
)
|
||||||
for loc in locations:
|
for loc in locations:
|
||||||
if loc is not None:
|
if loc is not None:
|
||||||
logging.info("Searching for config file in '%s'", loc)
|
logging.debug("Searching for config file in '%s'", loc)
|
||||||
config_path = loc + '/PDMameUpdate.json'
|
config_path = loc + '/PDMameUpdate.json'
|
||||||
if pathlib.Path(config_path).is_file():
|
if pathlib.Path(config_path).is_file():
|
||||||
config_file_loc = config_path
|
config_file_loc = config_path
|
||||||
@ -107,7 +107,9 @@ def fetch_local_torrents():
|
|||||||
"""Fetches local torrents versions"""
|
"""Fetches local torrents versions"""
|
||||||
|
|
||||||
logging.info('Fetching current MAME versions')
|
logging.info('Fetching current MAME versions')
|
||||||
directories = os.listdir(config['mame-directory'])
|
for mdirectory in config['mame-directory']:
|
||||||
|
logging.debug('checking: %s', mdirectory)
|
||||||
|
directories = os.listdir(mdirectory)
|
||||||
for directory in directories:
|
for directory in directories:
|
||||||
for regexp in regexps:
|
for regexp in regexps:
|
||||||
match = regexp.search(directory)
|
match = regexp.search(directory)
|
||||||
@ -116,6 +118,8 @@ def fetch_local_torrents():
|
|||||||
name = regexp.sub('#', directory)
|
name = regexp.sub('#', directory)
|
||||||
torrents[name]['local-version'] = version
|
torrents[name]['local-version'] = version
|
||||||
torrents[name]['local-name'] = directory
|
torrents[name]['local-name'] = directory
|
||||||
|
torrents[name]['local-path'] = mdirectory
|
||||||
|
|
||||||
logging.debug('Found the local torrent versions: %s', pformat(torrents))
|
logging.debug('Found the local torrent versions: %s', pformat(torrents))
|
||||||
|
|
||||||
|
|
||||||
@ -123,7 +127,12 @@ def fetch_remote_torrents():
|
|||||||
"""Fetches PleasureDome torrents versions"""
|
"""Fetches PleasureDome torrents versions"""
|
||||||
|
|
||||||
logging.info('Opening PleasureDome github feed')
|
logging.info('Opening PleasureDome github feed')
|
||||||
page = get('https://pleasuredome.github.io/pleasuredome/mame/index.html')
|
pdurls = [
|
||||||
|
'https://pleasuredome.github.io/pleasuredome/mame/index.html',
|
||||||
|
'https://pleasuredome.github.io/pleasuredome/hbmame/index.html'
|
||||||
|
]
|
||||||
|
for url in pdurls:
|
||||||
|
page = get(url)
|
||||||
html = bs(page.text, 'html.parser')
|
html = bs(page.text, 'html.parser')
|
||||||
|
|
||||||
for link in html.find_all('a'):
|
for link in html.find_all('a'):
|
||||||
@ -238,29 +247,33 @@ def update_torrents():
|
|||||||
for torrent in torrents.values():
|
for torrent in torrents.values():
|
||||||
logging.info('Updating torrent : %s', torrent['remote-name'])
|
logging.info('Updating torrent : %s', torrent['remote-name'])
|
||||||
old_name = os.path.join(
|
old_name = os.path.join(
|
||||||
config['mame-directory'],
|
torrent['local-path'],
|
||||||
torrent['local-name']
|
torrent['local-name']
|
||||||
)
|
)
|
||||||
new_name = os.path.join(
|
new_name = os.path.join(
|
||||||
config['mame-directory'],
|
torrent['local-path'],
|
||||||
torrent['remote-name']
|
torrent['remote-name']
|
||||||
)
|
)
|
||||||
|
|
||||||
if 'transmission-id' in torrent:
|
if 'transmission-id' in torrent:
|
||||||
logging.debug(
|
logging.debug(
|
||||||
'Removing from transmission : %s',
|
'Removing from transmission : %s',
|
||||||
torrent['transmission-id']
|
torrent['transmission-id']
|
||||||
)
|
)
|
||||||
client.torrent.remove(torrent['transmission-id'])
|
client.torrent.remove(torrent['transmission-id'])
|
||||||
|
|
||||||
logging.debug('Renaming %s to %s', old_name, new_name)
|
logging.debug('Renaming %s to %s', old_name, new_name)
|
||||||
os.rename(old_name, new_name)
|
os.rename(old_name, new_name)
|
||||||
logging.debug('Adding to transmission : %s', torrent['remote-link'])
|
|
||||||
|
|
||||||
client.torrent.add(
|
logging.debug('Adding to transmission : %s', torrent['remote-link'])
|
||||||
filename=torrent['remote-link'],
|
arguments = {
|
||||||
magnet_link=True,
|
"filename" : torrent['remote-link'],
|
||||||
download_dir=config['mame-directory'],
|
"magnet_link": True,
|
||||||
paused=True
|
"download_dir" : torrent['local-path'],
|
||||||
)
|
"paused" : True,
|
||||||
|
}
|
||||||
|
responce = client.torrent.add(arguments)
|
||||||
|
logging.debug('clutch responce : %s', responce)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"mame-directory":"/path/to/your/local/mame/files/target/folder",
|
"mame-directory":["/path/to/your/local/mame/files/target/folder","/path/to/your/local/mame/files/target/iotherfolder"],
|
||||||
"transmission-user":"user",
|
"transmission-user":"user",
|
||||||
"transmission-password":"pass",
|
"transmission-password":"pass",
|
||||||
"transmission-port":8080
|
"transmission-port":8080
|
||||||
|
Reference in New Issue
Block a user