Sha256: f386cd5d4dd3ded77b4e240f2eaa44d965d5d95c2161b18ea785410c65ffb16d

Contents?: true

Size: 1005 Bytes

Versions: 4

Compression:

Stored size: 1005 Bytes

Contents

# frozen_string_literal: true

require 'bundler'
Bundler.setup :default

require 'logger'
require 'mpd_client'

# MPD::Client.log = Logger.new($stderr)

client = MPD::Client.new

type = ARGV[0]
what = ARGV[1]

client = MPD::Client.new
client.log = Logger.new($stderr)

# Connecting to the server
client.connect('localhost', 6600)

puts "MPD version: #{client.mpd_version}"
puts "mpd_client version: #{MPD::Client::VERSION}"

client.stop
client.clear # clear the current playlist

# Finds songs in the db that are exactly `what`.
# `type` can be any tag supported by MPD
# or one of the two special parameters:
# * 'file' - to search by full path (relative to database root),
# * 'any' - to match against all available tags.
songs = client.search(type, what)

client.command_list_ok_begin # start a command list to speed up operations
songs.each do |song|
  client.add(song['file']) if song.key?('file')
end
client.command_list_end

client.play

client.close
client.disconnect # disconnect from the server

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
mpd_client-0.3.0 examples/search_and_replace_playlist.rb
o-mpd_client-0.2.0.1 examples/search_and_replace_playlist.rb
mpd_client-0.2.0 examples/search_and_replace_playlist.rb
mpd_client-0.1.0 examples/search_and_replace_playlist.rb