mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 13:41:15 -07:00
Don't retrieve metadata for recently added before it is available
* Fixes #1392
This commit is contained in:
parent
0ff2fd91d5
commit
1615a73da9
2 changed files with 64 additions and 56 deletions
|
@ -27,6 +27,7 @@ import pytz
|
||||||
import plexpy
|
import plexpy
|
||||||
if plexpy.PYTHON2:
|
if plexpy.PYTHON2:
|
||||||
import activity_processor
|
import activity_processor
|
||||||
|
import common
|
||||||
import datafactory
|
import datafactory
|
||||||
import helpers
|
import helpers
|
||||||
import logger
|
import logger
|
||||||
|
@ -34,6 +35,7 @@ if plexpy.PYTHON2:
|
||||||
import pmsconnect
|
import pmsconnect
|
||||||
else:
|
else:
|
||||||
from plexpy import activity_processor
|
from plexpy import activity_processor
|
||||||
|
from plexpy import common
|
||||||
from plexpy import datafactory
|
from plexpy import datafactory
|
||||||
from plexpy import helpers
|
from plexpy import helpers
|
||||||
from plexpy import logger
|
from plexpy import logger
|
||||||
|
@ -415,18 +417,12 @@ class TimelineHandler(object):
|
||||||
global RECENTLY_ADDED_QUEUE
|
global RECENTLY_ADDED_QUEUE
|
||||||
|
|
||||||
rating_key = self.get_rating_key()
|
rating_key = self.get_rating_key()
|
||||||
|
parent_rating_key = self.timeline.get('parentItemID')
|
||||||
media_types = {1: 'movie',
|
grandparent_rating_key = self.timeline.get('rootItemID')
|
||||||
2: 'show',
|
|
||||||
3: 'season',
|
|
||||||
4: 'episode',
|
|
||||||
8: 'artist',
|
|
||||||
9: 'album',
|
|
||||||
10: 'track'}
|
|
||||||
|
|
||||||
identifier = self.timeline.get('identifier')
|
identifier = self.timeline.get('identifier')
|
||||||
state_type = self.timeline.get('state')
|
state_type = self.timeline.get('state')
|
||||||
media_type = media_types.get(self.timeline.get('type'))
|
media_type = common.MEDIA_TYPE_VALUES.get(self.timeline.get('type'))
|
||||||
section_id = helpers.cast_to_int(self.timeline.get('sectionID', 0))
|
section_id = helpers.cast_to_int(self.timeline.get('sectionID', 0))
|
||||||
title = self.timeline.get('title', 'Unknown')
|
title = self.timeline.get('title', 'Unknown')
|
||||||
metadata_state = self.timeline.get('metadataState')
|
metadata_state = self.timeline.get('metadataState')
|
||||||
|
@ -438,81 +434,72 @@ class TimelineHandler(object):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Add a new media item to the recently added queue
|
# Add a new media item to the recently added queue
|
||||||
if media_type and section_id > 0 and \
|
if media_type and section_id > 0 and state_type == 0 and metadata_state == 'created':
|
||||||
((state_type == 0 and metadata_state == 'created')): # or \
|
|
||||||
#(plexpy.CONFIG.NOTIFY_RECENTLY_ADDED_UPGRADE and state_type in (1, 5) and \
|
|
||||||
#media_state == 'analyzing' and queue_size is None)):
|
|
||||||
|
|
||||||
if media_type in ('episode', 'track'):
|
if media_type in ('episode', 'track'):
|
||||||
metadata = self.get_metadata()
|
grandparent_set = RECENTLY_ADDED_QUEUE.get(grandparent_rating_key, set())
|
||||||
if metadata:
|
grandparent_set.add(parent_rating_key)
|
||||||
grandparent_title = metadata['grandparent_title']
|
RECENTLY_ADDED_QUEUE[grandparent_rating_key] = grandparent_set
|
||||||
grandparent_rating_key = int(metadata['grandparent_rating_key'])
|
|
||||||
parent_rating_key = int(metadata['parent_rating_key'])
|
|
||||||
|
|
||||||
grandparent_set = RECENTLY_ADDED_QUEUE.get(grandparent_rating_key, set())
|
parent_set = RECENTLY_ADDED_QUEUE.get(parent_rating_key, set())
|
||||||
grandparent_set.add(parent_rating_key)
|
parent_set.add(rating_key)
|
||||||
RECENTLY_ADDED_QUEUE[grandparent_rating_key] = grandparent_set
|
RECENTLY_ADDED_QUEUE[parent_rating_key] = parent_set
|
||||||
|
|
||||||
parent_set = RECENTLY_ADDED_QUEUE.get(parent_rating_key, set())
|
RECENTLY_ADDED_QUEUE[rating_key] = {grandparent_rating_key}
|
||||||
parent_set.add(rating_key)
|
|
||||||
RECENTLY_ADDED_QUEUE[parent_rating_key] = parent_set
|
|
||||||
|
|
||||||
RECENTLY_ADDED_QUEUE[rating_key] = set([grandparent_rating_key])
|
logger.debug("Tautulli TimelineHandler :: Library item '%s' (%s, grandparent %s) "
|
||||||
|
"added to recently added queue."
|
||||||
|
% (title, str(rating_key), str(grandparent_rating_key)))
|
||||||
|
|
||||||
logger.debug("Tautulli TimelineHandler :: Library item '%s' (%s, grandparent %s) added to recently added queue."
|
# Schedule a callback to clear the recently added queue
|
||||||
% (title, str(rating_key), str(grandparent_rating_key)))
|
schedule_callback('rating_key-{}'.format(grandparent_rating_key),
|
||||||
|
func=clear_recently_added_queue,
|
||||||
# Schedule a callback to clear the recently added queue
|
args=[grandparent_rating_key],
|
||||||
schedule_callback('rating_key-{}'.format(grandparent_rating_key),
|
seconds=plexpy.CONFIG.NOTIFY_RECENTLY_ADDED_DELAY)
|
||||||
func=clear_recently_added_queue,
|
|
||||||
args=[grandparent_rating_key, grandparent_title],
|
|
||||||
seconds=plexpy.CONFIG.NOTIFY_RECENTLY_ADDED_DELAY)
|
|
||||||
|
|
||||||
elif media_type in ('season', 'album'):
|
elif media_type in ('season', 'album'):
|
||||||
metadata = self.get_metadata()
|
parent_set = RECENTLY_ADDED_QUEUE.get(parent_rating_key, set())
|
||||||
if metadata:
|
parent_set.add(rating_key)
|
||||||
parent_title = metadata['parent_title']
|
RECENTLY_ADDED_QUEUE[parent_rating_key] = parent_set
|
||||||
parent_rating_key = int(metadata['parent_rating_key'])
|
|
||||||
|
|
||||||
parent_set = RECENTLY_ADDED_QUEUE.get(parent_rating_key, set())
|
logger.debug("Tautulli TimelineHandler :: Library item '%s' (%s , parent %s) "
|
||||||
parent_set.add(rating_key)
|
"added to recently added queue."
|
||||||
RECENTLY_ADDED_QUEUE[parent_rating_key] = parent_set
|
% (title, str(rating_key), str(parent_rating_key)))
|
||||||
|
|
||||||
logger.debug("Tautulli TimelineHandler :: Library item '%s' (%s , parent %s) added to recently added queue."
|
# Schedule a callback to clear the recently added queue
|
||||||
% (title, str(rating_key), str(parent_rating_key)))
|
schedule_callback('rating_key-{}'.format(parent_rating_key),
|
||||||
|
func=clear_recently_added_queue,
|
||||||
|
args=[parent_rating_key],
|
||||||
|
seconds=plexpy.CONFIG.NOTIFY_RECENTLY_ADDED_DELAY)
|
||||||
|
|
||||||
# Schedule a callback to clear the recently added queue
|
elif media_type in ('movie', 'show', 'artist'):
|
||||||
schedule_callback('rating_key-{}'.format(parent_rating_key),
|
|
||||||
func=clear_recently_added_queue,
|
|
||||||
args=[parent_rating_key, parent_title],
|
|
||||||
seconds=plexpy.CONFIG.NOTIFY_RECENTLY_ADDED_DELAY)
|
|
||||||
|
|
||||||
else:
|
|
||||||
queue_set = RECENTLY_ADDED_QUEUE.get(rating_key, set())
|
queue_set = RECENTLY_ADDED_QUEUE.get(rating_key, set())
|
||||||
RECENTLY_ADDED_QUEUE[rating_key] = queue_set
|
RECENTLY_ADDED_QUEUE[rating_key] = queue_set
|
||||||
|
|
||||||
logger.debug("Tautulli TimelineHandler :: Library item '%s' (%s) added to recently added queue."
|
logger.debug("Tautulli TimelineHandler :: Library item '%s' (%s) "
|
||||||
|
"added to recently added queue."
|
||||||
% (title, str(rating_key)))
|
% (title, str(rating_key)))
|
||||||
|
|
||||||
# Schedule a callback to clear the recently added queue
|
# Schedule a callback to clear the recently added queue
|
||||||
schedule_callback('rating_key-{}'.format(rating_key),
|
schedule_callback('rating_key-{}'.format(rating_key),
|
||||||
func=clear_recently_added_queue,
|
func=clear_recently_added_queue,
|
||||||
args=[rating_key, title],
|
args=[rating_key],
|
||||||
seconds=plexpy.CONFIG.NOTIFY_RECENTLY_ADDED_DELAY)
|
seconds=plexpy.CONFIG.NOTIFY_RECENTLY_ADDED_DELAY)
|
||||||
|
|
||||||
# A movie, show, or artist is done processing
|
# A movie, show, or artist is done processing
|
||||||
elif media_type in ('movie', 'show', 'artist') and section_id > 0 and \
|
elif media_type in ('movie', 'show', 'artist') and section_id > 0 and \
|
||||||
state_type == 5 and metadata_state is None and queue_size is None and \
|
state_type == 5 and metadata_state is None and queue_size is None and \
|
||||||
rating_key in RECENTLY_ADDED_QUEUE:
|
rating_key in RECENTLY_ADDED_QUEUE:
|
||||||
|
|
||||||
logger.debug("Tautulli TimelineHandler :: Library item '%s' (%s) done processing metadata."
|
logger.debug("Tautulli TimelineHandler :: Library item '%s' (%s) "
|
||||||
|
"done processing metadata."
|
||||||
% (title, str(rating_key)))
|
% (title, str(rating_key)))
|
||||||
|
|
||||||
# An item was deleted, make sure it is removed from the queue
|
# An item was deleted, make sure it is removed from the queue
|
||||||
elif state_type == 9 and metadata_state == 'deleted':
|
elif state_type == 9 and metadata_state == 'deleted':
|
||||||
if rating_key in RECENTLY_ADDED_QUEUE and not RECENTLY_ADDED_QUEUE[rating_key]:
|
if rating_key in RECENTLY_ADDED_QUEUE and not RECENTLY_ADDED_QUEUE[rating_key]:
|
||||||
logger.debug("Tautulli TimelineHandler :: Library item %s removed from recently added queue."
|
logger.debug("Tautulli TimelineHandler :: Library item %s "
|
||||||
|
"removed from recently added queue."
|
||||||
% str(rating_key))
|
% str(rating_key))
|
||||||
del_keys(rating_key)
|
del_keys(rating_key)
|
||||||
|
|
||||||
|
@ -646,7 +633,7 @@ def force_stop_stream(session_key, title, user):
|
||||||
delete_metadata_cache(session_key)
|
delete_metadata_cache(session_key)
|
||||||
|
|
||||||
|
|
||||||
def clear_recently_added_queue(rating_key, title):
|
def clear_recently_added_queue(rating_key):
|
||||||
child_keys = RECENTLY_ADDED_QUEUE[rating_key]
|
child_keys = RECENTLY_ADDED_QUEUE[rating_key]
|
||||||
|
|
||||||
if plexpy.CONFIG.NOTIFY_GROUP_RECENTLY_ADDED_GRANDPARENT and len(child_keys) > 1:
|
if plexpy.CONFIG.NOTIFY_GROUP_RECENTLY_ADDED_GRANDPARENT and len(child_keys) > 1:
|
||||||
|
|
|
@ -80,6 +80,27 @@ MEDIA_TYPE_HEADERS = {
|
||||||
'photo': 'Photos'
|
'photo': 'Photos'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MEDIA_TYPE_VALUES = {
|
||||||
|
1: 'movie',
|
||||||
|
2: 'show',
|
||||||
|
3: 'season',
|
||||||
|
4: 'episode',
|
||||||
|
5: 'trailer',
|
||||||
|
6: 'comic',
|
||||||
|
7: 'person',
|
||||||
|
8: 'artist',
|
||||||
|
9: 'album',
|
||||||
|
10: 'track',
|
||||||
|
11: 'picture',
|
||||||
|
12: 'clip',
|
||||||
|
13: 'photo',
|
||||||
|
14: 'photoalbum',
|
||||||
|
15: 'playlist',
|
||||||
|
16: 'playlistFolder',
|
||||||
|
18: 'collection',
|
||||||
|
42: 'optimizedVersion'
|
||||||
|
}
|
||||||
|
|
||||||
PLATFORM_NAME_OVERRIDES = {
|
PLATFORM_NAME_OVERRIDES = {
|
||||||
'Konvergo': 'Plex Media Player',
|
'Konvergo': 'Plex Media Player',
|
||||||
'Mystery 3': 'Playstation 3',
|
'Mystery 3': 'Playstation 3',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue