예제 #1
0
 def handle_endtag(self, tag):
     if tag == 'tr' and self.tr is not None:
         if len(self.tr) > 1:
             self.tr[0] = extract_mbid(self.tr[0], self.entity)
             if self.tr[0]:
                 self.trs.append(tuple(self.tr[:2]))
         self.tr = None
     if tag == 'td' and self.tr is not None and self.td is not None:
         if len(self.td) == 1:
             self.tr.append(self.td[0])
         self.td = None
예제 #2
0
 def add_artist(self, artist, edit_note, auto=False):
     self.b.open(self.url("/artist/create"))
     self.b.select_form(predicate=lambda f: f.method == "POST" and "/artist/create" in f.action)
     self.b["edit-artist.name"] = artist['name']
     self.b["edit-artist.sort_name"] = artist.get('sort_name', guess_artist_sort_name(artist['name']))
     self.b["edit-artist.edit_note"] = edit_note.encode('utf8')
     self.b.submit()
     mbid = extract_mbid(self.b.geturl(), 'artist')
     if not mbid:
         raise Exception('unable to post edit')
     return mbid
예제 #3
0
 def handle_endtag(self, tag):
     if tag == 'tr' and self.tr is not None:
         if len(self.tr) > 1:
             self.tr[0] = extract_mbid(self.tr[0], self.entity)
             if self.tr[0]:
                 self.trs.append(tuple(self.tr[:2]))
         self.tr = None
     if tag == 'td' and self.tr is not None and self.td is not None:
         if len(self.td) == 1:
             self.tr.append(self.td[0])
         self.td = None
예제 #4
0
 def add_release(self, album, edit_note, auto=False):
     form = album_to_form(album)
     self.b.open(self.url("/release/add"), urllib.urlencode(form))
     time.sleep(2.0)
     self.b.select_form(predicate=lambda f: f.method == "POST" and "/release" in f.action)
     self.b.submit(name="step_editnote")
     time.sleep(2.0)
     self.b.select_form(predicate=lambda f: f.method == "POST" and "/release" in f.action)
     print self.b.response().read()
     self.b.submit(name="save")
     release_mbid = extract_mbid(self.b.geturl(), 'release')
     if not release_mbid:
         raise Exception('unable to post edit')
     return release_mbid