Skip to content

Commit dddc73b

Browse files
committed
re-add directors for tv series
rel #105 #107
1 parent ee87da4 commit dddc73b

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

pythonbits/api_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def get_psk():
1212
'Manually fix {}'.format(config.config_path))
1313
return sha256(seed).hexdigest()
1414

15+
1516
def d(a):
1617
psk = get_psk()
1718
return "".join([chr(ord(a[i]) ^ ord(psk[i])) for i in range(len(a))])

pythonbits/bb.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ def format_choices(choices):
4949
])
5050

5151

52+
def uniq(seq):
53+
seen = set()
54+
seen_add = seen.add
55+
return [x for x in seq if not (x in seen or seen_add(x))]
56+
57+
5258
class BbSubmission(Submission):
5359
default_fields = ("form_title", "tags", "cover")
5460

@@ -293,21 +299,21 @@ def _render_tags(self):
293299
# todo: get episode-specific actors (from imdb?)
294300

295301
n = self['options']['num_cast']
302+
d = self['options']['num_directors']
296303
tags = list(self['summary']['genres'])
297304

298-
# only add the Director tag/s for movie submissions
299-
if(self.subcategory() == MovieSubmission):
300-
d = self['options']['num_directors']
301-
if 'directors' in self['summary']:
302-
tags += [a['name']
303-
for a in self['summary']['directors'][:d]
304-
if a['name']]
305+
if 'directors' in self['summary']:
306+
tags += [a['name']
307+
for a in self['summary']['directors'][:d]
308+
if a['name']]
305309

306310
if 'cast' in self['summary']:
307311
tags += [a['name']
308312
for a in self['summary']['cast'][:n]
309313
if a['name']]
310314

315+
tags = uniq(tags)
316+
311317
# Maximum tags length is 200 characters
312318
def tags_string(tags):
313319
return ",".join(format_tag(tag) for tag in tags)
@@ -687,6 +693,10 @@ def _render_summary(self):
687693
summary.update(**show_summary)
688694
summary.update(**title_i18n)
689695
summary['cover'] = summary['cover'][0]
696+
directors = uniq([n for names in summary['directors'] for n in names])
697+
summary['directors'] = [{'name': name} for name in directors]
698+
writers = uniq([n for names in summary['writers'] for n in names])
699+
summary['writers'] = [{'name': name} for name in writers]
690700
return summary
691701

692702
def _render_section_description(self):
@@ -728,8 +738,8 @@ def _render_section_information(self):
728738
air_date=' | '.join(s['air_date']),
729739
network=s['network'],
730740
rating=' | '.join(rating_bb),
731-
directors=' | '.join(set(sum(s['directors'], []))),
732-
writers=' | '.join(set(sum(s['writers'], []))),
741+
directors=' | '.join(d['name'] for d in s['directors']),
742+
writers=' | '.join(w['name'] for w in s['writers']),
733743
contentrating=s['contentrating']
734744
)
735745
return description

0 commit comments

Comments
 (0)