Convert function now export to the correct bitrate

This commit is contained in:
Andrea 2021-10-18 13:04:27 +02:00
parent 58832d2091
commit baacbdf14b
2 changed files with 51 additions and 44 deletions

3
.gitignore vendored
View File

@ -139,3 +139,6 @@ cython_debug/
# Spotify Credentials # Spotify Credentials
credentials.json credentials.json
#Download Folder
ZSpotify\ Music/

View File

@ -22,7 +22,7 @@ from librespot.metadata import TrackId
from pydub import AudioSegment from pydub import AudioSegment
quality: AudioQuality = AudioQuality.HIGH quality: AudioQuality = AudioQuality.HIGH
#quality: AudioQuality = AudioQuality.VERY_HIGH #Uncomment this line if you have a premium account quality: AudioQuality = AudioQuality.VERY_HIGH #Uncomment this line if you have a premium account
session: Session = None session: Session = None
import hashlib import hashlib
@ -241,7 +241,11 @@ def convertToMp3(filename):
print("### CONVERTING TO MP3 ###") print("### CONVERTING TO MP3 ###")
raw_audio = AudioSegment.from_file(filename, format="ogg", raw_audio = AudioSegment.from_file(filename, format="ogg",
frame_rate=44100, channels=2, sample_width=2) frame_rate=44100, channels=2, sample_width=2)
raw_audio.export(filename, format="mp3") if quality == AudioQuality.VERY_HIGH:
bitrate = "320k"
else:
bitrate = "160k"
raw_audio.export(filename, format="mp3", bitrate=bitrate)
def setAudioTags(filename, artists, name, albumName, releaseYear, disc_number, track_number): def setAudioTags(filename, artists, name, albumName, releaseYear, disc_number, track_number):
print("### SETTING MUSIC TAGS ###") print("### SETTING MUSIC TAGS ###")