Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Commit

Permalink
Added in media info and file info.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbart committed Jun 13, 2013
1 parent 6f041e4 commit b26e55e
Show file tree
Hide file tree
Showing 7 changed files with 1,086 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Plex.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
require_once(sprintf('%s/Server/Library/Section/Show.php', $phpPlexDir));
require_once(sprintf('%s/Server/Library/Section/Artist.php', $phpPlexDir));
require_once(sprintf('%s/Server/Library/Section/Photo.php', $phpPlexDir));
require_once(sprintf('%s/Server/Library/Item/Media/File/FileInterface.php', $phpPlexDir));
require_once(sprintf('%s/Server/Library/Item/Media/File/File.php', $phpPlexDir));
require_once(sprintf('%s/Server/Library/Item/Media/MediaInterface.php', $phpPlexDir));
require_once(sprintf('%s/Server/Library/Item/Media/Media.php', $phpPlexDir));
require_once(sprintf('%s/Server/Library/ItemInterface.php', $phpPlexDir));
require_once(sprintf('%s/Server/Library/ItemAbstract.php', $phpPlexDir));
require_once(sprintf('%s/Server/Library/ItemGrandparentAbstract.php', $phpPlexDir));
Expand Down Expand Up @@ -72,7 +76,7 @@
* @author <[email protected]> Nick Bartkowiak
* @copyright (c) 2013 Nick Bartkowiak
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3)
* @version 0.0.2
* @version 0.0.2.5
*/
class Plex
{
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,23 @@ Artists, albums, and tracks
$trackByKey = $albumByExactTitleMatch->getTrack('/library/metadata/57726');
$trackByExactTitleMatch = $albumByExactTitleMatch->getTrack('Rewind');

Item Media Info

$showSection = $library->getSection('TV Shows');
$episode = $showSection->getShow("The Simpsons")
->getSeason(4)
->getEpisode(12);

// Media Info
$media = $episode->getMedia();
$duration = $media->getDuration();
$bitrate = $media->getBitrate();

// File
$file = $media->getFile();
$path = $file->getFile();
$size = $file->getSize();

Playback Controller

$playback = $client->getPlaybackController();
Expand Down
269 changes: 269 additions & 0 deletions Server/Library/Item/Media/File/File.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
<?php

/**
* Plex Library Item Media File
*
* @category php-plex
* @package Plex_Server_Library_Item
* @subpackage Plex_Server_Library_Item_Media
* @author <[email protected]> Nick Bartkowiak
* @copyright (c) 2013 Nick Bartkowiak
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3)
* @version 0.0.2.5
*
* This file is part of php-plex.
*
* php-plex is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* php-plex is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

/**
* Class that represents a file associated with a media item.
*
* @category php-plex
* @package Plex_Server_Library_Item
* @subpackage Plex_Server_Library_Item_Media
* @author <[email protected]> Nick Bartkowiak
* @copyright (c) 2013 Nick Bartkowiak
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public Licence (GPLv3)
* @version 0.0.2.5
*/
class Plex_Server_Library_Item_Media_File
implements Plex_Server_Library_Item_Media_FileInterface
{
/**
* The ID of the file.
* @var integer
*/
private $id;

/**
* The key of the file.
* @var string
*/
private $key;

/**
* The duration of the file in milliseconds.
* @var integer
*/
private $duration;

/**
* Full path to the file.
* @var string
*/
private $file;

/**
* Size of the file in bytes.
* @var integer
*/
private $size;

/**
* Container of the file.
* @var string
*/
private $container;

/**
* Sets an array of file info to their corresponding class members.
*
* @param array $rawFile An array of the raw file info returned from the
* Plex HTTP API.
*
* @uses Plex_Server_Library_Item_Media_File::setId()
* @uses Plex_Server_Library_Item_Media_File::setKey()
* @uses Plex_Server_Library_Item_Media_File::setDuration()
* @uses Plex_Server_Library_Item_Media_File::setFile()
* @uses Plex_Server_Library_Item_Media_File::setSize()
* @uses Plex_Server_Library_Item_Media_File::setContainer()
*
* @return void
*/
public function __construct($rawFile)
{
if (isset($rawFile['id'])) {
$this->setId($rawFile['id']);
}
if (isset($rawFile['key'])) {
$this->setKey($rawFile['key']);
}
if (isset($rawFile['duration'])) {
$this->setDuration($rawFile['duration']);
}
if (isset($rawFile['file'])) {
$this->setFile($rawFile['file']);
}
if (isset($rawFile['size'])) {
$this->setSize($rawFile['size']);
}
if (isset($rawFile['container'])) {
$this->setContainer($rawFile['container']);
}
}

/**
* Returns the ID of the file.
*
* @uses Plex_Server_Library_Item_Media_File::$id
*
* @return integer The ID of the file.
*/
public function getId()
{
return $this->id;
}

/**
* Sets the ID of the file.
*
* @uses Plex_Server_Library_Item_Media_File::$id
*
* @param integer $id The ID of the file.
*
* @return void
*/
public function setId($id)
{
$this->id = $id;
}

/**
* Returns the key of the file.
*
* @uses Plex_Server_Library_Item_Media_File::$key
*
* @return string The key of the file.
*/
public function getKey()
{
return $this->key;
}

/**
* Sets the key of the file.
*
* @uses Plex_Server_Library_Item_Media_File::$key
*
* @param string $key The key of the file.
*
* @return void
*/
public function setKey($key)
{
$this->key = $key;
}

/**
* Returns the duration of the file.
*
* @uses Plex_Server_Library_Item_Media_File::$duration
*
* @return integer The duration of the file.
*/
public function getDuration()
{
return $this->duration;
}

/**
* Sets the duration of the file.
*
* @uses Plex_Server_Library_Item_Media_File::$duration
*
* @param integer $duration The duration of the file.
*
* @return void
*/
public function setDuration($duration)
{
$this->duration = $duration;
}

/**
* Returns the path of the file.
*
* @uses Plex_Server_Library_Item_Media_File::$file
*
* @return string The path of the file.
*/
public function getFile()
{
return $this->file;
}

/**
* Sets the path of the file.
*
* @uses Plex_Server_Library_Item_Media_File::$file
*
* @param string $file The path of the file.
*
* @return void
*/
public function setFile($file)
{
$this->file = $file;
}

/**
* Returns the size of the file.
*
* @uses Plex_Server_Library_Item_Media_File::$size
*
* @return integer The size of the file.
*/
public function getSize()
{
return $this->size;
}

/**
* Sets the size of the file.
*
* @uses Plex_Server_Library_Item_Media_File::$size
*
* @param integer $size The size of the file.
*
* @retur void
*/
public function setSize($size)
{
$this->size = $size;
}

/**
* Returns the container of the file.
*
* @uses Plex_Server_Library_Item_Media_File::$container
*
* @return string The container of the file.
*/
public function getContainer()
{
return $this->container;
}

/**
* Sets the container of the file.
*
* @uses Plex_Server_Library_Item_Media_File::$container
*
* @param string $container The container of the file.
*
* @return void
*/
public function setContainer($container)
{
$this->container = $container;
}
}
Loading

0 comments on commit b26e55e

Please sign in to comment.