Esempio n. 1
0
 def get_info_by_name(self, show_name):
     """<Results>
     <show>
     <showid>2445</showid>
     <name>24</name>
     <link>http://www.tvrage.com/24</link>
     <country>US</country>
     <started>2001</started>
     <ended>0</ended>
     <seasons>8</seasons>
     <status>Returning Series</status>
     <classification>Scripted</classification>
     <genres><genre01>Action</genre01><genre02>Adventure</genre02><genre03>Drama</genre03></genres>
     </show>
     <show>"""
     if show_name.endswith(", The"):
         show_name = show_name.replace(", The", "")
         show_name = "The " + show_name
     show_xml = http_get(self.search_info_url % urllib.urlencode({"show": show_name}))
     dom = parseString(show_xml)
     shows = dom.getElementsByTagName("show")
     show_id = None
     for show in shows:
         if normalize(unescape(show.getElementsByTagName("name")[0].firstChild.data)) == normalize(show_name):
             show_id = int(show.getElementsByTagName("showid")[0].firstChild.data)
             break
     if show_id is None:
         logging.warn("Did not really find %s" % show_name)
         if len(shows):
             logging.warn("Taking first")
             return self.get_info(int(shows[0].getElementsByTagName("showid")[0].firstChild.data))
         return None
     return self.get_info(show_id)
Esempio n. 2
0
 def get_info_by_name(self, show_name):
     """<Results>
     <show>
     <showid>2445</showid>
     <name>24</name>
     <link>http://www.tvrage.com/24</link>
     <country>US</country>
     <started>2001</started>
     <ended>0</ended>
     <seasons>8</seasons>
     <status>Returning Series</status>
     <classification>Scripted</classification>
     <genres><genre01>Action</genre01><genre02>Adventure</genre02><genre03>Drama</genre03></genres>
     </show>
     <show>"""
     if show_name.endswith(", The"):
         show_name = show_name.replace(", The", "")
         show_name = "The " + show_name
     show_xml = http_get(self.search_info_url % urllib.urlencode({"show": show_name}))
     dom = parseString(show_xml)
     shows = dom.getElementsByTagName("show")
     show_id = None
     for show in shows:
         if normalize(unescape(show.getElementsByTagName("name")[0].firstChild.data)) == normalize(show_name):
             show_id = int(show.getElementsByTagName("showid")[0].firstChild.data)
             break
     if show_id is None:
         logging.warn("Did not really find %s" % show_name)
         if len(shows):
             logging.warn("Taking first")
             return self.get_info(int(shows[0].getElementsByTagName("showid")[0].firstChild.data))
         return None
     return self.get_info(show_id)
Esempio n. 3
0
 def find(cls, show_name):
     if not len(show_name):
         return None
     norm_name = normalize(show_name)
     shows = Show.get_all_ordered()
     for show in shows:
         if show_name == show.name or norm_name == show.normalized_name or \
                 any([norm_name == alt_name for alt_name in show.alternative_names()]):
             return show
Esempio n. 4
0
 def put(self):
     self.normalized_name = normalize(self.name)
     return super(Show, self).put()