plex-ruby 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +15 -0
- data/README.md +12 -13
- data/lib/plex-ruby/client.rb +5 -1
- data/lib/plex-ruby/episode.rb +6 -2
- data/lib/plex-ruby/library.rb +7 -3
- data/lib/plex-ruby/movie.rb +5 -1
- data/lib/plex-ruby/season.rb +11 -3
- data/lib/plex-ruby/section.rb +7 -3
- data/lib/plex-ruby/server.rb +5 -1
- data/lib/plex-ruby/show.rb +7 -3
- data/lib/plex-ruby/version.rb +1 -1
- data/plex-ruby.gemspec +2 -2
- data/test/test_episode.rb +7 -0
- data/test/test_helper.rb +1 -0
- data/test/test_season.rb +8 -0
- data/test/test_show.rb +8 -0
- metadata +4 -4
data/CHANGELOG.md
CHANGED
@@ -44,3 +44,18 @@
|
|
44
44
|
## 1.2.0
|
45
45
|
|
46
46
|
* `Plex::Client#play_media` now can take an Object that `responds_to(:key)`
|
47
|
+
|
48
|
+
## 1.3.0
|
49
|
+
|
50
|
+
* snake_case() -> underscore()
|
51
|
+
* Added Plex class method `camalize`
|
52
|
+
* Added singular season and episode methods
|
53
|
+
* Attribute methods are now dynamicly created in the initializer. This gets ride of
|
54
|
+
the lazy loading, but allows this gem to grow with Plex without having to update
|
55
|
+
the code everytime the API changes.
|
56
|
+
|
57
|
+
## 1.3.1
|
58
|
+
|
59
|
+
* Got rid of stdout garbage
|
60
|
+
* Fixed `Show#season` not working
|
61
|
+
* Added tests
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# Plex-Ruby [](https://secure.travis-ci.org/ekosz/Plex-Ruby
|
1
|
+
# Plex-Ruby [](https://secure.travis-ci.org/ekosz/Plex-Ruby)
|
2
2
|
|
3
|
-
A handy gem for working with Plex within Ruby. Tries to emulate and document
|
3
|
+
A handy gem for working with [Plex Media Player](http://plexapp.com) within Ruby. Tries to emulate and document
|
4
4
|
all of the Plex APIs using simple ruby code. I will try and keep it as
|
5
5
|
up-to-date as possible, but pull requests are always welcomed.
|
6
6
|
|
@@ -36,23 +36,22 @@ server = Plex::Server.new(CONFIG[:host], CONFIG[:port])
|
|
36
36
|
From here we can start doing cool things. Lets pause whats currently playing.
|
37
37
|
|
38
38
|
```ruby
|
39
|
-
clients = server.clients
|
40
|
-
client =
|
41
|
-
client.pause
|
39
|
+
clients = server.clients # list of all connected clients
|
40
|
+
client = # pick the media player you want
|
41
|
+
client.pause # That was easy
|
42
42
|
````
|
43
43
|
|
44
44
|
Lets search the libary.
|
45
45
|
|
46
46
|
```ruby
|
47
47
|
sections = server.library.sections
|
48
|
-
section =
|
49
|
-
shows = section.all
|
50
|
-
bsg = shows.select { |s| s.title =~ /Battlestar/ }.first
|
51
|
-
bsg.seasons
|
52
|
-
|
53
|
-
episode
|
54
|
-
|
55
|
-
client.play_media(episode) # Play it!
|
48
|
+
section = # Pick the section you want I.E. TV, Movies, Home Videos
|
49
|
+
shows = section.all # Returns a list of shows/movies
|
50
|
+
bsg = shows.select { |s| s.title =~ /Battlestar/ }.first # Pick a great show
|
51
|
+
season = bsg.seasons.last # Pick the last season
|
52
|
+
episode = season.episode(5) # The fifth episode in the season
|
53
|
+
puts "#{episode.title} - #{episode.summary}" # Looks good
|
54
|
+
client.play_media(episode) # Play it!
|
56
55
|
```
|
57
56
|
|
58
57
|
For a full list of commands check out the [documentation](http://rubydoc.info/github/ekosz/Plex-Ruby/master/frames).
|
data/lib/plex-ruby/client.rb
CHANGED
@@ -120,10 +120,14 @@ module Plex
|
|
120
120
|
ping player_url+"/application/sendVirtualKey?code=#{CGI::escape(code.to_s)}"
|
121
121
|
end
|
122
122
|
|
123
|
-
def url
|
123
|
+
def url #:nodoc:
|
124
124
|
server.url
|
125
125
|
end
|
126
126
|
|
127
|
+
def inspect #:nodoc:
|
128
|
+
"#<Plex::Client: name=\"#{name}\" host=\"#{host}\" port=\"#{port}\">"
|
129
|
+
end
|
130
|
+
|
127
131
|
private
|
128
132
|
|
129
133
|
def player_url
|
data/lib/plex-ruby/episode.rb
CHANGED
@@ -20,11 +20,11 @@ module Plex
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def url
|
23
|
+
def url #:nodoc:
|
24
24
|
season.url
|
25
25
|
end
|
26
26
|
|
27
|
-
def ==(other)
|
27
|
+
def ==(other) #:nodoc:
|
28
28
|
if other.is_a? Plex::Episode
|
29
29
|
key == other.key
|
30
30
|
else
|
@@ -32,6 +32,10 @@ module Plex
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
def inspect #:nodoc:
|
36
|
+
"#<Plex::Episode key=\"#{key}\" title=\"#{title}\" index=\"#{index}\" season=\"#{season.index}\" show=\"#{season.show.title}\">"
|
37
|
+
end
|
38
|
+
|
35
39
|
private
|
36
40
|
|
37
41
|
def xml_doc
|
data/lib/plex-ruby/library.rb
CHANGED
@@ -33,15 +33,15 @@ module Plex
|
|
33
33
|
@sections = search_sections(xml_doc!)
|
34
34
|
end
|
35
35
|
|
36
|
-
def key
|
36
|
+
def key #:nodoc:
|
37
37
|
"/library/sections"
|
38
38
|
end
|
39
39
|
|
40
|
-
def url
|
40
|
+
def url #:nodoc:
|
41
41
|
server.url
|
42
42
|
end
|
43
43
|
|
44
|
-
def ==(other)
|
44
|
+
def ==(other) #:nodoc:
|
45
45
|
if other.is_a? Library
|
46
46
|
server == other.server
|
47
47
|
else
|
@@ -49,6 +49,10 @@ module Plex
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
def inspect #:nodoc:
|
53
|
+
"#<Plex::Libary: server=#{server.inspect}>"
|
54
|
+
end
|
55
|
+
|
52
56
|
private
|
53
57
|
|
54
58
|
def search_sections(doc, key = nil)
|
data/lib/plex-ruby/movie.rb
CHANGED
@@ -10,7 +10,7 @@ module Plex
|
|
10
10
|
@key = key
|
11
11
|
end
|
12
12
|
|
13
|
-
def url
|
13
|
+
def url #:nodoc:
|
14
14
|
section.url
|
15
15
|
end
|
16
16
|
|
@@ -24,6 +24,10 @@ module Plex
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
def inspect #:nodoc:
|
28
|
+
"#<Plex::Movie: key=\"#{key}\" title=\"#{title}\">"
|
29
|
+
end
|
30
|
+
|
27
31
|
private
|
28
32
|
|
29
33
|
def xml_doc
|
data/lib/plex-ruby/season.rb
CHANGED
@@ -39,11 +39,11 @@ module Plex
|
|
39
39
|
episodes.select { |epi| epi.index.to_i == number.to_i }.first
|
40
40
|
end
|
41
41
|
|
42
|
-
def url
|
42
|
+
def url #:nodoc:
|
43
43
|
show.url
|
44
44
|
end
|
45
45
|
|
46
|
-
def ==(other)
|
46
|
+
def ==(other) #:nodoc:
|
47
47
|
if other.is_a? Plex::Season
|
48
48
|
key == other.key
|
49
49
|
else
|
@@ -51,6 +51,10 @@ module Plex
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
def inspect #:nodoc:
|
55
|
+
"#<Plex::Season: key=\"#{key}\" title=\"#{title}\" index=\"#{index}\" show=\"#{show.title}\">"
|
56
|
+
end
|
57
|
+
|
54
58
|
private
|
55
59
|
|
56
60
|
def base_doc
|
@@ -70,12 +74,16 @@ module Plex
|
|
70
74
|
end
|
71
75
|
|
72
76
|
def episodes_from_video(node)
|
73
|
-
node.search("Video").map { |m|
|
77
|
+
node.search("Video").map { |m| plex_episode.new(self, m.attr('key')) }
|
74
78
|
end
|
75
79
|
|
76
80
|
def directory
|
77
81
|
@directory ||= xml_doc.search("Directory").first
|
78
82
|
end
|
79
83
|
|
84
|
+
def plex_episode
|
85
|
+
@plex_episode ||= Plex::Episode
|
86
|
+
end
|
87
|
+
|
80
88
|
end
|
81
89
|
end
|
data/lib/plex-ruby/section.rb
CHANGED
@@ -76,15 +76,15 @@ module Plex
|
|
76
76
|
)
|
77
77
|
}
|
78
78
|
|
79
|
-
def key
|
79
|
+
def key #:nodoc:
|
80
80
|
"/library/sections/#{@key}"
|
81
81
|
end
|
82
82
|
|
83
|
-
def url
|
83
|
+
def url #:nodoc:
|
84
84
|
library.url
|
85
85
|
end
|
86
86
|
|
87
|
-
def ==(other)
|
87
|
+
def ==(other) #:nodoc:
|
88
88
|
if other.is_a? Plex::Section
|
89
89
|
key == other.key
|
90
90
|
else
|
@@ -92,6 +92,10 @@ module Plex
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
+
def inspect #:nodoc:
|
96
|
+
"#<Plex::Section: key=\"#{key}\" type=\"#{type}\" title=\"#{title}\">"
|
97
|
+
end
|
98
|
+
|
95
99
|
private
|
96
100
|
|
97
101
|
def grab_keys(action)
|
data/lib/plex-ruby/server.rb
CHANGED
@@ -27,10 +27,14 @@ module Plex
|
|
27
27
|
@clients = search_clients clients_doc!
|
28
28
|
end
|
29
29
|
|
30
|
-
def url
|
30
|
+
def url #:nodoc:
|
31
31
|
"http://#{host}:#{port}"
|
32
32
|
end
|
33
33
|
|
34
|
+
def inspect #:nodoc:
|
35
|
+
"#<Plex::Server: host=#{host} port=#{port}>"
|
36
|
+
end
|
37
|
+
|
34
38
|
private
|
35
39
|
|
36
40
|
def clients_base
|
data/lib/plex-ruby/show.rb
CHANGED
@@ -36,14 +36,14 @@ module Plex
|
|
36
36
|
# @param [Fixnum, String] season index number
|
37
37
|
# @return [Season] season with the index of number
|
38
38
|
def season(number)
|
39
|
-
seasons.select { |sea| sea.index.to_i ==
|
39
|
+
seasons.select { |sea| sea.index.to_i == number.to_i }.first
|
40
40
|
end
|
41
41
|
|
42
|
-
def url
|
42
|
+
def url #:nodoc:
|
43
43
|
section.url
|
44
44
|
end
|
45
45
|
|
46
|
-
def ==(other)
|
46
|
+
def ==(other) #:nodoc:
|
47
47
|
if other.is_a? Plex::Show
|
48
48
|
key == other.key
|
49
49
|
else
|
@@ -51,6 +51,10 @@ module Plex
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
def inspect #:nodoc:
|
55
|
+
"#<Plex::Show: key=\"#{key}\" title=\"#{title}\">"
|
56
|
+
end
|
57
|
+
|
54
58
|
private
|
55
59
|
|
56
60
|
def base_doc
|
data/lib/plex-ruby/version.rb
CHANGED
data/plex-ruby.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.authors = ["Eric Koslow"]
|
10
10
|
s.email = ["ekoslow@gmail.com"]
|
11
11
|
s.homepage = "https://github.com/ekosz/Plex-Ruby"
|
12
|
-
s.summary = %q{Plex APIs in easy ruby code}
|
13
|
-
s.description = %q{Extracts the Plex API into easy to write ruby code}
|
12
|
+
s.summary = %q{Plex Media Server APIs in easy ruby code}
|
13
|
+
s.description = %q{Extracts the Plex Media Server API into easy to write ruby code}
|
14
14
|
|
15
15
|
s.rubyforge_project = "plex-ruby"
|
16
16
|
|
data/test/test_episode.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -183,6 +183,7 @@ FAKE_VIDEO_NODE_HASH = {
|
|
183
183
|
duration: '3400',
|
184
184
|
originally_available_at: '324124',
|
185
185
|
updated_at: '342214',
|
186
|
+
index: '1',
|
186
187
|
Media: FakeNode.new( FAKE_MEDIA_NODE_HASH ),
|
187
188
|
Genre: FakeNode.new( FAKE_GENRE_NODE_HASH ),
|
188
189
|
Writer: FakeNode.new( FAKE_WRITER_NODE_HASH ),
|
data/test/test_season.rb
CHANGED
@@ -28,6 +28,14 @@ describe Plex::Season do
|
|
28
28
|
)
|
29
29
|
end
|
30
30
|
|
31
|
+
it "should return a spesific show" do
|
32
|
+
@season.instance_variable_set(
|
33
|
+
"@children", FakeNode.new({Video: FakeNode.new(FAKE_VIDEO_NODE_HASH)})
|
34
|
+
)
|
35
|
+
@season.instance_variable_set( "@plex_episode", TestEpisode )
|
36
|
+
@season.episode(1).must_equal @season.episodes.first
|
37
|
+
end
|
38
|
+
|
31
39
|
it "should remember its parent (show)" do
|
32
40
|
@season.show.must_equal @show
|
33
41
|
end
|
data/test/test_show.rb
CHANGED
@@ -30,6 +30,14 @@ describe Plex::Show do
|
|
30
30
|
)
|
31
31
|
end
|
32
32
|
|
33
|
+
it "should return a spesific season" do
|
34
|
+
@show.instance_variable_set(
|
35
|
+
"@children", FakeNode.new(FAKE_SEASON_NODE_HASH)
|
36
|
+
)
|
37
|
+
@show.instance_variable_set( "@plex_season", TestSeason )
|
38
|
+
@show.season(1).must_equal @show.seasons.first
|
39
|
+
end
|
40
|
+
|
33
41
|
it "should remember its parent (section)" do
|
34
42
|
@show.section.must_equal @section
|
35
43
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: plex-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.3.
|
5
|
+
version: 1.3.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Eric Koslow
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
13
|
+
date: 2012-01-02 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -57,7 +57,7 @@ dependencies:
|
|
57
57
|
version: "0"
|
58
58
|
type: :runtime
|
59
59
|
version_requirements: *id004
|
60
|
-
description: Extracts the Plex API into easy to write ruby code
|
60
|
+
description: Extracts the Plex Media Server API into easy to write ruby code
|
61
61
|
email:
|
62
62
|
- ekoslow@gmail.com
|
63
63
|
executables: []
|
@@ -132,7 +132,7 @@ rubyforge_project: plex-ruby
|
|
132
132
|
rubygems_version: 1.6.2
|
133
133
|
signing_key:
|
134
134
|
specification_version: 3
|
135
|
-
summary: Plex APIs in easy ruby code
|
135
|
+
summary: Plex Media Server APIs in easy ruby code
|
136
136
|
test_files:
|
137
137
|
- test/test_client.rb
|
138
138
|
- test/test_episode.rb
|