@@ -44,7 +44,7 @@ def setup_env_file():
44
44
refresh_token = input ("Please enter your Spotify refresh token: " )
45
45
bot_refresh_rate = input ("Please enter the bot refresh rate (in seconds): " )
46
46
note_prefix = input ("Please enter the desired prefix that will be displayed before the song name and artist" )
47
-
47
+ separator = input ( "Please enter the separator between the song name and the artist" )
48
48
ig_username = input ("Please enter your Instagram username: " )
49
49
ig_password = input ("Please enter your Instagram password: " )
50
50
@@ -57,6 +57,7 @@ def setup_env_file():
57
57
env_file .write (f"SPOTIPY_CLIENT_SECRET={ client_secret } \n " )
58
58
env_file .write (f"SPOTIPY_REFRESH_TOKEN={ refresh_token } \n " )
59
59
env_file .write (f"BOT_REFRESH_RATE={ bot_refresh_rate } \n " )
60
+ env_file .write (f'SONG_SEPARATOR={ separator } ' )
60
61
env_file .write (f"IG_USERNAME={ ig_username } \n " )
61
62
env_file .write (f"IG_PASSWORD={ ig_password } \n " )
62
63
env_file .write (f"IG_NOTE_PREFIX={ note_prefix } \n " )
@@ -77,14 +78,16 @@ def setup_env_file():
77
78
IG_CREDENTIAL_PATH = './ig_settings.json'
78
79
79
80
SLEEP_TIME = os .getenv ("BOT_REFRESH_RATE" ) # in seconds
80
-
81
+ SONG_SEPARATOR = os . getenv ( "SONG_SEPARATOR" )
81
82
# Spotify credentials
82
83
SPOTIFY_CLIENT_ID = os .getenv ("SPOTIPY_CLIENT_ID" )
83
84
SPOTIFY_CLIENT_SECRET = os .getenv ("SPOTIPY_CLIENT_SECRET" )
84
85
SPOTIFY_REFRESH_TOKEN = os .getenv ("SPOTIPY_REFRESH_TOKEN" )
85
86
86
87
if not all ([SPOTIFY_CLIENT_SECRET , SPOTIFY_CLIENT_ID , SPOTIFY_REFRESH_TOKEN ]):
87
88
raise Exception ("Can't find Spotify credentials in the .env file" )
89
+ if not SONG_SEPARATOR :
90
+ SONG_SEPARATOR = "-"
88
91
89
92
def get_access_token (client_id , client_secret , refresh_token ):
90
93
debug ("Getting an access token from Spotify API ..." )
@@ -132,13 +135,14 @@ def __init__(self):
132
135
self ._cl .dump_settings (IG_CREDENTIAL_PATH )
133
136
debug ('Instagram credentials has been saved !' )
134
137
135
- def send_music_note (self , song_name , artist ):
138
+ def send_music_note (self , song_name , artist ,separator ):
139
+
136
140
previous_note = None
137
- note_content = f"{ IG_NOTE_PREFIX } { song_name } - { artist } " if IG_NOTE_PREFIX else f"🎧 { song_name } - { artist } "
141
+ note_content = f"{ IG_NOTE_PREFIX } { song_name } { separator } { artist } " if IG_NOTE_PREFIX else f"🎧 { song_name } { separator } { artist } "
138
142
if note_content == previous_note and previous_note is not None :
139
143
debug ("The content of the note is the same as before, no need to send a new one" )
140
144
if len (note_content ) < 60 :
141
- self ._cl .send_note (f"{ IG_NOTE_PREFIX } : { song_name } - { artist } " if IG_NOTE_PREFIX else f"🎧 : { song_name } - { artist } " , 0 )
145
+ self ._cl .send_note (f"{ IG_NOTE_PREFIX } : { song_name } { separator } { artist } " if IG_NOTE_PREFIX else f"🎧 : { song_name } { separator } { artist } " , 0 )
142
146
previous_note = note_content
143
147
144
148
else :
@@ -153,7 +157,7 @@ def update(self, spotify):
153
157
note_content = f"{ song_name } - { artist } "
154
158
debug (note_content )
155
159
debug ("Sending note to Instagram API." )
156
- bot .send_music_note (song_name , artist )
160
+ bot .send_music_note (song_name , artist , SONG_SEPARATOR )
157
161
debug (f'Note should be set on { IG_USERNAME } account.' )
158
162
else :
159
163
debug ("Nothing is playing currently." )
0 commit comments