# global config for all operations on S3 storages
[S3]
# --s3-endpoint
#Endpoint="%%GOCFL_S3_ENDPOINT%%"
# --s3-access-key-id
#AccessKeyID="%%GOCFL_S3_ACCESS_KEY_ID%%"
# --s3-secret-access-key
#AccessKey="%%GOCFL_S3_ACCESS_KEY%%"
# --s3-region
#Region="%%GOCFL_S3_REGION%%"

[log]
# "trace"
# "debug"
# "info" 
# "warn" 
# "error"
# "fatal"
# "panic"
level = "info"

[log.stash]
#logstash_host="sb-uwf4.swissbib.unibas.ch"
#logstashhost="localhost"
#logstashport=5046
#logstashtracelevel="ERROR"
#namespace="gocfl"
#dataset=""
#dataset="logs-mediaserver"
#[log.stash.tls]
#type="file"
#cert="certs/ub-log.ub.unibas.ch.cert.pem"
#key="certs/ub-log.ub.unibas.ch.key.pem"
#ca=["certs/ca.crt"]
#interval="1h"

[AES]
Enable=false
KeepassFile="c:/temp/test.kdbx"
KeepassEntry="keepass2://test.kdbx/Root/gocfl/test"
KeepassKey="%%GOCFL_KEEPASS_KEY%%"

[Init]
# --ocfl-version
OCFLVersion="1.1"
# --default-storageroot-extensions
StorageRootExtensions="/home/ocfl/gocfl/config/extensions/storageroot"
# --digest
Digest="sha512"

[Add]
# --message
Message="initial commit"
# --digest
Digest="sha512"
# --fixity
Fixity=["sha256", "sha1", "md5"]
# --default-object-extensions
ObjectExtensions="/home/ocfl/gocfl/config/extensions/object"

DefaultArea="content"

[Add.User]
# --user-name
Name="User OCFL"
# --user-address
Address="mailto:ocfl.user@unibas.ch"

#
# Extension parameter
#
[Extension]
[Extension.NNNN-metafile]
Source=""

[Extension.NNNN-mets]
# --ext-NNNN-mets-descriptive-metadata
descriptive-metadata="other:metadata:info.json"
#
# Indexer
#
[Indexer]
Enabled=true
# Enable this, if there are problem detecting length of audio files with ffmpeg
LocalCache=false

[Indexer.Checksum]
Enabled=true
Digest=["sha512", "blake2b-384"]

[Indexer.XML]
Enabled=true
[Indexer.XML.Format.document]
Attributes.xmlns = "http://www.abbyy.com/FineReader_xml/FineReader10-schema-v1.xml"
Type = "ocr"
Subtype = "FineReader10"
Mime = "application/xml"
[Indexer.XML.Format."mets:mets"]
Regexp = true
Attributes."xmlns:mets" = "^https?://www.loc.gov/METS/?$"
Type = "metadata"
Subtype = "METS"
Mime = "application/xml"

[Indexer.Siegfried]
Enabled=true
#Signature = "/usr/share/siegfried/default.sig"
#Signature = "file://C:/Users/micro/siegfried/default.sig"
Signature = "internal:/siegfried/default.sig"

# mapping of pronom id to mimetype if not found in siegfried
[Indexer.Siegfried.MimeMap]
"x-fmt/92" = "image/psd"
"fmt/134" = "audio/mp3"
"x-fmt/184" = "image/x-sun-raster"
"fmt/202" = "image/x-nikon-nef"
"fmt/211" = "image/x-photo-cd"
"x-fmt/383" = "image/fits"
"fmt/405" = "image/x-portable-anymap"
"fmt/406" = "image/x-portable-graymap"
"fmt/408" = "image/x-portable-pixmap"
"fmt/436" = "image/x-adobe-dng"
"fmt/437" = "image/x-adobe-dng"
"fmt/592" = "image/x-canon-cr2"
"fmt/642" = "image/x-raw-fuji"
"fmt/662" = "image/x-raw-panasonic"
"fmt/668" = "image/x-olympus-orf"
"fmt/986" = "text/xmp"
"fmt/1001" = "image/x-exr"
"fmt/1040" = "image/vnd.ms-dds"
"fmt/1781" = "image/x-pentax-pef"

