TVShowObject's episode_count argument is crashing Plex Media Center

I have no idea why this is happening. If i comment out the episode_count argument in the for loop that creates the TVShowObjects, everything works flawlessly. But when i add it back in it crashes Plex Media Center. More specifically, when i click on the OjbectContainer that creates the TVShowObjects, it crashes the client.



This is the windows version of Plex media center. It doesn’t affect the iOS client at all. That client properly shows the episode counts for each object. I’ve tested this on the PC running PMS, another PC, as well as my primary HTPC. All crash at the same point. All have the latest version of Plex Media Center. I don’t have access to a mac right now or i’d test that as well. Just tested this with a mac and it crashes exactly the same way. So either the code below is bad or there is a major bug in PMC.



Here is a snippet of the code causing the problem:



<br />
	request = makeAPIRequest()<br />
	if request['error'] is False:	<br />
		for series in request['data']:<br />
			oc.add(TVShowObject(<br />
				key = Callback(list_collections, series_id = series['series_id']), <br />
				rating_key = series['series_id'],<br />
				title = series['name'],<br />
				summary = series['description'],<br />
				episode_count = int(series['media_count']),<br />
				rating = (float(series['rating']) / 10),<br />
				thumb = series['portrait_image']['large_url']))<br />
	<br />
	elif request['error'] is True:<br />
		MessageContainer("Error", request['message'])<br />
<br />
	return oc



The error i get in the Plex.log for PMC is:



Any thought's or suggestions? Is this a known bug? If so, what workaround should i implement in my plugin?

Thanks!

I have a quick update. This is still a huge bug /imo. However i have discovered a workaround. There is an undocumented argument called “viewed_episode_count” which you can use with the TVShowObject() function. This object, obviously, sets the viewed count to 0. If you add it below the episode_count argument, it keeps PMC from crashing. I discovered this workaround by looking at the hulu.bundle code.



So, here is the working code.



<br />
	request = makeAPIRequest()<br />
	if request['error'] is False:	<br />
		for series in request['data']:<br />
			oc.add(TVShowObject(<br />
				key = Callback(list_collections, series_id = series['series_id']), <br />
				rating_key = series['series_id'],<br />
				title = series['name'],<br />
				summary = series['description'],<br />
				episode_count = int(series['media_count']),<br />
                                viewed_episode_count = 0,<br />
				rating = (float(series['rating']) / 10),<br />
				thumb = series['portrait_image']['large_url']))<br />
	<br />
	elif request['error'] is True:<br />
		MessageContainer("Error", request['message'])<br />
<br />
	return oc



Hopefully the dev team will either fix the bug or add this argument and it's required use into the documentation so no one else has to waste a full day troubleshooting.

mattrk, thanks for updating with your finds - I've also encountered this and your solution works for me!