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

Method search

tvdb_api.py:355–412  ·  view source on GitHub ↗

Search all episodes in show. Can search all data, or a specific key (for example, episodename) Always returns an array (can be empty). First index contains the first match, and so on. Each array index is an Episode() instance, so doing search_result

(self, term=None, key=None)

Source from the content-addressed store, hash-verified

353 return ret
354
355 def search(self, term=None, key=None):
356 """
357 Search all episodes in show. Can search all data, or a specific key
358 (for example, episodename)
359
360 Always returns an array (can be empty). First index contains the first
361 match, and so on.
362
363 Each array index is an Episode() instance, so doing
364 search_results[0]['episodename'] will retrieve the episode name of the
365 first match.
366
367 Search terms are converted to lower case (unicode) strings.
368
369 # Examples
370
371 These examples assume t is an instance of Tvdb():
372
373 >>> t = Tvdb()
374 >>>
375
376 To search for all episodes of Scrubs with a bit of data
377 containing "my first day":
378
379 >>> t['Scrubs'].search("my first day")
380 [<Episode 01x01 - u'My First Day'>]
381 >>>
382
383 Search for "My Name Is Earl" episode named "Faked His Own Death":
384
385 >>> t['My Name Is Earl'].search('Faked My Own Death', key='episodeName')
386 [<Episode 01x04 - u'Faked My Own Death'>]
387 >>>
388
389 To search Scrubs for all episodes with "mentor" in the episode name:
390
391 >>> t['scrubs'].search('mentor', key='episodeName')
392 [<Episode 01x02 - u'My Mentor'>, <Episode 03x15 - u'My Tormented Mentor'>]
393 >>>
394
395 # Using search results
396
397 >>> results = t['Scrubs'].search("my first")
398 >>> print results[0]['episodeName']
399 My First Day
400 >>> for x in results: print x['episodeName']
401 My First Day
402 My First Step
403 My First Kill
404 >>>
405 """
406 results = []
407 for cur_season in self.values():
408 searchresult = cur_season.search(term=term, key=key)
409 if len(searchresult) != 0:
410 results.extend(searchresult)
411
412 return results

Callers 10

aired_onMethod · 0.95
searchMethod · 0.45
test_search_lenMethod · 0.45
test_search_checknameMethod · 0.45
test_search_seasonMethod · 0.45
test_search_showMethod · 0.45
test_searchMethod · 0.45
test_1Method · 0.45

Calls

no outgoing calls

Tested by 8

test_search_lenMethod · 0.36
test_search_checknameMethod · 0.36
test_search_seasonMethod · 0.36
test_search_showMethod · 0.36
test_searchMethod · 0.36
test_1Method · 0.36