@@ -108,25 +108,32 @@ def create(self, inputs):
108
108
109
109
if jam_type in ("daily-jams" , "weekly-jams" ):
110
110
# Remove tracks that have not been listened to before.
111
- never_listened = troi .filters .NeverListenedFilterElement ()
111
+ never_listened = troi .filters .NeverListenedFilterElement (keep_unlistened_if_empty = True )
112
112
never_listened .set_sources (recent_listens_lookup )
113
113
if jam_type == "daily-jams" :
114
114
jam_name = "Daily Jams"
115
115
else :
116
116
jam_name = "Weekly Jams"
117
117
jam_date = "week of " + jam_date
118
+ self .local_storage ["jam_name" ] = jam_name
119
+
120
+ latest_filter = troi .filters .LatestListenedAtFilterElement (DAYS_OF_RECENT_LISTENS_TO_EXCLUDE ,
121
+ keep_unlistened_if_empty = True )
122
+ latest_filter .set_sources (never_listened )
118
123
elif jam_type == "weekly-exploration" :
119
124
# Remove tracks that have been listened to before.
120
125
never_listened = troi .filters .NeverListenedFilterElement (remove_unlistened = False )
121
126
never_listened .set_sources (recent_listens_lookup )
122
127
jam_name = "Weekly Exploration"
123
128
jam_date = "week of " + jam_date
129
+ self .local_storage ["jam_name" ] = jam_name
130
+
131
+ latest_filter = troi .filters .LatestListenedAtFilterElement (DAYS_OF_RECENT_LISTENS_TO_EXCLUDE )
132
+ latest_filter .set_sources (never_listened )
133
+
124
134
else :
125
135
raise RuntimeError ("someone goofed up!" )
126
136
127
- latest_filter = troi .filters .LatestListenedAtFilterElement (DAYS_OF_RECENT_LISTENS_TO_EXCLUDE )
128
- latest_filter .set_sources (never_listened )
129
-
130
137
feedback_lookup = troi .listenbrainz .feedback .ListensFeedbackLookup (user_name , auth_token = inputs .get ("token" ))
131
138
feedback_lookup .set_sources (latest_filter )
132
139
@@ -137,7 +144,7 @@ def create(self, inputs):
137
144
hate_filter .set_sources (recs_lookup )
138
145
139
146
pl_maker = PlaylistMakerElement (name = "%s for %s, %s" % (jam_name , user_name , jam_date ),
140
- desc = "%s playlist!" % jam_name ,
147
+ desc = None ,
141
148
patch_slug = jam_type ,
142
149
max_num_recordings = 50 ,
143
150
max_artist_occurrence = 2 ,
@@ -147,3 +154,18 @@ def create(self, inputs):
147
154
pl_maker .set_sources (hate_filter )
148
155
149
156
return pl_maker
157
+
158
+ def post_process (self ):
159
+ """
160
+ Take the information saved in local_storage and create proper playlist names and descriptions.
161
+ """
162
+
163
+ jam_name = self .local_storage ["jam_name" ]
164
+ if self .local_storage ["latest_listened_was_empty" ]:
165
+ desc = f"We made this { jam_name } playlist from your recommended recording recordings, some of which " + \
166
+ "you may have already listened to recently."
167
+ else :
168
+ desc = f"We made this { jam_name } playlist from your recommended recording recordings to create a " + \
169
+ "comfortable playlist of tracks you've not recently listened to."
170
+
171
+ self .local_storage ["_playlist_desc" ] = desc
0 commit comments