cplay-ng

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

commit
a87fc6fe2dd440e96178ba2d8ef176834cb1dcb7
parent
3323be696010068e788c68f834708d70d47afcb8
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2024-05-20 21:06
Fix backwards compatibility with mpv < 0.38.0

Diffstat

M cplay.py 12 +++++++++++-

1 files changed, 11 insertions, 1 deletions


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

@@ -93,6 +93,13 @@ def get_socket(path):
   93    93             return sock
   94    94 
   95    95 
   -1    96 @functools.cache
   -1    97 def get_mpv_version():
   -1    98     p = subprocess.run(['mpv', '--version'], stdout=subprocess.PIPE)
   -1    99     s = p.stdout.split(b' ', 2)[1].decode()
   -1   100     return tuple(int(i) for i in s.split('.'))
   -1   101 
   -1   102 
   96   103 @functools.lru_cache
   97   104 def relpath(path):
   98   105     if path.startswith('http'):
@@ -213,7 +220,10 @@ class Player:
  213   220             return
  214   221         self.is_playing = True
  215   222         self._playing += 1
  216    -1         self._ipc('loadfile', self.path, 'replace', 0, 'start=%i' % self.position)
   -1   223         if get_mpv_version() > (0, 38, 0):
   -1   224             self._ipc('loadfile', self.path, 'replace', 0, 'start=%i' % self.position)
   -1   225         else:
   -1   226             self._ipc('loadfile', self.path, 'replace', 'start=%i' % self.position)
  217   227 
  218   228     def play(self, path):
  219   229         if path and (m := re.match(r'^(http.*)#t=([0-9]+)$', path)):