| 413 | |
| 414 | |
| 415 | class Season(dict): |
| 416 | def __init__(self, show=None): |
| 417 | """The show attribute points to the parent show |
| 418 | """ |
| 419 | self.show = show |
| 420 | |
| 421 | def __repr__(self): |
| 422 | return "<Season instance (containing %s episodes)>" % (len(self.keys())) |
| 423 | |
| 424 | def __getitem__(self, episode_number): |
| 425 | if episode_number not in self: |
| 426 | raise tvdb_episodenotfound("Could not find episode %s" % (repr(episode_number))) |
| 427 | else: |
| 428 | return dict.__getitem__(self, episode_number) |
| 429 | |
| 430 | def search(self, term=None, key=None): |
| 431 | """Search all episodes in season, returns a list of matching Episode |
| 432 | instances. |
| 433 | |
| 434 | >>> t = Tvdb() |
| 435 | >>> t['scrubs'][1].search('first day') |
| 436 | [<Episode 01x01 - u'My First Day'>] |
| 437 | >>> |
| 438 | |
| 439 | See Show.search documentation for further information on search |
| 440 | """ |
| 441 | results = [] |
| 442 | for ep in self.values(): |
| 443 | searchresult = ep.search(term=term, key=key) |
| 444 | if searchresult is not None: |
| 445 | results.append(searchresult) |
| 446 | return results |
| 447 | |
| 448 | |
| 449 | class Episode(dict): |