tweaked artist search
authorKristoffer Grönlund <kristoffer.gronlund@purplescout.se>
Tue, 29 Dec 2009 09:29:07 +0000 (10:29 +0100)
committerKristoffer Grönlund <kristoffer.gronlund@purplescout.se>
Sat, 2 Jan 2010 23:37:43 +0000 (00:37 +0100)
jamaendo/api.py
scripts/artists

index 9524040..b3683d8 100644 (file)
@@ -77,7 +77,8 @@ class DB(object):
         else:
             ret = Obj()
             for child in element:
         else:
             ret = Obj()
             for child in element:
-                setattr(ret, child.tag, self.make_obj(child))
+                if child.tag in ['name', 'id']:
+                    setattr(ret, child.tag, child.text)
             return ret
 
     def artist_walker(self):
             return ret
 
     def artist_walker(self):
@@ -90,8 +91,4 @@ class DB(object):
 
     def search_artists(self, substr):
         substr = substr.lower()
 
     def search_artists(self, substr):
         substr = substr.lower()
-        #return [dir(artist) for artist in self.artist_walker() if artist.name.find(substr) > -1]
-        artist = self.artist_walker().next()
-        print artist
-        print artist.name
-        return [artist.id]
+        return [artist for artist in self.artist_walker() if artist.name.lower().find(substr) > -1]
index c8bc8b5..292fdd0 100755 (executable)
@@ -9,8 +9,8 @@ def main():
     print "Connected."
     q = sys.argv[1]
     print "Querying db for %s..." % (q)
     print "Connected."
     q = sys.argv[1]
     print "Querying db for %s..." % (q)
-    ids = db.search_artists(q)
-    print ", ".join(ids)
+    artists = db.search_artists(q)
+    print artists
 
 if __name__=="__main__":
     main()
 
 if __name__=="__main__":
     main()