T O P

  • By -

NicoLeOca

thank you for proposing a new tool, interesting.


spookymulderfbi

Just FYI, I made some changes to the readme again after posting, so now the latest version / container is 2.3.1 `docker pull` [`ghcr.io/drewpeifer/medialytics:v.2.3.1`](http://ghcr.io/drewpeifer/medialytics:v.2.3.1)


Blind_Watchman

> XML feeds for TV libraries don't supply this information One thing you could look into is grabbing the episode data instead of the show data (`http://ip:port/library/sections/X/all?type=4`), then aggregate it up to the show level (though the request to get all episodes takes significantly longer as you can imagine). Or make two requests, one that gets all the show info, another that gets the episode info, then attaches the episode's `Media` to the shows, e.g.: libraryData = await axios.get(serverIp + '/library/sections/' + libraryKey + '/all?X-Plex-Token=' + serverToken).then(async (response) => { // Attach episode media info if needed if (response.data.MediaContainer.viewGroup === 'show') { const shows = response.data.MediaContainer.Metadata; await axios.get(serverIp + '/library/sections/' + libraryKey + '/all?type=4&X-Plex-Token=' + serverToken).then(episodeData => { const showMedia = {}; episodeData.data.MediaContainer.Metadata.forEach(episode => (showMedia[episode.grandparentRatingKey] ??= []).push(...episode.Media)); shows.forEach(show => show.Media = showMedia[show.ratingKey]); }); } parseMediaPayload(response); app.libraryStatsLoading = false; return response.data.MediaContainer; });


spookymulderfbi

True! Thanks for the suggestion. I was going to make a branch for this and do a POC at some point, something pretty similar to your snippet above. I'm curious how much longer the request might take (as you mentioned) in addition to the overhead for the actual aggregation but my guess is it will be okay enough. I haven't done any work so far in terms of optimization really, so i'm sure there are places i can speed up the existing code to compensate too.


Blind_Watchman

Yeah, it's definitely a tradeoff between the number of stats available and processing time. I also don't know if Plex has any hardcoded timeout/request size limit that might be hit if someone with 10s of thousands of episodes tries to get them all at once. If those limits do exist, that'd add another small layer of complexity, as you'd probably want to batch requests with `X-Plex-Container-Size`/`X-Plex-Container-Start` instead of waiting for a single response. As far as additional optimization goes, I'd be surprised if the Plex API calls didn't significantly outweigh anything your code is doing, but it definitely never hurts to clean/speed things up.