@@ -253,7 +253,7 @@ def _render_tv_specifier(self):
253253 raise Exception ('Could not find a season in the path name. '
254254 'Try specifying it in the TITLE argument, '
255255 'e.g. "Some TV Show S02" for a season 2 pack' )
256- return TvSpecifier (title , season , guess .get ('episode' , None ))
256+ return TvSpecifier (title , season , guess .get ('episode' ))
257257
258258 @form_field ('tags' )
259259 def _render_tags (self ):
@@ -541,6 +541,10 @@ class TvSubmission(VideoSubmission):
541541 'form_description' : ('desc' , 'text' ),
542542 }
543543
544+ @property
545+ def season (self ):
546+ return self ['tv_specifier' ].season
547+
544548 def _render_guess (self ):
545549 return dict (guessit .guessit (self ['path' ],
546550 options = ('--type' , 'episode' )))
@@ -552,10 +556,9 @@ def subcategory(self):
552556 if type (self ) == TvSubmission :
553557 if self ['tv_specifier' ].episode is None :
554558 return SeasonSubmission
555- elif not isinstance (self ['tv_specifier' ].episode , abc .Sequence ):
556- return EpisodeSubmission
557559 else :
558- return MultiEpisodeSubmission
560+ return EpisodeSubmission
561+
559562 return type (self )
560563
561564 @staticmethod
@@ -604,69 +607,19 @@ def _render_form_description(self):
604607
605608
606609class EpisodeSubmission (TvSubmission ):
607- @form_field ('title' )
608- def _render_form_title (self ):
609- return "{t} S{s:02d}E{e:02d} [{m}]" .format (
610- t = self ['title' ], s = self ['tv_specifier' ].season ,
611- e = self ['tv_specifier' ].episode ,
612- m = " / " .join (self ['markers' ]))
613-
614- def _render_summary (self ):
615- t = tvdb .TVDB ()
616- result = t .search (self ['tv_specifier' ])
617- summary = result .summary ()
618- summary .update (self .tvdb_title_i18n (result ))
619- return summary
620-
621- def _render_section_description (self ):
622- summary = self ['summary' ]
623- return summary ['seriessummary' ] + bb .spoiler (
624- summary ['episodesummary' ], "Episode description" )
625-
626- def _render_section_information (self ):
627- s = self ['summary' ]
628- links = [('TVDB' , s ['url' ])]
629-
630- if s ['imdb_id' ]:
631- links .append (('IMDb' ,
632- "https://www.imdb.com/title/" + s ['imdb_id' ]))
633-
634- if s ['imdb_id' ]:
635- i = imdb .IMDB ()
636- rating , votes = i .get_rating (s ['imdb_id' ])
637-
638- rating_bb = (bb .format_rating (rating [0 ], max = rating [1 ]) + " " +
639- bb .s1 ("({votes} votes)" .format (
640- votes = votes )))
641- else :
642- rating_bb = ""
643-
644- description = dedent ("""\
645- [b]Episode title[/b]: {title} ({links})
646- [b]Aired[/b]: {air_date} on {network}
647- [b]IMDb Rating[/b]: {rating}
648- [b]Directors[/b]: {directors}
649- [b]Writer(s)[/b]: {writers}
650- [b]Content rating[/b]: {contentrating}""" ).format (
651- title = s ['episode_title' ],
652- links = ", " .join (bb .link (* l ) for l in links ), # noqa: E741
653- air_date = s ['air_date' ],
654- network = s ['network' ],
655- rating = rating_bb ,
656- directors = ' | ' .join (s ['directors' ]),
657- writers = ' | ' .join (s ['writers' ]),
658- contentrating = s ['contentrating' ]
659- )
660- return description
661-
610+ @property
611+ def episodes (self ):
612+ episodes = self ['tv_specifier' ].episode
613+ if isinstance (episodes , abc .Sequence ):
614+ return episodes
615+ return [episodes ]
662616
663- class MultiEpisodeSubmission (TvSubmission ):
664617 @form_field ('title' )
665618 def _render_form_title (self ):
666619 return "{t} S{s:02d}{es} [{m}]" .format (
667- t = self ['title' ], s = self [ 'tv_specifier' ] .season ,
620+ t = self ['title' ], s = self .season ,
668621 es = "" .join ("E{:02d}" .format (e )
669- for e in self [ 'tv_specifier' ]. episode ),
622+ for e in self . episodes ),
670623 m = " / " .join (self ['markers' ]))
671624
672625 def _render_summary (self ):
0 commit comments