mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-07 10:33:38 +00:00
Merge pull request #776 from JackDandy/feature/ChangeBacklogParts
Change update and use backlogparts when BACKLOG_FREQUENCY setting is …
This commit is contained in:
commit
289394ecee
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)
|
(ex(e), e.filename and (' (file %s)' % e.filename) or ''), logger.WARNING)
|
||||||
|
|
||||||
# Process video files in TV subdirectories
|
# 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)
|
# self._set_process_success(reset=True)
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@ class ProcessTVShow(object):
|
||||||
|
|
||||||
return archives, archive_history
|
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)
|
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
|
# check if the directory have at least one tv video file
|
||||||
for video in video_files:
|
for video in video_files:
|
||||||
try:
|
try:
|
||||||
NameParser().parse(video, cache_result=False)
|
NameParser(showObj=showObj).parse(video, cache_result=False)
|
||||||
return True
|
return True
|
||||||
except (InvalidNameException, InvalidShowException):
|
except (InvalidNameException, InvalidShowException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
for directory in all_dirs:
|
for directory in all_dirs:
|
||||||
try:
|
try:
|
||||||
NameParser().parse(directory, cache_result=False)
|
NameParser(showObj=showObj).parse(directory, cache_result=False)
|
||||||
return True
|
return True
|
||||||
except (InvalidNameException, InvalidShowException):
|
except (InvalidNameException, InvalidShowException):
|
||||||
pass
|
pass
|
||||||
|
@ -452,7 +452,7 @@ class ProcessTVShow(object):
|
||||||
|
|
||||||
for packed in packed_files:
|
for packed in packed_files:
|
||||||
try:
|
try:
|
||||||
NameParser().parse(packed, cache_result=False)
|
NameParser(showObj=showObj).parse(packed, cache_result=False)
|
||||||
return True
|
return True
|
||||||
except (InvalidNameException, InvalidShowException):
|
except (InvalidNameException, InvalidShowException):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -16,10 +16,11 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
# 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 datetime
|
||||||
import threading
|
import threading
|
||||||
|
from math import ceil
|
||||||
|
|
||||||
import sickbeard
|
import sickbeard
|
||||||
|
|
||||||
|
@ -119,6 +120,29 @@ class BacklogSearcher:
|
||||||
forced=forced, torrent_only=torrent_only)
|
forced=forced, torrent_only=torrent_only)
|
||||||
sickbeard.searchQueueScheduler.action.add_item(backlog_queue_item)
|
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):
|
def search_backlog(self, which_shows=None, force_type=NORMAL_BACKLOG, force=False):
|
||||||
|
|
||||||
if self.amActive:
|
if self.amActive:
|
||||||
|
@ -188,7 +212,7 @@ class BacklogSearcher:
|
||||||
|
|
||||||
parts = []
|
parts = []
|
||||||
if standard_backlog and not torrent_only and not continued_backlog:
|
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 = []
|
h_part = []
|
||||||
counter = 0
|
counter = 0
|
||||||
for w in wanted_list:
|
for w in wanted_list:
|
||||||
|
|
|
@ -4494,7 +4494,9 @@ class ConfigSearch(Config):
|
||||||
|
|
||||||
config.change_RECENTSEARCH_FREQUENCY(recentsearch_frequency)
|
config.change_RECENTSEARCH_FREQUENCY(recentsearch_frequency)
|
||||||
|
|
||||||
|
old_backlog_frequency = sickbeard.BACKLOG_FREQUENCY
|
||||||
config.change_BACKLOG_FREQUENCY(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.BACKLOG_DAYS = config.to_int(backlog_days, default=7)
|
||||||
|
|
||||||
sickbeard.USE_NZBS = config.checkbox_to_value(use_nzbs)
|
sickbeard.USE_NZBS = config.checkbox_to_value(use_nzbs)
|
||||||
|
|
Loading…
Reference in a new issue