# relevance of mimetype for sorting
# relevance < 100: rate down
# relevance > 100: rate up
# default = 100
[Indexer.MimeRelevance.1]
Regexp = "^application/octet-stream"
Weight = 1
[Indexer.MimeRelevance.2]
Regexp = "^text/plain"
Weight = 3
[Indexer.MimeRelevance.3]
Regexp = "^audio/mpeg"
Weight = 6
[Indexer.MimeRelevance.4]
Regexp = "^video/mpeg"
Weight = 5
[Indexer.MimeRelevance.5]
Regexp = "^application/vnd\\..+"
Weight = 4
[Indexer.MimeRelevance.6]
Regexp = "^application/rtf"
Weight = 4
[Indexer.MimeRelevance.7]
Regexp = "^application/.+"
Weight = 2
[Indexer.MimeRelevance.8]
Regexp = "^text/.+"
Weight = 4
[Indexer.MimeRelevance.9]
Regexp = "^audio/.+"
Weight = 5
[Indexer.MimeRelevance.10]
Regexp = "^video/.+"
Weight = 4
[Indexer.MimeRelevance.11]
Regexp = "^.+/x-.+"
Weight = 80

[Indexer.FFMPEG]
ffprobe = "ffprobe"
wsl = false  # true, if executable is within linux subsystem on windows
timeout = "25s"
online = true
enabled = true
[[Indexer.FFMPEG.Mime]]
video = false
audio = true
format = "mov,mp4,m4a,3gp,3g2,mj2"
mime = "audio/mp4"
[[Indexer.FFMPEG.Mime]]
video = true
audio = true
format = "mov,mp4,m4a,3gp,3g2,mj2"
mime = "video/mp4"
[[Indexer.FFMPEG.Mime]]
video = true
audio = false
format = "mov,mp4,m4a,3gp,3g2,mj2"
mime = "video/mp4"

[Indexer.ImageMagick]
identify = "identify"
convert = "convert"
wsl = false  # true, if executable is within linux subsystem on windows
timeout = "480s"
online = true
enabled = true

[Indexer.Tika]
addressMeta = "http://localhost:9998/meta"
addressFulltext = "http://localhost:9998/tika"
#address = "http://localhost:9998/rmeta/text"
timeout = "10s"
regexpMimeFulltext = "^application/(pdf|vnd\\.oasis.opendocument.+|vnd\\.openxmlformats.+|vnd\\.ms-.+)" # "^.*$" # ""^application/.*$"  # regexp for mimetype, which are used for tika queries
regexpMimeFulltextNot = "" # "^.*$" # ""^application/.*$"
regexpMimeMeta = ""
regexpMimeMetaNot = "^(image|video|audio)/.*$"
online = true
enabled = true

#
# Thumbnail
#
[Thumbnail]
Enable=true
Background="none"

[Thumbnail.Function.CR2]
ID = "CR2#01"
Title = "Thumbnail from Canon CR2"
Command = "convert 'CR2:{source}' -resize {width}x{height} -auto-orient -background {background} -gravity Center -extent {width}x{height} '{destination}' "
Timeout = "2m"
Pronoms = ["fmt/592"]

[Thumbnail.Function.Images]
ID = "Image#01"
Title = "Thumbnail from Image"
Command = "convert '{source}' -resize {width}x{height} -auto-orient -background {background} -gravity Center -extent {width}x{height} '{destination}' "
Timeout = "2m"
Mime = ["image/.+"]

[Thumbnail.Function.Audio]
ID = "Audio#01"
Title = "Spectrogram from Audio"
Command = "ffmpeg -i {source} -lavfi showspectrumpic=s={width}x{height} {destination} "
Timeout = "2m"
Mime = ["audio/.+"]

