tunecore_direct 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +1 -0
- data/examples/quick_tutorial.rb +60 -0
- data/lib/tunecore_direct/album.rb +16 -5
- data/lib/tunecore_direct/person.rb +6 -0
- data/lib/tunecore_direct/song.rb +11 -6
- data/lib/tunecore_direct/version.rb +1 -1
- data/test/test_tunecore_direct.rb +10 -2
- data.tar.gz.sig +0 -0
- metadata +3 -2
- metadata.gz.sig +0 -0
data/Manifest.txt
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
# This script will demonstrate how to create a user at TuneCore and add an Album and Song.
|
2
|
+
email = 'alex.kane@gmail.com'
|
3
|
+
tunecore_server = "http://localhost:3000"
|
4
|
+
api_key = "testkey"
|
5
|
+
|
6
|
+
# Set up our environment
|
7
|
+
#require 'rubygems'
|
8
|
+
require 'tunecore_direct'
|
9
|
+
include TunecoreDirect
|
10
|
+
TunecoreDirect::Base.tunecore_server = tunecore_server
|
11
|
+
TunecoreDirect::Base.api_key = api_key
|
12
|
+
|
13
|
+
person = Person.get("alex.kane@gmail.com")
|
14
|
+
|
15
|
+
|
16
|
+
# Create a person
|
17
|
+
person = TunecoreDirect::Person.new
|
18
|
+
person.name = "Joe Schmoe"
|
19
|
+
person.email = email
|
20
|
+
person.password = "pa$$word"
|
21
|
+
person.phone_number = "212-555-1212"
|
22
|
+
person.country = "United States"
|
23
|
+
person.postal_code = "11201"
|
24
|
+
# person.create should return true. If it returns false check person.errors to see why the person
|
25
|
+
# couldn't be created. Assuming that it returned true, the person_id attribute will now be set.
|
26
|
+
person.create
|
27
|
+
|
28
|
+
# Create an Album for our person
|
29
|
+
album = TunecoreDirect::Album.new
|
30
|
+
album.name = "My Album"
|
31
|
+
album.person_id = person.person_id # this is the person_id of the person we created above
|
32
|
+
album.orig_release_date = "2008-02-23"
|
33
|
+
album.sale_date = "2008-02-23"
|
34
|
+
album.primary_genre = "Rock"
|
35
|
+
album.secondary_genre = "Alternative"
|
36
|
+
album.artist_name = "Alex Kane"
|
37
|
+
album.label_name = "Shochu"
|
38
|
+
album.c_copyright = "1999"
|
39
|
+
album.p_copyright = "1999"
|
40
|
+
album.recording_location = "Brooklyn"
|
41
|
+
album.parental_advisory = false
|
42
|
+
album.stores = "iTunesUS,iTunesAU,iTunesCA,iTunesEU,iTunesJP,iTunesEU,RhapsodyRH,MusicNet,Napster,eMusic,Amazon,Lala"
|
43
|
+
# Our album object is built, now let's create it on the TuneCore server. Like person, the Album object will
|
44
|
+
# return true if the album was created, and false if there was a problem. If false check album.errors to see
|
45
|
+
# what the problem was.
|
46
|
+
album.create
|
47
|
+
|
48
|
+
|
49
|
+
# Create a song to go on the Album we just created
|
50
|
+
song = TunecoreDirect::Song.new
|
51
|
+
song.album_id = album.album_id
|
52
|
+
song.name = "My song"
|
53
|
+
song.track_num = 1
|
54
|
+
song.save
|
55
|
+
|
56
|
+
# Now that we've created the Song in TuneCore's server the next step is to upload the audio file
|
57
|
+
# to TuneCore. We do this by using TuneCore's flash uploade tool.
|
58
|
+
# The url to upload tool for this song is:
|
59
|
+
|
60
|
+
|
@@ -27,7 +27,7 @@ module TunecoreDirect
|
|
27
27
|
attr_accessor :artist_name, :label_name, :c_copyright, :p_copyright, :recording_location, :parental_advisory
|
28
28
|
attr_accessor :artwork_s3_id, :takedown_at
|
29
29
|
attr_accessor :errors
|
30
|
-
attr_accessor :stores, :state
|
30
|
+
attr_accessor :stores, :state, :xml
|
31
31
|
|
32
32
|
def initialize(options = {})
|
33
33
|
options.each do |k,v|
|
@@ -38,8 +38,8 @@ module TunecoreDirect
|
|
38
38
|
# Creates an Album object from a Rexml:Element
|
39
39
|
def self.from_xml_element( album_element)
|
40
40
|
@xml = album_element
|
41
|
-
|
42
|
-
album = self.new
|
41
|
+
puts @xml
|
42
|
+
album = self.new(:xml => @xml)
|
43
43
|
album.album_id = album_element.elements["id"].text
|
44
44
|
album.person_id = album_element.elements["person-id"].text
|
45
45
|
album.name = album_element.elements["name"].text
|
@@ -101,7 +101,13 @@ module TunecoreDirect
|
|
101
101
|
|
102
102
|
# Returns an array that contains every Song in this Album
|
103
103
|
def songs
|
104
|
-
|
104
|
+
# if @xml == nil
|
105
|
+
# self.
|
106
|
+
songs = []
|
107
|
+
@xml.elements.each("songs/song") do |song_element|
|
108
|
+
songs << Song.from_xml_element( song_element)
|
109
|
+
end
|
110
|
+
return songs
|
105
111
|
end
|
106
112
|
|
107
113
|
# Returns the number of songs that have been created for this album
|
@@ -129,7 +135,12 @@ module TunecoreDirect
|
|
129
135
|
|
130
136
|
def is_taken_down?
|
131
137
|
!@takedown.nil?
|
132
|
-
end
|
138
|
+
end
|
133
139
|
|
140
|
+
def upload_url
|
141
|
+
"http://#{TunecoreDirect::Base.tunecore_server}/partner/songs?album_id=#{self.album_id}"
|
142
|
+
end
|
143
|
+
|
144
|
+
|
134
145
|
end
|
135
146
|
end
|
@@ -71,6 +71,12 @@ module TunecoreDirect
|
|
71
71
|
req.get_people.object
|
72
72
|
end
|
73
73
|
|
74
|
+
# Get's a person object from the TuneCore server. Id can be either a person_id or an email address
|
75
|
+
def self.get(id)
|
76
|
+
req = Request.new
|
77
|
+
req.get_person(id).object
|
78
|
+
end
|
79
|
+
|
74
80
|
# Returns an array of albums owned by this person
|
75
81
|
def albums
|
76
82
|
req = Request.new
|
data/lib/tunecore_direct/song.rb
CHANGED
@@ -48,14 +48,19 @@ module TunecoreDirect
|
|
48
48
|
# Creates an Album object from a Rexml:Element
|
49
49
|
def self.from_xml_element( song_element)
|
50
50
|
song = self.new
|
51
|
-
song.song_id
|
52
|
-
song.album_id
|
53
|
-
song.name
|
54
|
-
song.artist_name
|
55
|
-
song.
|
51
|
+
song.song_id = song_element.elements["id"].text
|
52
|
+
song.album_id = song_element.elements["album-id"].text
|
53
|
+
song.name = song_element.elements["name"].text
|
54
|
+
song.artist_name = song_element.elements["artist-name"].text unless song_element.elements["artist-name"].nil?
|
55
|
+
song.parental_advisory = song_element.elements["parental-advisory"].text
|
56
|
+
song.track_num = song_element.elements["track-num"].text
|
56
57
|
return song
|
57
58
|
end
|
58
|
-
|
59
|
+
|
60
|
+
# Returns the URL for the upload tool
|
61
|
+
def upload_url
|
62
|
+
"#{tunecore_server}/partner/track_upload?api_key=#{api_key}&song_id=#{self.song_id}"
|
63
|
+
end
|
59
64
|
|
60
65
|
end
|
61
66
|
|
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/test_helper.rb'
|
|
3
3
|
class TestTunecoreDirect < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
|
-
TunecoreDirect::Base.tunecore_server = "http://
|
6
|
+
TunecoreDirect::Base.tunecore_server = "http://localhost:3000"
|
7
7
|
TunecoreDirect::Base.api_key = "testkey"
|
8
8
|
|
9
9
|
#random email address so we dont get collisions after the first test
|
@@ -46,7 +46,7 @@ class TestTunecoreDirect < Test::Unit::TestCase
|
|
46
46
|
album.label_name = "Shochu"
|
47
47
|
album.c_copyright = "1999"
|
48
48
|
album.p_copyright = "1999"
|
49
|
-
album.recording_location = "
|
49
|
+
album.recording_location = "Brooklyn"
|
50
50
|
album.parental_advisory = false
|
51
51
|
album.stores = "iTunesUS,iTunesAU,iTunesCA,iTunesEU,iTunesJP,iTunesEU,RhapsodyRH,MusicNet,Napster,eMusic,Amazon,Lala"
|
52
52
|
created = album.create
|
@@ -56,6 +56,7 @@ class TestTunecoreDirect < Test::Unit::TestCase
|
|
56
56
|
song = TunecoreDirect::Song.new
|
57
57
|
song.album_id = album.album_id
|
58
58
|
song.name = "My song"
|
59
|
+
song.track_num = 1
|
59
60
|
assert song.save == true
|
60
61
|
|
61
62
|
# get all albums
|
@@ -66,6 +67,13 @@ class TestTunecoreDirect < Test::Unit::TestCase
|
|
66
67
|
album_id = albums.first.album_id
|
67
68
|
assert TunecoreDirect::Album.takedown( album_id ) != nil
|
68
69
|
|
70
|
+
# get person by email
|
71
|
+
person = TunecoreDirect::Person.get(@email)
|
72
|
+
assert person.email = @email
|
73
|
+
|
74
|
+
# get all the songs for this album
|
75
|
+
songs = person.albums.first.songs
|
76
|
+
|
69
77
|
end
|
70
78
|
|
71
79
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tunecore_direct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Kane
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
f3TSOQ==
|
31
31
|
-----END CERTIFICATE-----
|
32
32
|
|
33
|
-
date: 2008-04-
|
33
|
+
date: 2008-04-15 00:00:00 -04:00
|
34
34
|
default_executable:
|
35
35
|
dependencies: []
|
36
36
|
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- Rakefile
|
55
55
|
- config/hoe.rb
|
56
56
|
- config/requirements.rb
|
57
|
+
- examples/quick_tutorial.rb
|
57
58
|
- lib/tunecore_direct.rb
|
58
59
|
- lib/tunecore_direct/album.rb
|
59
60
|
- lib/tunecore_direct/base.rb
|
metadata.gz.sig
CHANGED
Binary file
|