mirror of
https://github.com/shadoll/playing_now_2_mm.git
synced 2025-12-20 04:27:51 +00:00
Update music_app.py and readme.md with improvements
This commit is contained in:
@@ -10,10 +10,11 @@ import os
|
||||
load_dotenv()
|
||||
|
||||
SLEEP_TIME = 3
|
||||
|
||||
MUSIC_APP = (
|
||||
os.getenv("MUSIC_APP", "apple_music").replace("_", " ").title().replace(" ", "")
|
||||
)
|
||||
|
||||
print(f"Using 📀 {MUSIC_APP} connector")
|
||||
|
||||
def playing_now() -> tuple:
|
||||
music = Music(connector=globals()[MUSIC_APP])
|
||||
@@ -22,7 +23,7 @@ def playing_now() -> tuple:
|
||||
|
||||
def set_now_playing(name, artist, duration):
|
||||
now = datetime.now().strftime("%H:%M:%S")
|
||||
print(f"{now} 🎧 {name} - {artist} ⏲️ {duration}")
|
||||
print(f"{now} 🎧 {name} - {artist} ⏱️ {duration}")
|
||||
if name and artist and duration:
|
||||
Mattermost().set_now_playing(name, artist, duration)
|
||||
|
||||
|
||||
@@ -14,7 +14,9 @@ This is a Python application that fetches the currently playing track from eithe
|
||||
- Mattermost
|
||||
|
||||
## Environment Variables
|
||||
`MUSIC_APP`: This variable determines which music service the application will fetch the currently playing track from. It can be either `apple_music` or `spotify`.
|
||||
`MUSIC_APP` - This variable determines which music service the application will fetch the currently playing track from. It can be either `apple_music` or `spotify`.
|
||||
`MATTERMOST_SERVER_URL` variable represents the URL of the Mattermost server.
|
||||
`MATTERMOST_ACCESS_TOKEN` the access token for the Mattermost API, which is obtained by generating a personal access token from the Mattermost user settings and is used to authenticate and authorize API requests to the Mattermost server.
|
||||
|
||||
## How to Run
|
||||
1. Clone the repository
|
||||
|
||||
Reference in New Issue
Block a user