Jump to content


Photo

Latest Episodes Limited to Single Series and Next Up issue


  • Please log in to reply
8 replies to this topic

#1 bfir3 OFFLINE  

bfir3

    Advanced Member

  • Members
  • 412 posts
  • Local time: 06:09 AM

Posted 21 May 2017 - 04:05 AM

I've noticed that sometimes if I have several new episodes from one series, it will prevent other series from appearing in the latest section. In this case I have about 16 new episodes that were just added for the series Lost, and I can no longer see any other latest episodes for other series:

 

YCM9cPF.png

sb3s8Wf.png

 

Another issue I've noticed is that Next Up gets populated with the first episode from every single series if the user hasn't watched any content from that specific library. It will also show next up on a series page as the first episode of the series even if the user has never watched the series before.

 

edit: Just for clarity, I realized Emby just scraped a bunch of Special episodes as well, so there are actually 242 new episodes for Lost in total. The problem is, the query should be returning a minimum number of series with new episodes. It doesn't make sense that one series with a lot of new episodes would prevent other series from showing as well.


Edited by bfir3, 21 May 2017 - 04:50 AM.


#2 Happy2Play OFFLINE  

Happy2Play

    Trial and Error

  • Moderators
  • 17197 posts
  • Local time: 10:09 PM
  • LocationWashington State

Posted 21 May 2017 - 04:58 AM

"Latest " is a know issue do to the display limit (there are other topics on it).  I would guess this series was just added and all episodes have the newest date added, so they are blocking other series until the episode count is reduced or newer stuff is add. 

 

(Time Lord plugin can help with this, changing dates added to Release date.)

 

As for Next Up where exactly are you referring to?  As I can not reproduce any New unwatched Series showing up in Next Up.


Edited by Happy2Play, 21 May 2017 - 05:27 AM.


#3 bfir3 OFFLINE  

bfir3

    Advanced Member

  • Members
  • 412 posts
  • Local time: 06:09 AM

Posted 21 May 2017 - 10:44 AM

Here's what I'm referring to for Next Up: (this is a fresh account that I just created)

 

fePC39K.jpg

 

This account is brand new and has no content watched. Even if some content was watched, it doesn't make sense to use the first episode of a series as Next Up. In my mind, Next Up is intended for series that have been watched and should display the following episode (after the last one that was watched).

 

As for Latest episodes, if it's a known bug for now, okay. I will fix the Latest issue on my own by using a different query for now until it is resolved by the devs. I will post my fix here for anyone interested in using it for the time being (it won't be a true fix since I don't think I'll be able to use the Items/Latest/ call but it will still yield the expected results without limiting the number of series.



#4 bfir3 OFFLINE  

bfir3

    Advanced Member

  • Members
  • 412 posts
  • Local time: 06:09 AM

Posted 21 May 2017 - 11:12 AM

