Ejemplo n.º 1
0
        public static void ProcessItem(Item fileItem, DatabaseOperations dbOp)
        {
            // Set the fileItem's source path. The source path may be used by meta providers.
            fileItem.SourcePath = dbOp.BagLocation + "\\" + fileItem.Id;
            List <IMetaProvider> provOut;

            _metaProviderMap.TryGetValue(fileItem.Extension.ToLower(), out provOut);

            List <IMetaProvider> providers = new List <IMetaProvider>();

            // Add the default provider
            providers.Add(_defaultMetaProvider);

            if (provOut != null)
            {
                providers.AddRange(provOut);
            }

            // Iterate over all providers and let them do their thing
            foreach (IMetaProvider provider in providers)
            {
                TableRow row = provider.ProcessItem(fileItem);
                // Always add an itemId column. This should be the table's key.
                if (row != null)
                {
                    row.AddColumn("itemId", fileItem.Id);
                }
                // Insert the newly obtained metadata in the database
                try {
                    dbOp.InsertTableRow(row);
                } catch (SQLiteException ex) {
                    MjDebug.Log(ex.Message);
                }
            }
        }
Ejemplo n.º 2
0
        public TableRow ProcessItem(Item fileItem)
        {
            TableRow res  = new TableRow(TABLE_NAME);
            string   path = fileItem.SourcePath;

            TagLib.File file = TagLib.File.Create(path);

            uint   year  = file.Tag.Year;
            string album = file.Tag.Album;

            string[] artist = file.Tag.AlbumArtists;
            string   title  = file.Tag.Title;

            res.AddColumn("artist", artist[0]);
            res.AddColumn("album", album);
            res.AddColumn("title", title);

            return(res);
        }
Ejemplo n.º 3
0
        public TableRow ProcessItem(Item fileItem)
        {
            TableRow res  = new TableRow(TABLE_NAME);
            string   path = fileItem.SourcePath;

            try {
                using (ExifReader reader = new ExifReader(path)) {
                    string   outputStr;
                    double   outputDouble;
                    DateTime outputDate;
                    UInt16   outputUInt16;

                    if (reader.GetTagValue <string>(ExifTags.Artist, out outputStr))
                    {
                        res.AddColumn("artist", outputStr);
                    }

                    if (reader.GetTagValue <double>(ExifTags.FNumber, out outputDouble))
                    {
                        res.AddColumn("f-stop", Convert.ToString(outputDouble));
                    }

                    if (reader.GetTagValue <UInt16>(ExifTags.PhotographicSensitivity, out outputUInt16))
                    {
                        res.AddColumn("iso", Convert.ToString(outputUInt16));
                    }

                    if (reader.GetTagValue <string>(ExifTags.Model, out outputStr))
                    {
                        res.AddColumn("model", outputStr);
                    }
                }
            } catch (ExifLibException ex) {
                MjDebug.Log(ex.Message);
                return(null);
            } catch (IOException ex) {
                MjDebug.Log(ex.Message);
                return(null);
            }

            return(res);
        }
Ejemplo n.º 4
0
        public TableRow ProcessItem(Item fileItem)
        {
            TableRow row = new TableRow(TABLE_NAME);

            row.AddColumn("name", fileItem.Name);
            row.AddColumn("ext", fileItem.Extension.ToLower());
            row.AddColumn("size", fileItem.Size.ToString());
            row.AddColumn("attr", ((int)fileItem.Attributes).ToString());
            row.AddColumn("lat", fileItem.LastAccesTime.ToString());
            row.AddColumn("lwt", fileItem.LastWriteTime.ToString());
            row.AddColumn("ct", fileItem.CreationTime.ToString());
            return(row);
        }