Skip to content

Commit 380add5

Browse files
authored
Merge pull request #1149 from ittner/improvements-for-podcast-search-rule
Improvements for podcast search rule
2 parents 49174d5 + 0457fe2 commit 380add5

File tree

2 files changed

+26
-29
lines changed

2 files changed

+26
-29
lines changed

doc/html/searching_en.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,24 @@ <h4>Permanent Searches with Search Folders</h4>
143143
<tr><td style="background:#bfb">
144144
<b>Podcast included</b>
145145
</td><td>
146-
<b>Adds</b> all items that contain an enclosure to the search folder.
146+
<b>Adds</b> all items that contain a podcast to the search folder. For this rule, podcast is assumed to be any enclosure for an audio file.
147147
</td></tr>
148148
<!-- ----------------------------------------- -->
149149
<tr><td style="background:#fbb">
150150
<b>Podcast not included</b>
151151
</td><td>
152+
<b>Removes</b> all items that do not contain a podcast (i.e. an enclosure for an audio file) from the search folder.
153+
</td></tr>
154+
<!-- ----------------------------------------- -->
155+
<tr><td style="background:#bfb">
156+
<b>Enclosure included</b>
157+
</td><td>
158+
<b>Adds</b> all items that contain an enclosure (for any file type) to the search folder.
159+
</td></tr>
160+
<!-- ----------------------------------------- -->
161+
<tr><td style="background:#fbb">
162+
<b>Enclosure not included</b>
163+
</td><td>
152164
<b>Removes</b> all items that do not contain an enclosure from the search folder.
153165
</td></tr>
154166
</table>

src/rule.c

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -149,41 +149,26 @@ rule_check_item_has_enc (rulePtr rule, itemPtr item)
149149
return item->hasEnclosure;
150150
}
151151

152-
static void
153-
rule_check_item_has_podcast_metadata_cb ( const gchar *key, const gchar *value,
154-
guint index, gpointer user_data )
155-
{
156-
gboolean *found = (gboolean *) user_data;
157-
if (*found) {
158-
return; /* Already found, nothing else to do. */
159-
}
160-
if (g_strcmp0(key, "enclosure") != 0) {
161-
return;
162-
}
163-
enclosurePtr encl = enclosure_from_string (value);
164-
if (encl != NULL) {
165-
if (encl->mime && g_str_has_prefix (encl->mime, "audio/")) {
166-
*found = TRUE;
167-
}
168-
enclosure_free (encl);
169-
}
170-
}
171-
172152
static gboolean
173153
rule_check_item_has_podcast (rulePtr rule, itemPtr item)
174154
{
175-
if (!item->hasEnclosure) {
176-
return FALSE; /* Optimization. */
177-
}
178-
155+
GSList *iter = metadata_list_get_values (item->metadata, "enclosure");
179156
gboolean found = FALSE;
180-
metadata_list_foreach(item->metadata,
181-
rule_check_item_has_podcast_metadata_cb,
182-
&found);
157+
enclosurePtr encl;
158+
159+
while (iter && !found) {
160+
enclosurePtr encl = enclosure_from_string ((gchar *)iter->data);
161+
if (encl != NULL) {
162+
if (encl->mime && g_str_has_prefix (encl->mime, "audio/")) {
163+
found = TRUE;
164+
}
165+
enclosure_free (encl);
166+
}
167+
iter = g_slist_next (iter);
168+
}
183169
return found;
184170
}
185171

186-
187172
static gboolean
188173
rule_check_item_category (rulePtr rule, itemPtr item)
189174
{

0 commit comments

Comments
 (0)