fixed encoding bug with mp3 files
This commit is contained in:
parent
c6d8c7e18e
commit
fa7bfde4a1
BIN
dsbm/K.I.Z/Hurra die Welt geht unter/Ariane.mp3.part
Normal file
BIN
dsbm/K.I.Z/Hurra die Welt geht unter/Ariane.mp3.part
Normal file
Binary file not shown.
@ -129,7 +129,7 @@ class Download:
|
|||||||
|
|
||||||
src = row['src']
|
src = row['src']
|
||||||
if src == 'musify':
|
if src == 'musify':
|
||||||
self.download_from_musify(row['path'], row['file'], row['url'])
|
musify.download(row)
|
||||||
elif src == 'youtube':
|
elif src == 'youtube':
|
||||||
youtube_music.download(row)
|
youtube_music.download(row)
|
||||||
self.write_metadata(row, row['file'])
|
self.write_metadata(row, row['file'])
|
||||||
@ -142,18 +142,6 @@ class Download:
|
|||||||
os.makedirs(path, exist_ok=True)
|
os.makedirs(path, exist_ok=True)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def download_from_musify(self, path, file, url):
|
|
||||||
logging.info(f"downloading: '{url}'")
|
|
||||||
r = self.session.get(url)
|
|
||||||
if r.status_code != 200:
|
|
||||||
if r.status_code == 404:
|
|
||||||
logging.warning(f"{url} was not found")
|
|
||||||
return -1
|
|
||||||
raise ConnectionError(f"\"{url}\" returned {r.status_code}: {r.text}")
|
|
||||||
with open(file, "wb") as mp3_file:
|
|
||||||
mp3_file.write(r.content)
|
|
||||||
logging.info("finished")
|
|
||||||
|
|
||||||
def write_metadata(self, row, filePath):
|
def write_metadata(self, row, filePath):
|
||||||
AudioSegment.from_file(filePath).export(filePath, format="mp3")
|
AudioSegment.from_file(filePath).export(filePath, format="mp3")
|
||||||
|
|
||||||
|
@ -33,3 +33,20 @@ def get_download_link(default_url):
|
|||||||
logging.info(f"https://musify.club/track/dl/{musify_id}/{musify_name}.mp3")
|
logging.info(f"https://musify.club/track/dl/{musify_id}/{musify_name}.mp3")
|
||||||
|
|
||||||
return f"https://musify.club/track/dl/{musify_id}/{musify_name}.mp3"
|
return f"https://musify.club/track/dl/{musify_id}/{musify_name}.mp3"
|
||||||
|
|
||||||
|
def download_from_musify(path, file, url):
|
||||||
|
logging.info(f"downloading: '{url}'")
|
||||||
|
r = session.get(url)
|
||||||
|
if r.status_code != 200:
|
||||||
|
if r.status_code == 404:
|
||||||
|
logging.warning(f"{url} was not found")
|
||||||
|
return -1
|
||||||
|
raise ConnectionError(f"\"{url}\" returned {r.status_code}: {r.text}")
|
||||||
|
with open(file, "wb") as mp3_file:
|
||||||
|
mp3_file.write(r.content)
|
||||||
|
logging.info("finished")
|
||||||
|
|
||||||
|
def download(row):
|
||||||
|
url = row['url']
|
||||||
|
file_ = row['file']
|
||||||
|
return download_from_musify(file_, url)
|
||||||
|
Loading…
Reference in New Issue
Block a user