remote_vlc2019 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 93ff49964ea9454090f9bf365c0b38dbe0dac6b90a7ebb33933d356818f400f8
4
+ data.tar.gz: 74b3bd6dec59d002787df73a397c1a3b7c339f15694a5aa81cd3c771ca101a42
5
+ SHA512:
6
+ metadata.gz: 79365ae86d8833835c672fd27fd517292893dcd41574c8fb0d71300699577cf1498dc92129beb541b58a24a2a1a8deb9c69a32cbd38a207b40a1e4b9e520557e
7
+ data.tar.gz: 25bde35d2efcf487dcb39c67a8eba18d2163c3e29f7a96623b4ebf69ae04661bdec6526fdac3533e90b45bf780855a1228333c7c3c4a80c6b45f43bd5901e415
Binary file
Binary file
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: remote_vlc2019.rb
4
+
5
+ require 'rexle'
6
+ require 'open-uri'
7
+
8
+ MAX_VOL = 257
9
+
10
+ class RemoteVlc2019
11
+
12
+ attr_reader :info
13
+
14
+ def initialize(host: nil, port: '8080', password: 'password', verbose: false)
15
+
16
+ @host, @port, @password, verbose = host, port, password, verbose
17
+
18
+ end
19
+
20
+ def now_playing() @info[:now_playing] end
21
+ def play() req 'pl_play' end
22
+ def playing?() state() == :playing end
23
+ def pause() req 'pl_pause' end
24
+ def state() status(); @state.to_sym end
25
+ def stop() req 'pl_stop' end
26
+ def vol() @vol end
27
+ def vol_down() setvol(offset: -50) end
28
+ def vol_up() setvol(offset: 50) end
29
+ def vol=(val) setvol val end
30
+
31
+ alias volume vol
32
+ alias volume= vol=
33
+
34
+
35
+ def req(command='')
36
+
37
+ url = "http://%s:%s/requests/status.xml?command=%s" \
38
+ % [@host, @port, command]
39
+ s = open(url + '', http_basic_authentication: ["", @password]).read
40
+ doc = Rexle.new(s)
41
+ @state = %w(state).map {|x| doc.root.text(x) }
42
+ @vol = doc.root.text('volume').to_i
43
+
44
+ @info = doc.root.xpath('information/category/info').map do |x|
45
+ [x.attributes[:name].downcase.to_sym, x.text]
46
+ end.to_h
47
+
48
+ @verbose ? s : command.to_sym
49
+ end
50
+
51
+ alias status req
52
+
53
+ private
54
+
55
+ def setvol(raw_val)
56
+
57
+ offset = raw_val.is_a?(Hash) ? raw_val[:offset] : nil
58
+ val = offset ? @vol + offset : raw_val.to_i
59
+ val = MAX_VOL if val > MAX_VOL and offset
60
+ return status() unless val >= 0 and val <= MAX_VOL
61
+ req 'volume&val=' + val.to_s
62
+ vol()
63
+ end
64
+
65
+ end
66
+
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: remote_vlc2019
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
+ YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkwMjEwMjA0NDUyWhcN
15
+ MjAwMjEwMjA0NDUyWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
+ cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDFUMrP
17
+ 6ioTVR0H2HbRYSeWlXbbej65nKHK7XwUeyKOITnUTvO5Oo0wb8ByO5oTa/TOxkIN
18
+ PpKOtQcDt4dmaFEL70S5Ly1hx45jwWZ5OBiY+/oivylyBuC3s5UMKHeYVGl28dL7
19
+ SFs9RgQnBJrjpXNKQ51wr3BgiXSeQUb/iQYL0n8x2pEVNvrQMY3m651ZDjDpht0b
20
+ uDa0R/XkC1JSFStF+kwUaKsrCEuIuv2yG7QsZmBK3A+aG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qydDtC5HKeaQqW
36
+ Z+iFukz5NioE5TAGrxoHJPHJ
37
+ -----END CERTIFICATE-----
38
+ date: 2019-02-10 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: rexle
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.5'
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 1.5.1
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '1.5'
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 1.5.1
60
+ description:
61
+ email: james@jamesrobertson.eu
62
+ executables: []
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - lib/remote_vlc2019.rb
67
+ homepage: https://github.com/jrobertson/remote_vlc2019
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubygems_version: 3.0.2
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Sends remote commands to VLC via HTTP.
90
+ test_files: []
Binary file