mirror of
https://github.com/shadoll/playing_now_2_mm.git
synced 2026-02-04 02:53:21 +00:00
Update music_app.py and readme.md with improvements
This commit is contained in:
@@ -10,10 +10,11 @@ import os
|
|||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
SLEEP_TIME = 3
|
SLEEP_TIME = 3
|
||||||
|
|
||||||
MUSIC_APP = (
|
MUSIC_APP = (
|
||||||
os.getenv("MUSIC_APP", "apple_music").replace("_", " ").title().replace(" ", "")
|
os.getenv("MUSIC_APP", "apple_music").replace("_", " ").title().replace(" ", "")
|
||||||
)
|
)
|
||||||
|
print(f"Using 📀 {MUSIC_APP} connector")
|
||||||
|
|
||||||
def playing_now() -> tuple:
|
def playing_now() -> tuple:
|
||||||
music = Music(connector=globals()[MUSIC_APP])
|
music = Music(connector=globals()[MUSIC_APP])
|
||||||
@@ -22,7 +23,7 @@ def playing_now() -> tuple:
|
|||||||
|
|
||||||
def set_now_playing(name, artist, duration):
|
def set_now_playing(name, artist, duration):
|
||||||
now = datetime.now().strftime("%H:%M:%S")
|
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:
|
if name and artist and duration:
|
||||||
Mattermost().set_now_playing(name, artist, 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
|
- Mattermost
|
||||||
|
|
||||||
## Environment Variables
|
## 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
|
## How to Run
|
||||||
1. Clone the repository
|
1. Clone the repository
|
||||||
|
|||||||
Reference in New Issue
Block a user