def test_song_hqlocation(): import radio radio.visit_radio(state, config.radio_id) tracks = radio.get_radio_list(state, state['radio_type'], state['radio_id']) track = tracks[0] track.dump_info() print "hq location:", track.get_hq_location(state)
def test_radio_list(state): import radio radio.visit_radio(state, config.radio_id) for x in xrange(2): tracks = radio.get_radio_list(state, state['radio_type'], state['radio_id']) for track in tracks: track.dump_info() time.sleep(5)
def test_fav_radio(state): import radio fav_radios = radio.get_fav_radio(state, 1) for fav_radio in fav_radios: print "radio name:", fav_radio['radio_name'] radio.visit_radio(state, fav_radio['radio_id']) tracks = radio.get_radio_list(state, state['radio_type'], state['radio_id']) tracks[0].dump_info()
def fetch_from_station(self, station): try: tracks = radio.get_radio_list(self.state, self.state['radio_type'], self.state['radio_id']) except: logger.exception("fail to get list of songs") return for track in tracks: self.add_track(track)
def test_similar_artists(): import radio radio.visit_radio(state, config.radio_id) tracks = radio.get_radio_list(state, state['radio_type'], state['radio_id']) track = tracks[0] similar_artists = track.get_similar_artists(4) print similar_artists assert(len(similar_artists) == 4) for artist in similar_artists: assert('category' in artist) assert('name' in artist)
def play_radio(state, radio_id): radio.visit_radio(state, radio_id) while True: try: tracks = radio.get_radio_list(state, state['radio_type'], state['radio_id']) except: logger.exception("fail to get list of songs") time.sleep(ERROR_WAIT) continue if state['random']: random.shuffle(tracks) for track in tracks: play_track(state, track) # type 10 -> play from radio try: info.record_play(state, track.song_id, None, info.is_vip(state), "10") except: logger.exception("fail to record") time.sleep(1)
def test_related_info(state): import radio radio.visit_radio(state, config.radio_id) tracks = radio.get_radio_list(state, state['radio_type'], state['radio_id']) track = tracks[0] print track.get_related_info(state)