cplay-ng

simple curses audio player
git clone https://git.ce9e.org/cplay-ng.git

commit
58fd15c7a46b4bf6fb033a84d45827d864b0eb35
parent
cae896037a4c579bf183b620b4d69701267c1c9b
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2026-04-24 15:48
modernize: use f-strings

Diffstat

M cplay.py 14 +++++++-------

1 files changed, 7 insertions, 7 deletions


diff --git a/cplay.py b/cplay.py

@@ -15,6 +15,8 @@ from contextlib import contextmanager
   15    15 
   16    16 __version__ = '5.4.0'
   17    17 
   -1    18 XDG_RUNTIME_DIR = os.getenv('XDG_RUNTIME_DIR', '/tmp')
   -1    19 
   18    20 AUDIO_EXTENSIONS = [
   19    21     'mp3', 'ogg', 'oga', 'opus', 'flac', 'm4a', 'm4b', 'wav', 'mid', 'wma'
   20    22 ]
@@ -70,9 +72,9 @@ def space_between(a, b, n):
   70    72 
   71    73 
   72    74 def format_time(total):
   73    -1     h, s = divmod(total, 3600)
   -1    75     h, s = divmod(int(total), 3600)
   74    76     m, s = divmod(s, 60)
   75    -1     return '%02d:%02d:%02d' % (h, m, s)
   -1    77     return f'{h:02d}:{m:02d}:{s:02d}'
   76    78 
   77    79 
   78    80 def str_match(query, s):
@@ -154,9 +156,7 @@ class Player:
  154   156         self._playing = 0
  155   157         self._buffer = b''
  156   158 
  157    -1         self.socket_path = '%s/mpv-cplay-%i.sock' % (
  158    -1             os.getenv('XDG_RUNTIME_DIR', '/tmp'), os.getpid()
  159    -1         )
   -1   159         self.socket_path = f'{XDG_RUNTIME_DIR}/mpv-cplay-{os.getpid()}.sock'
  160   160         self._proc = subprocess.Popen(
  161   161             [
  162   162                 'mpv',
@@ -225,9 +225,9 @@ class Player:
  225   225         self.is_playing = True
  226   226         self._playing += 1
  227   227         if get_mpv_version() >= (0, 38, 0):
  228    -1             self._ipc('loadfile', self.path, 'replace', 0, 'start=%i' % self.position)
   -1   228             self._ipc('loadfile', self.path, 'replace', 0, f'start={self.position}')
  229   229         else:
  230    -1             self._ipc('loadfile', self.path, 'replace', 'start=%i' % self.position)
   -1   230             self._ipc('loadfile', self.path, 'replace', f'start={self.position}')
  231   231 
  232   232     def play(self, path):
  233   233         if path and (m := re.match(r'^(http.*)#t=([0-9]+)$', path)):