Ejemplo n.º 1
0
    def forIds(self, ids, args):
        dDetails = track.GetTrackDetail(ids)['songs']
        dAudios = track.GetTrackAudio(ids,
                                      bitrate=BITRATES[args.quality])['data']

        dDetails = sorted(dDetails, key=lambda song: song['id'])
        dAudios = sorted(dAudios, key=lambda song: song['id'])
        queued = 0
        for dDetail, dAudio in zip(dDetails, dAudios):
            song = TrackHelper(dDetail)
            logger.info('歌单 / 专辑单曲 #%d / %d - %s - %s (%dkbps)' %
                        (queued + 1, len(dDetails), song.Title, song.AlbumName,
                         dAudio['br'] // 1000))
            tSong = NETrackDownloadTask(
                song=song,
                cover=BaseDownloadTask(id=song.ID,
                                       url=song.AlbumCover,
                                       dest=args.output),
                lyrics=BaseDownloadTask(id=song.ID, dest=args.output),
                resource=BaseDownloadTask(id=song.ID,
                                          url=dAudio['url'],
                                          dest=args.output),
                resource_info=dAudio)
            queued += queue_task(tSong)
        return queued
Ejemplo n.º 2
0
 def getAudio(self):
     data = track.GetTrackAudio(self.sid)
     url = data["data"][0]["url"]
     if url == None:
         return None
     return MediaSource(
         data["data"][0]["url"], self.addXRealIP(Config.commonHeaders),
         "{}.{}".format(self._getParsedTitle(), vfile.getSuffixByUrl(url)))
Ejemplo n.º 3
0
 def load(self, *args, **kwargs):
     data = track.GetTrackDetail(self.sid)
     self.artists = [ar["name"] for ar in data["songs"][0]["ar"]]
     self.cover_url = data["songs"][0]["al"]["picUrl"]
     audiodata = track.GetTrackAudio(self.sid)["data"][0]
     self.vip = audiodata["freeTrialInfo"] != None
     self.available = audiodata["url"] != None
     self.title = data["songs"][0]["name"]
Ejemplo n.º 4
0
 def __call__(self, args):
     dSong = track.GetTrackDetail([match_id(args.url)])['songs'][0]
     song = TrackHelper(dSong)
     dAudio = track.GetTrackAudio([match_id(args.url)],
                                  bitrate=BITRATES[args.quality])['data'][0]
     logger.info('单曲 - %s - %s (%dkbps)' %
                 (song.Title, song.AlbumName, dAudio['br'] // 1000))
     tSong = NETrackDownloadTask(song=song,
                                 cover=BaseDownloadTask(id=song.ID,
                                                        url=song.AlbumCover,
                                                        dest=args.output),
                                 lyrics=BaseDownloadTask(id=song.ID,
                                                         dest=args.output),
                                 resource=BaseDownloadTask(
                                     id=song.ID,
                                     url=dAudio['url'],
                                     dest=args.output),
                                 resource_info=dAudio)
     queue_task(tSong)
     logger.info('下载任务已分配完成')
     return 1  # we queued 1 track for this
Ejemplo n.º 5
0
 def getAudio(self):
     data = track.GetTrackAudio(self.sid)
     url = data["data"][0]["url"]
     return MediaSource(
         data["data"][0]["url"], Config.commonHeaders,
         "{}.{}".format(self._getParsedTitle(), file.getSuffixByUrl(url)))