Skip to content

Commit 95f2eeb

Browse files
authored
added custom playlists, fixed bugs
1 parent 5919312 commit 95f2eeb

File tree

1 file changed

+46
-5
lines changed

1 file changed

+46
-5
lines changed

wisdom_tree/main.py

+46-5
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def key_events(stdscr, tree1, maxx):
129129
if tree1.currentmenu == "timer":
130130
tree1.starttimer(tree1.selectedtimer, stdscr, maxx)
131131
else:
132-
tree1.featureselect(tree1.selectedtimer)
132+
tree1.featureselect(tree1.selectedtimer, maxx, stdscr)
133133
timerstart = vlc.MediaPlayer(str(RES_FOLDER / "timerstart.wav"))
134134
timerstart.play()
135135
tree1.showtimer = False
@@ -156,6 +156,7 @@ def key_events(stdscr, tree1, maxx):
156156
tree1.currentmenu = "feature"
157157

158158
else:
159+
tree1.radiomode = False
159160
tree1.music_list_num += 1
160161
if tree1.music_list_num > len(tree1.music_list) - 1:
161162
tree1.music_list_num = len(tree1.music_list) - 1
@@ -170,6 +171,7 @@ def key_events(stdscr, tree1, maxx):
170171
tree1.selectedtimer = 0
171172
tree1.currentmenu = "timer"
172173
else:
174+
tree1.radiomode = False
173175
tree1.music_list_num -= 1
174176
if tree1.music_list_num < 0:
175177
tree1.music_list_num = 0
@@ -270,7 +272,10 @@ def __init__(self, stdscr, age):
270272
]
271273
self.featurelist = [
272274
" PLAY MUSIC FROM YOUTUBE ",
273-
" LOFI RADIO "
275+
" LOFI RADIO 1 ",
276+
" LOFI RADIO 2 ",
277+
" LOFI RADIO 3 ",
278+
" CUSTOM PLAYLIST "
274279
]
275280
self.currentmenu = "timer"
276281
self.selectedtimer = 0
@@ -531,7 +536,7 @@ def starttimer(self, inputtime, stdscr, maxx):
531536

532537
self.workendtime = int(time.time()) + self.worktime
533538

534-
def featureselect(self, inputfeature):
539+
def featureselect(self, inputfeature, maxx, stdscr):
535540
self.radiomode = False
536541
if inputfeature == 0:
537542
if hasattr(self, "media"):
@@ -541,6 +546,37 @@ def featureselect(self, inputfeature):
541546
self.playlist = Playlist("https://www.youtube.com/playlist?list=PLOzDu-MXXLliO9fBNZOQTBDddoA3FzZUo")
542547
self.lofiradio()
543548

549+
if inputfeature == 2:
550+
self.playlist = Playlist("https://www.youtube.com/playlist?list=PL0ONFXpPDe_mtm3ciwL-v7EE-7yLHDlP8")
551+
self.lofiradio()
552+
553+
if inputfeature == 3:
554+
self.playlist = Playlist("https://www.youtube.com/playlist?list=PLKYTmz7SemaqVDF6XJ15bv_8-j7ckkNgb")
555+
self.lofiradio()
556+
557+
if inputfeature == 4:
558+
curses.textpad.rectangle(stdscr, 0,0,2, maxx-1)
559+
stdscr.addstr(1,1, "ENTER PLAyLIST LINK : ")
560+
stdscr.refresh()
561+
562+
curses.echo()
563+
curses.nocbreak()
564+
stdscr.nodelay(False)
565+
stdscr.keypad(False)
566+
curses.curs_set(1)
567+
568+
templink = stdscr.getstr()
569+
templink = str(templink)[1:][:-1]
570+
self.playlist = Playlist(str(templink))
571+
572+
curses.noecho()
573+
curses.cbreak()
574+
stdscr.nodelay(True)
575+
stdscr.keypad(True)
576+
curses.curs_set(0)
577+
578+
self.lofiradio()
579+
544580
def loading(self, stdscr, maxx):
545581
spinner = [
546582
"[ ]",
@@ -802,8 +838,13 @@ def main():
802838

803839
tree1.timer()
804840

805-
if not tree1.isloading and tree1.radiomode and round(tree1.media.get_position()*100) == 100:
806-
tree1.lofiradio()
841+
if not tree1.isloading and round(tree1.media.get_position()*100) == 100:
842+
if tree1.radiomode:
843+
tree1.lofiradio()
844+
else:
845+
tree1.media.stop()
846+
tree1.media = vlc.MediaPlayer(tree1.music_list[tree1.music_list_num])
847+
tree1.media.play()
807848

808849
if tree1.isloading:
809850
tree1.loading(stdscr, maxx)

0 commit comments

Comments
 (0)