mirror of
https://github.com/Footsiefat/zspotify
synced 2021-12-21 22:06:14 +01:00
Added raw audio option
This commit is contained in:
parent
6616fd30f4
commit
f3da7398c7
11
zspotify.py
11
zspotify.py
@ -20,12 +20,13 @@ from librespot.metadata import TrackId
|
|||||||
from pydub import AudioSegment
|
from pydub import AudioSegment
|
||||||
|
|
||||||
SESSION: Session = None
|
SESSION: Session = None
|
||||||
|
sanitize = ["\\", "/", ":", "*", "?", "'", "<", ">", '"']
|
||||||
|
|
||||||
ROOT_PATH = "ZSpotify Music/"
|
ROOT_PATH = "ZSpotify Music/"
|
||||||
SKIP_EXISTING_FILES = True
|
SKIP_EXISTING_FILES = True
|
||||||
MUSIC_FORMAT = "mp3" # or "ogg"
|
MUSIC_FORMAT = "mp3" # or "ogg"
|
||||||
FORCE_PREMIUM = False # set to True if not detecting your premium account automatically
|
FORCE_PREMIUM = False # set to True if not detecting your premium account automatically
|
||||||
sanitize = ["\\", "/", ":", "*", "?", "'", "<", ">", '"']
|
RAW_AUDIO_AS_IS = False # set to True if you wish you save the raw audio without re-encoding it.
|
||||||
|
|
||||||
# miscellaneous functions for general use
|
# miscellaneous functions for general use
|
||||||
|
|
||||||
@ -411,7 +412,7 @@ def get_saved_tracks(access_token):
|
|||||||
# Functions directly related to downloading stuff
|
# Functions directly related to downloading stuff
|
||||||
def download_track(track_id_str: str, extra_paths=""):
|
def download_track(track_id_str: str, extra_paths=""):
|
||||||
""" Downloads raw song audio from Spotify """
|
""" Downloads raw song audio from Spotify """
|
||||||
global ROOT_PATH, SKIP_EXISTING_FILES, MUSIC_FORMAT
|
global ROOT_PATH, SKIP_EXISTING_FILES, MUSIC_FORMAT, RAW_AUDIO_AS_IS
|
||||||
|
|
||||||
track_id = TrackId.from_base62(track_id_str)
|
track_id = TrackId.from_base62(track_id_str)
|
||||||
artists, album_name, name, image_url, release_year, disc_number, track_number, scraped_song_id, is_playable = get_song_info(
|
artists, album_name, name, image_url, release_year, disc_number, track_number, scraped_song_id, is_playable = get_song_info(
|
||||||
@ -452,6 +453,7 @@ def download_track(track_id_str: str, extra_paths=""):
|
|||||||
if byte == b'':
|
if byte == b'':
|
||||||
break
|
break
|
||||||
file.write(byte)
|
file.write(byte)
|
||||||
|
if not RAW_AUDIO_AS_IS:
|
||||||
try:
|
try:
|
||||||
convert_audio_format(filename)
|
convert_audio_format(filename)
|
||||||
except:
|
except:
|
||||||
@ -495,9 +497,14 @@ def download_from_user_playlist():
|
|||||||
|
|
||||||
# Core functions here
|
# Core functions here
|
||||||
|
|
||||||
|
def checkRaw():
|
||||||
|
global RAW_AUDIO_AS_IS, MUSIC_FORMAT
|
||||||
|
if RAW_AUDIO_AS_IS:
|
||||||
|
MUSIC_FORMAT = "raw"
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
""" Main function """
|
""" Main function """
|
||||||
|
checkRaw()
|
||||||
login()
|
login()
|
||||||
client()
|
client()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user