Don't use parentdir for tagging
This commit is contained in:
@@ -86,7 +86,8 @@ class Downloader(Provider):
|
|||||||
return self.processComplete(item = item, delete_files = self.conf('delete_files', default = False))
|
return self.processComplete(item = item, delete_files = self.conf('delete_files', default = False))
|
||||||
|
|
||||||
return False
|
return False
|
||||||
return
|
|
||||||
|
return False
|
||||||
|
|
||||||
def processComplete(self, item, delete_files):
|
def processComplete(self, item, delete_files):
|
||||||
return
|
return
|
||||||
@@ -149,7 +150,8 @@ class Downloader(Provider):
|
|||||||
if item and item.get('downloader') == self.getName():
|
if item and item.get('downloader') == self.getName():
|
||||||
self.pause(item, pause)
|
self.pause(item, pause)
|
||||||
return True
|
return True
|
||||||
return
|
|
||||||
|
return False
|
||||||
|
|
||||||
def pause(self, item, pause):
|
def pause(self, item, pause):
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ config = [{
|
|||||||
'default': True,
|
'default': True,
|
||||||
'type': 'bool',
|
'type': 'bool',
|
||||||
'description': 'Remove the NZB from history after it completed.',
|
'description': 'Remove the NZB from history after it completed.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'delete_failed',
|
'name': 'delete_failed',
|
||||||
'default': True,
|
'default': True,
|
||||||
|
|||||||
@@ -49,14 +49,14 @@ config = [{
|
|||||||
'default': True,
|
'default': True,
|
||||||
'type': 'bool',
|
'type': 'bool',
|
||||||
'description': '(Hard)link/copy after download is complete (if enabled in renamer), wait for seeding to finish before (re)moving and set the seeding goal from the torrent providers.',
|
'description': '(Hard)link/copy after download is complete (if enabled in renamer), wait for seeding to finish before (re)moving and set the seeding goal from the torrent providers.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'remove_complete',
|
'name': 'remove_complete',
|
||||||
'label': 'Remove torrent',
|
'label': 'Remove torrent',
|
||||||
'default': True,
|
'default': True,
|
||||||
'type': 'bool',
|
'type': 'bool',
|
||||||
'description': 'Remove the torrent from Transmission after it finished seeding.',
|
'description': 'Remove the torrent from Transmission after it finished seeding.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'delete_files',
|
'name': 'delete_files',
|
||||||
'label': 'Remove files',
|
'label': 'Remove files',
|
||||||
|
|||||||
@@ -19,15 +19,17 @@ class Transmission(Downloader):
|
|||||||
type = ['torrent', 'torrent_magnet']
|
type = ['torrent', 'torrent_magnet']
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
trpc = None
|
trpc = None
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
# Load host from config and split out port.
|
# Load host from config and split out port.
|
||||||
host = self.conf('host').split(':')
|
host = self.conf('host').split(':')
|
||||||
if not isInt(host[1]):
|
if not isInt(host[1]):
|
||||||
log.error('Config properties are not filled in correctly, port is missing.')
|
log.error('Config properties are not filled in correctly, port is missing.')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not self.trpc:
|
if not self.trpc:
|
||||||
self.trpc = TransmissionRPC(host[0], port = host[1], username = self.conf('username'), password = self.conf('password'))
|
self.trpc = TransmissionRPC(host[0], port = host[1], username = self.conf('username'), password = self.conf('password'))
|
||||||
|
|
||||||
return self.trpc
|
return self.trpc
|
||||||
|
|
||||||
def download(self, data, movie, filedata = None):
|
def download(self, data, movie, filedata = None):
|
||||||
@@ -58,7 +60,7 @@ class Transmission(Downloader):
|
|||||||
torrent_params['seedRatioMode'] = 1
|
torrent_params['seedRatioMode'] = 1
|
||||||
|
|
||||||
if data.get('seed_time') and self.conf('seeding'):
|
if data.get('seed_time') and self.conf('seeding'):
|
||||||
torrent_params['seedIdleLimit'] = tryInt(data.get('seed_time'))*60
|
torrent_params['seedIdleLimit'] = tryInt(data.get('seed_time')) * 60
|
||||||
torrent_params['seedIdleMode'] = 1
|
torrent_params['seedIdleMode'] = 1
|
||||||
|
|
||||||
# Send request to Transmission
|
# Send request to Transmission
|
||||||
@@ -89,8 +91,8 @@ class Transmission(Downloader):
|
|||||||
statuses = StatusList(self)
|
statuses = StatusList(self)
|
||||||
|
|
||||||
return_params = {
|
return_params = {
|
||||||
'fields': ['id', 'name', 'hashString', 'percentDone', 'status', 'eta', 'isStalled', 'isFinished', 'downloadDir', 'uploadRatio', 'secondsSeeding', 'seedIdleLimit']
|
'fields': ['id', 'name', 'hashString', 'percentDone', 'status', 'eta', 'isStalled', 'isFinished', 'downloadDir', 'uploadRatio', 'secondsSeeding', 'seedIdleLimit']
|
||||||
}
|
}
|
||||||
|
|
||||||
queue = self.trpc.get_alltorrents(return_params)
|
queue = self.trpc.get_alltorrents(return_params)
|
||||||
if not (queue and queue.get('torrents')):
|
if not (queue and queue.get('torrents')):
|
||||||
@@ -98,7 +100,8 @@ class Transmission(Downloader):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
for item in queue['torrents']:
|
for item in queue['torrents']:
|
||||||
log.debug('name=%s / id=%s / downloadDir=%s / hashString=%s / percentDone=%s / status=%s / eta=%s / uploadRatio=%s / isFinished=%s', (item['name'], item['id'], item['downloadDir'], item['hashString'], item['percentDone'], item['status'], item['eta'], item['uploadRatio'], item['isFinished']))
|
log.debug('name=%s / id=%s / downloadDir=%s / hashString=%s / percentDone=%s / status=%s / eta=%s / uploadRatio=%s / isFinished=%s',
|
||||||
|
(item['name'], item['id'], item['downloadDir'], item['hashString'], item['percentDone'], item['status'], item['eta'], item['uploadRatio'], item['isFinished']))
|
||||||
|
|
||||||
if not os.path.isdir(Env.setting('from', 'renamer')):
|
if not os.path.isdir(Env.setting('from', 'renamer')):
|
||||||
log.error('Renamer "from" folder doesn\'t to exist.')
|
log.error('Renamer "from" folder doesn\'t to exist.')
|
||||||
|
|||||||
@@ -42,14 +42,14 @@ config = [{
|
|||||||
'default': True,
|
'default': True,
|
||||||
'type': 'bool',
|
'type': 'bool',
|
||||||
'description': '(Hard)links/copies after download is complete (if enabled in renamer), wait for seeding to finish before (re)moving.',
|
'description': '(Hard)links/copies after download is complete (if enabled in renamer), wait for seeding to finish before (re)moving.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'remove_complete',
|
'name': 'remove_complete',
|
||||||
'label': 'Remove torrent',
|
'label': 'Remove torrent',
|
||||||
'default': True,
|
'default': True,
|
||||||
'type': 'bool',
|
'type': 'bool',
|
||||||
'description': 'Remove the torrent from uTorrent after it finished seeding.',
|
'description': 'Remove the torrent from uTorrent after it finished seeding.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'delete_files',
|
'name': 'delete_files',
|
||||||
'label': 'Remove files',
|
'label': 'Remove files',
|
||||||
|
|||||||
@@ -76,11 +76,11 @@ class uTorrent(Downloader):
|
|||||||
|
|
||||||
if data.get('seed_ratio') and self.conf('seeding'):
|
if data.get('seed_ratio') and self.conf('seeding'):
|
||||||
torrent_params['seed_override'] = 1
|
torrent_params['seed_override'] = 1
|
||||||
torrent_params['seed_ratio'] = tryInt(tryFloat(data['seed_ratio'])*1000)
|
torrent_params['seed_ratio'] = tryInt(tryFloat(data['seed_ratio']) * 1000)
|
||||||
|
|
||||||
if data.get('seed_time') and self.conf('seeding'):
|
if data.get('seed_time') and self.conf('seeding'):
|
||||||
torrent_params['seed_override'] = 1
|
torrent_params['seed_override'] = 1
|
||||||
torrent_params['seed_time'] = tryInt(data['seed_time'])*3600
|
torrent_params['seed_time'] = tryInt(data['seed_time']) * 3600
|
||||||
|
|
||||||
# Convert base 32 to hex
|
# Convert base 32 to hex
|
||||||
if len(torrent_hash) == 32:
|
if len(torrent_hash) == 32:
|
||||||
@@ -139,7 +139,7 @@ class uTorrent(Downloader):
|
|||||||
'id': item[0],
|
'id': item[0],
|
||||||
'name': item[2],
|
'name': item[2],
|
||||||
'status': status,
|
'status': status,
|
||||||
'seed_ratio': float(item[7])/1000,
|
'seed_ratio': float(item[7]) / 1000,
|
||||||
'original_status': item[1],
|
'original_status': item[1],
|
||||||
'timeleft': str(timedelta(seconds = item[10])),
|
'timeleft': str(timedelta(seconds = item[10])),
|
||||||
'folder': item[26],
|
'folder': item[26],
|
||||||
@@ -228,16 +228,16 @@ class uTorrentAPI(object):
|
|||||||
action = "action=unpause&hash=%s" % hash
|
action = "action=unpause&hash=%s" % hash
|
||||||
return self._request(action)
|
return self._request(action)
|
||||||
|
|
||||||
def stop_torrent(self, hash):
|
def stop_torrent(self, hash):
|
||||||
action = "action=stop&hash=%s" % hash
|
action = "action=stop&hash=%s" % hash
|
||||||
return self._request(action)
|
return self._request(action)
|
||||||
|
|
||||||
def remove_torrent(self, hash, remove_data = False):
|
def remove_torrent(self, hash, remove_data = False):
|
||||||
if remove_data:
|
if remove_data:
|
||||||
action = "action=removedata&hash=%s" % hash
|
action = "action=removedata&hash=%s" % hash
|
||||||
else:
|
else:
|
||||||
action = "action=remove&hash=%s" % hash
|
action = "action=remove&hash=%s" % hash
|
||||||
return self._request(action)
|
return self._request(action)
|
||||||
|
|
||||||
def get_status(self):
|
def get_status(self):
|
||||||
action = "list=1"
|
action = "list=1"
|
||||||
@@ -270,5 +270,5 @@ class uTorrentAPI(object):
|
|||||||
if isinstance(settings_dict[key], bool):
|
if isinstance(settings_dict[key], bool):
|
||||||
settings_dict[key] = 1 if settings_dict[key] else 0
|
settings_dict[key] = 1 if settings_dict[key] else 0
|
||||||
|
|
||||||
action = 'action=setsetting' + ''.join(['&s=%s&v=%s' % (key, value) for (key, value) in settings_dict.items()])
|
action = 'action=setsetting' + ''.join(['&s=%s&v=%s' % (key, value) for (key, value) in settings_dict.items()])
|
||||||
return self._request(action)
|
return self._request(action)
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ class Renamer(Plugin):
|
|||||||
|
|
||||||
# Add _UNKNOWN_ if no library item is connected
|
# Add _UNKNOWN_ if no library item is connected
|
||||||
if not group['library'] or not movie_title:
|
if not group['library'] or not movie_title:
|
||||||
self.tagDir(group['parentdir'], 'unknown')
|
self.tagDir(group, 'unknown')
|
||||||
continue
|
continue
|
||||||
# Rename the files using the library data
|
# Rename the files using the library data
|
||||||
else:
|
else:
|
||||||
@@ -361,7 +361,7 @@ class Renamer(Plugin):
|
|||||||
log.info('Better quality release already exists for %s, with quality %s', (movie.library.titles[0].title, release.quality.label))
|
log.info('Better quality release already exists for %s, with quality %s', (movie.library.titles[0].title, release.quality.label))
|
||||||
|
|
||||||
# Add exists tag to the .ignore file
|
# Add exists tag to the .ignore file
|
||||||
self.tagDir(group['parentdir'], 'exists')
|
self.tagDir(group, 'exists')
|
||||||
|
|
||||||
# Notify on rename fail
|
# Notify on rename fail
|
||||||
download_message = 'Renaming of %s (%s) canceled, exists in %s already.' % (movie.library.titles[0].title, group['meta_data']['quality']['label'], release.quality.label)
|
download_message = 'Renaming of %s (%s) canceled, exists in %s already.' % (movie.library.titles[0].title, group['meta_data']['quality']['label'], release.quality.label)
|
||||||
@@ -412,7 +412,7 @@ class Renamer(Plugin):
|
|||||||
|
|
||||||
except:
|
except:
|
||||||
log.error('Failed removing %s: %s', (src, traceback.format_exc()))
|
log.error('Failed removing %s: %s', (src, traceback.format_exc()))
|
||||||
self.tagDir(group['parentdir'], 'failed_remove')
|
self.tagDir(group, 'failed_remove')
|
||||||
|
|
||||||
# Delete leftover folder from older releases
|
# Delete leftover folder from older releases
|
||||||
for delete_folder in delete_folders:
|
for delete_folder in delete_folders:
|
||||||
@@ -436,12 +436,12 @@ class Renamer(Plugin):
|
|||||||
group['renamed_files'].append(dst)
|
group['renamed_files'].append(dst)
|
||||||
except:
|
except:
|
||||||
log.error('Failed moving the file "%s" : %s', (os.path.basename(src), traceback.format_exc()))
|
log.error('Failed moving the file "%s" : %s', (os.path.basename(src), traceback.format_exc()))
|
||||||
self.tagDir(group['parentdir'], 'failed_rename')
|
self.tagDir(group, 'failed_rename')
|
||||||
|
|
||||||
# Tag folder if it is in the 'from' folder and it will not be removed because it is a torrent
|
# Tag folder if it is in the 'from' folder and it will not be removed because it is a torrent
|
||||||
if (movie_folder and self.conf('from') in movie_folder or not movie_folder) and \
|
if (movie_folder and self.conf('from') in movie_folder or not movie_folder) and \
|
||||||
self.conf('file_action') != 'move' and self.downloadIsTorrent(download_info):
|
self.conf('file_action') != 'move' and self.downloadIsTorrent(download_info):
|
||||||
self.tagDir(group['parentdir'], 'renamed_already')
|
self.tagDir(group, 'renamed_already')
|
||||||
|
|
||||||
# Remove matching releases
|
# Remove matching releases
|
||||||
for release in remove_releases:
|
for release in remove_releases:
|
||||||
@@ -489,9 +489,18 @@ class Renamer(Plugin):
|
|||||||
return rename_files
|
return rename_files
|
||||||
|
|
||||||
# This adds a file to ignore / tag a release so it is ignored later
|
# This adds a file to ignore / tag a release so it is ignored later
|
||||||
def tagDir(self, folder, tag):
|
def tagDir(self, group, tag):
|
||||||
if not os.path.isdir(folder) or not tag:
|
|
||||||
return
|
ignore_file = None
|
||||||
|
if isinstance(group, (dict)):
|
||||||
|
for movie_file in sorted(list(group['files']['movie'])):
|
||||||
|
ignore_file = '%s.%s.ignore' % (os.path.splitext(movie_file)[0], tag)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
if not os.path.isdir(group) or not tag:
|
||||||
|
return
|
||||||
|
ignore_file = os.path.join(group, '%s.ignore' % tag)
|
||||||
|
|
||||||
|
|
||||||
text = """This file is from CouchPotato
|
text = """This file is from CouchPotato
|
||||||
It has marked this release as "%s"
|
It has marked this release as "%s"
|
||||||
@@ -499,7 +508,8 @@ This file hides the release from the renamer
|
|||||||
Remove it if you want it to be renamed (again, or at least let it try again)
|
Remove it if you want it to be renamed (again, or at least let it try again)
|
||||||
""" % tag
|
""" % tag
|
||||||
|
|
||||||
self.createFile(os.path.join(folder, '%s.ignore' % tag), text)
|
if ignore_file:
|
||||||
|
self.createFile(ignore_file, text)
|
||||||
|
|
||||||
def untagDir(self, folder, tag = None):
|
def untagDir(self, folder, tag = None):
|
||||||
if not os.path.isdir(folder):
|
if not os.path.isdir(folder):
|
||||||
@@ -808,4 +818,4 @@ Remove it if you want it to be renamed (again, or at least let it try again)
|
|||||||
if not group['files'].get('added'):
|
if not group['files'].get('added'):
|
||||||
return False
|
return False
|
||||||
return src in group['files']['added']
|
return src in group['files']['added']
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user