forked from djib/PDMameUpdate
Add clean disconnect and count down timer
This commit is contained in:
@ -43,6 +43,7 @@ import logging
|
||||
import os
|
||||
import re
|
||||
import requests
|
||||
import time
|
||||
from clutch.core import Client
|
||||
from collections import defaultdict
|
||||
from pprint import pformat
|
||||
@ -98,7 +99,7 @@ def prompt_for_update():
|
||||
"""Ask for user confirmation before updating"""
|
||||
|
||||
if len(torrents) > 0:
|
||||
for torrent, data in torrents:
|
||||
for torrent, data in torrents.items():
|
||||
print('Torrent {}: {} -> {}'.format(
|
||||
torrent,
|
||||
data['local-version'],
|
||||
@ -128,6 +129,8 @@ def get_cookies_from_pleasuredome():
|
||||
r = requests.post('http://www.pleasuredome.org.uk/login2.php', data=data)
|
||||
if r.status_code == 200:
|
||||
logging.info('Connected to PleasureDome')
|
||||
logging.info('Logging out')
|
||||
requests.get('http://www.pleasuredome.org.uk/logout.php')
|
||||
else:
|
||||
logging.error(
|
||||
'Connection to PleasureDome failed with status %s',
|
||||
@ -176,15 +179,22 @@ def update_torrents():
|
||||
client.torrent.add(
|
||||
filename=torrent['remote-link'],
|
||||
cookies=cookies,
|
||||
paused=True
|
||||
paused=False
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format=' %(asctime)s - %(levelname)s - %(message)s'
|
||||
)
|
||||
|
||||
print('PDMameUpdate is about to start')
|
||||
# Useful if you run this script when your machine boots
|
||||
for i in range(5,0,-1):
|
||||
print('{}\r'.format(i), end=''),
|
||||
time.sleep(1)
|
||||
|
||||
re_mame_version = re.compile('MAME 0.(\d+) (.*)')
|
||||
config = open_config_file()
|
||||
torrents = defaultdict(dict)
|
||||
|
Reference in New Issue
Block a user