si 100 años vivo, 100 años chingas a tu madre spotify

This commit is contained in:
cool.gitter.choco
2025-03-15 10:23:41 -06:00
parent 728639d9dd
commit c6204ada00
24 changed files with 869 additions and 146 deletions

View File

@@ -3,6 +3,7 @@ import json
import traceback
from deezspot.spotloader import SpoLogin
from deezspot.deezloader import DeeLogin
from pathlib import Path
def download_track(
service,
@@ -16,6 +17,19 @@ def download_track(
custom_track_format="%tracknum%. %music% - %artist%"
):
try:
# Load Spotify client credentials if available
spotify_client_id = None
spotify_client_secret = None
search_creds_path = Path(f'./creds/spotify/{main}/search.json')
if search_creds_path.exists():
try:
with open(search_creds_path, 'r') as f:
search_creds = json.load(f)
spotify_client_id = search_creds.get('client_id')
spotify_client_secret = search_creds.get('client_secret')
except Exception as e:
print(f"Error loading Spotify search credentials: {e}")
if service == 'spotify':
if fallback:
if quality is None:
@@ -29,7 +43,9 @@ def download_track(
with open(deezer_creds_path, 'r') as f:
deezer_creds = json.load(f)
dl = DeeLogin(
arl=deezer_creds.get('arl', '')
arl=deezer_creds.get('arl', ''),
spotify_client_id=spotify_client_id,
spotify_client_secret=spotify_client_secret
)
dl.download_trackspo(
link_track=url,
@@ -46,7 +62,25 @@ def download_track(
# If the first attempt fails, use the fallback Spotify credentials
spo_creds_dir = os.path.join('./creds/spotify', fallback)
spo_creds_path = os.path.abspath(os.path.join(spo_creds_dir, 'credentials.json'))
spo = SpoLogin(credentials_path=spo_creds_path)
# Check for Spotify client credentials in fallback account
fallback_client_id = spotify_client_id
fallback_client_secret = spotify_client_secret
fallback_search_path = Path(f'./creds/spotify/{fallback}/search.json')
if fallback_search_path.exists():
try:
with open(fallback_search_path, 'r') as f:
fallback_search_creds = json.load(f)
fallback_client_id = fallback_search_creds.get('client_id')
fallback_client_secret = fallback_search_creds.get('client_secret')
except Exception as e:
print(f"Error loading fallback Spotify search credentials: {e}")
spo = SpoLogin(
credentials_path=spo_creds_path,
spotify_client_id=fallback_client_id,
spotify_client_secret=fallback_client_secret
)
spo.download_track(
link_track=url,
output_dir="./downloads",
@@ -65,7 +99,11 @@ def download_track(
quality = 'HIGH'
creds_dir = os.path.join('./creds/spotify', main)
credentials_path = os.path.abspath(os.path.join(creds_dir, 'credentials.json'))
spo = SpoLogin(credentials_path=credentials_path)
spo = SpoLogin(
credentials_path=credentials_path,
spotify_client_id=spotify_client_id,
spotify_client_secret=spotify_client_secret
)
spo.download_track(
link_track=url,
output_dir="./downloads",
@@ -87,7 +125,9 @@ def download_track(
with open(creds_path, 'r') as f:
creds = json.load(f)
dl = DeeLogin(
arl=creds.get('arl', '')
arl=creds.get('arl', ''),
spotify_client_id=spotify_client_id,
spotify_client_secret=spotify_client_secret
)
dl.download_trackdee(
link_track=url,