-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
66 lines (56 loc) · 2.75 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import os
import subprocess
ascii = """
##############################################################################################
# #
# _ _ __ __ _ _ _ #
# ___ _ __ ___ | |_(_)/ _|_ _ \ \ _ _| |_| |__ _ __ ___ _ _ ___(_) ___ #
# / __| '_ \ / _ \| __| | |_| | | | _____\ \ | | | | __| '_ \ | '_ ` _ \| | | / __| |/ __| #
# \__ \ |_) | (_) | |_| | _| |_| | |_____/ / | |_| | |_| |_) | | | | | | | |_| \__ \ | (__ #
# |___/ .__/ \___/ \__|_|_| \__, | /_/ \__, |\__|_.__/ |_| |_| |_|\__,_|___/_|\___| #
# |_| |___/ |___/ #
# #
##############################################################################################
"""
print(ascii)
def check_env_variables():
# Check if .env file exists
if not os.path.exists('.env'):
create_env_file()
return False
# Load .env file
with open('.env', 'r') as file:
env_content = file.read()
# Check if SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET are declared
if "SPOTIFY_CLIENT_ID" not in env_content or "SPOTIFY_CLIENT_SECRET" not in env_content:
print("Error: SPOTIFY_CLIENT_ID or SPOTIFY_CLIENT_SECRET not found in .env file.")
return False
return True
def create_env_file():
print("Creating .env file...")
with open('.env', 'w') as file:
client_id = input("Enter your Spotify client ID: ")
client_secret = input("Enter your Spotify client secret: ")
file.write(f"SPOTIFY_CLIENT_ID={client_id}\n")
file.write(f"SPOTIFY_CLIENT_SECRET={client_secret}\n")
print(".env file created successfully.")
if __name__ == "__main__":
if check_env_variables():
print("Environment variables are correctly set.")
# Proceed with your main logic here
# Path to the Python scripts
spotify_script = "spotify.py"
ytbmusic_script = "ytbmusic.py"
# Execute the Spotify script to generate the JSON file
print("Executing spotify.py...")
subprocess.run(["python3", spotify_script])
# Check if the JSON file has been created
if os.path.exists("spotify_results.json"):
print("The JSON file has been generated successfully.")
# Execute the ytbmusic.py script
print("Executing ytbmusic.py...")
subprocess.run(["python3", ytbmusic_script])
else:
print("Error: The JSON file was not generated by spotify.py.")
else:
print("Exiting program.")