Example #1
0
 def get_rank_list(self):
     songs = list()
     musics = self.mysql.select_music_from_rank()
     for music in musics:
         song = SongModel(music[0], music[1])
         songs.append(song)
     return songs
Example #2
0
 def get_song(self, id=None, **params):
     logging.debug('get song %s' % id)
     struct = self.client._request('AudioLibrary.GetSongDetails',
                                   songid=id,
                                   properties=SongModel.PROPERTIES)
     item = SongModel(*struct)
     return item
Example #3
0
 def get_playlist_all_music(self, pid, name):
     songs = list()
     mids, num = self.mysql.select_mid_from_playlist(pid, name)
     for i in range(num):
         url = self.mysql.select_url_from_music_all(mids[i][0])
         song = SongModel(mids[i][0], url[0][0])
         songs.append(song)
     return songs
Example #4
0
 def get_user_love_music(self, uid):
     songs = list()
     musics, num = self.mysql.select_mid_from_user_love(uid)
     for i in range(num):
         url = self.mysql.select_url_from_music_all(musics[i][0])
         song = SongModel(musics[i][0], url[0][0])
         songs.append(song)
     return songs
Example #5
0
 def get_all_music_from_sql(self):
     """get_all_music
     :return: song_model
     """
     songs = list()
     musics, num = self.mysql.select_mid_url_from_music_all()
     for i in range(num):
         song = SongModel(musics[i][0], musics[i][1])
         songs.append(song)
     return songs
Example #6
0
 def get_current_song(self):
     logging.debug('get current song')
     struct = self.client._request('Player.GetItem',
                                   playerid=self.playerid,
                                   properties=SongModel.PROPERTIES)
     _type = struct['item'].pop('type')
     if _type == 'song':
         item = SongModel(**struct['item'])
         self.model.current_song = item
         return item
     else:
         raise Exception('unknown item type')
Example #7
0
 def _init_sql(self):
     """ init music_all table
     WARNING ! NOTICE PLEASE!
     this function should be dangerous,
     you should use it carefully.
     DON'T CALL IT DIRECTLY!
     AHH.
     """
     if self.song_urls is not None:
         for i, url in enumerate(self.song_urls):
             try:
                 song = SongModel(i, url)
                 self.mysql.insert_into_music_all(i, song.title,
                                                  song.artists, url,
                                                  song.length, song.album,
                                                  song.buy_num)
             except Exception as e:
                 print(e)
     else:
         print('[-]ERROR: dir empty!')