Jump to content

Recommended Posts

Posted

have you tried the swagger docs? you can get to them from the dashboard in the links section. that links section also has a github link with api documentation as well

TinkeringTot
Posted

I am familiar with java and javascript.

 

However, I'm not familiar enough to know what/how to use an API.

 

I code in Notepad++ or Eclipse.  Is it possible to view/use the API in these?

TinkeringTot
Posted

have you tried the swagger docs? you can get to them from the dashboard in the links section. that links section also has a github link with api documentation as well

 

Thanks! That is exactly what I was looking for.

 

The swagger part. I still have no idea what to do with the API documentation.

Posted

Hi, welcome.

 

What are you trying to do?

TinkeringTot
Posted (edited)

I want to be able to access the data.  Currently I'm trying to improve on the text list of each collection that MonGooseMan made.

 

I want to see a list of the available calls so I can add the year to each name, and have a while statement for each collection that will list those out.

Edited by TinkeringTot
Cheesegeezer
Posted

Thanks! That is helpful.  I've managed to do a few things of little importance.  Is there a sub forum with a group of people that wouldn't mind helping me through an issue or two as I learn?  The issue may not be related to the API.

I would just use this thread, unfortunately i'm no good with JS so cant help.

TinkeringTot
Posted

Thanks! That is helpful.  I've managed to do a few things of little importance.  Is there a sub forum with a group of people that wouldn't mind helping me through an issue or two as I learn?  The issue may not be related to the API.

TinkeringTot
Posted

Alright, I am working with a script Mongoose made that I linked to above.

I've added years, ratings, and code to run through boxsets.

 

Though my boxsets all end up at the very end of the div.  I'm not sure why. Can anyone offer some assistance?

https://drive.google.com/file/d/0BybYJG8wuuLnVWJ0dnFfOHBfeVk/edit?usp=sharing 

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<div id="server">
<p>Enter the details of your server</p>
IP Address (eg 192.168.1.100)<input type="text" id="serverField" value="192.168.1.100"/><br/>
Port (normally 8096)<input type="text" id="serverPort" value="8096"/><br/>
<p>
<input type="button" id="serverButton" value="Go"/>
</div>
<div id="userChoice" style="display:none">
Choose a user:
</div>
<div id="collectionChoice" style="display:none">
Choose a collection:
</div>
<div id="collectionView" style="display:none">
</div>
<script>
var serverIP;
var userId;
var collectionId;
var serverPort;
var collectionName;


$("#serverButton").click(function(){
	serverIP = $("#serverField").val();
	serverPort = $("#serverPort").val();
	$.getJSON('http://'+serverIP+':'+serverPort+'/mediabrowser/Users', function(data){
  		for(var j=0;j<data.length;j++)
			$("#userChoice").append("<br/><a href='#' onClick='userSelected(\""+data[j].Id+"\")'>"+data[j].Name+"</a>");
		$("#server").hide();
		$("#userChoice").show();
  });
});

function userSelected(thisUserId)
{
	userId=thisUserId;
	$.getJSON('http://'+serverIP+':'+serverPort+'/mediabrowser/Users/'+userId+'/Items?sortBy=SortName', function(data){
  		for(var j=0;j<data.Items.length;j++)
			$("#collectionChoice").append("<br/><a href='#' onClick='collectionSelected(\""+data.Items[j].Id+"\",\""+data.Items[j].Name+"\")'>"+data.Items[j].Name+"</a>");

		$("#userChoice").hide();
		$("#collectionChoice").show();
  });
}

function collectionSelected(thisCollectionId,thisCollectionName)
{
	collectionId=thisCollectionId;
	//collectionId="ca943aab9c4ec8c8b08d4f8bac4b4fa0";
	collectionName=thisCollectionName
	var premiereYear;
	var premiereDate;
	$("#collectionView").append("<br/><b>"+collectionName+"</b><br/>");
	//$("#collectionView").append('<br/>http://'+serverIP+':'+serverPort+'/mediabrowser/Users/'+userId+'/Items?sortBy=SortName&SortOrder=Ascending&Fields=DateCreated&StartIndex=0&Limit=2000&ParentId='+collectionId+'&Filters=&NameStartsWithOrGreater=');
	$.getJSON('http://'+serverIP+':'+serverPort+'/mediabrowser/Users/'+userId+'/Items?sortBy=SortName&SortOrder=Ascending&Fields=DateCreated&StartIndex=0&Limit=2000&ParentId='+collectionId+'&Filters=&NameStartsWithOrGreater=', function(data){
		for(var j=0;j<data.Items.length;j++){
			premiereDate=""+data.Items[j].PremiereDate;
			if(premiereDate == "undefined"){
				premiereYear="";
			} else {
				premiereYear="("+premiereDate.substr(0,4)+") ";
			}
			if (data.Items[j].Type == "BoxSet"){
				//$("#collectionView").append("<br/>"+data.Items[j].Name+" "+premiereYear+" ("+data.Items[j].Type+") " +data.Items[j].Id);
				collectionSelected(data.Items[j].Id,data.Items[j].Name);
			} else {
				$("#collectionView").append("<br/>"+data.Items[j].Name+" ("+data.Items[j].OfficialRating+") "+premiereYear);
			}
			
		}
		$("#collectionChoice").hide();
		$("#collectionView").show();

	});
}
</script>
</body>
</html>

MongooseMan
Posted

At a guess (given 5 minutes of looking at the code) I'd say its because getJson is an async call, which JavaScript doesn't wait for.

So, it'll finish appending all the non-boxset items before it gets the response from the getJson call and therefore appends those afterwards.

Make sense?

TinkeringTot
Posted

That makes sense.  I've never worked with Json before.  Looks like I've got some learning to do.  :) Thanks Mongoose!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...