Make compatible with python-mpv 0.3

This commit is contained in:
Nguyễn Gia Phong 2017-08-07 14:22:17 +07:00 committed by Nguyễn Gia Phong
parent 7542fb3892
commit b01b6abd1a
4 changed files with 12 additions and 11 deletions

6
comp
View File

@ -109,7 +109,7 @@ class Comp(Omp):
add_status_str('/', x=13, X=14)
add_status_str(self.mp.osd.duration or '00:00:00', x=15, X=23)
add_status_str('|' if self.mp.pause else '>', x=24, X=25)
add_status_str((self.mp.media_title or b'').decode(), x=26,
add_status_str(self.mp.media_title or '', x=26,
attr=curses.color_pair(12)|curses.A_BOLD)
add_status_str(_(self.mode), x=-2-len(_(self.mode)))
self.scr.refresh()
@ -199,7 +199,6 @@ class Comp(Omp):
def property_handler(self, name, val): self.update_status()
def __init__(self, entries, json_file, mode, mpv_vid, mpv_vo, ytdlf):
Omp.__init__(self, entries, json_file, mode, mpv_vid, mpv_vo, ytdlf)
curses.noecho()
curses.cbreak()
self.scr.keypad(True)
@ -209,6 +208,7 @@ class Comp(Omp):
for i in range(1, 8): curses.init_pair(i, i, -1)
curses.init_pair(8, -1, 7)
for i in range(1, 7): curses.init_pair(i + 8, -1, i)
Omp.__init__(self, entries, json_file, mode, mpv_vid, mpv_vo, ytdlf)
self.refresh()
def __enter__(self): return self
@ -369,7 +369,7 @@ with Comp(entries, json_file, mode, vid, vo, ytdlf) as comp:
comp.search()
elif c == 60: # <
try:
if comp.mp._get_property('time-pos', float) < 1:
if comp.mp.time_pos < 1:
comp.next(backward=True)
else:
comp.seek(0, 'absolute')

View File

@ -74,8 +74,9 @@ class Omp(object):
if mpv_vo is not None: self.mp['vo'] = mpv_vo
@self.mp.property_observer('mute')
@self.mp.property_observer('pause')
@self.mp.property_observer('time-pos', force_fmt=MpvFormat.INT64)
@self.mp.property_observer('time-pos')
def observer(name, value): self.property_handler(name, value)
self.mp.register_key_binding('q', lambda state, key: None)
def __enter__(self): return self

View File

@ -7,7 +7,7 @@ with open('README.rst') as f:
setup(
name='comp',
version='0.3.11',
version='0.3.12',
description=('Curses Omni Media Player'),
long_description=long_description,
url='https://github.com/McSinyx/comp',

View File

@ -160,7 +160,7 @@
"title": "David Banner - Play (Dirty version)"
},
{
"duration": "00:00:00",
"duration": "00:03:55",
"error": false,
"filename": "https://youtu.be/NGLxoKOvzu4",
"playing": false,
@ -184,7 +184,7 @@
"title": "Post Malone - Congratulations ft. Quavo"
},
{
"duration": "00:00:00",
"duration": "00:03:51",
"error": false,
"filename": "https://youtu.be/nfs8NYg7yQM",
"playing": false,
@ -232,7 +232,7 @@
"title": "Sam Hunt - Body Like A Back Road (Audio)"
},
{
"duration": "00:00:00",
"duration": "00:03:40",
"error": false,
"filename": "https://youtu.be/Fq0xEpRDL9Q",
"playing": false,
@ -240,10 +240,10 @@
"title": "Chris Brown - Privacy (Explicit Version)"
},
{
"duration": "00:00:00",
"duration": "00:03:36",
"error": false,
"filename": "https://youtu.be/7wtfhZwyrcc",
"playing": false,
"playing": true,
"selected": false,
"title": "Imagine Dragons - Believer"
},
@ -264,7 +264,7 @@
"title": "DNCE - Kissing Strangers ft. Nicki Minaj"
},
{
"duration": "00:00:00",
"duration": "00:03:18",
"error": false,
"filename": "https://youtu.be/AEB6ibtdPZc",
"playing": false,