Browse Source

Don't use parentdir for tagging

pull/1921/merge
Ruud 12 years ago
parent
commit
8a252bff64
  1. 6
      couchpotato/core/downloaders/base.py
  2. 7
      couchpotato/core/downloaders/transmission/main.py
  3. 6
      couchpotato/core/downloaders/utorrent/main.py
  4. 26
      couchpotato/core/plugins/renamer/main.py

6
couchpotato/core/downloaders/base.py

@ -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

7
couchpotato/core/downloaders/transmission/main.py

@ -26,8 +26,10 @@ class Transmission(Downloader):
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
@ -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.')

6
couchpotato/core/downloaders/utorrent/main.py

@ -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],

26
couchpotato/core/plugins/renamer/main.py

@ -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:
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 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):

Loading…
Cancel
Save