mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-05 17:43:37 +00:00
Change update and use backlogparts when BACKLOG_FREQUENCY setting is changed.
This commit is contained in:
parent
05b5a2dceb
commit
d5a5b94af8
3 changed files with 33 additions and 7 deletions
|
@ -265,7 +265,7 @@ class ProcessTVShow(object):
|
|||
(ex(e), e.filename and (' (file %s)' % e.filename) or ''), logger.WARNING)
|
||||
|
||||
# Process video files in TV subdirectories
|
||||
for directory in [x for x in dirs if self._validate_dir(path, x, nzb_name_original, failed)]:
|
||||
for directory in [x for x in dirs if self._validate_dir(path, x, nzb_name_original, failed, showObj=showObj)]:
|
||||
|
||||
# self._set_process_success(reset=True)
|
||||
|
||||
|
@ -386,7 +386,7 @@ class ProcessTVShow(object):
|
|||
|
||||
return archives, archive_history
|
||||
|
||||
def _validate_dir(self, path, dir_name, nzb_name_original, failed):
|
||||
def _validate_dir(self, path, dir_name, nzb_name_original, failed, showObj=None):
|
||||
|
||||
self._log_helper(u'Processing sub dir: ' + dir_name)
|
||||
|
||||
|
@ -434,14 +434,14 @@ class ProcessTVShow(object):
|
|||
# check if the directory have at least one tv video file
|
||||
for video in video_files:
|
||||
try:
|
||||
NameParser().parse(video, cache_result=False)
|
||||
NameParser(showObj=showObj).parse(video, cache_result=False)
|
||||
return True
|
||||
except (InvalidNameException, InvalidShowException):
|
||||
pass
|
||||
|
||||
for directory in all_dirs:
|
||||
try:
|
||||
NameParser().parse(directory, cache_result=False)
|
||||
NameParser(showObj=showObj).parse(directory, cache_result=False)
|
||||
return True
|
||||
except (InvalidNameException, InvalidShowException):
|
||||
pass
|
||||
|
@ -452,7 +452,7 @@ class ProcessTVShow(object):
|
|||
|
||||
for packed in packed_files:
|
||||
try:
|
||||
NameParser().parse(packed, cache_result=False)
|
||||
NameParser(showObj=showObj).parse(packed, cache_result=False)
|
||||
return True
|
||||
except (InvalidNameException, InvalidShowException):
|
||||
pass
|
||||
|
|
|
@ -16,10 +16,11 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import with_statement
|
||||
from __future__ import with_statement, division
|
||||
|
||||
import datetime
|
||||
import threading
|
||||
from math import ceil
|
||||
|
||||
import sickbeard
|
||||
|
||||
|
@ -119,6 +120,29 @@ class BacklogSearcher:
|
|||
forced=forced, torrent_only=torrent_only)
|
||||
sickbeard.searchQueueScheduler.action.add_item(backlog_queue_item)
|
||||
|
||||
@staticmethod
|
||||
def change_backlog_parts(old_count, new_count):
|
||||
try:
|
||||
my_db = db.DBConnection('cache.db')
|
||||
sql_result = my_db.select('SELECT * FROM backlogparts')
|
||||
if sql_result:
|
||||
current_parts = len(set(s['part'] for s in sql_result))
|
||||
parts_count = len(sql_result)
|
||||
new_part_count = int(ceil(new_count / old_count * current_parts))
|
||||
parts = int(ceil(parts_count / new_part_count))
|
||||
cl = ([], [['DELETE FROM backlogparts']])[parts_count > 1]
|
||||
p = new_count - new_part_count
|
||||
for i, s in enumerate(sql_result):
|
||||
if i % parts == 0:
|
||||
p += 1
|
||||
cl.append(['INSERT INTO backlogparts (part, indexerid, indexer) VALUES (?,?,?)',
|
||||
[p, s['indexerid'], s['indexer']]])
|
||||
|
||||
if 0 < len(cl):
|
||||
my_db.mass_action(cl)
|
||||
except:
|
||||
pass
|
||||
|
||||
def search_backlog(self, which_shows=None, force_type=NORMAL_BACKLOG, force=False):
|
||||
|
||||
if self.amActive:
|
||||
|
@ -188,7 +212,7 @@ class BacklogSearcher:
|
|||
|
||||
parts = []
|
||||
if standard_backlog and not torrent_only and not continued_backlog:
|
||||
fullbacklogparts = sum([len(w) for w in wanted_list if w]) / sickbeard.BACKLOG_FREQUENCY
|
||||
fullbacklogparts = sum([len(w) for w in wanted_list if w]) // sickbeard.BACKLOG_FREQUENCY
|
||||
h_part = []
|
||||
counter = 0
|
||||
for w in wanted_list:
|
||||
|
|
|
@ -4494,7 +4494,9 @@ class ConfigSearch(Config):
|
|||
|
||||
config.change_RECENTSEARCH_FREQUENCY(recentsearch_frequency)
|
||||
|
||||
old_backlog_frequency = sickbeard.BACKLOG_FREQUENCY
|
||||
config.change_BACKLOG_FREQUENCY(backlog_frequency)
|
||||
sickbeard.search_backlog.BacklogSearcher.change_backlog_parts(old_backlog_frequency, sickbeard.BACKLOG_FREQUENCY)
|
||||
sickbeard.BACKLOG_DAYS = config.to_int(backlog_days, default=7)
|
||||
|
||||
sickbeard.USE_NZBS = config.checkbox_to_value(use_nzbs)
|
||||
|
|
Loading…
Reference in a new issue