Changeset - e13b62bfdaff
[Not reviewed]
default
0 4 0
drewp@bigasterisk.com - 20 months ago 2023-05-18 02:34:12
drewp@bigasterisk.com
fix some warnings
4 files changed with 6 insertions and 4 deletions:
0 comments (0 inline, 0 general)
light9/ascoltami/main.py
Show inline comments
 
@@ -4,25 +4,25 @@ import optparse
 
import sys
 
from typing import cast
 

	
 
import gi
 
from light9.run_local import log
 
from rdflib import URIRef
 
from twisted.internet import reactor
 
from twisted.internet.interfaces import IReactorCore
 

	
 
gi.require_version('Gst', '1.0')
 
gi.require_version('Gtk', '3.0')
 

	
 
from gi.repository import GObject, Gst
 
from gi.repository import Gst # type: ignore
 
from light9 import networking, showconfig
 
from light9.ascoltami.player import Player
 
from light9.ascoltami.playlist import NoSuchSong, Playlist
 
from light9.ascoltami.webapp import makeWebApp, songLocation, songUri
 

	
 
reactor = cast(IReactorCore, reactor)
 

	
 

	
 
class App(object):
 

	
 
    def __init__(self, graph, show):
 
        self.graph = graph
light9/ascoltami/musictime_client.py
Show inline comments
 
@@ -21,24 +21,25 @@ class MusicTime(object):
 
                 onChange=lambda position: None,
 
                 pollCurvecalc='ignored'):
 
        """period is the seconds between
 
        http time requests.
 

	
 
        We call onChange with the time in seconds and the total time
 

	
 
        The choice of period doesn't need to be tied to framerate,
 
        it's more the size of the error you can tolerate (since we
 
        make up times between the samples, and we'll just run off the
 
        end of a song)
 
        """
 
        self.positionFetchTime = 0
 
        self.period = period
 
        self.hoverPeriod = .05
 
        self.onChange = onChange
 

	
 
        self.position: Dict[str, float] = {}
 
        # driven by our pollCurvecalcTime and also by Gui.incomingTime
 
        self.lastHoverTime = None  # None means "no recent value"
 
        self.pollMusicTime()
 

	
 
    def getLatest(self, frameTime=None) -> Dict:
 
        """
 
        dict with 't' and 'song', etc.
light9/ascoltami/player.py
Show inline comments
 
#!/usr/bin/python
 
"""
 
alternate to the mpd music player, for ascoltami
 
"""
 

	
 
import time, logging, traceback
 
from gi.repository import Gst
 
from gi.repository import Gst # type: ignore
 
from twisted.internet import task
 
from light9.metrics import metrics
 
log = logging.getLogger()
 

	
 

	
 

	
 
class Player(object):
 

	
 
    def __init__(self, autoStopOffset=4, onEOS=None):
 
        """autoStopOffset is the number of seconds before the end of
 
        song before automatically stopping (which is really pausing).
 
        onEOS is an optional function to be called when we reach the
light9/ascoltami/playlist.py
Show inline comments
 
@@ -2,24 +2,25 @@ from light9.showconfig import songOnDisk
 
from light9.namespaces import L9
 

	
 

	
 
class NoSuchSong(ValueError):
 
    """Raised when a song is requested that doesn't exist (e.g. one
 
    after the last song in the playlist)."""
 

	
 

	
 
class Playlist(object):
 

	
 
    def __init__(self, graph, playlistUri):
 
        self.graph = graph
 
        self.playlistUri = playlistUri
 
        self.songs = list(graph.items(playlistUri))
 

	
 
    def nextSong(self, currentSong):
 
        """Returns the next song in the playlist or raises NoSuchSong if 
 
        we are at the end of the playlist."""
 
        try:
 
            currentIndex = self.songs.index(currentSong)
 
        except IndexError:
 
            raise ValueError("%r is not in the current playlist (%r)." %
 
                             (currentSong, self.playlistUri))
 

	
 
        try:
 
@@ -38,17 +39,17 @@ class Playlist(object):
 
        """Returns a list of the filesystem paths to all songs in order."""
 
        paths = []
 
        for song in self.songs:
 
            paths.append(songOnDisk(song))
 
        return paths
 

	
 
    def songPath(self, uri):
 
        """filesystem path to a song"""
 
        raise NotImplementedError("see showconfig.songOnDisk")
 
        # maybe that function should be moved to this method
 

	
 
    @classmethod
 
    def fromShow(playlistClass, graph, show):
 
    def fromShow(cls, graph, show):
 
        playlistUri = graph.value(show, L9['playList'])
 
        if not playlistUri:
 
            raise ValueError("%r has no l9:playList" % show)
 
        return playlistClass(graph, playlistUri)
 
        return cls(graph, playlistUri)
0 comments (0 inline, 0 general)