For anyone interested, here is my temporary work around for the Latest items. This will only work if the combined total of new episodes from the 5 latest series is less than 1000 items (you can increase this limit if necessary, but don't remove it altogether if you have a large library). Additionally, this will only show the latest episode for each series instead of showing a stack of episodes for series that have more than one new series. I may work on fixing that as well, but this seems fine for now.

var query = {
	SortBy: "DateCreated",
	SortOrder: "Descending",
	IncludeItemTypes: "Episode",
	Recursive: true,
	Fields: "PrimaryImageAspectRatio,BasicSyncInfo,DateCreated",
	EnableImageTypes: "Primary,Backdrop,Thumb",
	ExcludeLocationTypes: "Virtual",
	ParentId: parent.Id,
	Limit: 1000
}	

ApiClient.getItems(Dashboard.getCurrentUserId(), query).then(function (result) {				
	var uniqueSeries = [];
	
	var oneWeekAgo = new Date();
	oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);
	
	result.Items = result.Items.filter(function (item) {
		return new Date(item.DateCreated) > oneWeekAgo;
	});
	
	var items = result.Items;
	
	items = items.filter(function (item) {
		if (uniqueSeries.indexOf(item.SeriesId) >= 0) {
			return false;
		}
		item.ChildCount = result.Items.filter(function (resultItem) { return item.SeriesId == resultItem.SeriesId}).length;
		uniqueSeries.push(item.SeriesId);
		return true;				
	}).slice(0, limit);
	
	var html = "";
	if (items.length) {
		html += '<div class="sectionTitleContainer">', html += '<h2 class="sectionTitle sectionTitle-cards padded-left">' + globalize.translate("sharedcomponents#LatestFromLibrary", parent.Name) + "</h2>", layoutManager.tv || (html += '<a is="emby-linkbutton" href="' + embyRouter.getRouteUrl(parent, {
			section: "latest"
		}) + '" class="raised raised-mini sectionTitleButton btnMore">' + globalize.translate("sharedcomponents#More") + "</a>"), html += "</div>", html += enableScrollX() ? '<div is="emby-scroller" class="padded-top-focusscale padded-bottom-focusscale" data-mousewheel="false" data-centerfocus="true"><div is="emby-itemscontainer" class="scrollSlider focuscontainer-x padded-left padded-right">' : '<div is="emby-itemscontainer" class="itemsContainer padded-left padded-right vertical-wrap focuscontainer-x">';
		var viewType = parent.CollectionType,
			shape = "movies" === viewType ? getPortraitShape() : "music" === viewType ? getSquareShape() : getThumbShape(),
			supportsImageAnalysis = appHost.supports("imageanalysis");
		supportsImageAnalysis = !1;
		var cardLayout = supportsImageAnalysis && ("music" === viewType || "movies" === viewType || "tvshows" === viewType || "musicvideos" === viewType || !viewType);
		html += cardBuilder.getCardsHtml({
			items: items,
			shape: shape,
			preferThumb: "movies" !== viewType && "music" !== viewType,
			showGroupCount: true,
			showUnplayedIndicator: !1,
			showChildCountIndicator: !0,
			context: "home",
			overlayText: !1,
			centerText: !cardLayout,
			overlayPlayButton: "photos" !== viewType,
			allowBottomPadding: !enableScrollX() && !cardLayout,
			cardLayout: cardLayout,
			showTitle: "music" === viewType || "tvshows" === viewType || "movies" === viewType || !viewType || cardLayout,
			showYear: "movies" === viewType || "tvshows" === viewType || !viewType,
			showParentTitle: "music" === viewType || "tvshows" === viewType || !viewType || cardLayout && "tvshows" === viewType,
			vibrant: supportsImageAnalysis && cardLayout,
			lines: 2
		}), enableScrollX() && (html += "</div>"), html += "</div>"
	}
	elem.innerHTML = html, imageLoader.lazyChildren(elem)
});

That code is for the renderLatestSection function in the homesections.js file. Here's what it looks like for me now:

 

0WXCtCN.png

 

EDIT: Just updated the code so that it will also return the total number of new episodes for each series as well. In this case, it will still only show the name of the most recently added episode instead of showing the years that the show was active, but it will show the correct new episode count in the corner as well like so:

 

xy2NShu.png

 

The query above is modified to include the code that will show the episode count.

 

EDIT2: Just realized that fix is only relevant for the homepage, and you'll still have the issue when viewing the Latest tab within a library. To fix that, you will also need to edit the loadLatest function inside the tvlatest.js file as follows:

