Ejemplo n.º 1
0
def bigscreen(request):
    with mpdConnection():
        cursong = Song()
        cursong.now_playing()
    return render(
        request, 'music/bigscreen.html', {
            'artist': cursong.artist if hasattr(cursong, 'artist') else '',
            'title': cursong.title if hasattr(cursong, 'title') else '',
            'album': cursong.album if hasattr(cursong, 'album') else ''
        })
Ejemplo n.º 2
0
def index(request):
    with mpdConnection() as client:
        cursong = Song()
        cursong.now_playing()
        playlist = client.playlistinfo()
        artistList = client.list('Artist')
    return render(
        request, 'music/index.html', {
            'artist': cursong.artist if hasattr(cursong, 'artist') else '',
            'title': cursong.title if hasattr(cursong, 'title') else '',
            'album': cursong.album if hasattr(cursong, 'album') else '',
            'lUpcoming': playlist[1:11],
            'iTotalTracks': len(playlist) - 1,
            'artistList': artistList
        })
Ejemplo n.º 3
0
def artwork(request):
    client = MPDClient()
    client.connect("localhost", 6600)
    current = Song()
    current.now_playing()
    if current.file:
        file = mutagen.File(os.environ['HOME'] + "/Music/" + current.file)
        if type(file) is mutagen.mp4.MP4:
            if 'covr' in file.tags:
                return HttpResponse(file.tags['covr'][0],
                                    content_type="image/jpeg")

        if type(file) is mutagen.mp3.MP3:
            if 'APIC:' in file.tags:
                return HttpResponse(file.tags['APIC:'].data,
                                    content_type=file.tags['APIC:'].mime)

    with open(os.path.join(settings.BASE_DIR, "static/no-artwork.png"),
              "rb") as f:
        return HttpResponse(f.read(), content_type="image/jpeg")
Ejemplo n.º 4
0
import pusher
pusher_client = pusher.Pusher(
  app_id='190359',
  key='18e076434d0479a10e71',
  secret='e9a5ea2bc88d8ffedf76',
  cluster='ap1',
  ssl=True
)

print('Starting Monitor')

client = MPDClient()
client.connect("localhost",6600)

cursong = Song()
cursong.now_playing()
while True:
	client.idle()
	nextsong = Song()
	nextsong.now_playing()
	if cursong != nextsong:
		cursong = nextsong
		backoff = 2
		delay = 2
		while True:
			try:
				pusher_client.trigger('play-py', 'now-playing', {
					'artist': cursong.artist if hasattr(cursong,'artist') else '',
					'title': cursong.title if hasattr(cursong,'title') else '',
					'album': cursong.album if hasattr(cursong,'album') else '',
					'file': cursong.file if hasattr(cursong,'file') else ''