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

2 Library and Sections

Jose Erick Carreon edited this page Apr 25, 2019 · 2 revisions

How access to Library and Sections?

Access to Library

The function 'getLibrary' gives us access movies or shows recently added or that are on deck of plex.

// First get library instantiate.
$library = $plex->getServer('my_server')->getLibrary();

$library->getOnDeckItems(); // Get movies or shows that is on deck
$library->getRecentlyAddedItems(); // Get movies or shows recently added

Access to Section

Before continuing, you need to know that the sections are those that is in the panel de plex website, for example:

Sections

Having said that, we have 3 functions for the sections:

// Get section of your library.
$sections = $library->getSections(); // Get all Sections.
foreach ($sections as $section){
	echo $sections->getTitle();
}
$library->getSection(1); // Get section by index.
$library->getSection('TV Shows'); // Get section by name.

Access to Section information.

The sections have multiples data like genres, directors, actors and collections.

// Get a section instantiate
$section = $plex->getServer('my_server')->getLibrary()->getSection('Movies');

// Get section tags.
$genres = $section->getGenres(); // Get all genres of the section.
foreach ($genres as $genre){
	echo $genre->title;
}
$section->getDirectors(); // Get all directors of the section.
$section->getActors(); // Get all actors of the section.
$section->getCollections(); // Get all collections of the section.
$section->getAlphabet(); // Get a list of the first character of each title of the section

Note: The collections let you gather related movies, For example, you might add all the James Bond movies together in a “Bond” collection, more information here

Clone this wiki locally