Update Pipfile and bump transmission-clutch to latest version
This commit is contained in:
@ -25,7 +25,8 @@ Requirements:
|
||||
* Transmission for Bitorrent
|
||||
* A proper PDMameUpdate.json file (see PDMameUpdate.template.json)
|
||||
* Python3 with the libraries below
|
||||
- feedparser
|
||||
- bs4
|
||||
- requests
|
||||
- transmission-clutch
|
||||
- tabulate
|
||||
* Linux (untested on other OS, but it might work)
|
||||
@ -47,11 +48,11 @@ import re
|
||||
from requests import get
|
||||
import time
|
||||
import pathlib
|
||||
from clutch.core import Client
|
||||
from clutch import Client
|
||||
from tabulate import tabulate
|
||||
from collections import defaultdict
|
||||
from pprint import pformat
|
||||
from urllib.parse import quote, urlparse
|
||||
from urllib.parse import urlparse
|
||||
|
||||
|
||||
def open_config_file():
|
||||
@ -98,7 +99,7 @@ def get_magnet_link(link):
|
||||
|
||||
for link in html.find_all('a'):
|
||||
href = link.get('href')
|
||||
if urlparse(href).scheme=='magnet':
|
||||
if urlparse(href).scheme == 'magnet':
|
||||
return link.string
|
||||
|
||||
|
||||
@ -132,7 +133,8 @@ def fetch_remote_torrents():
|
||||
if urlparse(link.get('href')).netloc == 'mgnet.me':
|
||||
matched_version = match.group(0)
|
||||
matched_torrent = torrents[regexp.sub('#', link.string)]
|
||||
if matched_version > matched_torrent.get('remote-version', ''):
|
||||
remote_version = matched_torrent.get('remote-version', '')
|
||||
if matched_version > remote_version:
|
||||
matched_torrent['remote-version'] = matched_version
|
||||
matched_torrent['remote-link'] = link.get('href')
|
||||
matched_torrent['remote-name'] = link.string
|
||||
@ -177,7 +179,12 @@ def prompt_for_update():
|
||||
data['remote-version'],
|
||||
data.get('transmission-id', 'N/A')
|
||||
])
|
||||
print(tabulate(output, headers=output_header, tablefmt="simple", disable_numparse=True))
|
||||
print(tabulate(
|
||||
output,
|
||||
headers=output_header,
|
||||
tablefmt="simple",
|
||||
disable_numparse=True
|
||||
))
|
||||
print('Should I update the torrents listed above? (y/N)')
|
||||
answer = input()
|
||||
if answer.lower() != 'y':
|
||||
@ -206,7 +213,11 @@ def fetch_transmission_torrents():
|
||||
"""Gets the torrents id from Transmission"""
|
||||
|
||||
logging.info('Listing Transmission torrents')
|
||||
for torrent in client.list().values():
|
||||
local_torrents = client.torrent.accessor(
|
||||
fields=['id', 'name']
|
||||
).arguments.torrents
|
||||
for local_torrent in local_torrents:
|
||||
torrent = local_torrent.dict(exclude_none=True)
|
||||
for regexp in regexps:
|
||||
match = regexp.search(torrent['name'])
|
||||
if match:
|
||||
@ -235,9 +246,12 @@ def update_torrents():
|
||||
torrent['remote-name']
|
||||
)
|
||||
if 'transmission-id' in torrent:
|
||||
logging.debug('Removing from transmission : %s',torrent['transmission-id'])
|
||||
logging.debug(
|
||||
'Removing from transmission : %s',
|
||||
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)
|
||||
logging.debug('Adding to transmission : %s', torrent['remote-link'])
|
||||
|
||||
|
Reference in New Issue
Block a user