|
|
@ -1,4 +1,4 @@
|
|
|
|
import mplayer
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
|
|
|
|
from bureau import Bureau, add_command
|
|
|
|
from bureau import Bureau, add_command
|
|
|
|
|
|
|
|
|
|
|
@ -16,8 +16,8 @@ class Audio(Bureau):
|
|
|
|
def __init__(self):
|
|
|
|
def __init__(self):
|
|
|
|
Bureau.__init__(self)
|
|
|
|
Bureau.__init__(self)
|
|
|
|
|
|
|
|
|
|
|
|
self.player = mplayer.Player()
|
|
|
|
|
|
|
|
self.urldb = self.open_db("urldb")
|
|
|
|
self.urldb = self.open_db("urldb")
|
|
|
|
|
|
|
|
subprocess.call(["mocp", "-S"])
|
|
|
|
|
|
|
|
|
|
|
|
@add_command("p", "Play an album, track or a live stream.")
|
|
|
|
@add_command("p", "Play an album, track or a live stream.")
|
|
|
|
def play(self, data):
|
|
|
|
def play(self, data):
|
|
|
@ -29,10 +29,45 @@ class Audio(Bureau):
|
|
|
|
shortcode, _ = data.split(".")
|
|
|
|
shortcode, _ = data.split(".")
|
|
|
|
url = self.urldb.get(shortcode)
|
|
|
|
url = self.urldb.get(shortcode)
|
|
|
|
|
|
|
|
|
|
|
|
if not self.player.is_alive():
|
|
|
|
subprocess.call(["mocp", "-c"])
|
|
|
|
self.player.spawn()
|
|
|
|
subprocess.call(["mocp", "-a", url])
|
|
|
|
|
|
|
|
subprocess.call(["mocp", "-p"])
|
|
|
|
|
|
|
|
|
|
|
|
self.player.loadfile(url)
|
|
|
|
@add_command("stop", "Halt audio playback.")
|
|
|
|
|
|
|
|
def stop(self):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Stops all audio currently playing audio output.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
subprocess.call(["mocp", "-P"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@add_command("resu", "Resume playback.")
|
|
|
|
|
|
|
|
def resume(self):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Resume playback of paused audio.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
subprocess.call(["mocp", "-U"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@add_command("next", "Play the next song.")
|
|
|
|
|
|
|
|
def play_next(self):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Skip to the next song in the playlist or album.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
subprocess.call(["mocp", "-f"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@add_command("prev", "Play the previous song.")
|
|
|
|
|
|
|
|
def play_prev(self):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Skip to the previous song in the playlist or album.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
subprocess.call(["mocp", "-r"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@add_command("nowp", "Now Playing")
|
|
|
|
|
|
|
|
def now_playing(self):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Prints the currently playing song or stream on the small printer.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
out = subprocess.check_output(["mocp", "-i"])
|
|
|
|
|
|
|
|
self.print_small(out)
|
|
|
|
|
|
|
|
|
|
|
|
def save_url(self, url):
|
|
|
|
def save_url(self, url):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|