forked from djib/PDMameUpdate
Merge branch 'master' of sebastian404/PDMameUpdate into master
This commit is contained in:
@ -20,7 +20,7 @@ Work in progress…
|
|||||||
Requirements:
|
Requirements:
|
||||||
* Transmission for Bitorrent
|
* Transmission for Bitorrent
|
||||||
* A PleasureDome account
|
* A PleasureDome account
|
||||||
* A proper config.json file (see config.template.json)
|
* A proper PDMameUpdate.json file (see PDMameUpdate.template.json)
|
||||||
* Python3 with the libraries below
|
* Python3 with the libraries below
|
||||||
- feedparser
|
- feedparser
|
||||||
- transmission-clutch
|
- transmission-clutch
|
||||||
@ -48,6 +48,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
|
import pathlib
|
||||||
from clutch.core import Client
|
from clutch.core import Client
|
||||||
from tabulate import tabulate
|
from tabulate import tabulate
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
@ -56,10 +57,18 @@ from urllib.parse import quote
|
|||||||
|
|
||||||
|
|
||||||
def open_config_file():
|
def open_config_file():
|
||||||
"""Reads configuration from config.json file"""
|
"""Reads configuration from PDMameUpdate.json file"""
|
||||||
|
|
||||||
logging.info('Opening config file: config.json')
|
for loc in os.environ.get("PDMAMEUPDATE_CONF"), "/etc", os.path.expanduser("~"), os.curdir:
|
||||||
with open('config.json') as config_file:
|
if loc is not None:
|
||||||
|
config_path = loc + '/PDMameUpdate.json'
|
||||||
|
if pathlib.Path(config_path).is_file():
|
||||||
|
config_file_loc = config_path
|
||||||
|
break
|
||||||
|
|
||||||
|
logging.info('Opening config file: '+config_file_loc)
|
||||||
|
config_file = None;
|
||||||
|
with open(config_file_loc, 'r') as config_file:
|
||||||
config = json.load(config_file)
|
config = json.load(config_file)
|
||||||
return config
|
return config
|
||||||
|
|
||||||
@ -224,6 +233,10 @@ def update_torrents():
|
|||||||
config['mame-directory'],
|
config['mame-directory'],
|
||||||
torrent['remote-name']
|
torrent['remote-name']
|
||||||
)
|
)
|
||||||
|
new_torrent = os.path.join(
|
||||||
|
config['torrent-directory'],
|
||||||
|
torrent['remote-name']+'.torrent'
|
||||||
|
)
|
||||||
|
|
||||||
client.torrent.remove(torrent['transmission-id'])
|
client.torrent.remove(torrent['transmission-id'])
|
||||||
os.rename(old_name, new_name)
|
os.rename(old_name, new_name)
|
||||||
@ -234,6 +247,9 @@ def update_torrents():
|
|||||||
paused=False
|
paused=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if args.keep:
|
||||||
|
t = requests.get(torrent['remote-link'], verify=False)
|
||||||
|
open(new_torrent, 'wb').write(t.content)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
@ -253,6 +269,11 @@ if __name__ == '__main__':
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
help='Display debugging messages'
|
help='Display debugging messages'
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'-k', '--keep',
|
||||||
|
action='store_true',
|
||||||
|
help='Keep torrent files localy'
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-c', '--countdown',
|
'-c', '--countdown',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"mame-directory":"/path/to/your/locol/mame/torrent/target/folders",
|
"mame-directory":"/path/to/your/local/mame/files/target/folder",
|
||||||
|
"torrent-directory":"/path/to/your/local/mame/torrent/target/folder",
|
||||||
"transmission-user":"user",
|
"transmission-user":"user",
|
||||||
"transmission-password":"pass",
|
"transmission-password":"pass",
|
||||||
"pleasuredome-user":"user",
|
"pleasuredome-user":"user",
|
@ -7,7 +7,7 @@ versions are detected
|
|||||||

|

|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
You need to rename `config.template.json` to `config.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.
|
||||||
|
|
||||||
You should have Python3 and a few libraries installed (see header in source code).
|
You should have Python3 and a few libraries installed (see header in source code).
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ pipenv run python3 PDMameUpdate.py
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
```shell
|
```shell
|
||||||
usage: PDMameUpdate.py [-h] [-l] [-d] [-c]
|
usage: PDMameUpdate.py [-h] [-l] [-d] [-k] [-c]
|
||||||
|
|
||||||
Update PleasureDome MAME Torrents
|
Update PleasureDome MAME Torrents
|
||||||
|
|
||||||
@ -28,5 +28,6 @@ optional arguments:
|
|||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
-l, --log Display more log messages
|
-l, --log Display more log messages
|
||||||
-d, --debug Display debugging messages
|
-d, --debug Display debugging messages
|
||||||
|
-k, --keep Keep torrent files localy
|
||||||
-c, --countdown Start with a 5 second countdown
|
-c, --countdown Start with a 5 second countdown
|
||||||
```
|
```
|
||||||
|
Reference in New Issue
Block a user