|
|
@ -1,3 +1,4 @@
|
|
|
|
|
|
|
|
import glob
|
|
|
|
import urllib.request
|
|
|
|
import urllib.request
|
|
|
|
|
|
|
|
|
|
|
|
import kode256
|
|
|
|
import kode256
|
|
|
@ -6,8 +7,9 @@ import gi
|
|
|
|
|
|
|
|
|
|
|
|
from gi.repository import TotemPlParser
|
|
|
|
from gi.repository import TotemPlParser
|
|
|
|
from gsp import GstreamerPlayer
|
|
|
|
from gsp import GstreamerPlayer
|
|
|
|
|
|
|
|
from tinytag import TinyTag
|
|
|
|
|
|
|
|
|
|
|
|
from bureau import Bureau, add_command, add_webview
|
|
|
|
from bureau import Bureau, add_command, add_webview, add_api
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Audio(Bureau):
|
|
|
|
class Audio(Bureau):
|
|
|
@ -34,6 +36,7 @@ class Audio(Bureau):
|
|
|
|
stored on the local office or remote URLs for live playback. Currently,
|
|
|
|
stored on the local office or remote URLs for live playback. Currently,
|
|
|
|
only supports line-out signals on the default DAC.
|
|
|
|
only supports line-out signals on the default DAC.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
self.stop()
|
|
|
|
shortcode, _ = data.split(".")
|
|
|
|
shortcode, _ = data.split(".")
|
|
|
|
self.log.debug("looking up shortcode " + shortcode)
|
|
|
|
self.log.debug("looking up shortcode " + shortcode)
|
|
|
|
pl_url = self.urldb.get(shortcode)
|
|
|
|
pl_url = self.urldb.get(shortcode)
|
|
|
@ -51,9 +54,8 @@ class Audio(Bureau):
|
|
|
|
parser.parse(pl_file, False)
|
|
|
|
parser.parse(pl_file, False)
|
|
|
|
|
|
|
|
|
|
|
|
for url in urls:
|
|
|
|
for url in urls:
|
|
|
|
print("stream uri", url)
|
|
|
|
|
|
|
|
self.player.queue(url)
|
|
|
|
self.player.queue(url)
|
|
|
|
self.current_uri = url
|
|
|
|
self.current_uri = urls[0]
|
|
|
|
|
|
|
|
|
|
|
|
@add_command("stop", "Halt audio playback.")
|
|
|
|
@add_command("stop", "Halt audio playback.")
|
|
|
|
def stop(self):
|
|
|
|
def stop(self):
|
|
|
@ -147,6 +149,24 @@ class Audio(Bureau):
|
|
|
|
|
|
|
|
|
|
|
|
return ret
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@add_api("add_album", "Add a music album.")
|
|
|
|
|
|
|
|
def add_album(self, data):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
add a local folder with music or audio
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
im_dir = data["album_dir"]
|
|
|
|
|
|
|
|
store = data["music_dir"]
|
|
|
|
|
|
|
|
except KeyError as e:
|
|
|
|
|
|
|
|
self.log.error("you must specify a directory to import")
|
|
|
|
|
|
|
|
# scan to find out the name(s) of artist/albums and track order
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# create necessary folders and copy the files over
|
|
|
|
|
|
|
|
# create a playlist and add the files in the right order
|
|
|
|
|
|
|
|
# save the url
|
|
|
|
|
|
|
|
# print a nice card for perusal and playing
|
|
|
|
|
|
|
|
|
|
|
|
def save_url(self, url):
|
|
|
|
def save_url(self, url):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
saves an url for a local file or network audio stream.
|
|
|
|
saves an url for a local file or network audio stream.
|
|
|
@ -171,11 +191,8 @@ class Audio(Bureau):
|
|
|
|
self.print_small("Error: connect error on " + url)
|
|
|
|
self.print_small("Error: connect error on " + url)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: support #EXTINF: extended attributes - logo or #EXTIMG or #PLAYLIST
|
|
|
|
# TODO: get rid of this stuff and use the playlist parser
|
|
|
|
# TODO: support XSPF?? does anyone use this?
|
|
|
|
|
|
|
|
# TODO: what to do with unwrapped links - raw mp3 or whateva - use vlc info?
|
|
|
|
# TODO: what to do with unwrapped links - raw mp3 or whateva - use vlc info?
|
|
|
|
# if line startswith #EXTINF: title = first comma to EOL
|
|
|
|
|
|
|
|
# if line startswith Title then title = first '=' to EOL
|
|
|
|
|
|
|
|
title = ""
|
|
|
|
title = ""
|
|
|
|
for line in resp.text.splitlines():
|
|
|
|
for line in resp.text.splitlines():
|
|
|
|
if line.startswith("#EXTINF:"):
|
|
|
|
if line.startswith("#EXTINF:"):
|
|
|
@ -185,7 +202,6 @@ class Audio(Bureau):
|
|
|
|
# this looks like a pls playlist - title is from first '=' to EOL
|
|
|
|
# this looks like a pls playlist - title is from first '=' to EOL
|
|
|
|
title = line[(line.find('=') + 1):].strip()
|
|
|
|
title = line[(line.find('=') + 1):].strip()
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: create barcode
|
|
|
|
|
|
|
|
# small print title, url, barcode
|
|
|
|
# small print title, url, barcode
|
|
|
|
prn = self._get_small_printer()
|
|
|
|
prn = self._get_small_printer()
|
|
|
|
|
|
|
|
|
|
|
@ -199,7 +215,6 @@ class Audio(Bureau):
|
|
|
|
prn.close()
|
|
|
|
prn.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
au = Audio()
|
|
|
|
au = Audio()
|
|
|
|
au.run()
|
|
|
|
au.run()
|
|
|
|