Comments (2)
I've come up with a good solution, I think. It's in the 'answer' to the link above. The hash-for-filename was a bad idea, because it does not identify the files, and makes it very hard to edit them.
Instead, I've got test files like this sitting in a directory:
initialversion.recording
--putsabove--getsbelow--
OK MPD 0.19.0
listplaylists.recording
listplaylists
--putsabove--getsbelow--
playlist: Mix Rock Alternative Electric
Last-Modified: 2015-11-23T15:58:51Z
playlist: SNBRN
Last-Modified: 2016-01-26T00:25:52Z
playlist: Enya-esque
Last-Modified: 2015-11-18T16:19:12Z
playlist: RecentNice
Last-Modified: 2015-12-01T15:52:38Z
playlist: Dancetown
Last-Modified: 2015-11-18T16:19:26Z
playlist: Piano
Last-Modified: 2015-11-18T16:17:13Z
playlist: Thump
Last-Modified: 2015-11-20T15:32:30Z
playlist: GavinLikesIt
Last-Modified: 2015-11-20T15:54:49Z
OK
clear-and-add
command_list_begin
clear
addid test1.mp3
addid "test 2.mp3"
addid test3.mp3
command_list_end
--putsabove--getsbelow--
Id: 107
Id: 108
Id: 109
OK
...(more files)...
And now I can just do:
require '../lib/ruby-mpd'
require './socket_spoof'
class PlaybackMPD < MPD
def initialize( recordings_directory=nil )
super()
@socket = SocketSpoof::Player.new(directory:recordings_directory)
end
def last_messages
@socket.last_messages
end
end
require 'minitest/autorun'
class TestQueue < MiniTest::Unit::TestCase
def setup
@mpd = PlaybackMPD.new 'socket_recordings'
end
def test_songs
songs = @mpd.queue
assert_equal ["playlistinfo"], @mpd.last_messages
assert_equal 5, songs.length
assert songs.all?{ |value| value.is_a? MPD::Song }
assert_equal [310,226,243,258,347], songs.map(&:track_length)
end
def test_command_lists
ids = @mpd.command_list(:values) do
clear
%w[test1.mp3 test\ 2.mp3 test3.mp3].each{ |f| addid(f) }
end
assert_equal(
["command_list_begin", "clear", "addid test1.mp3", 'addid "test 2.mp3"',
"addid test3.mp3", "command_list_end"],
@mpd.last_messages
)
assert_equal [107,108,109], ids
pls = @mpd.command_list(:playlists){ playlists }
assert_equal(
["command_list_begin", "listplaylists", "command_list_end"],
@mpd.last_messages
)
assert_equal(8,pls.length)
assert pls.all?{ |value| value.is_a? MPD::Playlist }
end
end
from ruby-mpd.
Once I get a good suite of recordings saved (which, BTW, I can create super-easily by copy-pasting from a telnet-into-MPD session), I'll be checking this in as part of a test suite for command lists.
from ruby-mpd.
Related Issues (20)
- Detect invalid songs
- Instantiate a playlist by name
- Support `idle` HOT 4
- song_with_id( nil ) causes error
- Getting stickers does not parse the values HOT 1
- .songs returns empty array despite reporting 200k songs HOT 4
- Adding songs to the queue is slow HOT 7
- Song with multiple genres causes runtime error
- Song filename with double-quotes causes errors
- Song#length does not handle multi-hour songs well
- track_length errors when a song has no time
- Error adding song with backslash in name
- Correct way of handling timeouts? HOT 3
- Cannot fetch songs for playlist (TypeError)
- First command causes error HOT 1
- Add toggle command (mpc like) HOT 1
- Error when attempting to play stream
- New release?
- Insert at position HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ruby-mpd.