mpd: Cleanup confusing argument names, fixes #1134
Makes sure not to use tlid when we mean songpos and also be a bit more consistent about what we call things across functions.
This commit is contained in:
parent
7af570418f
commit
14910730bd
@ -8,7 +8,7 @@ def disableoutput(context, outputid):
|
||||
"""
|
||||
*musicpd.org, audio output section:*
|
||||
|
||||
``disableoutput``
|
||||
``disableoutput {ID}``
|
||||
|
||||
Turns an output off.
|
||||
"""
|
||||
@ -25,7 +25,7 @@ def enableoutput(context, outputid):
|
||||
"""
|
||||
*musicpd.org, audio output section:*
|
||||
|
||||
``enableoutput``
|
||||
``enableoutput {ID}``
|
||||
|
||||
Turns an output on.
|
||||
"""
|
||||
|
||||
@ -73,8 +73,8 @@ def addid(context, uri, songpos=None):
|
||||
return ('Id', tl_tracks[0].tlid)
|
||||
|
||||
|
||||
@protocol.commands.add('delete', position=protocol.RANGE)
|
||||
def delete(context, position):
|
||||
@protocol.commands.add('delete', songrange=protocol.RANGE)
|
||||
def delete(context, songrange):
|
||||
"""
|
||||
*musicpd.org, current playlist section:*
|
||||
|
||||
@ -82,8 +82,8 @@ def delete(context, position):
|
||||
|
||||
Deletes a song from the playlist.
|
||||
"""
|
||||
start = position.start
|
||||
end = position.stop
|
||||
start = songrange.start
|
||||
end = songrange.stop
|
||||
if end is None:
|
||||
end = context.core.tracklist.length.get()
|
||||
tl_tracks = context.core.tracklist.slice(start, end).get()
|
||||
@ -119,8 +119,8 @@ def clear(context):
|
||||
context.core.tracklist.clear()
|
||||
|
||||
|
||||
@protocol.commands.add('move', position=protocol.RANGE, to=protocol.UINT)
|
||||
def move_range(context, position, to):
|
||||
@protocol.commands.add('move', songrange=protocol.RANGE, to=protocol.UINT)
|
||||
def move_range(context, songrange, to):
|
||||
"""
|
||||
*musicpd.org, current playlist section:*
|
||||
|
||||
@ -129,8 +129,8 @@ def move_range(context, position, to):
|
||||
Moves the song at ``FROM`` or range of songs at ``START:END`` to
|
||||
``TO`` in the playlist.
|
||||
"""
|
||||
start = position.start
|
||||
end = position.stop
|
||||
start = songrange.start
|
||||
end = songrange.stop
|
||||
if end is None:
|
||||
end = context.core.tracklist.length.get()
|
||||
context.core.tracklist.move(start, end, to)
|
||||
@ -320,8 +320,8 @@ def plchangesposid(context, version):
|
||||
return result
|
||||
|
||||
|
||||
@protocol.commands.add('shuffle', position=protocol.RANGE)
|
||||
def shuffle(context, position=None):
|
||||
@protocol.commands.add('shuffle', songrange=protocol.RANGE)
|
||||
def shuffle(context, songrange=None):
|
||||
"""
|
||||
*musicpd.org, current playlist section:*
|
||||
|
||||
@ -330,10 +330,10 @@ def shuffle(context, position=None):
|
||||
Shuffles the current playlist. ``START:END`` is optional and
|
||||
specifies a range of songs.
|
||||
"""
|
||||
if position is None:
|
||||
if songrange is None:
|
||||
start, end = None, None
|
||||
else:
|
||||
start, end = position.start, position.stop
|
||||
start, end = songrange.start, songrange.stop
|
||||
context.core.tracklist.shuffle(start, end)
|
||||
|
||||
|
||||
|
||||
@ -145,8 +145,8 @@ def pause(context, state=None):
|
||||
context.core.playback.resume()
|
||||
|
||||
|
||||
@protocol.commands.add('play', tlid=protocol.INT)
|
||||
def play(context, tlid=None):
|
||||
@protocol.commands.add('play', songpos=protocol.INT)
|
||||
def play(context, songpos=None):
|
||||
"""
|
||||
*musicpd.org, playback section:*
|
||||
|
||||
@ -170,13 +170,13 @@ def play(context, tlid=None):
|
||||
|
||||
- issues ``play 6`` without quotes around the argument.
|
||||
"""
|
||||
if tlid is None:
|
||||
if songpos is None:
|
||||
return context.core.playback.play().get()
|
||||
elif tlid == -1:
|
||||
elif songpos == -1:
|
||||
return _play_minus_one(context)
|
||||
|
||||
try:
|
||||
tl_track = context.core.tracklist.slice(tlid, tlid + 1).get()[0]
|
||||
tl_track = context.core.tracklist.slice(songpos, songpos + 1).get()[0]
|
||||
return context.core.playback.play(tl_track).get()
|
||||
except IndexError:
|
||||
raise exceptions.MpdArgError('Bad song index')
|
||||
@ -324,8 +324,8 @@ def replay_gain_status(context):
|
||||
return 'off' # TODO
|
||||
|
||||
|
||||
@protocol.commands.add('seek', tlid=protocol.UINT, seconds=protocol.UINT)
|
||||
def seek(context, tlid, seconds):
|
||||
@protocol.commands.add('seek', songpos=protocol.UINT, seconds=protocol.UINT)
|
||||
def seek(context, songpos, seconds):
|
||||
"""
|
||||
*musicpd.org, playback section:*
|
||||
|
||||
@ -339,8 +339,8 @@ def seek(context, tlid, seconds):
|
||||
- issues ``seek 1 120`` without quotes around the arguments.
|
||||
"""
|
||||
tl_track = context.core.playback.current_tl_track.get()
|
||||
if context.core.tracklist.index(tl_track).get() != tlid:
|
||||
play(context, tlid)
|
||||
if context.core.tracklist.index(tl_track).get() != songpos:
|
||||
play(context, songpos)
|
||||
context.core.playback.seek(seconds * 1000).get()
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user