[shotwell/shotwell-0.24] Fix import of files ending in ogg



commit 4e19479c9172dc62cf218e62ba17b4886cfa0c4a
Author: Jens Georg <mail jensge org>
Date:   Sat Feb 25 23:24:31 2017 +0100

    Fix import of files ending in ogg
    
    This will only work for "local" imports, not from camera.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=717305

 src/BatchImport.vala  |    2 +-
 src/VideoSupport.vala |   22 +++++++++++++++++++---
 2 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/src/BatchImport.vala b/src/BatchImport.vala
index 4a46a26..229db93 100644
--- a/src/BatchImport.vala
+++ b/src/BatchImport.vala
@@ -1777,7 +1777,7 @@ private class PrepareFilesJob : BackgroundImportJob {
     private ImportResult prepare_file(BatchImportJob job, File file, File? associated_file, 
         bool copy_to_library, out PreparedFile prepared_file) {
         prepared_file = null;
-        
+
         bool is_video = VideoReader.is_supported_video_file(file);
         
         if ((!is_video) && (!Photo.is_file_image(file)))
diff --git a/src/VideoSupport.vala b/src/VideoSupport.vala
index 540aad4..5076a31 100644
--- a/src/VideoSupport.vala
+++ b/src/VideoSupport.vala
@@ -53,9 +53,24 @@ public class VideoReader {
      }
     
     public static bool is_supported_video_file(File file) {
+        var mime_type = ContentType.guess(file.get_basename(), new uchar[0], null);
+        // special case: deep-check content-type of files ending with .ogg
+        if (mime_type == "audio/ogg" && file.has_uri_scheme("file")) {
+            try {
+                var info = file.query_info(FileAttribute.STANDARD_CONTENT_TYPE,
+                                           FileQueryInfoFlags.NONE);
+                var content_type = info.get_content_type();
+                if (content_type != null && content_type.has_prefix ("video/")) {
+                    return true;
+                }
+            } catch (Error error) {
+                debug("Failed to query content type: %s", error.message);
+            }
+        }
+
         return is_supported_video_filename(file.get_basename());
     }
-    
+
     public static bool is_supported_video_filename(string filename) {
         string mime_type;
         mime_type = ContentType.guess(filename, new uchar[0], null);
@@ -63,7 +78,7 @@ public class VideoReader {
             string? extension = null;
             string? name = null;
             disassemble_filename(filename, out name, out extension);
-            
+
             if (extension == null)
                 return true;
 
@@ -71,9 +86,10 @@ public class VideoReader {
                 if (utf8_ci_compare(s, extension) == 0)
                     return false;
             }
-                
+
             return true;
         } else {
+            debug("Skipping %s, unsupported mime type %s", filename, mime_type);
             return false;
         }
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]