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
def check_quality_song(infos, datas): ids = infos["SNG_ID"] num_quality = self.qualities[quality]["n_quality"] file_format = self.qualities[quality]["f_format"] song_quality = self.qualities[quality]["s_quality"] song_md5, version = utils.check_md5_song(infos) song_hash = download_utils.genurl(song_md5, num_quality, ids, version) try: crypted_audio = utils.song_exist(song_md5[0], song_hash) except (IndexError, exceptions.TrackNotFound): if not recursive_quality: raise exceptions.QualityNotFound( "The quality chosen can't be downloaded") for a in self.qualities: if details["quality"] == a: continue num_quality = self.qualities[a]["n_quality"] file_format = self.qualities[a]["f_format"] song_quality = self.qualities[a]["s_quality"] song_hash = download_utils.genurl(song_md5, num_quality, ids, infos["MEDIA_VERSION"]) try: crypted_audio = utils.song_exist( song_md5[0], song_hash) except exceptions.TrackNotFound: raise exceptions.TrackNotFound( "Error with this song %s" % link) album = utils.var_excape(datas["album"]) directory = "%s%s %s/" % ("%s/" % output, album, datas["upc"]) name = "%s%s CD %s TRACK %s" % ( directory, album, datas["discnum"], datas["tracknum"], ) utils.check_dir(directory) name += " ({}){}".format(song_quality, file_format) if isfile(name): if recursive_download: return name ans = input( "Track %s already exists, do you want to redownload it?(y or n):" % name) if not ans in answers: return name decrypted_audio = open(name, "wb") download_utils.decryptfile( crypted_audio.iter_content(2048), download_utils.calcbfkey(ids), decrypted_audio, ) utils.write_tags(name, add_more_tags(datas, infos, ids)) return name
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
def check_quality_song(infos, datas): ids = infos['SNG_ID'] num_quality = self.qualities[quality]['n_quality'] file_format = self.qualities[quality]['f_format'] song_quality = self.qualities[quality]['s_quality'] song_md5, version = utils.check_md5_song(infos) song_hash = download_utils.genurl(song_md5, num_quality, ids, version) try: crypted_audio = utils.song_exist(song_md5[0], song_hash) except (IndexError, exceptions.TrackNotFound): if not recursive_quality: raise exceptions.QualityNotFound( "The quality chosen can't be downloaded") for a in self.qualities: if details['quality'] == a: continue num_quality = self.qualities[a]['n_quality'] file_format = self.qualities[a]['f_format'] song_quality = self.qualities[a]['s_quality'] song_hash = download_utils.genurl(song_md5, num_quality, ids, infos['MEDIA_VERSION']) try: crypted_audio = utils.song_exist( song_md5[0], song_hash) except exceptions.TrackNotFound: raise exceptions.TrackNotFound( "Error with this song %s" % link) music = utils.var_excape(datas['music']) artist = utils.var_excape(infos['ART_NAME']) directory = ("%s" % ("%s/" % output)) name = ("%s%s %s" % (directory, music, artist)) utils.check_dir(directory) name += " ({}){}".format(song_quality, file_format) if isfile(name): if recursive_download: return name ans = input( "Track %s already exists, do you want to redownload it?(y or n):" % name) if not ans in answers: return name decrypted_audio = open(name, "wb") download_utils.decryptfile(crypted_audio.iter_content(2048), download_utils.calcbfkey(ids), decrypted_audio) utils.write_tags(name, add_more_tags(datas, infos, ids)) return name