Skip to content
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

Last Watched Identifier #1492

Draft
wants to merge 4 commits into
base: nightly
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions data/interfaces/default/home_stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@

== Only if 'stat_id' is 'last_watched' ==
last_watch Returns the time the media item was last watched.
media_type Returns the type of media of the media item.
media_index Returns the index of the media item in its season.
parent_media_index Returns the index of the parent media item of the media item.

== Only if 'stat_id' is 'most_concurrent' ==
count Returns the count of the most concurrent streams.
Expand All @@ -53,6 +56,7 @@
</%doc>

<%!
import plexpy
from plexpy.helpers import cast_to_int, page

# Human readable duration
Expand All @@ -62,6 +66,11 @@
m += 1
h, m = divmod(m, 60)
return str(h).zfill(1) + ':' + str(m).zfill(2)

# Formatting media index for representation
def fi(media_index, parent_media_index):
return 'S' + str(parent_media_index).zfill(2) + 'E' + str(media_index).zfill(2) if plexpy.CONFIG.IDENTIFIER_LAST_WATCHED else ''

%>

% if data and any(top_stat['rows'] for top_stat in data):
Expand Down Expand Up @@ -187,6 +196,8 @@ <h4>${top_stat['stat_title']}</h4>
${row['users_watched']}
% elif stat_id == 'most_concurrent':
${row['count']}
% elif stat_id == 'last_watched' and row['media_type'] == 'episode':
${fi(row['media_index'], row['parent_media_index'])}
herby2212 marked this conversation as resolved.
Show resolved Hide resolved
% endif
</div>
</li>
Expand Down
7 changes: 7 additions & 0 deletions data/interfaces/default/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,13 @@ <h3>Watch Statistics</h3>
</div>
</div>

<div class="checkbox">
<label>
<input type="checkbox" id="identifier_last_watched" name="identifier_last_watched" value="1" ${config['identifier_last_watched']}> Identifier for Last Watched
</label>
<p class="help-block">Enable to have the season and episode number listed for entries in the Last Watched card.</p>
</div>

<div class="padded-header">
<h3>Library Statistics</h3>
</div>
Expand Down
6 changes: 6 additions & 0 deletions plexpy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def bool_int(value):
'HTTP_RATE_LIMIT_ATTEMPTS_INTERVAL': (int, 'General', 300),
'HTTP_RATE_LIMIT_LOCKOUT_TIME': (int, 'General', 300),
'HTTP_THREAD_POOL': (int, 'General', 10),
'IDENTIFIER_LAST_WATCHED': (int, 'Monitoring', 0),
'INTERFACE': (str, 'General', 'default'),
'IMGUR_CLIENT_ID': (str, 'Monitoring', ''),
'JOURNAL_MODE': (str, 'Advanced', 'WAL'),
Expand Down Expand Up @@ -580,3 +581,8 @@ def _upgrade(self):
self.HTTP_HASHED_PASSWORD = 1

self.CONFIG_VERSION = 20

if self.CONFIG_VERSION == 20:
self.IDENTIFIER_LAST_WATCHED = 0

self.CONFIG_VERSION = 21
3 changes: 2 additions & 1 deletion plexpy/webserve.py
Original file line number Diff line number Diff line change
Expand Up @@ -3187,6 +3187,7 @@ def settings(self, **kwargs):
"week_start_monday": checked(plexpy.CONFIG.WEEK_START_MONDAY),
"get_file_sizes": checked(plexpy.CONFIG.GET_FILE_SIZES),
"monitor_pms_updates": checked(plexpy.CONFIG.MONITOR_PMS_UPDATES),
"identifier_last_watched": checked(plexpy.CONFIG.IDENTIFIER_LAST_WATCHED),
"refresh_libraries_interval": plexpy.CONFIG.REFRESH_LIBRARIES_INTERVAL,
"refresh_libraries_on_startup": checked(plexpy.CONFIG.REFRESH_LIBRARIES_ON_STARTUP),
"refresh_users_interval": plexpy.CONFIG.REFRESH_USERS_INTERVAL,
Expand Down Expand Up @@ -3271,7 +3272,7 @@ def configUpdate(self, **kwargs):
"notify_group_recently_added_grandparent", "notify_group_recently_added_parent",
"notify_new_device_initial_only",
"notify_server_update_repeat", "notify_plexpy_update_repeat",
"monitor_pms_updates", "get_file_sizes", "log_blacklist",
"monitor_pms_updates", "identifier_last_watched", "get_file_sizes", "log_blacklist",
"allow_guest_access", "cache_images", "http_proxy", "notify_concurrent_by_ip",
"history_table_activity", "plexpy_auto_update",
"themoviedb_lookup", "tvmaze_lookup", "musicbrainz_lookup", "http_plex_admin",
Expand Down