def replacep(args): songs = list(parser.parse(args.collection)) if songs: mpd.replace(songs) mpd.play() else: mpd.clear()
def play(args): songs = parser.parse(args.collection) if songs: positions = mpd.get_playlist_positions() try: first_matched_song = next(s for s in positions if s in songs) except StopIteration: pass else: mpd.play(positions[first_matched_song][0])