Add fuzzy and text-classification light model #1
2 changed files with 14 additions and 12 deletions
23
src/mpd.py
23
src/mpd.py
|
@ -32,24 +32,27 @@ class Mpd():
|
||||||
self.client.disconnect()
|
self.client.disconnect()
|
||||||
|
|
||||||
def play_genre(self, genre):
|
def play_genre(self, genre):
|
||||||
|
res = ""
|
||||||
self.client.connect(self.ip, self.port)
|
self.client.connect(self.ip, self.port)
|
||||||
logging.debug('Listing '+self.normalize_genre(genre))
|
logging.debug('Listing '+self.normalize_genre(genre))
|
||||||
|
list_album = []
|
||||||
try:
|
try:
|
||||||
# todo: select only one album instead of the artist
|
# todo: select only one album instead of the artist
|
||||||
list_album = self.client.lsinfo(
|
list_album = self.client.lsinfo(
|
||||||
"Subsonic/Genre/"+self.normalize_genre(genre))
|
"Subsonic/Genre/"+self.normalize_genre(genre))
|
||||||
|
|
||||||
|
if (list_album):
|
||||||
|
random_album = random.choice(list_album)["directory"]
|
||||||
|
self.play_album(random_album)
|
||||||
|
res = "C'est parti !"
|
||||||
|
else:
|
||||||
|
res = "Je n\'ai rien trouvé."
|
||||||
except:
|
except:
|
||||||
list_album = []
|
res = "Il y a eu une erreur durant le lancement de la musique"
|
||||||
|
finally:
|
||||||
|
self.client.close()
|
||||||
|
self.client.disconnect()
|
||||||
|
|
||||||
if (list_album):
|
|
||||||
random_album = random.choice(list_album)["directory"]
|
|
||||||
self.play_album(random_album)
|
|
||||||
res = "C'est parti !"
|
|
||||||
else:
|
|
||||||
res = "Je n\'ai rien trouvé."
|
|
||||||
|
|
||||||
self.client.close()
|
|
||||||
self.client.disconnect()
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def play_album(self, directory):
|
def play_album(self, directory):
|
||||||
|
|
|
@ -69,8 +69,7 @@ class Ratatouille():
|
||||||
elif command == "LightOff":
|
elif command == "LightOff":
|
||||||
return self.light_off_single(payload['intentArg'][0])
|
return self.light_off_single(payload['intentArg'][0])
|
||||||
elif command == "PlayMusicGenre":
|
elif command == "PlayMusicGenre":
|
||||||
self.play_genre(payload['intentArg'][0])
|
return self.mopidy.play_genre(payload['intentArg'][0])
|
||||||
return 'Lancement de la musique...'
|
|
||||||
return '42'
|
return '42'
|
||||||
|
|
||||||
def weather_query(self, entities):
|
def weather_query(self, entities):
|
||||||
|
|
Loading…
Add table
Reference in a new issue