diff --git a/data/interfaces/newsletters/recently_added.html b/data/interfaces/newsletters/recently_added.html index 1a9408c5..c6f5fba1 100644 --- a/data/interfaces/newsletters/recently_added.html +++ b/data/interfaces/newsletters/recently_added.html @@ -368,6 +368,7 @@ line-height: 1.2rem; font-size: 0.9rem; padding: 5px; + max-width: 320px; } .card-info-title a { text-decoration: none; @@ -952,6 +953,124 @@ % endif + % if recently_added.get('other_video'): + + +
+
+ Recently Added Videos +
+
+ ${len(recently_added['other_video'])} video${'s' if len(recently_added['other_video']) > 1 else ''} +
+ + + + + + % for video_a, video_b in grouper(recently_added['other_video'], 2): + + + + % endfor +
+ + + % for video in (video_a, video_b): + % if video: + % if not video_b: + + % endif + + % if not video_b: + + % endif + % endif + % endfor + +
+ + + + + +
+ + + + +
+ + + +
+
+ + + + + + + + + + +
+ ${video['title']} +
+ % if video['tagline']: +

+ ${video['tagline']} +

+ % endif +

+ ${video['summary'][:450] + (video['summary'][450:] and '...')} +

+
+
+
+
+ + + % endif diff --git a/data/interfaces/newsletters/recently_added.internal.html b/data/interfaces/newsletters/recently_added.internal.html index 679d40b7..198ba49e 100644 --- a/data/interfaces/newsletters/recently_added.internal.html +++ b/data/interfaces/newsletters/recently_added.internal.html @@ -953,6 +953,124 @@ % endif + % if recently_added.get('other_video'): + + +
+
+ Recently Added Videos +
+
+ ${len(recently_added['other_video'])} video${'s' if len(recently_added['other_video']) > 1 else ''} +
+ + + + + + % for video_a, video_b in grouper(recently_added['other_video'], 2): + + + + % endfor +
+ + + % for video in (video_a, video_b): + % if video: + % if not video_b: + + % endif + + % if not video_b: + + % endif + % endif + % endfor + +
+ + + + + +
+ + + + +
+ + + +
+
+ + + + + + + + + + +
+ ${video['title']} +
+ % if video['tagline']: +

+ ${video['tagline']} +

+ % endif +

+ ${video['summary'][:450] + (video['summary'][450:] and '...')} +

+
+
+
+
+ + + % endif diff --git a/plexpy/newsletters.py b/plexpy/newsletters.py index f409353b..47f5900b 100644 --- a/plexpy/newsletters.py +++ b/plexpy/newsletters.py @@ -14,6 +14,7 @@ # along with Tautulli. If not, see . import arrow +from collections import OrderedDict import json from itertools import groupby from mako.lookup import TemplateLookup @@ -693,7 +694,7 @@ class RecentlyAdded(Newsletter): recently_added.extend(filtered_items) - if media_type == 'movie': + if media_type in ('movie', 'other_video'): movie_list = [] for item in recently_added: # Filter included libraries @@ -795,8 +796,13 @@ class RecentlyAdded(Newsletter): if not self.config['incl_libraries']: logger.warn(u"Tautulli Newsletters :: Failed to retrieve %s newsletter data: no libraries selected." % self.NAME) - media_types = {s['section_type'] for s in self._get_sections() - if str(s['section_id']) in self.config['incl_libraries']} + media_types = set() + for s in self._get_sections(): + if str(s['section_id']) in self.config['incl_libraries']: + if s['section_type'] == 'movie' and s['agent'] == 'com.plexapp.agents.none': + media_types.add('other_video') + else: + media_types.add(s['section_type']) recently_added = {} for media_type in media_types: @@ -807,9 +813,10 @@ class RecentlyAdded(Newsletter): shows = recently_added.get('show', []) artists = recently_added.get('artist', []) albums = [a for artist in artists for a in artist['album']] + other_video = recently_added.get('other_video', []) if self.is_preview or helpers.get_img_service(include_self=True) == 'self-hosted': - for item in movies + shows + albums: + for item in movies + shows + albums + other_video: if item['media_type'] == 'album': height = 150 fallback = 'cover' @@ -833,7 +840,7 @@ class RecentlyAdded(Newsletter): elif helpers.get_img_service(): # Upload posters and art to image hosting service - for item in movies + shows + albums: + for item in movies + shows + albums + other_video: if item['media_type'] == 'album': height = 150 fallback = 'cover' @@ -858,7 +865,7 @@ class RecentlyAdded(Newsletter): item['poster_url'] = item['thumb_url'] # Keep for backwards compatibility else: - for item in movies + shows + albums: + for item in movies + shows + albums + other_video: item['thumb_hash'] = '' item['art_hash'] = '' item['thumb_url'] = '' @@ -871,10 +878,11 @@ class RecentlyAdded(Newsletter): def _has_data(self): recently_added = self.data.get('recently_added') - if recently_added and \ - recently_added.get('movie') or \ - recently_added.get('show') or \ - recently_added.get('artist'): + if recently_added and ( + recently_added.get('movie') or + recently_added.get('show') or + recently_added.get('artist') or + recently_added.get('other_video')): return True return False @@ -883,18 +891,26 @@ class RecentlyAdded(Newsletter): return libraries.Libraries().get_sections() def _get_sections_options(self): - library_types = {'movie': 'Movie Libraries', - 'show': 'TV Show Libraries', - 'artist': 'Music Libraries'} sections = {} for s in self._get_sections(): if s['section_type'] != 'photo': - library_type = library_types[s['section_type']] + if s['section_type'] == 'movie' and s['agent'] == 'com.plexapp.agents.none': + library_type = 'other_video' + else: + library_type = s['section_type'] group = sections.get(library_type, []) group.append({'value': s['section_id'], 'text': s['section_name']}) sections[library_type] = group - return sections + + groups = OrderedDict([(k, v) for k, v in [ + ('Movie Libraries', sections.get('movie')), + ('TV Show Libraries', sections.get('show')), + ('Music Libraries', sections.get('artist')), + ('Other Video Libraries', sections.get('other_video')) + ] if v is not None]) + + return groups def build_params(self): parameters = self._build_params()