HTTP API?

Want to get started, don't know where to start!
I want to create a quick tool to tell me the total running length of all the videos I have combined using the Plex HTTP API, however I am unable to find and docs or information.

I love to just dive straight in, however I don't even know where to start! What does that API look like and how do I access it?

Starting point:

http://127.0.0.1:32400/

The IP Adr might have to be edited in case you are not “sitting” at your PMS machine.

From there you basically can climb the tree…

Fantastic. Thanks! I’ve noticed that only a few of my media items have a duration attribute. Why would that be?


I checked my library,

http://10.0.1.2:32400/library/sections/2/all

which is my movie section, and all the ones I checked (first 30 movies) had the duration attribute. Can you find a common denominator between the ones missing the duration? For example are the split files? Or are they in a special format?

If you use my ruby library you can do this in a few lines



require 'plex-ruby'<br />
<br />
server = Plex::Server.new(HOST, PORT) # Replace with whatever your host and port are. i.e ('127.0.0.1', 32400)<br />
<br />
total_duration = server.library.sections.inject(0) do |sum, section|<br />
   sum + section.all.inject(0) { |sum, video| sum + video.duration.to_i }<br />
end<br />
<br />
puts total_duration / 1000 / 60 #convert from milisecs to minutes 



/shameless plug


Ok so all my movies have the duration attribute, however TV Shows are a bit of a hit and miss. For example, I'm looking at all the episodes for 30 Rock. Here's just the first two episodes ([full output](http://slexy.org/view/s2zmPdN9dJ)):


http://localhost:32400/library/metadata/4256/allLeaves




<br />
<Video ratingKey="4258" key="/library/metadata/4258" studio="NBC" type="episode" title="Pilot" grandparentTitle="30 Rock" contentRating="TV-PG" summary="Liz Lemon is the head writer on a demanding, live TV program in New York City. However, things begin to get complicated when her new boss insists that a wild and unpredictable movie star joins the cast." index="1" parentIndex="1" rating="7.2" viewCount="1" thumb="/library/metadata/4258/thumb?t=1317311527" parentThumb="/library/metadata/4257/thumb?t=1317311526" duration="1281000" originallyAvailableAt="2006-10-11" addedAt="1317310859" updatedAt="1317311527"><br />
	<Media id="4164" duration="1281000" bitrate="1119" width="624" height="352" aspectRatio="1.78" audioChannels="2" audioCodec="mp3" videoCodec="mpeg4" videoResolution="sd" container="avi" videoFrameRate="24p" optimizedForStreaming="0"><br />
		<Part key="/library/parts/4193/file.avi" duration="1281000" file="/Volumes/The Second/Media/TV Shows/30 Rock/Season 1/30.Rock.S01E01.Pilot.avi" size="183558144"/><br />
	</Media><br />
	<br />
	<Writer tag="Tina Fey"/><br />
	<Director tag="Adam Bernstein"/><br />
</Video><br />




Of the 98 entries in total, only 46 have an actual duration element. It's a very similar story for a lot of other shows (Archer, Summer Heights High, That 70's Show, True Blood). For what it's worth, there are some shows that do have a duration, such as Ashes to Ashes, Man vs Wild, Terra Nova. There are many others that are both missing, and have the duration. There seems to be no pattern between them all.

Hmm, weird. Is it possible that the episodes which have the duration attributes are shows that were scanned in using a different version of PMS? Or the other way around of course.
What I'm trying to understand is if maybe we had a buggy version of PMS which weren'nt able to get that attribute back then, but now it is. Or the other way around.


Sure. Ill try doing a hard refresh of my library and see what happens. Ill update this post when that has finished,

**Edit:** Just did two refreshes by holding down shift whist clicking refresh in the media manager, a long with a 'Refresh Metadata' for a single show (30 Rock) and nothing has changed! Still only the duration attr for roughly half the entries.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.