[rygel/rygel-0-16] media-export: Drop file suffix filter
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/rygel-0-16] media-export: Drop file suffix filter
- Date: Mon, 17 Sep 2012 22:29:45 +0000 (UTC)
commit 9cc882f47facb5688a8fcb44de8ef32531045b65
Author: Jens Georg <mail jensge org>
Date: Mon Sep 17 13:43:48 2012 +0200
media-export: Drop file suffix filter
Use content-type based filter instead
data/rygel.conf | 1 -
doc/man/rygel.conf.xml | 8 ----
.../media-export/rygel-media-export-harvester.vala | 45 ++++----------------
.../rygel-media-export-harvesting-task.vala | 15 +++----
4 files changed, 16 insertions(+), 53 deletions(-)
---
diff --git a/data/rygel.conf b/data/rygel.conf
index 4f3ad22..35b3f01 100644
--- a/data/rygel.conf
+++ b/data/rygel.conf
@@ -112,7 +112,6 @@ title= REALNAME@'s media
# * @PICTURES@: The standard pictures folder (typically ${HOME}/Pictures).
#
uris= MUSIC@;@VIDEOS@;@PICTURES@
-include-filter=.mp3;.oga;.ogv;.ogg;.mkv;.avi;.mp4;.m4v;.m4a;.mpeg;.mpg;.ts;.flac;.jpeg;.jpg;.png;.wav;.wma;.wmv;.asf;.mpc;.mpp;.wv;.aac;.mka;.mp2;.webm;.ape;.m2ts
extract-metadata=true
monitor-changes=true
diff --git a/doc/man/rygel.conf.xml b/doc/man/rygel.conf.xml
index 82c000a..1d70476 100644
--- a/doc/man/rygel.conf.xml
+++ b/doc/man/rygel.conf.xml
@@ -373,14 +373,6 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
</varlistentry>
<varlistentry>
<term>
- <option>include-filter</option>
- </term>
- <listitem>
- <para>A list of filename extensions. If this option is omitted or empty, every file will be analyzed for meta-data. The extensions are case-insensitive.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
<option>extract-metadata</option>
</term>
<listitem>
diff --git a/src/plugins/media-export/rygel-media-export-harvester.vala b/src/plugins/media-export/rygel-media-export-harvester.vala
index 769558a..7c9a06c 100644
--- a/src/plugins/media-export/rygel-media-export-harvester.vala
+++ b/src/plugins/media-export/rygel-media-export-harvester.vala
@@ -30,7 +30,6 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
private HashMap<File, uint> extraction_grace_timers;
private MetadataExtractor extractor;
private RecursiveFileMonitor monitor;
- private Regex file_filter;
private Cancellable cancellable;
// Properties
@@ -60,7 +59,6 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
(EqualFunc) File.equal);
this.extraction_grace_timers = new HashMap<File, uint> (File.hash,
(EqualFunc)File.equal);
- this.create_file_filter ();
}
/**
@@ -85,7 +83,6 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
var task = new HarvestingTask (new MetadataExtractor (),
this.monitor,
- this.file_filter,
file,
parent,
flag);
@@ -126,34 +123,6 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
}
}
- /**
- * Construct positive filter from config
- *
- * Takes a list of file extensions from config, escapes them and builds a
- * regular expression to match against the files encountered.
- */
- private void create_file_filter () {
- try {
- var config = MetaConfig.get_default ();
- var extensions = config.get_string_list ("MediaExport",
- "include-filter");
-
- // never trust user input
- string[] escaped_extensions = new string[0];
- foreach (var extension in extensions) {
- escaped_extensions += Regex.escape_string (extension);
- }
-
- var list = string.joinv ("|", escaped_extensions);
- this.file_filter = new Regex (
- "(%s)$".printf (list),
- RegexCompileFlags.CASELESS |
- RegexCompileFlags.OPTIMIZE);
- } catch (Error error) {
- this.file_filter = null;
- }
- }
-
private void on_file_changed (File file,
File? other,
FileMonitorEvent event) {
@@ -177,11 +146,15 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
file.get_uri ());
try {
var cache = MediaCache.get_default ();
- var type = file.query_file_type (FileQueryInfoFlags.NONE,
- this.cancellable);
- if (type == FileType.DIRECTORY ||
- this.file_filter == null ||
- this.file_filter.match (file.get_uri ())) {
+ var info = file.query_info (FileAttribute.STANDARD_TYPE + "," +
+ FileAttribute.STANDARD_CONTENT_TYPE,
+ FileQueryInfoFlags.NONE,
+ this.cancellable);
+ if (info.get_file_type () == FileType.DIRECTORY ||
+ info.get_content_type ().has_prefix ("image/") ||
+ info.get_content_type ().has_prefix ("video/") ||
+ info.get_content_type ().has_prefix ("audio/") ||
+ info.get_content_type () == "application/ogg") {
string id;
try {
MediaContainer parent_container = null;
diff --git a/src/plugins/media-export/rygel-media-export-harvesting-task.vala b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
index 72c5428..d8d89b3 100644
--- a/src/plugins/media-export/rygel-media-export-harvesting-task.vala
+++ b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
@@ -29,7 +29,6 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine,
private GLib.Queue<MediaContainer> containers;
private Gee.Queue<File> files;
private RecursiveFileMonitor monitor;
- private Regex file_filter;
private string flag;
private MediaContainer parent;
private const int BATCH_SIZE = 256;
@@ -40,12 +39,11 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine,
FileAttribute.STANDARD_NAME + "," +
FileAttribute.STANDARD_TYPE + "," +
FileAttribute.TIME_MODIFIED + "," +
+ FileAttribute.STANDARD_CONTENT_TYPE + "," +
FileAttribute.STANDARD_SIZE;
-
public HarvestingTask (MetadataExtractor extractor,
RecursiveFileMonitor monitor,
- Regex? file_filter,
File file,
MediaContainer parent,
string? flag = null) {
@@ -69,7 +67,6 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine,
this.containers = new GLib.Queue<MediaContainer> ();
this.monitor = monitor;
this.flag = flag;
- this.file_filter = file_filter;
}
public void cancel () {
@@ -187,12 +184,14 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine,
} else {
// Check if the file needs to be harvested at all either because
// it is denied by filter or it hasn't updated
- if (this.file_filter != null &&
- !this.file_filter.match (file.get_uri ())) {
- return false;
+ if (info.get_content_type ().has_prefix ("image/") ||
+ info.get_content_type ().has_prefix ("video/") ||
+ info.get_content_type ().has_prefix ("audio/") ||
+ info.get_content_type () == "application/ogg") {
+ return this.push_if_changed_or_unknown (file, info);
}
- return this.push_if_changed_or_unknown (file, info);
+ return false;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]