function loadLatest(context, params, promise) {
		
		var query = {
				SortBy: "DateCreated",
				SortOrder: "Descending",
				IncludeItemTypes: "Episode",
				Recursive: true,
				Fields: "PrimaryImageAspectRatio,BasicSyncInfo,DateCreated",
				EnableImageTypes: "Primary,Backdrop,Thumb",
				ExcludeLocationTypes: "Virtual",
				ParentId: params.topParentId,
				Limit: 1000
			}	

			ApiClient.getItems(Dashboard.getCurrentUserId(), query).then(function (result) {				
				var uniqueSeries = [];
				
				var oneWeekAgo = new Date();
				oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);
				
				result.Items = result.Items.filter(function (item) {
					return new Date(item.DateCreated) > oneWeekAgo;
				});
				
				var items = result.Items;
				
				items = items.filter(function (item) {
					if (uniqueSeries.indexOf(item.SeriesId) >= 0) {
						return false;
					}
					item.ChildCount = result.Items.filter(function (resultItem) { return item.SeriesId == resultItem.SeriesId}).length;
					uniqueSeries.push(item.SeriesId);
					return true;				
				}).slice(0, 25);
		
		
				var html = ""
				  , supportsImageAnalysis = appHost.supports("imageanalysis")
				  , cardLayout = !1;
				html += cardBuilder.getCardsHtml({
					items: items,
					shape: "backdrop",
					preferThumb: !0,
					showTitle: !0,
					showSeriesYear: !0,
					showParentTitle: !0,
					overlayText: !1,
					cardLayout: cardLayout,
					showGroupCount: true,
					showUnplayedIndicator: !1,
					showChildCountIndicator: !0,
					centerText: !cardLayout,
					lazy: !0,
					overlayPlayButton: !0,
					vibrant: cardLayout && supportsImageAnalysis,
					lines: 2
				});
				var elem = context.querySelector("#latestEpisodes");
				elem.innerHTML = html,
				imageLoader.lazyChildren(elem),
				loading.hide();	
				
			});
    }

This will show the latest 25 series with new episodes and will show the correct new child count for each series.

 

Final Edit:

 

Because we are using a hard limit of 1000 episodes, we are returning episodes that can be much older than desirable for the "Latest" items sections. To fix this, I've implemented a DateAdded check that will make it only count episodes that were added within the last 7 days. This makes the child count numbers much more accurate. This is probably as good as I will be able to make the work around for now, and I've updated the code above to include the Date check. If you want to use a date limit that is more or less than 7 days, simply edit the "7" in this line:

oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);

Edited by bfir3, 21 May 2017 - 12:07 PM.


#5 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 146738 posts
  • Local time: 01:09 AM

Posted 21 May 2017 - 02:06 PM

The first item is just a limitation, yes, it should be improved.

 

The second has always been that way.



#6 bfir3 OFFLINE  

bfir3

    Advanced Member

  • Members
  • 412 posts
  • Local time: 06:09 AM

Posted 21 May 2017 - 04:26 PM

The first item is just a limitation, yes, it should be improved.

 

The second has always been that way.

 

So it makes sense that the Next Up would populate endlessly for a user who has not watched any items, but for a user that has watched some items, it should only populate with episodes from a series that has been watched by that user? I mean it's a simple fix on my end, just hide any Series Premiere episodes from Next Up. To me, the only reason a Series Premiere should ever show in Next Up is if that Series aired webisodes as Specials before airing it's real Series Premiere and the user has watched those Specials...but this is a very rare scenario.

 

By definition to me, Next Up is the episode that immediately follows the last episode that was watched for a given series. Therefore, if no episode has been watched for a given series, there cannot be a Next Up episode for it. Is this definition of Next Up incorrect? This also means that if a user watches Episode 5 of Season 3 without having marked any preceding episodes as watched, the Next Up should be Episode 6 of Season 3, and not Episode 1 of Season 1.



#7 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 146738 posts
  • Local time: 01:09 AM

Posted 21 May 2017 - 04:29 PM

Yes I think it makes sense for everyone, it at least offers some suggestions of what to watch, which I think is preferable to have an empty screen.

 

On the detail screen you can obviously argue either way, but when you add a new series, it's a nice way of letting you know that as you watch episodes, you can always quickly get to your next one from there.



#8 bfir3 OFFLINE  

bfir3

    Advanced Member

  • Members
  • 412 posts
  • Local time: 06:09 AM

Posted 21 May 2017 - 04:48 PM

Ah okay, I see your logic then. I keep Next Up off of the homepage, and don't really see the benefit in offering people random suggestions in the Next Up section. On my system, if users are looking for suggestions they visit the Suggestions tab for the appropriate library which I've populated with default genre suggestions in addition to the normal suggestions based on watched items and favorites/likes. 

 

Looking forward to seeing the progress you make to restore the old Latest items functionality.



#9 ldexterldesign OFFLINE  

ldexterldesign

    Advanced Member

  • Members
  • 93 posts
  • Local time: 06:09 AM
  • LocationUK ✈ EU (currently Malta)

Posted 27 December 2017 - 01:35 PM

https://emby.media/c...total-episodes/






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users