upnp_content_explorer 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b4988b418c9159f786046868740f5bec4e30a3b
4
- data.tar.gz: 3e0fa7672ef7e7aa4f0b0a1c52ab38ec0806a5ba
3
+ metadata.gz: 70b8cb6774af6666726032cb2ab87783f2b5c656
4
+ data.tar.gz: d036b630bbd5e416a5067a6a54573e146734924d
5
5
  SHA512:
6
- metadata.gz: 4335c1369615a03dea77582c64171a00a8c3b37f7660df50e9e57bc76e766db40361ac6c661637e4e278e75b433ba51913ec73a0710b31e730db427780761cf1
7
- data.tar.gz: 4627fbb79b24530685dd49dc0b7d11f61dc8b51cf41045f28a75c26fd4a20f8311ff9a323229eb9f5572e2dd821c8b088deb7f0d271f773b4d5fe2be1dd4edde
6
+ metadata.gz: 5fd717a10acee244d770c45c7291019feb61a30738e55ed2033ae2f113bba29a77c65f2be736893635fcb16b4090384629f6d7d582584596518c2b4db64d45f4
7
+ data.tar.gz: 7b7ea40f94d190e3cce26fe15c3b3a3707d7a83f7508cbd738925b4afd4e400983a5ff329da5f492427f515082878b98099c22eee342a18f7e61a19956de35ef
data/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # upnp_content_explorer
2
+ A convenience wrapper around an [easy_upnp](https://github.com/sidoh/easy_upnp) service to access content.
3
+
4
+ ## Installing
5
+
6
+ `upnp_content_explorer` is available on [Rubygems](https://rubygems.org). You can install it with:
7
+
8
+ ```
9
+ $ gem install upnp_content_explorer
10
+ ```
11
+
12
+ You can also add it to your Gemfile:
13
+
14
+ ```
15
+ gem 'upnp_content_explorer'
16
+ ```
17
+
18
+ ## What's this for?
19
+
20
+ This gem makes it easy to explore and navigate content provided by a UPnP media server implementing the `urn:schemas-upnp-org:service:ContentDirectory:1` service. At the moment, it relies on [`easy_upnp`](https://github.com/sidoh/easy_upnp) to interface with the UPnP server.
21
+
22
+ ## Example usage
23
+
24
+ Given an `easy_upnp` server identified by `service`, you can construct a content explorer as follows:
25
+
26
+ ```ruby
27
+ require 'upnp_content_explorer'
28
+
29
+ explorer = UpnpContentExplorer::Explorer.new(service)
30
+ ```
31
+
32
+ You can then do the following:
33
+
34
+ ### Get the contents of a directory
35
+
36
+ ```ruby
37
+ node = explorer.node_at('/Movies')
38
+
39
+ node.children.map(&:title)
40
+ # => ["Comedy", "Horror", "Suspense"]
41
+
42
+ node.items.map(&:title)
43
+ # => ["Inside Out (2015).mkv"]
44
+ ```
45
+
46
+ ### List the children of a directory
47
+ ```ruby
48
+ children = explorer.children_of('/Movies')
49
+
50
+ children.map(&:title)
51
+ # => ["Comedy", "Horror", "Suspense"]
52
+ ```
53
+
54
+ ### List the files inside of a directory
55
+ ```ruby
56
+ items = explorer.items_of('/Movies')
57
+
58
+ items.map(&:title)
59
+ # => ["Inside Out (2015).mkv"]
60
+ ```
61
+
62
+ ### Recursively scrape all content of a directory
63
+ ```ruby
64
+ movies = explorer.scrape('/Movies')
65
+
66
+ items.map(&:title)
67
+ # => ["Inside Out (2015).mkv", "Exorcist, The (1973).mkv", "Seven (1995).mkv", "Airplane (1980).mkv"]
68
+ ```
69
+
70
+ ## Extracting metadata
71
+
72
+ To extract DIDL Lite metadata for an item, you should generally call `Browse` with the `BrowseFlag` parameter equal to `'BrowseMetadata'`, passing the `ObjectID` of the item in question. For example:
73
+
74
+ ```ruby
75
+ # Choose a random movie
76
+ movie = explorer.scrape('/Movies').sample
77
+
78
+ movie.title
79
+ # => "Airplane (1980).mkv"
80
+
81
+ # Get movie metadata
82
+ movie_metadata = service.Browse(
83
+ ObjectID: movie.id,
84
+ BrowseFlag: 'BrowseMetadata',
85
+ Filter: '*'
86
+ )[:Result]
87
+ # => ... (Raw DIDL Lite metadata) ...
88
+ ```
@@ -4,6 +4,10 @@ module UpnpContentExplorer
4
4
  @data = data
5
5
  end
6
6
 
7
+ def item_class
8
+ @data[:class]
9
+ end
10
+
7
11
  def method_missing(key)
8
12
  return @data[key] if @data.has_key?(key)
9
13
  super
@@ -1,3 +1,3 @@
1
1
  module UpnpContentExplorer
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: upnp_content_explorer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Mullins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-12 00:00:00.000000000 Z
11
+ date: 2015-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nori
@@ -90,6 +90,7 @@ files:
90
90
  - .gitignore
91
91
  - Gemfile
92
92
  - LICENSE.txt
93
+ - README.md
93
94
  - Rakefile
94
95
  - lib/upnp_content_explorer.rb
95
96
  - lib/upnp_content_explorer/explorer.rb