MCPcopy Create free account
hub / github.com/dbr/tvdb_api / Episode

Class Episode

tvdb_api.py:449–503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

447
448
449class Episode(dict):
450 def __init__(self, season=None):
451 """The season attribute points to the parent season
452 """
453 self.season = season
454
455 def __repr__(self):
456 seasno = self.get(u'airedSeason', 0)
457 epno = self.get(u'airedEpisodeNumber', 0)
458 epname = self.get(u'episodeName')
459 if epname is not None:
460 return "<Episode %02dx%02d - %r>" % (seasno, epno, epname)
461 else:
462 return "<Episode %02dx%02d>" % (seasno, epno)
463
464 def __getitem__(self, key):
465 try:
466 return dict.__getitem__(self, key)
467 except KeyError:
468 raise tvdb_attributenotfound("Cannot find attribute %s" % (repr(key)))
469
470 def search(self, term=None, key=None):
471 """Search episode data for term, if it matches, return the Episode (self).
472 The key parameter can be used to limit the search to a specific element,
473 for example, episodename.
474
475 This primarily for use use by Show.search and Season.search. See
476 Show.search for further information on search
477
478 Simple example:
479
480 >>> e = Episode()
481 >>> e['episodeName'] = "An Example"
482 >>> e.search("examp")
483 <Episode 00x00 - 'An Example'>
484 >>>
485
486 Limiting by key:
487
488 >>> e.search("examp", key = "episodeName")
489 <Episode 00x00 - 'An Example'>
490 >>>
491 """
492 if term is None:
493 raise TypeError("must supply string to search for (contents)")
494
495 term = text_type(term).lower()
496 for cur_key, cur_value in self.items():
497 cur_key = text_type(cur_key)
498 cur_value = text_type(cur_value).lower()
499 if key is not None and cur_key != key:
500 # Do not search this key
501 continue
502 if cur_value.find(text_type(term)) > -1:
503 return self
504
505
506class Actors(list):

Callers 1

_setItemMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected