I have the following code:
def coming_episode ( show ): try: show = api.search ( show , 'en' ) [ 0 ] except: print "a" return announced = [ 'show title' ] for e in show [ len ( show ) -1 ]: if e.FirstAired != '' and time.time () < time.mktime ( e.FirstAired.timetuple () ): announced.append ( [ e.EpisodeName , e.id , time.mktime ( e.FirstAired.timetuple () ) ] ) return announced And this works fine when I look for a show which exsists in the TVDB api. However, I also want to catch the exception when I type something stupid, such as "awdawd" as a show.
I tried except: and also except TVDBIndexError: but both still give me the following error:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "init.py", line 27, in <module> series = coming_episode ( series ) File "init.py", line 19, in coming_episode for e in show [ len ( show ) -1 ]: File "/Users/Sites/Python/_envs/Series/lib/python2.7/site-packages/pytvdbapi/api.py", line 340, in __getitem__ raise error.TVDBIndexError("Season {0} not found".format(item)) pytvdbapi.error.TVDBIndexError: (u'Season 0 not found', (), {}) What am I doing wrong here?
Thanks in advance ;)
api.search. What are you trying to iterate over?