Browse Source

Make sure that Rating support is suppressed completely when disabled.

0.7.x
shypike 11 years ago
parent
commit
543eeae124
  1. 3
      sabnzbd/api.py
  2. 3
      sabnzbd/interface.py
  3. 25
      sabnzbd/nzbstuff.py
  4. 15
      sabnzbd/postproc.py

3
sabnzbd/api.py

@ -283,7 +283,8 @@ def _api_queue_rating(output, value, kwargs):
audio = setting if type == 'audio' and setting != "-" else None
vote = vote_map[setting] if type == 'vote' else None
flag = flag_map[setting] if type == 'flag' else None
Rating.do.update_user_rating(value, video, audio, vote, flag, kwargs.get('detail'))
if cfg.rating_enable():
Rating.do.update_user_rating(value, video, audio, vote, flag, kwargs.get('detail'))
return report(output)
except:
return report(output, _MSG_BAD_SERVER_PARMS)

3
sabnzbd/interface.py

@ -1056,7 +1056,8 @@ class HistoryPage(object):
audio = kwargs.get('audio') if kwargs.get('audio') != "-" else None
flag = flag_map.get(kwargs.get('rating_flag'))
detail = kwargs.get('expired_host') if kwargs.get('expired_host') != '<Host>' else None
Rating.do.update_user_rating(kwargs.get('job'), video, audio, flag, detail)
if cfg.rating_enable():
Rating.do.update_user_rating(kwargs.get('job'), video, audio, flag, detail)
except:
pass
self.__edit_rating = None;

25
sabnzbd/nzbstuff.py

@ -1310,18 +1310,19 @@ class NzbObject(TryList):
# Determine if rating information (including site identifier so rating can be updated)
# is present in metadata and if so store it
def update_rating(self):
try:
def _get_first_meta(type):
values = self.meta.get('x-oznzb-rating-' + type, None) or self.meta.get('x-rating-' + type, None)
return values[0] if values else None
rating_types = ['video', 'videocnt', 'audio', 'audiocnt', 'voteup' ,'votedown', \
'spam', 'confirmed-spam', 'passworded', 'confirmed-passworded']
fields = {}
for k in rating_types:
fields[k] = _get_first_meta(k)
Rating.do.add_rating(_get_first_meta('id'), self.nzo_id, self.meta.get('x-rating-host'), fields)
except:
pass
if cfg.rating_enable():
try:
def _get_first_meta(type):
values = self.meta.get('x-oznzb-rating-' + type, None) or self.meta.get('x-rating-' + type, None)
return values[0] if values else None
rating_types = ['video', 'videocnt', 'audio', 'audiocnt', 'voteup' ,'votedown', \
'spam', 'confirmed-spam', 'passworded', 'confirmed-passworded']
fields = {}
for k in rating_types:
fields[k] = _get_first_meta(k)
Rating.do.add_rating(_get_first_meta('id'), self.nzo_id, self.meta.get('x-rating-host'), fields)
except:
pass
## end nzo.Mutators #######################################################
###########################################################################

15
sabnzbd/postproc.py

@ -489,13 +489,14 @@ def process_job(nzo):
all_ok = all_ok and not empty
## Update indexer with results
if nzo.encrypted > 0:
Rating.do.update_auto_flag(nzo.nzo_id, Rating.FLAG_ENCRYPTED)
if empty:
hosts = map(lambda s: s.host, sabnzbd.downloader.Downloader.do.nzo_servers(nzo))
if not hosts: hosts = [None]
for host in hosts:
Rating.do.update_auto_flag(nzo.nzo_id, Rating.FLAG_EXPIRED, host)
if cfg.rating_enable():
if nzo.encrypted > 0:
Rating.do.update_auto_flag(nzo.nzo_id, Rating.FLAG_ENCRYPTED)
if empty:
hosts = map(lambda s: s.host, sabnzbd.downloader.Downloader.do.nzo_servers(nzo))
if not hosts: hosts = [None]
for host in hosts:
Rating.do.update_auto_flag(nzo.nzo_id, Rating.FLAG_EXPIRED, host)
## Show final status in history
if all_ok:

Loading…
Cancel
Save