[Thumbnail.Function.PDF]
ID = "PDF#01"
Title = "Thumbnail from Image"
Command = "/home/ocfl/gocfl/config/scripts/pdf2thumb.sh -Source {source} -Destination {destination} -Background {background} -Width {width} -Height {height}"
Timeout = "2m"
Mime = ["application/pdf"]

[Thumbnail.Function.Video]
ID = "Video#01"
Title = "Thumbnail from Video"
Command = "/home/ocfl/gocfl/config/scripts/video2thumb.sh -Source {source} -Destination {destination} -Background {background} -Width {width} -Height {height}"
Timeout = "2m"
Mime = ["video/.+"]

#
# Migration
#
[Migration]
# --with-migration
Enable=true

[Migration.Function.CR2]
ID = "CR2#01"
Title = "Convert Canon CR2 to PNG"
Command = "convert 'CR2:{source}' '{destination}' "
Strategy = "folder"
FilenameRegexp = "^(.+/)?([^/]+)$"
FilenameReplacement = "${2}.png"
Timeout = "2m"
Pronoms = ["fmt/592"]

[Migration.Function.Image]
ID = "Image#01"
Title = "Convert Image to PNG"
Command = "convert '{source}' '{destination}' "
Strategy = "folder"
FilenameRegexp = "^(.+/)?([^/]+)$"
FilenameReplacement = "${2}.png"
Timeout = "2m"
Pronoms = ["fmt/202","fmt/436","fmt/437","x-fmt/367","fmt/528","fmt/662", "fmt/1101"]

[Migration.Function.PDFA]
ID = "PDFA#01"
Title = "Convert Acrobat PDF to PDF/A - Portable Document Format 2a"
Command = "gs -dBATCH -dNOPAUSE -dNOSAFER -sDEVICE=pdfwrite -dPDFA=2 -sColorConversionStrategy=RGB -dPDFACompatibilityPolicy=1 --permit-file-read='/tmp/' -sOutputFile='{destination}' /home/ocfl/gocfl/config/pdfa_def.ps '{source}'"
#Command = "gs -dBATCH -dNODISPLAY -dNOPAUSE -dNOSAFER -sDEVICE=pdfwrite -dPDFA=2 -sColorConversionStrategy=RGB -dPDFACompatibilityPolicy=1 --permit-file-read='/tmp/' -sOutputFile='{destination}' /home/ocfl/gocfl/config/pdfa_def.ps '{source}'"
#Command = "powershell -command C:/daten/go/dev/gocfl/data/migration/pdfa.ps1"
Strategy = "folder"
FilenameRegexp = "^(.+/)?([^/]+)$"
FilenameReplacement = "${2}"
Timeout = "2m"
Pronoms = ["fmt/14","fmt/15","fmt/16","fmt/17","fmt/18","fmt/19","fmt/276","fmt/95","fmt/354","fmt/493","fmt/144","fmt/145","fmt/157","fmt/146","fmt/147","fmt/158","fmt/148","fmt/488","fmt/489","fmt/490","fmt/492","fmt/491","fmt/1129","fmt/1451"]
# "fmt/14": Acrobat PDF 1.0 - Portable Document Format
# "fmt/15": Acrobat PDF 1.1 - Portable Document Format
# "fmt/16": Acrobat PDF 1.2 - Portable Document Format
# "fmt/17": Acrobat PDF 1.3 - Portable Document Format
# "fmt/18": Acrobat PDF 1.4 - Portable Document Format
# "fmt/19": Acrobat PDF 1.5 - Portable Document Format
# "fmt/20": Acrobat PDF 1.6 - Portable Document Format
# "fmt/276": Acrobat PDF 1.7 - Portable Document Format
# "fmt/95": Acrobat PDF/A - Portable Document Format	1a
# "fmt/354": Acrobat PDF/A - Portable Document Format	1b
# "fmt/476": Acrobat PDF/A - Portable Document Format	2a
# "fmt/477": Acrobat PDF/A - Portable Document Format	2b
# "fmt/478": Acrobat PDF/A - Portable Document Format	2u
# "fmt/479": Acrobat PDF/A - Portable Document Format	3a
# "fmt/480": Acrobat PDF/A - Portable Document Format	3b
# "fmt/481": Acrobat PDF/A - Portable Document Format	3u
# "fmt/493": Acrobat PDF/E - Portable Document Format for Engineering PDF/E-1
# "fmt/144": Acrobat PDF/X - Portable Document Format - Exchange 1:1999
# "fmt/145": Acrobat PDF/X - Portable Document Format - Exchange 2:2001
# "fmt/157": Acrobat PDF/X - Portable Document Format - Exchange 1a:2001
# "fmt/146": Acrobat PDF/X - Portable Document Format - Exchange 1a:2003
# "fmt/147": Acrobat PDF/X - Portable Document Format - Exchange 2:2002
# "fmt/158": Acrobat PDF/X - Portable Document Format - Exchange 3:2002
# "fmt/148": Acrobat PDF/X - Portable Document Format - Exchange 3:2003
# "fmt/488": Acrobat PDF/X - Portable Document Format - Exchange PDF/X-4
# "fmt/489": Acrobat PDF/X - Portable Document Format - Exchange PDF/X-4p
# "fmt/490": Acrobat PDF/X - Portable Document Format - Exchange PDF/X-5g
# "fmt/492": Acrobat PDF/X - Portable Document Format - Exchange PDF/X-5n
# "fmt/491": Acrobat PDF/X - Portable Document Format - Exchange PDF/X-5pg
# "fmt/1129": PDF 2.0 - Portable Document Format - 2.0
# "fmt/1451": PDF Portfolio - 1.7

