mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Add support for setting metadata on image conversion.
This commit is contained in:
@@ -1109,6 +1109,13 @@ namespace DiscImageChef.DiscImages
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool SetMetadata(ImageInfo metadata)
|
||||||
|
{
|
||||||
|
header.DiskName = metadata.MediaTitle ?? "-DiscImageChef converted image-";
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static uint DC42CheckSum(byte[] buffer)
|
static uint DC42CheckSum(byte[] buffer)
|
||||||
{
|
{
|
||||||
uint dc42Chk = 0;
|
uint dc42Chk = 0;
|
||||||
|
|||||||
@@ -133,5 +133,12 @@ namespace DiscImageChef.DiscImages
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||||
bool Close();
|
bool Close();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets image metadata
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="metadata"><see cref="ImageInfo"/> containing image metadata</param>
|
||||||
|
/// <returns><c>true</c> if operating completed successfully, <c>false</c> otherwise</returns>
|
||||||
|
bool SetMetadata(ImageInfo metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,13 +45,27 @@ namespace DiscImageChef.Commands
|
|||||||
{
|
{
|
||||||
public static void DoConvert(ConvertImageOptions options)
|
public static void DoConvert(ConvertImageOptions options)
|
||||||
{
|
{
|
||||||
DicConsole.DebugWriteLine("Analyze command", "--debug={0}", options.Debug);
|
DicConsole.DebugWriteLine("Analyze command", "--debug={0}", options.Debug);
|
||||||
DicConsole.DebugWriteLine("Analyze command", "--verbose={0}", options.Verbose);
|
DicConsole.DebugWriteLine("Analyze command", "--verbose={0}", options.Verbose);
|
||||||
DicConsole.DebugWriteLine("Analyze command", "--input={0}", options.InputFile);
|
DicConsole.DebugWriteLine("Analyze command", "--input={0}", options.InputFile);
|
||||||
DicConsole.DebugWriteLine("Analyze command", "--output={0}", options.OutputFile);
|
DicConsole.DebugWriteLine("Analyze command", "--output={0}", options.OutputFile);
|
||||||
DicConsole.DebugWriteLine("Analyze command", "--format={0}", options.OutputFormat);
|
DicConsole.DebugWriteLine("Analyze command", "--format={0}", options.OutputFormat);
|
||||||
DicConsole.DebugWriteLine("Analyze command", "--count={0}", options.Count);
|
DicConsole.DebugWriteLine("Analyze command", "--count={0}", options.Count);
|
||||||
DicConsole.DebugWriteLine("Analyze command", "--force={0}", options.Force);
|
DicConsole.DebugWriteLine("Analyze command", "--force={0}", options.Force);
|
||||||
|
DicConsole.DebugWriteLine("Analyze command", "--creator={0}", options.Creator);
|
||||||
|
DicConsole.DebugWriteLine("Analyze command", "--media-title={0}", options.MediaTitle);
|
||||||
|
DicConsole.DebugWriteLine("Analyze command", "--comments={0}", options.Comments);
|
||||||
|
DicConsole.DebugWriteLine("Analyze command", "--media-manufacturer={0}", options.MediaManufacturer);
|
||||||
|
DicConsole.DebugWriteLine("Analyze command", "--media-model={0}", options.MediaModel);
|
||||||
|
DicConsole.DebugWriteLine("Analyze command", "--media-serial={0}", options.MediaSerialNumber);
|
||||||
|
DicConsole.DebugWriteLine("Analyze command", "--media-barcode={0}", options.MediaBarcode);
|
||||||
|
DicConsole.DebugWriteLine("Analyze command", "--media-partnumber={0}", options.MediaPartNumber);
|
||||||
|
DicConsole.DebugWriteLine("Analyze command", "--media-sequence={0}", options.MediaSequence);
|
||||||
|
DicConsole.DebugWriteLine("Analyze command", "--media-lastsequence={0}", options.LastMediaSequence);
|
||||||
|
DicConsole.DebugWriteLine("Analyze command", "--drive-manufacturer={0}", options.DriveManufacturer);
|
||||||
|
DicConsole.DebugWriteLine("Analyze command", "--drive-model={0}", options.DriveModel);
|
||||||
|
DicConsole.DebugWriteLine("Analyze command", "--drive-serial={0}", options.DriveSerialNumber);
|
||||||
|
DicConsole.DebugWriteLine("Analyze command", "--drive-revision={0}", options.DriveFirmwareRevision);
|
||||||
|
|
||||||
if(options.Count == 0)
|
if(options.Count == 0)
|
||||||
{
|
{
|
||||||
@@ -141,16 +155,16 @@ namespace DiscImageChef.Commands
|
|||||||
|
|
||||||
IWritableImage outputFormat = candidates[0];
|
IWritableImage outputFormat = candidates[0];
|
||||||
|
|
||||||
|
if(options.Verbose)
|
||||||
|
DicConsole.VerboseWriteLine("Output image format: {0} ({1}).", outputFormat.Name, outputFormat.Id);
|
||||||
|
else DicConsole.WriteLine("Output image format: {0}.", outputFormat.Name);
|
||||||
|
|
||||||
if(!outputFormat.SupportedMediaTypes.Contains(inputFormat.Info.MediaType))
|
if(!outputFormat.SupportedMediaTypes.Contains(inputFormat.Info.MediaType))
|
||||||
{
|
{
|
||||||
DicConsole.ErrorWriteLine("Output format does not support media type, cannot continue...");
|
DicConsole.ErrorWriteLine("Output format does not support media type, cannot continue...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(options.Verbose)
|
|
||||||
DicConsole.VerboseWriteLine("Output image format: {0} ({1}).", outputFormat.Name, outputFormat.Id);
|
|
||||||
else DicConsole.WriteLine("Output image format: {0}.", outputFormat.Name);
|
|
||||||
|
|
||||||
foreach(MediaTagType mediaTag in inputFormat.Info.ReadableMediaTags)
|
foreach(MediaTagType mediaTag in inputFormat.Info.ReadableMediaTags)
|
||||||
{
|
{
|
||||||
if(outputFormat.SupportedMediaTags.Contains(mediaTag) || options.Force) continue;
|
if(outputFormat.SupportedMediaTags.Contains(mediaTag) || options.Force) continue;
|
||||||
@@ -184,6 +198,38 @@ namespace DiscImageChef.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImageInfo metadata = new ImageInfo
|
||||||
|
{
|
||||||
|
Application = "DiscImageChef",
|
||||||
|
ApplicationVersion = "", // TODO
|
||||||
|
Comments = options.Comments,
|
||||||
|
Creator = options.Creator,
|
||||||
|
DriveFirmwareRevision = options.DriveFirmwareRevision,
|
||||||
|
DriveManufacturer = options.DriveManufacturer,
|
||||||
|
DriveModel = options.DriveModel,
|
||||||
|
DriveSerialNumber = options.DriveSerialNumber,
|
||||||
|
LastMediaSequence = options.LastMediaSequence,
|
||||||
|
MediaBarcode = options.MediaBarcode,
|
||||||
|
MediaManufacturer = options.MediaManufacturer,
|
||||||
|
MediaModel = options.MediaModel,
|
||||||
|
MediaPartNumber = options.MediaPartNumber,
|
||||||
|
MediaSequence = options.MediaSequence,
|
||||||
|
MediaSerialNumber = options.MediaSerialNumber,
|
||||||
|
MediaTitle = options.MediaTitle
|
||||||
|
};
|
||||||
|
|
||||||
|
if(!outputFormat.SetMetadata(metadata))
|
||||||
|
{
|
||||||
|
DicConsole.ErrorWrite("Error {0} setting metadata, ", outputFormat.ErrorMessage);
|
||||||
|
if(!options.Force)
|
||||||
|
{
|
||||||
|
DicConsole.ErrorWriteLine("not continuing...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DicConsole.ErrorWriteLine("continuing...");
|
||||||
|
}
|
||||||
|
|
||||||
List<Track> tracks;
|
List<Track> tracks;
|
||||||
|
|
||||||
try { tracks = inputFormat.Tracks; }
|
try { tracks = inputFormat.Tracks; }
|
||||||
|
|||||||
@@ -375,5 +375,42 @@ namespace DiscImageChef
|
|||||||
HelpText =
|
HelpText =
|
||||||
"Continue conversion even if sector or media tags will be lost in the process.")]
|
"Continue conversion even if sector or media tags will be lost in the process.")]
|
||||||
public bool Force { get; set; }
|
public bool Force { get; set; }
|
||||||
|
|
||||||
|
[Option("creator", Default = null, HelpText = "Who (person) created the image?")]
|
||||||
|
public string Creator { get; set; }
|
||||||
|
[Option("media-title", Default = null, HelpText = "Title of the media represented by the image")]
|
||||||
|
public string MediaTitle { get; set; }
|
||||||
|
[Option("comments", Default = null, HelpText = "Image comments")]
|
||||||
|
public string Comments { get; set; }
|
||||||
|
[Option("media-manufacturer", Default = null, HelpText = "Manufacturer of the media represented by the image")]
|
||||||
|
public string MediaManufacturer { get; set; }
|
||||||
|
[Option("media-model", Default = null, HelpText = "Model of the media represented by the image")]
|
||||||
|
public string MediaModel { get; set; }
|
||||||
|
[Option("media-serial", Default = null, HelpText = "Serial number of the media represented by the image")]
|
||||||
|
public string MediaSerialNumber { get; set; }
|
||||||
|
[Option("media-barcode", Default = null, HelpText = "Barcode of the media represented by the image")]
|
||||||
|
public string MediaBarcode { get; set; }
|
||||||
|
[Option("media-partnumber", Default = null, HelpText = "Part number of the media represented by the image")]
|
||||||
|
public string MediaPartNumber { get; set; }
|
||||||
|
[Option("media-sequence", Default = 0, HelpText = "Number in sequence for the media represented by the image")]
|
||||||
|
public int MediaSequence { get; set; }
|
||||||
|
[Option("media-lastsequence", Default = 0,
|
||||||
|
HelpText =
|
||||||
|
"Last media of the sequence the media represented by the image corresponds to")]
|
||||||
|
public int LastMediaSequence { get; set; }
|
||||||
|
[Option("drive-manufacturer", Default = null,
|
||||||
|
HelpText =
|
||||||
|
"Manufacturer of the drive used to read the media represented by the image")]
|
||||||
|
public string DriveManufacturer { get; set; }
|
||||||
|
[Option("drive-model", Default = null,
|
||||||
|
HelpText = "Model of the drive used to read the media represented by the image")]
|
||||||
|
public string DriveModel { get; set; }
|
||||||
|
[Option("drive-serial", Default = null,
|
||||||
|
HelpText = "Serial number of the drive used to read the media represented by the image")]
|
||||||
|
public string DriveSerialNumber { get; set; }
|
||||||
|
[Option("drive-revision", Default = null,
|
||||||
|
HelpText =
|
||||||
|
"Firmware revision of the drive used to read the media represented by the image")]
|
||||||
|
public string DriveFirmwareRevision { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user