Permalink
Browse files

If anything is null it means the episode was not found

  • Loading branch information...
dbr committed May 15, 2009
1 parent 976c491 commit 3959fd9c06aa3f8e005daa13afa876f4083353e6
Showing with 19 additions and 0 deletions.
  1. +19 −0 tvdb_api_wrapper.m
View
@@ -136,9 +136,28 @@ -(NSString*)getEpNameForSid:(NSNumber*)sid
withArgs:[NSArray arrayWithObject:sid]];
PyObject *season = PyObject_GetItem(show, PyInt_FromLong([seasno longValue]));
+ if(!season){
+ Py_Finalize();
+ NSLog(@"Panic, season is null");
+ return nil;
+ }
+
PyObject *episode = PyObject_GetItem(season, PyInt_FromLong([epno longValue]));
+ if(!episode){
+ Py_Finalize();
+ NSLog(@"Panic, episode is null");
+ return nil;
+ };
+
PyObject *attr = PyObject_GetItem(episode, PyString_FromString("episodename"));
+ if(!attr){
+ Py_Finalize();
+ NSLog(@"Panic, attr is null");
+ return nil;
+ }
+
NSString *epname = [NSString stringWithUTF8String:PyString_AsString(attr)];
+
Py_Finalize();
return epname;
}

0 comments on commit 3959fd9

Please sign in to comment.