From 52a946339926c31010f794da5f5858fecc5f5b1d Mon Sep 17 00:00:00 2001 From: p0ps Date: Thu, 18 Jan 2018 11:28:43 +0100 Subject: [PATCH] Fixed BlackAndWhiteList parameters. (#3621) --- medusa/black_and_white_list.py | 20 ++++++++++---------- medusa/show_queue.py | 2 +- medusa/tv/series.py | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/medusa/black_and_white_list.py b/medusa/black_and_white_list.py index a8bf42ddf1..1baf4bd16f 100644 --- a/medusa/black_and_white_list.py +++ b/medusa/black_and_white_list.py @@ -33,22 +33,22 @@ class BlackAndWhiteList(object): """Black and White List.""" - def __init__(self, series): + def __init__(self, series_obj): """Init method. - :param show_id: - :type show_id: int + :param series_obj: + :type series_obj: Series """ - if not series.indexerid: + if not series_obj.indexerid: raise BlackWhitelistNoShowIDException() - self.series = series + self.series_obj = series_obj self.blacklist = [] self.whitelist = [] self.load() def load(self): """Build black and whitelist.""" - logger.debug('Building black and white list for {id}', id=self.series.indexerid) + logger.debug('Building black and white list for {id}', id=self.series_obj.name) self.blacklist = self._load_list(b'blacklist') self.whitelist = self._load_list(b'whitelist') @@ -63,7 +63,7 @@ def _add_keywords(self, table, values): main_db_con.action( b'INSERT INTO [{table}] (show_id, keyword, indexer_id) ' b'VALUES (?, ?, ?)'.format(table=table), - [self.series.indexerid, value, self.series.indexer] + [self.series_obj.series_id, value, self.series_obj.indexer] ) def set_black_keywords(self, values): @@ -95,7 +95,7 @@ def _del_all_keywords(self, table): main_db_con.action( b'DELETE FROM [{table}] ' b'WHERE show_id = ? AND indexer_id = ?'.format(table=table), - [self.series.indexerid, self.series.indexer] + [self.series_obj.series_id, self.series_obj.indexer] ) def _load_list(self, table): @@ -110,7 +110,7 @@ def _load_list(self, table): b'SELECT keyword ' b'FROM [{table}] ' b'WHERE show_id = ? AND indexer_id = ?'.format(table=table), - [self.series.indexerid, self.series.indexer] + [self.series_obj.series_id, self.series_obj.indexer] ) groups = [result[b'keyword'] @@ -119,7 +119,7 @@ def _load_list(self, table): if groups: logger.debug('BWL: {id} loaded keywords from {table}: {groups}', - id=self.series.indexerid, table=table, groups=groups) + id=self.series_obj.series_id, table=table, groups=groups) return groups diff --git a/medusa/show_queue.py b/medusa/show_queue.py index 7866b9f9df..a735643de4 100644 --- a/medusa/show_queue.py +++ b/medusa/show_queue.py @@ -488,7 +488,7 @@ def run(self): self.show.default_ep_status = self.default_status if self.show.anime: - self.show.release_groups = BlackAndWhiteList(self.show.indexerid) + self.show.release_groups = BlackAndWhiteList(self.show) if self.blacklist: self.show.release_groups.set_black_keywords(self.blacklist) if self.whitelist: diff --git a/medusa/tv/series.py b/medusa/tv/series.py index 2b2f7f9bf4..8632e05a9e 100644 --- a/medusa/tv/series.py +++ b/medusa/tv/series.py @@ -1986,7 +1986,7 @@ def __unicode__(self): def to_json(self, detailed=True): """Return JSON representation.""" - bw_list = self.release_groups or BlackAndWhiteList(self.series_id) + bw_list = self.release_groups or BlackAndWhiteList(self) data = NonEmptyDict() data['id'] = NonEmptyDict()