spotify-api 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ == 0.0.7 / 2010-03-14
2
+ * Updated jotify.jar
3
+
1
4
  == 0.0.6 / 2009-10-26
2
5
  * More interesting demo apps, more robust API
3
6
 
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ gem "sinatra"
2
+ gem "json-jruby"
3
+
4
+ group :development do
5
+ gem "rspec"
6
+ gem "rack-test"
7
+ end
data/README.md CHANGED
@@ -51,6 +51,11 @@ See examples directory for usage. The demo application ([lastfm2spotify_loved_tr
51
51
  grab all recently loved tracks by your last.fm friends to create a new
52
52
  spotify playlist. A nice way to listen to some good new music (if you share a similar music taste with most of your friends :)).
53
53
 
54
+ ## Hacking
55
+
56
+ Test your changes with *rake spec* for unit tests, *rake integration* for integration tests. The jotify jar file is build from
57
+ [github.com/jberkel/jotify/tree/spotify-api](http://github.com/jberkel/jotify/tree/spotify-api).
58
+
54
59
  ## Credits
55
60
 
56
61
  Contains code from the jotify project:
@@ -1,4 +1,5 @@
1
1
  ---
2
- :patch: 6
3
2
  :major: 0
4
3
  :minor: 0
4
+ :patch: 7
5
+ :build:
@@ -17,7 +17,8 @@ class LastFM
17
17
  class <<self
18
18
  def loved_tracks(user_id, limit=5)
19
19
  if tracks = query('user.getLovedTracks', :user=>user_id, :limit=>limit)['lovedtracks']['track']
20
- tracks.map do |r|
20
+
21
+ [tracks].flatten.map do |r|
21
22
  { 'artist' => r['artist']['name'], 'title'=>r['name'], 'mbid' => r['mbid'] }
22
23
  end
23
24
  else
Binary file
@@ -13,7 +13,14 @@ class Jotify
13
13
  end
14
14
 
15
15
  import 'de.felixbruns.jotify.gui.util.JotifyPreferences'
16
- import 'de.felixbruns.jotify.util.SpotifyURI'
16
+ import 'de.felixbruns.jotify.media.Link'
17
+
18
+ class Java::DeFelixbrunsJotifyMedia::Link
19
+ def to_s
20
+ self.asHTTPLink
21
+ end
22
+ end
23
+
17
24
 
18
25
  ByPopularity = Proc.new { |a,b| b.popularity <=> a.popularity }
19
26
 
@@ -46,7 +53,7 @@ class Jotify
46
53
  end
47
54
 
48
55
  def playlists
49
- @jotify.playlists.map { |p| playlist(p.getId()) }
56
+ @jotify.playlistContainer.playlists.map { |p| playlist(p.getId()) }
50
57
  end
51
58
 
52
59
  def playlist(id, resolve_tracks=false)
@@ -60,17 +67,17 @@ class Jotify
60
67
  playlist
61
68
  end
62
69
 
63
- def create_playlist(name, collaborative=false)
70
+ def create_playlist(name, collaborative=false, description=nil, picture=nil)
64
71
  raise ArgumentError, "need name" unless name
65
72
 
66
- playlist = @jotify.playlistCreate(name, collaborative)
73
+ playlist = @jotify.playlistCreate(name, collaborative, description, picture)
67
74
  return nil unless playlist
68
75
  add_playlist(playlist)
69
76
  playlist
70
77
  end
71
78
 
72
79
  def add_playlist(id)
73
- @jotify.playlistsAddPlaylist(@jotify.playlists, id.is_a?(Media::Playlist) ? id : playlist(id))
80
+ @jotify.playlistContainerAddPlaylist(@jotify.playlistContainer, id.is_a?(Media::Playlist) ? id : playlist(id))
74
81
  end
75
82
 
76
83
  def rename_playlist(playlist, name)
@@ -97,11 +104,12 @@ class Jotify
97
104
  end
98
105
 
99
106
  def self.resolve_id(id)
107
+
100
108
  case id
101
- when /\Ahttp:\/\/open\.spotify\.com/: SpotifyURI.to_hex(id[id.rindex('/')+1..-1])
102
- when /spotify:/: SpotifyURI.to_hex(id[id.rindex(':')+1..-1])
109
+ when /\Ahttp:\/\/open\.spotify\.com/: Link.to_hex(id[id.rindex('/')+1..-1])
110
+ when /spotify:/: Link.to_hex(id[id.rindex(':')+1..-1])
103
111
  when /\A[0-9a-f]{32}\Z/: id
104
- when /\A[a-zA-Z0-9]{22}\Z/: SpotifyURI.to_hex(id)
112
+ when /\A[a-zA-Z0-9]{22}\Z/: Link.to_hex(id)
105
113
  else
106
114
  raise "invalid id: #{id}"
107
115
  end
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env jruby
1
+
2
2
  require 'rubygems'
3
3
  require 'json'
4
4
  require 'sinatra/base'
@@ -113,7 +113,7 @@ Sinatra::Application.post('/playlists') do
113
113
  return error(500, 'playlist created but tracks could not be added')
114
114
  end
115
115
  end
116
- redirect playlist.link, 201 # created
116
+ redirect playlist.link.asHTTPLink, 201 # created
117
117
  else
118
118
  error(500, 'playlist could not be created')
119
119
  end
@@ -11,7 +11,7 @@ module Java
11
11
 
12
12
  def to_h
13
13
  h = { :id=>self.getId(), :popularity=> popularity.nan? ? 0.0 : popularity.to_f }
14
- h[:url] = self.link if self.respond_to?(:link)
14
+ h[:url] = self.link.asHTTPLink if self.respond_to?(:link)
15
15
  h
16
16
  end
17
17
  end
@@ -39,7 +39,7 @@ module Java
39
39
  {
40
40
  :id => getId(),
41
41
  :name=> name,
42
- :url => link,
42
+ :url => link.asHTTPLink,
43
43
  :tracks => tracks.map { |t| t.to_h },
44
44
  :author => author,
45
45
  :revision => revision,
@@ -40,12 +40,11 @@ describe "Integration" do
40
40
 
41
41
  it "should return name and id, not tracks (GH-3)" do
42
42
  @playlists.each do |pl|
43
- puts pl.inspect
44
43
  pl.name.should_not be_nil
45
44
 
46
45
  pl.tracks.each do |t|
47
46
  t.getId().should_not be_nil
48
- t.getName().should be_nil
47
+ t.getTitle().should be_nil
49
48
  end
50
49
  end
51
50
  end
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{spotify-api}
8
- s.version = "0.0.6"
8
+ s.version = "0.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jan Berkel"]
12
- s.date = %q{2009-10-26}
12
+ s.date = %q{2010-03-14}
13
13
  s.default_executable = %q{spotify-api-server}
14
14
  s.description = %q{an api for spotify, based on jotify}
15
15
  s.email = %q{jan.berkel@gmail.com}
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.files = [
22
22
  ".gitignore",
23
23
  "CHANGELOG",
24
+ "Gemfile",
24
25
  "LICENSE",
25
26
  "README.md",
26
27
  "Rakefile",
@@ -45,7 +46,7 @@ Gem::Specification.new do |s|
45
46
  s.homepage = %q{http://github.com/jberkel/spotify-api}
46
47
  s.rdoc_options = ["--charset=UTF-8"]
47
48
  s.require_paths = ["lib"]
48
- s.rubygems_version = %q{1.3.5}
49
+ s.rubygems_version = %q{1.3.6}
49
50
  s.summary = %q{an api for spotify, based on jotify}
50
51
  s.test_files = [
51
52
  "spec/integration_spec.rb",
@@ -80,3 +81,4 @@ Gem::Specification.new do |s|
80
81
  s.add_dependency(%q<httparty>, [">= 0"])
81
82
  end
82
83
  end
84
+
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spotify-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 7
9
+ version: 0.0.7
5
10
  platform: ruby
6
11
  authors:
7
12
  - Jan Berkel
@@ -9,59 +14,69 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-10-26 00:00:00 +01:00
17
+ date: 2010-03-14 00:00:00 +01:00
13
18
  default_executable: spotify-api-server
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: rack
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
23
29
  version: "0"
24
- version:
30
+ type: :runtime
31
+ version_requirements: *id001
25
32
  - !ruby/object:Gem::Dependency
26
33
  name: rack-test
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
33
41
  version: "0"
34
- version:
42
+ type: :runtime
43
+ version_requirements: *id002
35
44
  - !ruby/object:Gem::Dependency
36
45
  name: sinatra
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
46
+ prerelease: false
47
+ requirement: &id003 !ruby/object:Gem::Requirement
40
48
  requirements:
41
49
  - - ">="
42
50
  - !ruby/object:Gem::Version
51
+ segments:
52
+ - 0
43
53
  version: "0"
44
- version:
54
+ type: :runtime
55
+ version_requirements: *id003
45
56
  - !ruby/object:Gem::Dependency
46
57
  name: json-jruby
47
- type: :runtime
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
58
+ prerelease: false
59
+ requirement: &id004 !ruby/object:Gem::Requirement
50
60
  requirements:
51
61
  - - ">="
52
62
  - !ruby/object:Gem::Version
63
+ segments:
64
+ - 0
53
65
  version: "0"
54
- version:
66
+ type: :runtime
67
+ version_requirements: *id004
55
68
  - !ruby/object:Gem::Dependency
56
69
  name: httparty
57
- type: :runtime
58
- version_requirement:
59
- version_requirements: !ruby/object:Gem::Requirement
70
+ prerelease: false
71
+ requirement: &id005 !ruby/object:Gem::Requirement
60
72
  requirements:
61
73
  - - ">="
62
74
  - !ruby/object:Gem::Version
75
+ segments:
76
+ - 0
63
77
  version: "0"
64
- version:
78
+ type: :runtime
79
+ version_requirements: *id005
65
80
  description: an api for spotify, based on jotify
66
81
  email: jan.berkel@gmail.com
67
82
  executables:
@@ -74,6 +89,7 @@ extra_rdoc_files:
74
89
  files:
75
90
  - .gitignore
76
91
  - CHANGELOG
92
+ - Gemfile
77
93
  - LICENSE
78
94
  - README.md
79
95
  - Rakefile
@@ -107,18 +123,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
123
  requirements:
108
124
  - - ">="
109
125
  - !ruby/object:Gem::Version
126
+ segments:
127
+ - 0
110
128
  version: "0"
111
- version:
112
129
  required_rubygems_version: !ruby/object:Gem::Requirement
113
130
  requirements:
114
131
  - - ">="
115
132
  - !ruby/object:Gem::Version
133
+ segments:
134
+ - 0
116
135
  version: "0"
117
- version:
118
136
  requirements: []
119
137
 
120
138
  rubyforge_project:
121
- rubygems_version: 1.3.5
139
+ rubygems_version: 1.3.6
122
140
  signing_key:
123
141
  specification_version: 3
124
142
  summary: an api for spotify, based on jotify