boutzo 0 Posted February 22, 2015 Share Posted February 22, 2015 What is the proper way to get the results of an episode query? This is my query getEpisodeID(string seriesID, int? seasonNum, int episodeNum) EpisodeQuery iq = new EpisodeQuery { UserId = this._uid, SeasonNumber = seasonNum, SeriesId = seriesID, }; ItemsResult items = null; this._client.GetEpisodesAsync(iq); foreach (BaseItemDto dto in items.Items) { int? indexNumber = dto.IndexNumber; int num2 = episodeNum; if ((indexNumber.GetValueOrDefault() == num2) && indexNumber.HasValue) { return dto.Id; } } But I am at a loss I'm trying to get the episode ID. Is everything after the query correct? I'm just concerned about the code after the query. Any help would be appreciated. Link to comment Share on other sites More sharing options...
ebr 14960 Posted February 22, 2015 Share Posted February 22, 2015 Not sure what you are looking for. Perhaps some more background about what you are actually trying to accomplish and in what program/context would help. The Episode ID (which is just a unique identifier of the item for MB) is in dto.Id. The episode number (as in the number within the specific season) is in dto.IndexNumber. Link to comment Share on other sites More sharing options...
boutzo 0 Posted February 22, 2015 Author Share Posted February 22, 2015 I'm trying to query the episode ID ex. episode 1, season 1 of the blacklist I'm just not sure if the code after the query is correct. The GetEpisodesAsync says it needs a (Episodequery query, [Cancellation token cancellation token = null]) Everytime I write it, VS keeps giving me errors. I can obtain the season number from a series with an items query but I can't dig any deeper than that. I thought the episode query would do the trick without having an extra query after I get the season Itemsquery results. Link to comment Share on other sites More sharing options...
chef 3750 Posted February 22, 2015 Share Posted February 22, 2015 (edited) I will try to help. This is written in Vb.net because that is what I know. (Forgive my own model Items are written here because I cut and pasted it outta my app...) Get library Items: Dim LibResult As ItemsResult = Nothing Try LibResult = Await Client.GetItemsAsync(New ItemQuery _ With { _ .UserId = UserModel.AuthenticateUserDto.Id, .SortOrder = SortOrder.Ascending _ }) Catch Ex As TaskCanceledException End Try For Each LibItem As BaseItemDto In LibResult.Items ' All your Library Names return here in "LibItem.Name" Next So if you dig deeper into TV Series which I am sure you already are, the you can loop through a new tier of media items with in your original loop by adding "ParentId" parameter to your item query. Like this: Dim ItemResult As ItemsResult = Nothing Try ItemResult = Await Client.GetItemsAsync(New ItemQuery _ With { _ .UserId = UserModel.AuthenticateUserDto.Id, .ParentId = LibItem.Id, .SortOrder = SortOrder.Ascending _ }) Catch Ex As Exception End Try If ItemResult IsNot Nothing Then For Each MediaItem As BaseItemDto In ItemResult.Items 'Return Series Info Here! if you know the name of your series then 'ask for the "MediaItem.Name" that it is equals to Next End If Now dig even Deeper by acquiring the series Id from the loop above (MediaItem.Name = "Season 1"), and use the same type of Query and add the MediaItem.Id (Or the series ID) to the "ParentId" parameter. This will return seasons. etc. Note: You could also set the "Recursive" parameter to true which would cause the Query to dig all the way down through your media folders. I really don't know if this is helping at all... Edited February 22, 2015 by chef Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now