lilyplaying 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/bin/lilyplaying +58 -0
- data/lib/lilyplaying.rb +24 -0
- data/lib/lilyplaying/current.rb +25 -0
- data/lib/lilyplaying/user.rb +15 -0
- data/lib/lilyplaying/version.rb +4 -0
- data/lilyplaying.gemspec +27 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZDc3MzFiZGVjNWI0NzcwY2Y0ZmEwYzIyOWI1N2EwYjhjZWVjYWY4OA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NGRjMjgyNDcwMzg1NGFiZGQzMDFlYzJiMjE4ZDZhM2M4N2ExMDM1Mg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MjE5NmM3MzdhNmNiZjkzODVlYjk4ODJkODhhZWM4ODFmMjhkMmE5OTMwYjM5
|
10
|
+
NjY1ZjNmNGYxZTE0MmY4YjBkNTRmYjQyYTE0NjVhZDdlODVjOWIxMDRjMzI4
|
11
|
+
OTAwMjEyNGY1OTMwZWRiNGY5MTAyOGQ3NmVkZTQ1NWU3YjIwMzU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZDg0MzczZDk0NjY0N2Q0MDNmNmFiNzkxNjk3NTZiMDMxMWFhOTYzYzBjOWRm
|
14
|
+
MTdjNDk2YmU1MmFhZWU3ODVlZDY1NGRlYjliMjY1MGI4OWY1OGE2NzQ2Zjkx
|
15
|
+
ODBiYmFkMjZiMTlmYTNmNDQxOGRkZmU1YTE4YWRkOTBkYWJkYzQ=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Christopher Giroir
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Lilyplaying
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'lilyplaying'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install lilyplaying
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/lilyplaying
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
STDOUT.sync = true
|
3
|
+
|
4
|
+
$:.unshift File.join(File.dirname(__FILE__), *%w{ .. lib })
|
5
|
+
|
6
|
+
require 'commander/import'
|
7
|
+
require 'lilyplaying'
|
8
|
+
|
9
|
+
program :name, 'LilyPlaying'
|
10
|
+
program :version, LilyPlaying::VERSION
|
11
|
+
program :description, LilyPlaying::DESCRIPTION
|
12
|
+
|
13
|
+
default_command :help
|
14
|
+
|
15
|
+
command :auth do |c|
|
16
|
+
c.syntax = 'lilyplaying auth'
|
17
|
+
c.description = 'Returns the url to use to authorize lilyplaying to your last.fm account'
|
18
|
+
|
19
|
+
c.action do |args, options|
|
20
|
+
key = LilyPlaying.config['api']['key']
|
21
|
+
token = LilyPlaying.client.auth.get_token
|
22
|
+
puts "Go to: http://www.last.fm/api/auth/?api_key=#{key}&token=#{token}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
command :current do |c|
|
27
|
+
c.syntax = 'lilyplaying current'
|
28
|
+
c.description = 'Returns the currently playing song'
|
29
|
+
c.action do |args, options|
|
30
|
+
user = LilyPlaying.user
|
31
|
+
current = user.current
|
32
|
+
|
33
|
+
puts "#{current.name} - #{current.artist}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
command :run do |c|
|
38
|
+
c.syntax = 'lilyplaying run [file]'
|
39
|
+
c.description = 'Run in the background and update song every 10 seconds, writing output to [file] which defaults to ~/.currently_playing'
|
40
|
+
|
41
|
+
c.action do |args, options|
|
42
|
+
file = args[0] || "~/.currently_playing"
|
43
|
+
|
44
|
+
exit_requested = false
|
45
|
+
Kernel.trap( "INT" ) { exit_requested = true }
|
46
|
+
|
47
|
+
while !exit_requested
|
48
|
+
user = LilyPlaying.user
|
49
|
+
current = user.current
|
50
|
+
string = current.to_s
|
51
|
+
puts "Updating: #{string}"
|
52
|
+
File.write(File.expand_path(file), string)
|
53
|
+
sleep 15
|
54
|
+
end
|
55
|
+
|
56
|
+
puts "Exiting"
|
57
|
+
end
|
58
|
+
end
|
data/lib/lilyplaying.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'lilyplaying/version'
|
2
|
+
require 'lastfm'
|
3
|
+
require 'safe_yaml'
|
4
|
+
|
5
|
+
require 'lilyplaying/user'
|
6
|
+
require 'lilyplaying/current'
|
7
|
+
|
8
|
+
module LilyPlaying
|
9
|
+
def self.config
|
10
|
+
@@config ||= YAML.safe_load_file(File.expand_path("~/.lilyplaying"))
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.client
|
14
|
+
@@client ||= Lastfm.new(config['api']['key'], config['api']['secret'])
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.session
|
18
|
+
@@session = client.auth.get_session(:token => config['api']['token'])['key']
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.user
|
22
|
+
LilyPlaying::User.new(config['user'])
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module LilyPlaying
|
2
|
+
class Current
|
3
|
+
attr_reader :data
|
4
|
+
|
5
|
+
def initialize(data)
|
6
|
+
@data = data[0]
|
7
|
+
end
|
8
|
+
|
9
|
+
def playing?
|
10
|
+
@data["nowplaying"]
|
11
|
+
end
|
12
|
+
|
13
|
+
def album
|
14
|
+
(@data['album']['content'] || artist) if @data
|
15
|
+
end
|
16
|
+
|
17
|
+
def method_missing(meth, *args, &block)
|
18
|
+
(@data[meth.to_s]['content'] || @data[meth.to_s]) if @data
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
"#{name} - #{artist}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'lilyplaying/current'
|
2
|
+
|
3
|
+
module LilyPlaying
|
4
|
+
class User
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
def initialize(name)
|
8
|
+
@name = name
|
9
|
+
end
|
10
|
+
|
11
|
+
def current
|
12
|
+
LilyPlaying::Current.new(LilyPlaying.client.user.get_recent_tracks(:user => name))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lilyplaying.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'lilyplaying/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "lilyplaying"
|
8
|
+
spec.version = LilyPlaying::VERSION
|
9
|
+
spec.authors = ["Christopher Giroir"]
|
10
|
+
spec.email = ["kelsin@valefor.com"]
|
11
|
+
spec.description = LilyPlaying::DESCRIPTION
|
12
|
+
spec.summary = LilyPlaying::DESCRIPTION
|
13
|
+
spec.homepage = "https://github.com/Kelsin/lilyplaying"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency('commander', "~> 4.1.3")
|
22
|
+
spec.add_runtime_dependency('lastfm', "~> 1.21.0")
|
23
|
+
spec.add_runtime_dependency('safe_yaml', "~> 0.7.0")
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lilyplaying
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christopher Giroir
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: commander
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.1.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.1.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: lastfm
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.21.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.21.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: safe_yaml
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.7.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.7.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Outputs the currently playing last.fm song to a text file for use while
|
84
|
+
streaming
|
85
|
+
email:
|
86
|
+
- kelsin@valefor.com
|
87
|
+
executables:
|
88
|
+
- lilyplaying
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- .gitignore
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- bin/lilyplaying
|
98
|
+
- lib/lilyplaying.rb
|
99
|
+
- lib/lilyplaying/current.rb
|
100
|
+
- lib/lilyplaying/user.rb
|
101
|
+
- lib/lilyplaying/version.rb
|
102
|
+
- lilyplaying.gemspec
|
103
|
+
homepage: https://github.com/Kelsin/lilyplaying
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ! '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.0.3
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Outputs the currently playing last.fm song to a text file for use while streaming
|
127
|
+
test_files: []
|