[44] | 1 | <?php
|
---|
| 2 | /**
|
---|
| 3 | * Copyright 2006, 2007, 2008, 2009 Eric D. Hough (http://ehough.com)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of TubePress (http://tubepress.org)
|
---|
| 6 | *
|
---|
| 7 | * TubePress is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * TubePress is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with TubePress. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | *
|
---|
| 20 | */
|
---|
| 21 |
|
---|
| 22 | /**
|
---|
| 23 | * A YouTube video that TubePress can pass around easily
|
---|
| 24 | */
|
---|
| 25 | class org_tubepress_video_Video
|
---|
| 26 | {
|
---|
| 27 | private $_author;
|
---|
| 28 | private $_category;
|
---|
| 29 | private $_description;
|
---|
| 30 | private $_displayable;
|
---|
| 31 | private $_id;
|
---|
| 32 | private $_rating;
|
---|
| 33 | private $_ratings;
|
---|
| 34 | private $_length;
|
---|
| 35 | private $_tags;
|
---|
| 36 | private $_thumbUrls;
|
---|
| 37 | private $_title;
|
---|
| 38 | private $_uploadTime;
|
---|
| 39 | private $_youTubeUrl;
|
---|
| 40 | private $_views;
|
---|
| 41 |
|
---|
| 42 | /**
|
---|
| 43 | * Get the video's author
|
---|
| 44 | *
|
---|
| 45 | * @return string The YouTube username of the person that uploaded
|
---|
| 46 | * the video.
|
---|
| 47 | *
|
---|
| 48 | * Example: "3hough"
|
---|
| 49 | */
|
---|
| 50 | public function getAuthor()
|
---|
| 51 | {
|
---|
| 52 | return $this->_author;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | /**
|
---|
| 56 | * Get the video's category
|
---|
| 57 | *
|
---|
| 58 | * @return string The YouTube-defined category of the video
|
---|
| 59 | *
|
---|
| 60 | * Example: "Sports"
|
---|
| 61 | */
|
---|
| 62 | public function getCategory()
|
---|
| 63 | {
|
---|
| 64 | return $this->_category;
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | /**
|
---|
| 68 | * Returns the "default" YouTube thumbnail URL for this video
|
---|
| 69 | *
|
---|
| 70 | * @return string the "default" thumbnail URL for this video
|
---|
| 71 | */
|
---|
| 72 | public function getDefaultThumbURL()
|
---|
| 73 | {
|
---|
| 74 | return "http://img.youtube.com/vi/" . $this->getId() . "/default.jpg";
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | /**
|
---|
| 78 | * Get the video's description
|
---|
| 79 | *
|
---|
| 80 | * @return string The description field of the video.
|
---|
| 81 | *
|
---|
| 82 | * Example: "This is a great video."
|
---|
| 83 | */
|
---|
| 84 | public function getDescription()
|
---|
| 85 | {
|
---|
| 86 | return $this->_description;
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | /**
|
---|
| 90 | * Returns true if this video can be displayed. False otherwise.
|
---|
| 91 | *
|
---|
| 92 | * @return boolean Can the video be displayed.
|
---|
| 93 | */
|
---|
| 94 | public function isDisplayable()
|
---|
| 95 | {
|
---|
| 96 | return $this->_displayable;
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | /**
|
---|
| 100 | * Get the video's ID
|
---|
| 101 | *
|
---|
| 102 | * @return string The YouTube video ID
|
---|
| 103 | *
|
---|
| 104 | * Example: "3EVVD77X2FD"
|
---|
| 105 | */
|
---|
| 106 | public function getId()
|
---|
| 107 | {
|
---|
| 108 | return $this->_id;
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | /**
|
---|
| 112 | * Get the video's length
|
---|
| 113 | *
|
---|
| 114 | * @return string The runtime of the video
|
---|
| 115 | *
|
---|
| 116 | * Example: "3:25"
|
---|
| 117 | */
|
---|
| 118 | public function getLength()
|
---|
| 119 | {
|
---|
| 120 | return $this->_length;
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | /**
|
---|
| 124 | * Get a random thumbnail URL for this video
|
---|
| 125 | *
|
---|
| 126 | * @return string A random thumbnail URL for this video
|
---|
| 127 | */
|
---|
| 128 | public function getRandomThumbURL()
|
---|
| 129 | {
|
---|
| 130 | $thumbs = $this->getThumbUrls();
|
---|
| 131 | return $thumbs[array_rand($this->getThumbUrls())];
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | /**
|
---|
| 135 | * Get the video's average rating
|
---|
| 136 | *
|
---|
| 137 | * @return string The average rating of the video
|
---|
| 138 | *
|
---|
| 139 | * Example: "4.3"
|
---|
| 140 | */
|
---|
| 141 | public function getRating()
|
---|
| 142 | {
|
---|
| 143 | return $this->_rating;
|
---|
| 144 | }
|
---|
| 145 |
|
---|
| 146 | /**
|
---|
| 147 | * Get the number of ratings
|
---|
| 148 | *
|
---|
| 149 | * @return string The number of times this video has been rated.
|
---|
| 150 | *
|
---|
| 151 | * Example: "3hough"
|
---|
| 152 | */
|
---|
| 153 | public function getRatings()
|
---|
| 154 | {
|
---|
| 155 | return $this->_ratings;
|
---|
| 156 | }
|
---|
| 157 |
|
---|
| 158 | /**
|
---|
| 159 | * Get the video's tags
|
---|
| 160 | *
|
---|
| 161 | * @return array The tags of this video
|
---|
| 162 | *
|
---|
| 163 | * Example: "beer sports women awesome"
|
---|
| 164 | */
|
---|
| 165 | public function getTags()
|
---|
| 166 | {
|
---|
| 167 | return $this->_tags;
|
---|
| 168 | }
|
---|
| 169 |
|
---|
| 170 | /**
|
---|
| 171 | * Get the video's thumbnail URLs
|
---|
| 172 | *
|
---|
| 173 | * @return string All of the video's thumbnail URLs
|
---|
| 174 | *
|
---|
| 175 | * Example: "http://img.youtube.com/355VDRRJK8/default.jpg"
|
---|
| 176 | */
|
---|
| 177 | public function getThumbUrls()
|
---|
| 178 | {
|
---|
| 179 | return $this->_thumbUrls;
|
---|
| 180 | }
|
---|
| 181 |
|
---|
| 182 | /**
|
---|
| 183 | * Get the video's title
|
---|
| 184 | *
|
---|
| 185 | * @return string The title of the video
|
---|
| 186 | *
|
---|
| 187 | * Example: "My Awesome Video"
|
---|
| 188 | */
|
---|
| 189 | public function getTitle()
|
---|
| 190 | {
|
---|
| 191 | return $this->_title;
|
---|
| 192 | }
|
---|
| 193 |
|
---|
| 194 | /**
|
---|
| 195 | * Get the video's upload time
|
---|
| 196 | *
|
---|
| 197 | * @return string The timestamp of when this video was uploaded
|
---|
| 198 | *
|
---|
| 199 | * Example: "3hough"
|
---|
| 200 | */
|
---|
| 201 | public function getUploadTime()
|
---|
| 202 | {
|
---|
| 203 | return $this->_uploadTime;
|
---|
| 204 | }
|
---|
| 205 |
|
---|
| 206 | /**
|
---|
| 207 | * Get the video's view count
|
---|
| 208 | *
|
---|
| 209 | * @return string The number of times this video has been viewed
|
---|
| 210 | *
|
---|
| 211 | * Example: "3hough"
|
---|
| 212 | */
|
---|
| 213 | public function getViews()
|
---|
| 214 | {
|
---|
| 215 | return $this->_views;
|
---|
| 216 | }
|
---|
| 217 |
|
---|
| 218 | /**
|
---|
| 219 | * Get the video's URL on YouTube
|
---|
| 220 | *
|
---|
| 221 | * @return string The absolute URL of this video's home on YouTube
|
---|
| 222 | *
|
---|
| 223 | * Example: "http://www.youtube.com/v/355VDRRJK8"
|
---|
| 224 | */
|
---|
| 225 | public function getYouTubeUrl()
|
---|
| 226 | {
|
---|
| 227 | return $this->_youTubeUrl;
|
---|
| 228 | }
|
---|
| 229 |
|
---|
| 230 | /**
|
---|
| 231 | * Set this video's author
|
---|
| 232 | *
|
---|
| 233 | * @param string $author The YouTube author of this video
|
---|
| 234 | *
|
---|
| 235 | * @return void
|
---|
| 236 | */
|
---|
| 237 | public function setAuthor($author)
|
---|
| 238 | {
|
---|
| 239 | $this->_author = $author;
|
---|
| 240 | }
|
---|
| 241 |
|
---|
| 242 | /**
|
---|
| 243 | * Set this video's category
|
---|
| 244 | *
|
---|
| 245 | * @param string $category The YouTube category of this video
|
---|
| 246 | *
|
---|
| 247 | * @return void
|
---|
| 248 | */
|
---|
| 249 | public function setCategory($category)
|
---|
| 250 | {
|
---|
| 251 | $this->_category = $category;
|
---|
| 252 | }
|
---|
| 253 |
|
---|
| 254 | /**
|
---|
| 255 | * Set the description for this video
|
---|
| 256 | *
|
---|
| 257 | * @param string $description The description for this video
|
---|
| 258 | *
|
---|
| 259 | * @return void
|
---|
| 260 | */
|
---|
| 261 | public function setDescription($description)
|
---|
| 262 | {
|
---|
| 263 | $this->_description = $description;
|
---|
| 264 | }
|
---|
| 265 |
|
---|
| 266 | /**
|
---|
| 267 | * Set whether or not this video can be displayed.
|
---|
| 268 | *
|
---|
| 269 | * @param boolean If this video can be displayed
|
---|
| 270 | *
|
---|
| 271 | * @return void
|
---|
| 272 | */
|
---|
| 273 | public function setDisplayable($displayable)
|
---|
| 274 | {
|
---|
| 275 | $this->_displayable = $displayable;
|
---|
| 276 | }
|
---|
| 277 |
|
---|
| 278 | /**
|
---|
| 279 | * Set the YouTube video ID of this video
|
---|
| 280 | *
|
---|
| 281 | * @param string $id The YouTube video ID of this video
|
---|
| 282 | *
|
---|
| 283 | * @return void
|
---|
| 284 | */
|
---|
| 285 | public function setId($id)
|
---|
| 286 | {
|
---|
| 287 | $this->_id = $id;
|
---|
| 288 | }
|
---|
| 289 |
|
---|
| 290 | /**
|
---|
| 291 | * Set the length of this video
|
---|
| 292 | *
|
---|
| 293 | * @param string $length The runtime of this video
|
---|
| 294 | *
|
---|
| 295 | * @return void
|
---|
| 296 | */
|
---|
| 297 | public function setLength($length)
|
---|
| 298 | {
|
---|
| 299 | $this->_length = $length;
|
---|
| 300 | }
|
---|
| 301 |
|
---|
| 302 | /**
|
---|
| 303 | * Set the average rating of this video
|
---|
| 304 | *
|
---|
| 305 | * @param string $rating The average rating of this video
|
---|
| 306 | *
|
---|
| 307 | * @return void
|
---|
| 308 | */
|
---|
| 309 | public function setRating($rating)
|
---|
| 310 | {
|
---|
| 311 | $this->_rating = $rating;
|
---|
| 312 | }
|
---|
| 313 |
|
---|
| 314 | /**
|
---|
| 315 | * Set the number of ratings of this video
|
---|
| 316 | *
|
---|
| 317 | * @param string $ratings The bumber of times this video has been rated
|
---|
| 318 | *
|
---|
| 319 | * @return void
|
---|
| 320 | */
|
---|
| 321 | public function setRatings($ratings)
|
---|
| 322 | {
|
---|
| 323 | $this->_ratings = $ratings;
|
---|
| 324 | }
|
---|
| 325 |
|
---|
| 326 | /**
|
---|
| 327 | * Set the tags of this video
|
---|
| 328 | *
|
---|
| 329 | * @param array $tags The tags of this video
|
---|
| 330 | *
|
---|
| 331 | * @return void
|
---|
| 332 | */
|
---|
| 333 | public function setTags($tags)
|
---|
| 334 | {
|
---|
| 335 | $this->_tags = $tags;
|
---|
| 336 | }
|
---|
| 337 |
|
---|
| 338 | /**
|
---|
| 339 | * Set the thumbnail URLs of this video
|
---|
| 340 | *
|
---|
| 341 | * @param array $thumbUrls The thumbnail URLs of this video
|
---|
| 342 | *
|
---|
| 343 | * @return void
|
---|
| 344 | */
|
---|
| 345 | public function setThumbUrls($thumbUrls)
|
---|
| 346 | {
|
---|
| 347 | $this->_thumbUrls = $thumbUrls;
|
---|
| 348 | }
|
---|
| 349 |
|
---|
| 350 | /**
|
---|
| 351 | * Set the title of this video
|
---|
| 352 | *
|
---|
| 353 | * @param string $title The title of this video
|
---|
| 354 | *
|
---|
| 355 | * @return void
|
---|
| 356 | */
|
---|
| 357 | public function setTitle($title)
|
---|
| 358 | {
|
---|
| 359 | $this->_title = $title;
|
---|
| 360 | }
|
---|
| 361 |
|
---|
| 362 | /**
|
---|
| 363 | * Set the upload time of this video
|
---|
| 364 | *
|
---|
| 365 | * @param string $uploadTime The upload time of this video
|
---|
| 366 | *
|
---|
| 367 | * @return void
|
---|
| 368 | */
|
---|
| 369 | public function setUploadTime($uploadTime)
|
---|
| 370 | {
|
---|
| 371 | $this->_uploadTime = $uploadTime;
|
---|
| 372 | }
|
---|
| 373 |
|
---|
| 374 | /**
|
---|
| 375 | * Set the number of views of this video
|
---|
| 376 | *
|
---|
| 377 | * @param string $views The number of views for this video
|
---|
| 378 | *
|
---|
| 379 | * @return void
|
---|
| 380 | */
|
---|
| 381 | public function setViews($views)
|
---|
| 382 | {
|
---|
| 383 | $this->_views = $views;
|
---|
| 384 | }
|
---|
| 385 |
|
---|
| 386 | /**
|
---|
| 387 | * Set the YouTube URL of this video
|
---|
| 388 | *
|
---|
| 389 | * @param string $youTubeUrl The YouTube URL of this video
|
---|
| 390 | *
|
---|
| 391 | * @return void
|
---|
| 392 | */
|
---|
| 393 | public function setYouTubeUrl($youTubeUrl)
|
---|
| 394 | {
|
---|
| 395 | $this->_youTubeUrl = $youTubeUrl;
|
---|
| 396 | }
|
---|
| 397 | }
|
---|