Get Recently Added TV Shows
This API command is used to get all recently added TV show episodes to a library.
URL
GET http://{ip_address}:32400/library/sections/{id}/recentlyAdded?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 TV show library. This key can be found by calling the Libraries API command and using the value of the key attribute associated with the TV show library. |
Return Status
HTTP Code | Description |
---|---|
200 | Success - The request was successful. |
401 | Unauthorized - The Plex token provided was not valid. |
404 | Not Found - The URL path is incorrect. See Remarks below. |
Response
XML string value that lists the all the recently added TV shows in the library. An example of the XML returned from the request is shown below:
<?xml version="1.0" encoding="UTF-8"?> <MediaContainer size="99" allowSync="1" art="/:/resources/show-fanart.jpg" identifier="com.plexapp.plugins.library" librarySectionID="4" librarySectionTitle="TV Shows" librarySectionUUID="3bbbe6f7-628f-4983-ae5d-7c05779c4c28" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1710434120" mixedParents="1" nocache="1" sortAsc="1" thumb="/:/resources/show.png" title1="TV Shows" title2="Recently Added" viewGroup="episode" viewMode="131133"> <Video ratingKey="284997" key="/library/metadata/284997" skipParent="1" parentRatingKey="284996" grandparentRatingKey="284995" guid="plex://episode/5ee7425070a20200424dcd66" parentGuid="plex://season/602e7afac96042002d09cdaa" grandparentGuid="plex://show/5ee7425070a20200424dcd49" grandparentSlug="men-in-kilts-a-roadtrip-with-sam-and-graham" type="episode" title="Food and Drink" grandparentKey="/library/metadata/284995" parentKey="/library/metadata/284996" grandparentTitle="Men in Kilts: A Roadtrip with Sam and Graham" parentTitle="Season 1" contentRating="TV-PG" summary="Scotland's cuisine and whisky are renown throughout the world, for different reasons. In this episode, Sam and Graham explore the world's finest whisky and dishes like Haggis." index="1" parentIndex="1" viewCount="1" lastViewedAt="1660701675" thumb="/library/metadata/284997/thumb/1660697962" art="/library/metadata/284995/art/1710311992" parentThumb="/library/metadata/284996/thumb/1660697962" grandparentThumb="/library/metadata/284995/thumb/1710311992" grandparentArt="/library/metadata/284995/art/1710311992" duration="1745792" originallyAvailableAt="2021-02-14" addedAt="1660697959" updatedAt="1660697962"> <Media id="347530" duration="1745792" bitrate="9847" width="1920" height="1080" aspectRatio="1.78" audioChannels="6" audioCodec="eac3" videoCodec="h264" videoResolution="1080" container="mkv" videoFrameRate="24p" videoProfile="high"> <Part id="347884" key="/library/parts/347884/1660602452/file.mkv" duration="1745792" file="M:\Media\TV Shows\Men in Kilts - A Roadtrip with Sam and Graham\Season 1\Men.in.Kilts.A.Roadtrip.with.Sam.and.Graham.S01E01.Food.and.Drink.1080p.AMZN.WEB-DL.DDP.5.1.H.264-FLUX[eztv.re].mkv" size="2149536961" container="mkv" videoProfile="high" /> </Media> </Video> ... </MediaContainer>
The XML returned provides a list of the all TV shows in a library have been recently added to the Plex server. The root is the MediaContainer
element. This element contains a few attributes that provide overall information about the TV shows on the server.
Attribute | Description |
---|---|
size | The number of episodes. |
allowSync | 1 - allow syncing content. 0 - don't allow syncing content. |
art | Background artwork used to represent the episode. |
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. |
mixedParents | Media items returned contain multiple parents. |
nocache | 1 - cache the library. 0 - do not cache the library. |
sortAsc | 1 - the library is sorted in ascending order. 0 - the library is sorted in descending order. |
thumb | The thumbnail for the episode. |
title1 | The title of the episode. Note: This appears to be internally created, and can't be changed by the server owner. |
title2 | A descriptive title for the episode. |
viewGroup | The group type used to view the episode. |
viewMode | Unknown integer value. |
Within the MediaContainer
there are one or more Video
child elements. Each Video
element represents one TV show available on the Plex server.
Attribute | Description |
---|---|
ratingKey | A key associated with the episode. |
key | The relative URL of the episode information. |
skipParent | Flag indicate how to display the seasons. 0 - show the season. 1 - hide for single-season series. 2 - hide all seasons. |
parentRatingKey | The relative URL of the information for the season. |
grandparentRatingKey | The relative URL of the information for the TV show. |
guid | The unique identifier comprised of the Plex agent and episode identifier for the agent. |
parentGuid | The GUID for the season. |
grandparentGuid | The GUID for the TV show. |
grandparentSlug | The short path name for the TV show. |
type | The type of media. |
title | The title of the episode. |
grandparentKey | The unique identifier for the TV show. |
parentKey | The unique identifier for the season. |
grandparentTitle | The title of the TV show. |
parentTitle | The title of the season. |
contentRating | The content rating associated with the episode. |
summary | A summary of the episode. |
index | The index of the episode. |
parentIndex | The index of the season. |
viewCount | The number of times the episode has been viewed. |
lastViewedAt | The date and time for the last time the episode was viewed. |
thumb | The thumbnail for the episode. |
art | The background artwork used to represent the episode. |
parentThumb | The thumbnail for the season. |
grandparentThumb | The thumbnail for the TV show. |
grandparentArt | The background artwork used to represent the TV show. |
duration | The length of the episode in milliseconds. |
originallyAvailableAt | The original release date of the episode. |
addedAt | The date and time, in Unix time, the episode was added to the library. |
updatedAt | The date and time in epoch time, the episode was updated in the library. |
Within the Video
there are one or more Media
child elements. Each Media
element represents one media file of the episode available on the Plex server.
If there are two media files associated with the episode, 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 episode. |
duration | The length of the episode in milliseconds. |
bitrate | The bitrate of the episode. |
width | The width of the episode. |
height | The height of the episode. |
aspectRatio | The aspect ratio of the episode. |
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 episode container. |
videoFrameRate | The framerate standard used for the video. |
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 TV show episode.
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. |
container | The type of media container. |
videoProfile | The video profile associated with the video part. |
Remarks
When using the command ensure that the 'A' in 'recentlyAdded' is in uppercase. A lowercase 'A' will return a 404 status code.
Examples
curl -X GET http://{ip_address}:32400/library/sections/{id}/recentlyAdded?X-Plex-Token={plex_token}
import requests plex_url = http://{ip_address}:32400/library/sections/{id}/recentlyAdded?X-Plex-Token={plex_token} response = requests.get(plex_url) print(response.text)
$response = Invoke-RestMethod 'http://{ip_address}:32400/library/sections/{id}/recentlyAdded?X-Plex-Token={plex_token}' -Method 'GET' Write-Output $response