def next_list(self): """ Each time this func is invoked, a next pagination of tracks is loaded Then self.get_cur_tracks should be called to retrieve the current list of tracks @return bool: True if this new pagination still contains tracks, False if no more tracks, i.e. last pagination None if something wrong with the station, e.g. incorrect stationId """ self.__curStartIdx += self.__prevItems self.__prevItems = 0 self.__curThumbUpTracks = [] url = self.STATION_TRACKS_BASE_URL url = url.replace("[stationId]", self.__stationId) url = url.replace("[startIdx]", str(self.__curStartIdx)) try: response = urllib2.urlopen(url) except: # there must be something wrong with the url, i.e. incorrect url return None html = response.read() elements = DOM.get_elements("li", {"data-date": "[0-9]+", "data-artist": "[^>]+"}, html) for e in elements: trackNodes = DOM.get_elements("h3", {}, e.nodeValue) if len(trackNodes)==0: continue trackNode = trackNodes[0] songNodes = DOM.get_elements("a", {}, trackNode.nodeValue) if len(songNodes)<2: continue song = String.decode_html_entities(songNodes[0].nodeValue) song = String.symbols_to_words(song) song = self.__remove_redundant_words(song) artist = String.decode_html_entities(songNodes[1].nodeValue) artist = String.symbols_to_words(artist) record = song+' '+artist if not record in self.__thumbUpTracks: self.__thumbUpTracks.append(record) self.__curThumbUpTracks.append(record) self.__prevItems += 1 if self.__prevItems == 0: return False return True