This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
forked from olds/phpbrainz
-
Notifications
You must be signed in to change notification settings - Fork 2
/
phpBrainz.release.class.php
173 lines (155 loc) · 3.6 KB
/
phpBrainz.release.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php
/**
* Represents a release object.
*
* @package phpBrainz
* @author Jeff Sherlock
* @copyright Jeff Sherlock 2007
* @name phpBrainz_Release
*
*/
class phpBrainz_Release{
private $artist;
private $title;
private $tracksCount;
private $id;
private $discCount;
private $asin;
private $tracks;
private $score;
private $tracksOffset;
function __construct(){
$this->tracks = array();
}
/**
* Sets the artist for this release
* object.
*
* @param phpBrainz_Artist $artist
* @return none
*/
public function setArtist(phpBrainz_Artist $artist){
$this->artist = $artist;
}
/**
* Returns the artist for this release
*
* @param none
* @return phpBrainz_Artist
*/
public function getArtist(){
return $this->artist;
}
/**
* Sets the musicbrainz id for this
* release.
*
* @param string $id
* @return none
*/
public function setId($id){
$this->id = $id;
}
/**
* Returns the musicbrainz id for this
* release.
*
* @param none
* @return string
*/
public function getId(){
return $this->id;
}
public function setTracksCount($trackCount){
$trackCount = (int)$trackCount;
if(!is_numeric($trackCount) && strlen($trackCount)>0){
die(print("setTrackCount requires an integer."));
}
$this->tracksCount = $trackCount;
}
public function getTracksCount(){
return $this->tracksCount;
}
public function addTrack($track){
if(!($track instanceof phpBrainz_Track)){
die(print("addTrack only takes a phpBrainz_Track object"));
}
$this->tracks[] = $track;
}
public function getTracks($track){
return $this->tracks;
}
public function getTitle(){
return $this->title;
}
public function setTitle($title){
$this->title = (string)$title;
}
public function getScore(){
return $this->score;
}
public function setScore($score){
$this->score = intval($score);
}
public function getTracksOffset(){
return $this->tracksOffset;
}
public function setTracksOffset($offset){
$this->tracksOffset = intval($offset);
}
/**
* Returns the number of discs in this release,
* if this information is available.
*
* @return int
*/
public function getDiscCount(){
return $this->discCount;
}
/**
* Sets the number of discs in this release.
*
* @param int
*/
public function setDiscCount($count){
$this->discCount = $count;
}
/**
* Sets the asin value.
* @param string $asin
*/
public function setASIN($asin){
$this->asin = $asin;
}
/**
* Retrieves the asin value.
* @param none
* @return string
*/
public function getASIN(){
return $this->asin;
}
public function equals(phpBrainz_Release $compareObj){
if((
$this->id == $compareObj->getId() &&
phpBrainz::isValidMBID($this->id)
) ||
(
$this->artist->equals($compareObj->getArtist()) &&
$this->title == $compareObj->getTitle()
)
){
return true;
}
return false;
}
public function isSingleArtistRelease(){
foreach($this->tracks as $track){
if($track->id != $this->artist->id){
return false;
}
}
return true;
}
}
?>