[Migration.Function.PDFA2]
ID = "PDFA#02"
Title = "Convert non Acrobat PDF to PDF/A - Portable Document Format 2a"
Command = "gs -dBATCH -dNOPAUSE -dNOSAFER -sDEVICE=pdfwrite -dPDFA=2 -sColorConversionStrategy=RGB -dPDFACompatibilityPolicy=1 --permit-file-read='/tmp/' -sOutputFile='{destination}' /home/ocfl/gocfl/config/pdfa_def.ps '{source}'"
#Command = "gs -dBATCH -dNODISPLAY -dNOPAUSE -dNOSAFER -sDEVICE=pdfwrite -dPDFA=2 -sColorConversionStrategy=RGB -dPDFACompatibilityPolicy=1 --permit-file-read='C:/Users/micro/AppData/Local/Temp/' -sOutputFile='{destination}' c:/daten/go/dev/gocfl/data/migration/pdfa_def.ps '{source}'"
#Command = "powershell -command C:/daten/go/dev/gocfl/data/migration/pdfa.ps1"
Strategy = "folder"
FilenameRegexp = "^(.+/)?([^/]+)$"
FilenameReplacement = "${2}.pdf"
Timeout = "2m"
Pronoms = ["fmt/20"]


[Migration.Function.EPS]
ID = "EPS#01"
Title = "Convert non Acrobat PDF to PDF/A - Portable Document Format 2a"
Command = "gs -dBATCH -dNOPAUSE -dNOSAFER -sDEVICE=pdfwrite -dPDFA=2 -sColorConversionStrategy=RGB -dPDFACompatibilityPolicy=1 --permit-file-read='/tmp/' -sOutputFile='{destination}' /home/ocfl/gocfl/config/pdfa_def.ps '{source}'"
#Command = "gs[5~ -dBATCH -dNODISPLAY -dNOPAUSE -dNOSAFER -sDEVICE=pdfwrite -dPDFA=2 -sColorConversionStrategy=RGB -dPDFACompatibilityPolicy=1 --permit-file-read='C:/Users/micro/AppData/Local/Temp/' -sOutputFile='{destination}' c:/daten/go/dev/gocfl/data/migration/pdfa_def.ps '{source}'"
#Command = "powershell -command C:/daten/go/dev/gocfl/data/migration/pdfa.ps1"
Strategy = "folder"
FilenameRegexp = "^(.+/)?([^/]+)$"
FilenameReplacement = "${2}.pdf"
Timeout = "2m"
Pronoms = ["fmt/124"]
