Get All Movies for a Decade
This API command will return all movies from a Plex server that were released in the 10 years following the year specified in the command.
URL
GET http://{ip_address}:32400/library/sections/{id}/decade/{decade}?X-Plex-Token={plex_token}
Parameters
Name | Description |
---|---|
ip_address | The IP address of the Plex Media server. |
plex_token | The Plex token. |
id | The key associated with a movies/video library. This key can be found by calling the Libraries API command and looking for a movies library. |
decade | The decade for the movies. See the Decade remarks for more information on specifying the decade parameter. |
Return Status
HTTP Code | Description |
---|---|
200 | Success - The request was successful. |
401 | Unauthorized - The Plex token provided was not valid. |
Response
XML string value that lists the all the movies in the library. An example of the XML returned from the request is shown below:
<?xml version="1.0" encoding="UTF-8"?> <MediaContainer size="72" allowSync="1" art="/:/resources/movie-fanart.jpg" identifier="com.plexapp.plugins.library" librarySectionID="2" librarySectionTitle="Movies" librarySectionUUID="493a64e7-b541-4667-b050-d702beebf2f6" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1713459976" sortAsc="1" thumb="/:/resources/movie.png" title1="Movies" title2="2004" viewGroup="movie" viewMode="131624"> <Video ratingKey="1416" key="/library/metadata/1416" guid="plex://movie/5d776d057a53e9001e74ed5d" slug="avatar" studio="Dune Entertainment" type="movie" title="Avatar" titleSort="Avatar 01" contentRating="PG-13" summary="A paraplegic Marine dispatched to the moon Pandora on a unique mission becomes torn between following his orders and protecting the world he feels is his home." rating="8.2" audienceRating="8.2" viewCount="4" skipCount="1" lastViewedAt="1678244163" year="2009" tagline="Enter the world of Pandora." thumb="/library/metadata/1416/thumb/1713849980" art="/library/metadata/1416/art/1713849980" duration="9701779" originallyAvailableAt="2009-12-16" addedAt="1421027988" updatedAt="1713849980" audienceRatingImage="rottentomatoes://image.rating.upright" chapterSource="media" primaryExtraKey="/library/metadata/282482" ratingImage="rottentomatoes://image.rating.ripe"> <Media id="71855" duration="9701779" bitrate="15378" width="1916" height="1078" aspectRatio="1.78" audioChannels="6" audioCodec="dca" videoCodec="h264" videoResolution="1080" container="mkv" videoFrameRate="24p" audioProfile="dts" videoProfile="high"> <Part id="71980" key="/library/parts/71980/1449134841/file.mkv" duration="9701779" file="M:\Media\Movies\Avatar (2009)\Avatar (2009) [1080p h.264][AAC DTS DTS-HD].mkv" size="18649138726" audioProfile="dts" container="mkv" videoProfile="high" /> </Media> <Genre tag="Action" /> <Genre tag="Adventure" /> <Country tag="United States of America" /> <Country tag="United Kingdom" /> <Director tag="James Cameron" /> <Writer tag="James Cameron" /> <Role tag="Sam Worthington" /> <Role tag="Zoe Saldaña" /> <Role tag="Sigourney Weaver" /> </Video> <Video ratingKey="65437" key="/library/metadata/65437" guid="plex://movie/5d7768a247dd6e001f6bca0e" slug="brave-2012" studio="Walt Disney Pictures" type="movie" title="Brave" contentRating="PG" summary="Determined to make her own path in life, Princess Merida defies a custom that brings chaos to her kingdom. Granted one wish, Merida must rely on her bravery and her archery skills to undo a beastly curse." rating="7.9" audienceRating="7.5" viewCount="1" lastViewedAt="1672709165" year="2012" tagline="Change your fate." thumb="/library/metadata/65437/thumb/1713850034" art="/library/metadata/65437/art/1713850034" duration="5617386" originallyAvailableAt="2012-06-19" addedAt="1450147194" updatedAt="1713850034" audienceRatingImage="rottentomatoes://image.rating.upright" chapterSource="mixed" primaryExtraKey="/library/metadata/282763" ratingImage="rottentomatoes://image.rating.ripe"> <Media id="73442" duration="5617386" bitrate="4292" width="1920" height="802" aspectRatio="2.35" audioChannels="6" audioCodec="ac3" videoCodec="h264" videoResolution="1080" container="mkv" videoFrameRate="24p" videoProfile="high" title="Original"> <Part id="73572" key="/library/parts/73572/1450145901/file.mkv" duration="5617386" file="M:\Media\Movies\Brave (2012)\Brave (2012) [1080p h.264][AAC AC3].mkv" size="3014010908" container="mkv" videoProfile="high" /> </Media> <Media id="182077" duration="5617368" bitrate="1776" width="1276" height="532" aspectRatio="2.35" audioChannels="2" audioCodec="aac" videoCodec="h264" videoResolution="720" container="mp4" videoFrameRate="24p" optimizedForStreaming="1" proxyType="42" audioProfile="lc" has64bitOffsets="0" target="Optimized for Mobile" targetTagID="6207" videoProfile="high" title="Optimized for Mobile"> <Part id="182398" key="/library/parts/182398/1466183291/file.mp4" duration="5617368" file="M:\Media\Movies\Brave (2012)\Plex Versions\Optimized for Mobile\Brave (2012).mp4" size="1247272053" audioProfile="lc" container="mp4" has64bitOffsets="0" optimizedForStreaming="1" videoProfile="high" /> </Media> <Genre tag="Adventure" /> <Genre tag="Action" /> <Country tag="United States of America" /> <Director tag="Brenda Chapman" /> <Director tag="Mark Andrews" /> <Writer tag="Louis Gonzales" /> <Writer tag="Irene Mecchi" /> <Role tag="Kelly Macdonald" /> <Role tag="Emma Thompson" /> <Role tag="Billy Connolly" /> </Video> ... </MediaContainer>
The XML returned provides a list of the all movies in a library for the specified decade that are available on the Plex server. The root is the MediaContainer
element. This element contains a few attributes that provide overall information about the movies on the server.
Attribute | Description |
---|---|
size | The number of libraries. |
allowSync | 1 - allow syncing content. 0 - don't allow syncing content. |
art | Background artwork used to represent the library. |
identifier | The type of item. |
librarySectionID | The unique key associated with the library. |
librarySectionTitle | The title of the library. |
librarySectionUUID | Unique GUID identifier for the library. |
mediaTagPrefix | Prefix for the media tag. |
mediaTagVersion | Media tag version. Note: This could be a date and time value. |
sortAsc | 1 - the library is sorted in ascending order. 0 - the library is sorted in descending order. |
thumb | The thumbnail for the library. |
title1 | The title of the library. Note: This appears to be internally created, and can't be changed by the server owner. |
title2 | A descriptive title for the library. |
viewGroup | The group type used to view the library. |
viewMode | Unknown integer value. |
Within the MediaContainer
there are one or more Video
child elements. Each Video
element represents one movie available on the Plex server.
Attribute | Description |
---|---|
ratingKey | A key associated with the item. |
key | The relative URL of the item information. |
guid | The unique identifier comprised of the Plex agent and item identifier for the agent. |
studio | The name of the item studio. |
type | The type of media. |
title | The title of the item. |
titleSort | The title of the item used to sort the items in a collection or list. |
contentRating | The content rating associated with the item. |
summary | A summary of the item. |
rating | The rating for the item. |
audienceRating | The audience rating for the item. |
skipCount | The skip count. |
lastViewedAt | The date and time for the last time the item was viewed. |
year | The year the item was released. |
tagline | The tagline associated with the item. |
thumb | The thumbnail for the item. |
art | The background artwork used to represent the item. |
duration | The length of the item in milliseconds. |
originallyAvailableAt | The original release date of the item. |
addedAt | The date and time, in Unix time, the item was added to the library. |
updatedAt | The date and time in epoch time, the item was updated in the library. |
audienceRatingImage | The image associated with the audience rating. |
chapterSource | The chapter source type. |
primaryExtraKey | The extra key value. |
ratingImage | The image associated with the rating. |
Within the Video
there are one or more Media
child elements. Each Media
element represents one media file of the movie available on the Plex server.
If there are two media files associated with the movie, such as a 1080p and 480p version, then there would be two Media
child elements in the Video
element.
Attribute | Description |
---|---|
id | Unique ID associated with the item. |
duration | The length of the item in milliseconds. |
bitrate | The bitrate of the item. |
width | The width of the item. |
height | The height of the item. |
aspectRatio | The aspect ratio of the item. |
audioChannels | The number of audio channels. |
audioCodec | The audio codec used to encode the audio. |
videoCodec | The video codec used to encode the video. |
videoResolution | The video resolution. |
container | The item container. |
videoFrameRate | The framerate standard used for the video. |
audioProfile | The audio profile of the media. |
videoProfile | The video profile of the media. |
Within the Media
there are one or more Part
child elements. Each Part
element represents one part of the movie. If the movie has been added to the Plex server as a multi-part movie, then each of those parts will be represented by one Part
child element.
Attribute | Description |
---|---|
id | Unique ID associated with the part. |
key | The unique relative path for the part that is used at its key. |
duration | The length of the part in milliseconds. |
file | The file associated with the part. |
size | The file size of the part. |
audioProfile | The audio profile associated with the audio part. |
container | The type of media container. |
videoProfile | The video profile associated with the video part. |
Also within the Video
element there are multiple additional child elements that provide more details about the movie. These child elements include Genre
, Director
, Writer
, Country
, Collection
, and Role
.
Within each of these child elements is a single tag
attribute that provides the information for the element. There could be multiple of the same child element within the Video
, such as multiple directors or writers.
Attribute | Description |
---|---|
tag | A genre of the movie. |
Attribute | Description |
---|---|
tag | A director of the movie. |
Attribute | Description |
---|---|
tag | A writer for the movie |
Attribute | Description |
---|---|
tag | A country of origin for the movie. |
Attribute | Description |
---|---|
tag | The name of a collection containing the movie. |
Attribute | Description |
---|---|
tag | The name of a person with a role in the movie. |
Remarks
Decade parameter
The decade parameter that is passed into the command doesn't need to be a actual decade. For example, the value doesn't need to be 1990, 2000, or 2010. The value can be any year.
The command will find all movies that were released in the 10 years from the decade value that is provided. For example, if 2004 was specified in the command, then all movies from 2004 to 2013 will be returned.
If no decade is specified, then the command will return a listing of all valid directories along with their keys. The decade key can be used to return movies release in that decade.
Examples
curl -X GET http://{ip_address}:32400/library/sections/{id}/decade/{decade}?X-Plex-Token={plex_token}
import requests plex_url = http://{ip_address}:32400/library/sections/{id}/decade/{decade}?X-Plex-Token={plex_token} response = requests.get(plex_url) print(response.text)
$response = Invoke-RestMethod 'http://{ip_address}:32400/library/sections/{id}/decade/{decade}?X-Plex-Token={plex_token}' -Method 'GET' Write-Output $response