         if res.statusCode is 200 and !err?
           parser = new xml2js.Parser()
           parser.parseString body, (err, result) ->
-            if result.show?
+            if result.Results and (result = result.Results).show?
               if result.show.length?
                 show = result.show[0]
               else

                    if res.statusCode is 200 and !err?
                      parser = new xml2js.Parser()
                      parser.parseString details, (err, showdetails) ->
                        now = new Date();
                        ecb = (season_arr) ->
                          for episode in season_arr.episode
                            edate = new Date()
                            edate.setTime(Date.parse(episode.airdate+' '+show.airtime))
                            if edate.getTime() > now.getTime()
                              return episode
                        if showdetails.Episodelist.Season.length?
                          unaired = ecb season for season in showdetails.Episodelist.Season
                        else
                          unaired = ecb showdetails.Episodelist.Season
                        if unaired
                          response = "#{show.name} is a #{show.status} which started airing #{show.started}. The next show, titled \"#{unaired.title}\" is scheduled for #{unaired.airdate}"
                          response += " #{show.day}" if show.day?
                          response += " at #{show.airtime}" if show.airtime?
                          response += " on #{show.network['#']}" if show.network? and show.network['#']

xml2js = require "xml2js"
module.exports = (robot) ->
  robot.respond /tvshow(?: me)? (.*)/i, (msg) ->
