Browse Source

Seeding cleanup and better defaults

pull/1921/merge
Ruud 12 years ago
parent
commit
36f63bdf99
  1. 2
      couchpotato/core/downloaders/base.py
  2. 1
      couchpotato/core/downloaders/blackhole/main.py
  3. 2
      couchpotato/core/downloaders/nzbget/__init__.py
  4. 1
      couchpotato/core/downloaders/nzbget/main.py
  5. 1
      couchpotato/core/downloaders/nzbvortex/__init__.py
  6. 1
      couchpotato/core/downloaders/nzbvortex/main.py
  7. 1
      couchpotato/core/downloaders/pneumatic/main.py
  8. 4
      couchpotato/core/downloaders/sabnzbd/__init__.py
  9. 1
      couchpotato/core/downloaders/sabnzbd/main.py
  10. 19
      couchpotato/core/downloaders/transmission/__init__.py
  11. 4
      couchpotato/core/downloaders/transmission/main.py
  12. 18
      couchpotato/core/downloaders/utorrent/__init__.py
  13. 22
      couchpotato/core/downloaders/utorrent/main.py
  14. 21
      couchpotato/core/plugins/renamer/main.py
  15. 2
      couchpotato/core/plugins/subtitle/main.py

2
couchpotato/core/downloaders/base.py

@ -82,7 +82,7 @@ class Downloader(Provider):
return
if item and item.get('downloader') == self.getName():
if self.conf('remove_complete'):
if self.conf('remove_complete', default = False):
return self.processComplete(item = item, delete_files = self.conf('delete_files', default = False))
return False

1
couchpotato/core/downloaders/blackhole/main.py

@ -7,6 +7,7 @@ import traceback
log = CPLog(__name__)
class Blackhole(Downloader):
type = ['nzb', 'torrent', 'torrent_magnet']

2
couchpotato/core/downloaders/nzbget/__init__.py

