def run(self): if not self.songs: self.listType, self.listId, self.album = self.preference.get_prefs() #url="http://www.google.cn/music/chartlisting?cat=song&q=chinese_songs_cn&output=xml" url="http://www.google.cn/music/album?id=B679efdab97c7afc7&output=xml" if self.listType is not None and self.listId is not None: if self.listType == 'song': url="http://www.google.cn/music/chartlisting?cat=song&q=%s&output=xml" % self.listId elif self.listType == 'topic': url="http://www.google.cn/music/topiclisting?cat=song&q=%s&output=xml" % self.listId print 'Load List from the %s' % url self.songs = Analyze.getSongList(url, True) if not self.songs: return None for row in self.source.props.query_model: entry = row[0] self.db.entry_delete(entry) self.is_run = True load_count = 0 load_all = len(self.songs) gobject.idle_add(self.source.notify_progress, True, load_count, load_all) for song in self.songs: if not self.set_stop: time.sleep(0.2) self.add_song(song) load_count += 1 gobject.idle_add(self.source.notify_progress, True, load_count, load_all) self.db.commit() self.is_run = False gobject.idle_add(self.source.notify_progress, False, 1, 1)
def search_music(self, btn, store, flag): search_key = self.search_entry.get_text().strip() if search_key == '': return None xml_url="http://www.google.cn/music/search?cat=song&q=%s&start=%d&num=%d&cad=player&output=xml" % (search_key, self.count * 20, ONE_PAGE_SIZE) song_list = Analyze.getSongList(xml_url, False) if not song_list or len(song_list) == 0: msgBox = gtk.MessageDialog(parent=self.dialog, flags=gtk.DIALOG_MODAL, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_CLOSE, message_format=_("No more song!")) msgBox.connect("response", lambda a, b: msgBox.hide()) msgBox.run() return None if flag: store.clear() iter = None #'', 'Title', 'Album', 'Artist', 'Time', 'ID' for song in song_list: title = song['name'] album = song['album'] artist = song['artist'] time = song['duration'] id = song['id'] iter = store.append([False, title, album, artist, time, id]) if not flag: self.search_tree.scroll_to_cell(store.get_path(iter)) self.count += 1 if len(song_list) < ONE_PAGE_SIZE: self.has_next = False else: self.has_next = True