Ejemplo n.º 1
0
    def download_albumdee(self,
                          URL,
                          output=stock_output + "/",
                          quality=stock_quality,
                          recursive_quality=stock_recursive_quality,
                          recursive_download=stock_recursive_download,
                          not_interface=stock_not_interface,
                          zips=stock_zip):
        datas = {}
        datas['music'] = []
        datas['artist'] = []
        datas['tracknum'] = []
        datas['discnum'] = []
        datas['bpm'] = []
        datas['gain'] = []
        datas['duration'] = []
        datas['isrc'] = []
        names = []
        array = []
        URL = URL.split("?utm")[0]
        URL1 = "https://www.deezer.com/album/%s" % URL.split("/")[-1]
        URL2 = "https://api.deezer.com/album/%s" % URL.split("/")[-1]
        url = request(URL2, True).json()
        datas['album'] = url['title']
        datas['label'] = url['label']
        datas['year'] = url['release_date']
        datas['genre'] = []

        try:
            for a in url['genres']['data']:
                datas['genre'].append(a['name'])
        except KeyError:
            pass

        datas['genre'] = " & ".join(datas['genre'])
        datas['ar_album'] = []

        for a in url['contributors']:
            if a['role'] == "Main":
                datas['ar_album'].append(a['name'])

        datas['ar_album'] = " & ".join(datas['ar_album'])
        album = var_excape(datas['album'])

        directory = ("%s%s %s/" % (output, album, url['upc']))

        for a in url['tracks']['data']:
            del array[:]
            datas['music'].append(a['title'])

            ur = request("https://api.deezer.com/track/%d" % a['id'],
                         True).json()

            discnum = str(ur['disk_number'])
            tracknum = str(ur['track_position'])

            names.append("%s%s CD %s TRACK %s" %
                         (directory, album, discnum, tracknum))

            datas['tracknum'].append(tracknum)
            datas['discnum'].append(discnum)

            datas['bpm'].append(str(ur['bpm']))

            datas['gain'].append(str(ur['gain']))

            datas['duration'].append(str(ur['duration']))

            datas['isrc'].append(ur['isrc'])

            for a in ur['contributors']:
                if a['name'] != "":
                    array.append(a['name'])

            array.append(ur['artist']['name'])

            datas['artist'].append(artist_sort(array))

        check_dir(directory)

        names, zip_name = self.download(URL, names, quality, recursive_quality,
                                        recursive_download, datas,
                                        not_interface, directory, zips)

        if zips:
            return names, zip_name

        return names
Ejemplo n.º 2
0
    def download_trackdee(self,
                          URL,
                          output=stock_output,
                          quality=stock_quality,
                          recursive_quality=stock_recursive_quality,
                          recursive_download=stock_recursive_download,
                          not_interface=stock_not_interface):
        output += "/"
        datas = {}

        ids = (URL.split("?utm")[0].split("/")[-1])

        URL1 = "https://www.deezer.com/track/%s" % ids
        URL2 = "https://api.deezer.com/track/%s" % ids
        url = request(URL2, True).json()

        url1 = request("http://api.deezer.com/album/%d" % url['album']['id'],
                       True).json()

        datas['music'] = url['title']
        array = []

        for a in url['contributors']:
            if a['name'] != "":
                array.append(a['name'])

        array.append(url['artist']['name'])

        datas['artist'] = artist_sort(array)
        datas['album'] = url1['title']
        datas['tracknum'] = str(url['track_position'])
        datas['discnum'] = str(url['disk_number'])
        datas['year'] = url['release_date']
        datas['genre'] = []

        try:
            for a in url1['genres']['data']:
                datas['genre'].append(a['name'])
        except KeyError:
            pass

        datas['genre'] = " & ".join(datas['genre'])
        datas['ar_album'] = []

        for a in url1['contributors']:
            if a['role'] == "Main":
                datas['ar_album'].append(a['name'])

        datas['ar_album'] = " & ".join(datas['ar_album'])
        datas['label'] = url1['label']
        datas['bpm'] = str(url['bpm'])
        datas['gain'] = str(url['gain'])
        datas['duration'] = str(url['duration'])
        datas['isrc'] = url['isrc']
        album = var_excape(datas['album'])

        directory = (output)

        check_dir(directory)

        name = ("%s%s" % (directory, ids))

        name = self.download(URL, name, quality, recursive_quality,
                             recursive_download, datas, not_interface,
                             directory)

        return name