New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Library Media Stats #2186
base: nightly
Are you sure you want to change the base?
Library Media Stats #2186
Conversation
My idea was to decouple the media info from the total. We can get the total directly from Plex without adding up all the individual items. This means the total can be shown regardless of the file sizes setting. Refer to the Plex API library here: This also opens up the option to add the totals to columns on the Libraries table (cache to database |
Interesting. This would save both on loading time and also on complexity, but would mean to replace the calculation logic entirely. It would also allow to make a new call which can be used internally for the total, but also provided via the API. I will start working on that, but keep the visual changes so far made as those still seem fitting to me. Since when is this call supported by Plex? Do we need to check for a special plex server version.
Good call👍 |
Over 3 years when Plex Dash was released. Might need to verify that the API endpoint isn't Plex Pass only because Plex Dash is Plex Pass only. I don't think it is. |
Ready for review. I updated the main message to reflect the new changes. I also decided to keep the addition of the duration in the file size calculation per item as it seems like a logical addition and doesn't increase the runtime as no additional call is made. Did you verify if the calls for the properties are Plex Pass only? Does the python-plexapi include a field or indication for premium required functions/calls, if not this would seem like a good addition. |
I dont know if this is a bug or not. But i wanted to sort out which of my movies that have been watched. If i choose a movie that i know have been seen by me and others the all time watch time is 0. Why is that? I installed Tautulli using the simple way with the EXE file. Is there anything else that i need? |
Please use the issue section of github to report a problem or ask for support in the future (https://github.com/Tautulli/Tautulli/issues) as this discussion is only regarding the content of the PR.
Yes as Tautulli tracks informations far more detailed then Plex does and so needs to run to gather this data. |
This PR is stale because it has been open for 30 days with no activity. Remove the stale label or comment, otherwise this will be closed in 5 days. |
This PR was closed because it has been stalled for 5 days with no activity. |
@JonnyWong16 Still ready for review. Any timeframe the review will be done? |
I will get to this soon. I've been busy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert the cache changes. It's making this PR very difficult to review.
@@ -143,6 +145,44 @@ def has_library_type(section_type): | |||
result = monitor_db.select_single(query=query, args=args) | |||
return bool(result) | |||
|
|||
def get_library_media_stats(section_id=None, refresh=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Save to the database library_sections
table instead of caching to a file. Add two new columns total_storage
and total_duration
. total_size
is already the count
column in the database.
You can keep the total_size
in the returned dict for the API.
@@ -409,18 +449,23 @@ def get_datatables_list(self, kwargs=None, grouping=None): | |||
else: | |||
library_art = item['library_art'] | |||
|
|||
library_media_stats = get_library_media_stats(item['section_id']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once added to the database, just add the columns to the query above.
Description
This PR adds the
total media runtime
andtotal file size
as indicators to several sections of the library.The table header of the Media Info section of the library now directly displays those indicators.
If
Calculate Total File Size
is enabled in the config the duration aka. runtime is now included for each item. This column, like the other ones, an be shown/hidden.The Libraries overview also includes those as fields in two new configurable columns.
For this a new method
get_library_media_stats
got added to the API which returns the total size, the total duration aka. runtime and total storage of a library.This data gets cached into a new file
media_stats_<section_id>
to allow for faster loading times. For this the caching methods for saving and loading have been rebuild to a generic version.After first updating to this version, when enabled in the config, the file size and duration will be recalculated and saved to the cache for the items.
The API documentation got updated.
Issues Fixed or Closed
Type of Change
Checklist