Skip to content

Commit

Permalink
rename + bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TexturedPolak committed Jun 9, 2024
1 parent 4fc361b commit 95b2eb3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 6 additions & 6 deletions main.py → texturedplayer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

# Creating Playlists
import utils
import texturedplayer_utils
# TUI
try:
from textual.app import App, ComposeResult
Expand All @@ -27,7 +27,7 @@
discordRPC_enabled = False

# Init playlist and second process for playing music :)
newplaylist = utils.get_newplaylist()
newplaylist = texturedplayer_utils.get_newplaylist()
if os.name == "posix":
proc = subprocess.Popen('echo "TexturedPlayer for Linux/MacOS"', shell=True, preexec_fn=os.setsid)
else:
Expand Down Expand Up @@ -126,15 +126,15 @@ def play_next_song(self):
else:
proc = subprocess.Popen(f'ffplay -nodisp -autoexit -af "volume=0.4" "{newplaylist["playlist"][newplaylist["next"]]}"',stdout=subprocess.DEVNULL,stderr=subprocess.STDOUT,
shell=True)
self.change_text(str(utils.get_metadata(newplaylist["playlist"][newplaylist["next"]])))
self.change_text(str(texturedplayer_utils.get_metadata(newplaylist["playlist"][newplaylist["next"]])))
# Change song in discord RPC (may display after 15 seconds)
if discordRPC_enabled:
current_song.value = str(utils.get_metadata(newplaylist["playlist"][newplaylist["next"]]))
current_song.value = str(texturedplayer_utils.get_metadata(newplaylist["playlist"][newplaylist["next"]]))
newplaylist["next"] += 1
utils.save_playlist(newplaylist)
texturedplayer_utils.save_playlist(newplaylist)
# Create new playlist, if next song don't exist
else:
newplaylist = utils.get_random_playlist(utils.create_playlist())
newplaylist = texturedplayer_utils.get_random_playlist(texturedplayer_utils.create_playlist())
self.play_next_song()

# Next button
Expand Down
5 changes: 4 additions & 1 deletion utils.py → texturedplayer_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ def create_playlist():
# Get song metadata. If not have metadata, just return filename.
def get_metadata(song_file: str):
if tinytag_enabled is True:
song_data = TinyTag.get(song_file)
try:
song_data = TinyTag.get(song_file)
except:
return(song_file)
if song_data.artist is None:
return(song_file)
else:
Expand Down

0 comments on commit 95b2eb3

Please sign in to comment.