Skip to content

Commit

Permalink
Fixed BlackAndWhiteList parameters. (#3621)
Browse files Browse the repository at this point in the history
  • Loading branch information
p0psicles authored and medariox committed Jan 18, 2018
1 parent 87cbe75 commit 52a9463
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions medusa/black_and_white_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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']
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion medusa/show_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion medusa/tv/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 52a9463

Please sign in to comment.