@ -42,6 +42,7 @@ config = [{
},
{
'name': 'priority',
'advanced': True,
'default': '0',
'type': 'dropdown',
'values': [('Very Low', -100), ('Low', -50), ('Normal', 0), ('High', 50), ('Very High', 100)],
@ -57,6 +58,7 @@ config = [{
{
'name': 'delete_failed',
'default': True,
'advanced': True,
'type': 'bool',
'description': 'Delete a release after the download has failed.',
},

1
couchpotato/core/downloaders/nzbget/main.py

@ -12,6 +12,7 @@ import xmlrpclib
log = CPLog(__name__)
class NZBGet(Downloader):
type = ['nzb']

1
couchpotato/core/downloaders/nzbvortex/__init__.py

@ -38,6 +38,7 @@ config = [{
{
'name': 'delete_failed',
'default': True,
'advanced': True,
'type': 'bool',
'description': 'Delete a release after the download has failed.',
},

1
couchpotato/core/downloaders/nzbvortex/main.py

@ -16,6 +16,7 @@ import urllib2
log = CPLog(__name__)
class NZBVortex(Downloader):
type = ['nzb']

1
couchpotato/core/downloaders/pneumatic/main.py

@ -6,6 +6,7 @@ import traceback
log = CPLog(__name__)
class Pneumatic(Downloader):
type = ['nzb']

4
couchpotato/core/downloaders/sabnzbd/__init__.py

@ -43,14 +43,16 @@ config = [{
},
{
'name': 'remove_complete',
'advanced': True,
'label': 'Remove NZB',
'default': True,
'default': False,
'type': 'bool',
'description': 'Remove the NZB from history after it completed.',
},
{
'name': 'delete_failed',
'default': True,
'advanced': True,
'type': 'bool',
'description': 'Delete a release after the download has failed.',
},

1
couchpotato/core/downloaders/sabnzbd/main.py

@ -10,6 +10,7 @@ import traceback
log = CPLog(__name__)
class Sabnzbd(Downloader):
type = ['nzb']

19
couchpotato/core/downloaders/transmission/__init__.py

@ -33,27 +33,15 @@ config = [{
'type': 'password',
},
{
'name': 'paused',
'type': 'bool',
'default': False,
'description': 'Add the torrent paused.',
},
{
'name': 'directory',
'type': 'directory',
'description': 'Download to this directory. Keep empty for default Transmission download directory.',
},
{
'name': 'seeding',
'label': 'Seeding support',
'default': True,
'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.',
},
{
'name': 'remove_complete',
'label': 'Remove torrent',
'default': True,
'default': False,
'advanced': True,
'type': 'bool',
'description': 'Remove the torrent from Transmission after it finished seeding.',
},
@ -68,6 +56,7 @@ config = [{
{
'name': 'paused',
'type': 'bool',
'advanced': True,
'default': False,
'description': 'Add the torrent paused.',
},
@ -81,12 +70,14 @@ config = [{
{
'name': 'stalled_as_failed',
'default': True,
'advanced': True,
'type': 'bool',
'description': 'Consider a stalled torrent as failed',
},
{
'name': 'delete_failed',
'default': True,
'advanced': True,
'type': 'bool',
'description': 'Delete a release after the download has failed.',
},

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

@ -55,11 +55,11 @@ class Transmission(Downloader):
# Change parameters of torrent
torrent_params = {}
if data.get('seed_ratio') and self.conf('seeding'):
if data.get('seed_ratio'):
torrent_params['seedRatioLimit'] = tryFloat(data.get('seed_ratio'))
torrent_params['seedRatioMode'] = 1
if data.get('seed_time') and self.conf('seeding'):
if data.get('seed_time'):
torrent_params['seedIdleLimit'] = tryInt(data.get('seed_time')) * 60
torrent_params['seedIdleMode'] = 1

18
couchpotato/core/downloaders/utorrent/__init__.py

@ -37,16 +37,10 @@ config = [{
'description': 'Label to add torrent as.',
},
{
'name': 'seeding',
'label': 'Seeding support',
'default': True,
'type': 'bool',
'description': '(Hard)links/copies after download is complete (if enabled in renamer), wait for seeding to finish before (re)moving.',
},
{
'name': 'remove_complete',
'label': 'Remove torrent',
'default': True,
'default': False,
'advanced': True,
'type': 'bool',
'description': 'Remove the torrent from uTorrent after it finished seeding.',
},
@ -61,6 +55,7 @@ config = [{
{
'name': 'paused',
'type': 'bool',
'advanced': True,
'default': False,
'description': 'Add the torrent paused.',
},
@ -71,6 +66,13 @@ config = [{
'advanced': True,
'description': 'Disable this downloader for automated searches, but use it when I manually send a release.',
},
{
'name': 'delete_failed',
'default': True,
'advanced': True,
'type': 'bool',
'description': 'Delete a release after the download has failed.',
},
],
}
],

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

@ -15,7 +15,6 @@ import time
import urllib
import urllib2
log = CPLog(__name__)
@ -31,8 +30,8 @@ class uTorrent(Downloader):
log.error('Config properties are not filled in correctly, port is missing.')
return False
if not self.utorrent_api:
self.utorrent_api = uTorrentAPI(host[0], port = host[1], username = self.conf('username'), password = self.conf('password'))
return self.utorrent_api
def download(self, data, movie, filedata = None):
@ -42,19 +41,23 @@ class uTorrent(Downloader):
if not self.connect():
return False
print 'test'
settings = self.utorrent_api.get_settings()
if not settings:
return False
#Fix settings in case they are not set for CPS compatibility
new_settings = {}
if self.conf('seeding') and not (settings.get('seed_prio_limitul') == 0 and settings['seed_prio_limitul_flag']):
if not (settings.get('seed_prio_limitul') == 0 and settings['seed_prio_limitul_flag']):
new_settings['seed_prio_limitul'] = 0
new_settings['seed_prio_limitul_flag'] = True
log.info('Updated uTorrent settings to set a torrent to complete after it the seeding requirements are met.')
if settings.get('bt.read_only_on_complete'): #This doesnt work as this option seems to be not available through the api
new_settings['bt.read_only_on_complete'] = False
log.info('Updated uTorrent settings to not set the files to read only after completing.')
if new_settings:
self.utorrent_api.set_settings(new_settings)
@ -74,11 +77,11 @@ class uTorrent(Downloader):
torrent_hash = sha1(bencode(info)).hexdigest().upper()
torrent_filename = self.createFileName(data, filedata, movie)
if data.get('seed_ratio') and self.conf('seeding'):
if data.get('seed_ratio'):
torrent_params['seed_override'] = 1
torrent_params['seed_ratio'] = tryInt(tryFloat(data['seed_ratio']) * 1000)
if data.get('seed_time') and self.conf('seeding'):
if data.get('seed_time'):
torrent_params['seed_override'] = 1
torrent_params['seed_time'] = tryInt(data['seed_time']) * 3600
@ -130,10 +133,7 @@ class uTorrent(Downloader):
if 'Finished' in item[21]:
status = 'completed'
elif 'Seeding' in item[21]:
if self.conf('seeding'):
status = 'seeding'
else:
status = 'completed'
statuses.append({
'id': item[0],
@ -152,6 +152,12 @@ class uTorrent(Downloader):
return False
return self.utorrent_api.pause_torrent(download_info['id'], pause)
def removeFailed(self, item):
log.info('%s failed downloading, deleting...', item['name'])
if not self.connect():
return False
return self.utorrent_api.remove_torrent(item['id'], remove_data = True)
def processComplete(self, item, delete_files = False):
log.debug('Requesting uTorrent to remove the torrent %s%s.', (item['name'], ' and cleanup the downloaded files' if delete_files else ''))
if not self.connect():

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

@ -164,6 +164,7 @@ class Renamer(Plugin):
movie_title = getTitle(library)
# Find subtitle for renaming
group['before_rename'] = []
fireEvent('renamer.before', group)
# Remove weird chars from moviename
@ -451,7 +452,7 @@ class Renamer(Plugin):
except:
log.error('Failed removing %s: %s', (release.identifier, traceback.format_exc()))
if group['dirname'] and group['parentdir']:
if group['dirname'] and group['parentdir'] and self.conf('file_action') == 'move':
try:
log.info('Deleting folder: %s', group['parentdir'])
self.deleteEmptyFolder(group['parentdir'])
@ -642,17 +643,6 @@ Remove it if you want it to be renamed (again, or at least let it try again)
for rel in rels:
rel_dict = rel.to_dict({'info': {}})
# Get current selected title
default_title = getTitle(rel.movie.library)
# Check if movie has already completed and is manage tab (legacy db correction)
if rel.movie.status_id == done_status.get('id') and rel.status_id == snatched_status.get('id'):
log.debug('Found a completed movie with a snatched release : %s. Setting release status to ignored...' , default_title)
rel.status_id = ignored_status.get('id')
rel.last_edit = int(time.time())
db.commit()
continue
movie_dict = fireEvent('movie.get', rel.movie_id, single = True)
# check status
@ -678,8 +668,8 @@ Remove it if you want it to be renamed (again, or at least let it try again)
if item['folder'] and self.conf('from') in item['folder']:
self.tagDir(item['folder'], 'downloading')
pass
elif item['status'] == 'seeding':
#If linking setting is enabled, process release
if self.conf('file_action') != 'move' and not rel.movie.status_id == done_status.get('id') and item['id'] and item['downloader'] and item['folder']:
log.info('Download of %s completed! It is now being processed while leaving the original files alone for seeding. Current ratio: %s.', (item['name'], item['seed_ratio']))
@ -702,7 +692,6 @@ Remove it if you want it to be renamed (again, or at least let it try again)
#let it seed
log.debug('%s is seeding with ratio: %s', (item['name'], item['seed_ratio']))
pass
elif item['status'] == 'failed':
fireEvent('download.remove_failed', item, single = True)
rel.status_id = failed_status.get('id')
@ -815,7 +804,7 @@ Remove it if you want it to be renamed (again, or at least let it try again)
return download_info and download_info.get('type') in ['torrent', 'torrent_magnet']
def fileIsAdded(self, src, group):
if not group['files'].get('added'):
if not group or not group.get('before_rename'):
return False
return src in group['files']['added']
return src in group['before_rename']

2
couchpotato/core/plugins/subtitle/main.py

@ -60,7 +60,7 @@ class Subtitle(Plugin):
for d_sub in downloaded:
log.info('Found subtitle (%s): %s', (d_sub.language.alpha2, files))
group['files']['subtitle'].append(d_sub.path)
group['files']['added'].append(d_sub.path)
group['before_rename'].append(d_sub.path)
group['subtitle_language'][d_sub.path] = [d_sub.language.alpha2]
return True

Loading…
Cancel
Save