mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Use Aaru Metadata instead of CICM Metadata and convert to it if found.
This commit is contained in:
@@ -912,7 +912,10 @@ public partial class Dump
|
|||||||
|
|
||||||
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
|
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
|
||||||
|
|
||||||
JsonSerializer.Serialize(jsonFs, sidecar, new JsonSerializerOptions
|
JsonSerializer.Serialize(jsonFs, new MetadataJson
|
||||||
|
{
|
||||||
|
AaruMetadata = sidecar
|
||||||
|
}, new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||||
WriteIndented = true
|
WriteIndented = true
|
||||||
|
|||||||
@@ -147,7 +147,10 @@ partial class Dump
|
|||||||
|
|
||||||
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
|
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
|
||||||
|
|
||||||
JsonSerializer.Serialize(jsonFs, sidecar, new JsonSerializerOptions
|
JsonSerializer.Serialize(jsonFs, new MetadataJson
|
||||||
|
{
|
||||||
|
AaruMetadata = sidecar
|
||||||
|
}, new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||||
WriteIndented = true
|
WriteIndented = true
|
||||||
|
|||||||
@@ -876,7 +876,10 @@ partial class Dump
|
|||||||
|
|
||||||
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
|
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
|
||||||
|
|
||||||
JsonSerializer.Serialize(jsonFs, sidecar, new JsonSerializerOptions
|
JsonSerializer.Serialize(jsonFs, new MetadataJson
|
||||||
|
{
|
||||||
|
AaruMetadata = sidecar
|
||||||
|
}, new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||||
WriteIndented = true
|
WriteIndented = true
|
||||||
|
|||||||
@@ -718,7 +718,10 @@ public partial class Dump
|
|||||||
|
|
||||||
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
|
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
|
||||||
|
|
||||||
JsonSerializer.Serialize(jsonFs, sidecar, new JsonSerializerOptions
|
JsonSerializer.Serialize(jsonFs, new MetadataJson
|
||||||
|
{
|
||||||
|
AaruMetadata = sidecar
|
||||||
|
}, new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||||
WriteIndented = true
|
WriteIndented = true
|
||||||
|
|||||||
@@ -1450,7 +1450,10 @@ partial class Dump
|
|||||||
|
|
||||||
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
|
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
|
||||||
|
|
||||||
JsonSerializer.Serialize(jsonFs, sidecar, new JsonSerializerOptions
|
JsonSerializer.Serialize(jsonFs, new MetadataJson
|
||||||
|
{
|
||||||
|
AaruMetadata = sidecar
|
||||||
|
}, new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||||
WriteIndented = true
|
WriteIndented = true
|
||||||
|
|||||||
@@ -1305,7 +1305,10 @@ partial class Dump
|
|||||||
|
|
||||||
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
|
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
|
||||||
|
|
||||||
JsonSerializer.Serialize(jsonFs, sidecar, new JsonSerializerOptions
|
JsonSerializer.Serialize(jsonFs, new MetadataJson
|
||||||
|
{
|
||||||
|
AaruMetadata = sidecar
|
||||||
|
}, new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||||
WriteIndented = true
|
WriteIndented = true
|
||||||
|
|||||||
@@ -982,7 +982,10 @@ public partial class Dump
|
|||||||
|
|
||||||
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
|
var jsonFs = new FileStream(_outputPrefix + ".metadata.json", FileMode.Create);
|
||||||
|
|
||||||
JsonSerializer.Serialize(jsonFs, sidecar, new JsonSerializerOptions
|
JsonSerializer.Serialize(jsonFs, new MetadataJson
|
||||||
|
{
|
||||||
|
AaruMetadata = sidecar
|
||||||
|
}, new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||||
WriteIndented = true
|
WriteIndented = true
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
@@ -57,7 +59,6 @@ using Avalonia.Threading;
|
|||||||
using MessageBox.Avalonia;
|
using MessageBox.Avalonia;
|
||||||
using MessageBox.Avalonia.Enums;
|
using MessageBox.Avalonia.Enums;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Schemas;
|
|
||||||
using ImageInfo = Aaru.CommonTypes.Structs.ImageInfo;
|
using ImageInfo = Aaru.CommonTypes.Structs.ImageInfo;
|
||||||
using Track = Aaru.CommonTypes.Structs.Track;
|
using Track = Aaru.CommonTypes.Structs.Track;
|
||||||
using Version = Aaru.CommonTypes.Interop.Version;
|
using Version = Aaru.CommonTypes.Interop.Version;
|
||||||
@@ -150,7 +151,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
|
|||||||
public string DriveLabel => UI.Title_Drive;
|
public string DriveLabel => UI.Title_Drive;
|
||||||
public string FirmwareRevisionLabel => UI.Title_Firmware_revision;
|
public string FirmwareRevisionLabel => UI.Title_Firmware_revision;
|
||||||
public string CommentsLabel => UI.Title_Comments;
|
public string CommentsLabel => UI.Title_Comments;
|
||||||
public string CicmXmlLabel => UI.Title_Existing_CICM_XML_sidecar;
|
public string AaruMetadataLabel => UI.Title_Existing_Aaru_Metadata_sidecar;
|
||||||
public string FromImageLabel => UI.Title_From_image;
|
public string FromImageLabel => UI.Title_From_image;
|
||||||
public string ResumeFileLabel => UI.Title_Existing_resume_file;
|
public string ResumeFileLabel => UI.Title_Existing_resume_file;
|
||||||
public string StartLabel => UI.ButtonLabel_Start;
|
public string StartLabel => UI.ButtonLabel_Start;
|
||||||
@@ -179,7 +180,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
|
|||||||
DriveFirmwareRevisionCommand = ReactiveCommand.Create(ExecuteDriveFirmwareRevisionCommand);
|
DriveFirmwareRevisionCommand = ReactiveCommand.Create(ExecuteDriveFirmwareRevisionCommand);
|
||||||
CommentsCommand = ReactiveCommand.Create(ExecuteCommentsCommand);
|
CommentsCommand = ReactiveCommand.Create(ExecuteCommentsCommand);
|
||||||
AaruMetadataFromImageCommand = ReactiveCommand.Create(ExecuteAaruMetadataFromImageCommand);
|
AaruMetadataFromImageCommand = ReactiveCommand.Create(ExecuteAaruMetadataFromImageCommand);
|
||||||
CicmXmlCommand = ReactiveCommand.Create(ExecuteCicmXmlCommand);
|
AaruMetadataCommand = ReactiveCommand.Create(ExecuteAaruMetadataCommand);
|
||||||
ResumeFileFromImageCommand = ReactiveCommand.Create(ExecuteResumeFileFromImageCommand);
|
ResumeFileFromImageCommand = ReactiveCommand.Create(ExecuteResumeFileFromImageCommand);
|
||||||
ResumeFileCommand = ReactiveCommand.Create(ExecuteResumeFileCommand);
|
ResumeFileCommand = ReactiveCommand.Create(ExecuteResumeFileCommand);
|
||||||
StartCommand = ReactiveCommand.Create(ExecuteStartCommand);
|
StartCommand = ReactiveCommand.Create(ExecuteStartCommand);
|
||||||
@@ -570,7 +571,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
|
|||||||
public ReactiveCommand<Unit, Unit> DriveFirmwareRevisionCommand { get; }
|
public ReactiveCommand<Unit, Unit> DriveFirmwareRevisionCommand { get; }
|
||||||
public ReactiveCommand<Unit, Unit> CommentsCommand { get; }
|
public ReactiveCommand<Unit, Unit> CommentsCommand { get; }
|
||||||
public ReactiveCommand<Unit, Unit> AaruMetadataFromImageCommand { get; }
|
public ReactiveCommand<Unit, Unit> AaruMetadataFromImageCommand { get; }
|
||||||
public ReactiveCommand<Unit, Task> CicmXmlCommand { get; }
|
public ReactiveCommand<Unit, Task> AaruMetadataCommand { get; }
|
||||||
public ReactiveCommand<Unit, Unit> ResumeFileFromImageCommand { get; }
|
public ReactiveCommand<Unit, Unit> ResumeFileFromImageCommand { get; }
|
||||||
public ReactiveCommand<Unit, Task> ResumeFileCommand { get; }
|
public ReactiveCommand<Unit, Task> ResumeFileCommand { get; }
|
||||||
public ReactiveCommand<Unit, Task> StartCommand { get; }
|
public ReactiveCommand<Unit, Task> StartCommand { get; }
|
||||||
@@ -2005,7 +2006,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
|
|||||||
_aaruMetadata = _inputFormat.AaruMetadata;
|
_aaruMetadata = _inputFormat.AaruMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task ExecuteCicmXmlCommand()
|
async Task ExecuteAaruMetadataCommand()
|
||||||
{
|
{
|
||||||
_aaruMetadata = null;
|
_aaruMetadata = null;
|
||||||
MetadataJsonText = "";
|
MetadataJsonText = "";
|
||||||
@@ -2020,7 +2021,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
|
|||||||
Name = UI.Dialog_Aaru_Metadata,
|
Name = UI.Dialog_Aaru_Metadata,
|
||||||
Extensions = new List<string>(new[]
|
Extensions = new List<string>(new[]
|
||||||
{
|
{
|
||||||
".xml"
|
".json"
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2030,14 +2031,17 @@ public sealed class ImageConvertViewModel : ViewModelBase
|
|||||||
result.Length != 1)
|
result.Length != 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var sidecarXs = new XmlSerializer(typeof(CICMMetadataType));
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sr = new StreamReader(result[0]);
|
var fs = new FileStream(result[0], FileMode.Open);
|
||||||
|
|
||||||
// _aaruMetadata = (CICMMetadataType)sidecarXs.Deserialize(sr);
|
_aaruMetadata = JsonSerializer.Deserialize<MetadataJson>(fs, new JsonSerializerOptions
|
||||||
sr.Close();
|
{
|
||||||
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||||
|
PropertyNameCaseInsensitive = true
|
||||||
|
})?.AaruMetadata;
|
||||||
|
|
||||||
|
fs.Close();
|
||||||
MetadataJsonText = result[0];
|
MetadataJsonText = result[0];
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
@@ -2065,7 +2069,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
|
|||||||
|
|
||||||
dlgMetadata.Filters?.Add(new FileDialogFilter
|
dlgMetadata.Filters?.Add(new FileDialogFilter
|
||||||
{
|
{
|
||||||
Name = UI.Dialog_Aaru_Metadata,
|
Name = UI.Dialog_Choose_existing_resume_file,
|
||||||
Extensions = new List<string>(new[]
|
Extensions = new List<string>(new[]
|
||||||
{
|
{
|
||||||
".xml"
|
".xml"
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ using JetBrains.Annotations;
|
|||||||
using MessageBox.Avalonia;
|
using MessageBox.Avalonia;
|
||||||
using MessageBox.Avalonia.Enums;
|
using MessageBox.Avalonia.Enums;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Schemas;
|
|
||||||
using DeviceInfo = Aaru.Core.Devices.Info.DeviceInfo;
|
using DeviceInfo = Aaru.Core.Devices.Info.DeviceInfo;
|
||||||
using Dump = Aaru.Core.Devices.Dumping.Dump;
|
using Dump = Aaru.Core.Devices.Dumping.Dump;
|
||||||
using File = System.IO.File;
|
using File = System.IO.File;
|
||||||
@@ -515,7 +514,7 @@ public sealed class MediaDumpViewModel : ViewModelBase
|
|||||||
Name = UI.Dialog_Aaru_Metadata,
|
Name = UI.Dialog_Aaru_Metadata,
|
||||||
Extensions = new List<string>(new[]
|
Extensions = new List<string>(new[]
|
||||||
{
|
{
|
||||||
".xml"
|
".json"
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -528,14 +527,17 @@ public sealed class MediaDumpViewModel : ViewModelBase
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var sidecarXs = new XmlSerializer(typeof(CICMMetadataType));
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sr = new StreamReader(result[0]);
|
var fs = new FileStream(result[0], FileMode.Open);
|
||||||
|
|
||||||
// _sidecar = (CICMMetadataType)sidecarXs.Deserialize(sr);
|
_sidecar = JsonSerializer.Deserialize<MetadataJson>(fs, new JsonSerializerOptions
|
||||||
sr.Close();
|
{
|
||||||
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||||
|
PropertyNameCaseInsensitive = true
|
||||||
|
})?.AaruMetadata;
|
||||||
|
|
||||||
|
fs.Close();
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -191,14 +191,14 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</TabControl>
|
</TabControl>
|
||||||
<TextBlock Text="{Binding CicmXmlLabel}" />
|
<TextBlock Text="{Binding AaruMetadataLabel}" />
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBox Text="{Binding MetadataJsonText}" IsReadOnly="True" />
|
<TextBox Text="{Binding MetadataJsonText}" IsReadOnly="True" />
|
||||||
<Button Command="{Binding AaruMetadataFromImageCommand}"
|
<Button Command="{Binding AaruMetadataFromImageCommand}"
|
||||||
IsVisible="{Binding AaruMetadataFromImageVisible}">
|
IsVisible="{Binding AaruMetadataFromImageVisible}">
|
||||||
<TextBlock Text="{Binding FromImageLabel}" />
|
<TextBlock Text="{Binding FromImageLabel}" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button Command="{Binding CicmXmlCommand}">
|
<Button Command="{Binding AaruMetadataCommand}">
|
||||||
<TextBlock Text="{Binding ChooseLabel}" />
|
<TextBlock Text="{Binding ChooseLabel}" />
|
||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@@ -34,11 +34,13 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using Aaru.CommonTypes;
|
using Aaru.CommonTypes;
|
||||||
|
using Aaru.CommonTypes.AaruMetadata;
|
||||||
using Aaru.CommonTypes.Enums;
|
using Aaru.CommonTypes.Enums;
|
||||||
using Aaru.CommonTypes.Interfaces;
|
using Aaru.CommonTypes.Interfaces;
|
||||||
using Aaru.CommonTypes.Structs;
|
|
||||||
using Aaru.CommonTypes.Structs.Devices.ATA;
|
using Aaru.CommonTypes.Structs.Devices.ATA;
|
||||||
using Aaru.CommonTypes.Structs.Devices.SCSI;
|
using Aaru.CommonTypes.Structs.Devices.SCSI;
|
||||||
using Aaru.Console;
|
using Aaru.Console;
|
||||||
@@ -48,8 +50,10 @@ using Aaru.Decoders.SCSI;
|
|||||||
using Aaru.Helpers;
|
using Aaru.Helpers;
|
||||||
using Schemas;
|
using Schemas;
|
||||||
using DMI = Aaru.Decoders.Xbox.DMI;
|
using DMI = Aaru.Decoders.Xbox.DMI;
|
||||||
|
using File = System.IO.File;
|
||||||
using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry;
|
using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry;
|
||||||
using Session = Aaru.CommonTypes.Structs.Session;
|
using Session = Aaru.CommonTypes.Structs.Session;
|
||||||
|
using Track = Aaru.CommonTypes.Structs.Track;
|
||||||
using TrackType = Aaru.CommonTypes.Enums.TrackType;
|
using TrackType = Aaru.CommonTypes.Enums.TrackType;
|
||||||
|
|
||||||
namespace Aaru.DiscImages;
|
namespace Aaru.DiscImages;
|
||||||
@@ -1125,20 +1129,41 @@ public sealed partial class ZZZRawImage
|
|||||||
|
|
||||||
AaruConsole.VerboseWriteLine(Localization.Raw_disk_image_contains_a_disk_of_type_0, _imageInfo.MediaType);
|
AaruConsole.VerboseWriteLine(Localization.Raw_disk_image_contains_a_disk_of_type_0, _imageInfo.MediaType);
|
||||||
|
|
||||||
var sidecarXs = new XmlSerializer(typeof(CICMMetadataType));
|
try
|
||||||
|
{
|
||||||
if(File.Exists(basename + "cicm.xml"))
|
if(File.Exists(basename + ".metadata.json"))
|
||||||
try
|
|
||||||
{
|
{
|
||||||
var sr = new StreamReader(basename + "cicm.xml");
|
var fs = new FileStream(basename + ".metadata.json", FileMode.Open);
|
||||||
|
|
||||||
|
AaruMetadata = JsonSerializer.Deserialize<MetadataJson>(fs, new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||||
|
PropertyNameCaseInsensitive = true
|
||||||
|
})?.AaruMetadata;
|
||||||
|
|
||||||
|
fs.Close();
|
||||||
|
}
|
||||||
|
else if(File.Exists(basename + ".cicm.xml"))
|
||||||
|
{
|
||||||
|
// The converter to AaruMetadata basically overcomes this (should?)
|
||||||
|
#pragma warning disable IL2026
|
||||||
|
var sidecarXs = new XmlSerializer(typeof(CICMMetadataType));
|
||||||
|
#pragma warning restore IL2026
|
||||||
|
|
||||||
|
var sr = new StreamReader(basename + ".cicm.xml");
|
||||||
|
|
||||||
|
// The converter to AaruMetadata basically overcomes this (should?)
|
||||||
|
#pragma warning disable IL2026
|
||||||
|
AaruMetadata = (CICMMetadataType)sidecarXs.Deserialize(sr);
|
||||||
|
#pragma warning restore IL2026
|
||||||
|
|
||||||
// AaruMetadata = (CICMMetadataType)sidecarXs.Deserialize(sr);
|
|
||||||
sr.Close();
|
sr.Close();
|
||||||
}
|
}
|
||||||
catch
|
}
|
||||||
{
|
catch
|
||||||
// Do nothing.
|
{
|
||||||
}
|
// Do nothing.
|
||||||
|
}
|
||||||
|
|
||||||
_imageInfo.ReadableMediaTags = new List<MediaTagType>(_mediaTags.Keys);
|
_imageInfo.ReadableMediaTags = new List<MediaTagType>(_mediaTags.Keys);
|
||||||
|
|
||||||
|
|||||||
6
Aaru.Localization/UI.Designer.cs
generated
6
Aaru.Localization/UI.Designer.cs
generated
@@ -6953,11 +6953,11 @@ namespace Aaru.Localization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Existing CICM XML sidecar.
|
/// Looks up a localized string similar to Existing Aaru Metadata sidecar.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string Title_Existing_CICM_XML_sidecar {
|
public static string Title_Existing_Aaru_Metadata_sidecar {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("Title_Existing_CICM_XML_sidecar", resourceCulture);
|
return ResourceManager.GetString("Title_Existing_Aaru_Metadata_sidecar", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2703,8 +2703,8 @@ Do you want to continue?</value>
|
|||||||
<data name="Title_Firmware_revision" xml:space="preserve">
|
<data name="Title_Firmware_revision" xml:space="preserve">
|
||||||
<value>Firmware revision</value>
|
<value>Firmware revision</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Title_Existing_CICM_XML_sidecar" xml:space="preserve">
|
<data name="Title_Existing_Aaru_Metadata_sidecar" xml:space="preserve">
|
||||||
<value>Existing CICM XML sidecar</value>
|
<value>Existing Aaru Metadata sidecar</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Title_From_image" xml:space="preserve">
|
<data name="Title_From_image" xml:space="preserve">
|
||||||
<value>From image...</value>
|
<value>From image...</value>
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ using System.CommandLine.NamingConventionBinder;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using Aaru.CommonTypes;
|
using Aaru.CommonTypes;
|
||||||
using Aaru.CommonTypes.AaruMetadata;
|
using Aaru.CommonTypes.AaruMetadata;
|
||||||
@@ -143,6 +145,11 @@ sealed class ConvertImageCommand : Command
|
|||||||
"--generate-subchannels"
|
"--generate-subchannels"
|
||||||
}, () => false, UI.Generates_subchannels_help));
|
}, () => false, UI.Generates_subchannels_help));
|
||||||
|
|
||||||
|
Add(new Option<string>(new[]
|
||||||
|
{
|
||||||
|
"--aaru-metadata", "-m"
|
||||||
|
}, () => null, "Take metadata from existing Aaru Metadata sidecar."));
|
||||||
|
|
||||||
AddArgument(new Argument<string>
|
AddArgument(new Argument<string>
|
||||||
{
|
{
|
||||||
Arity = ArgumentArity.ExactlyOne,
|
Arity = ArgumentArity.ExactlyOne,
|
||||||
@@ -167,7 +174,7 @@ sealed class ConvertImageCommand : Command
|
|||||||
int mediaSequence, string mediaSerialNumber, string mediaTitle, string outputPath,
|
int mediaSequence, string mediaSerialNumber, string mediaTitle, string outputPath,
|
||||||
string options, string resumeFile, string format, string geometry,
|
string options, string resumeFile, string format, string geometry,
|
||||||
bool fixSubchannelPosition, bool fixSubchannel, bool fixSubchannelCrc,
|
bool fixSubchannelPosition, bool fixSubchannel, bool fixSubchannelCrc,
|
||||||
bool generateSubchannels)
|
bool generateSubchannels, string aaruMetadata)
|
||||||
{
|
{
|
||||||
MainClass.PrintCopyright();
|
MainClass.PrintCopyright();
|
||||||
|
|
||||||
@@ -233,6 +240,7 @@ sealed class ConvertImageCommand : Command
|
|||||||
AaruConsole.DebugWriteLine("Image convert command", "--fix-subchannel={0}", fixSubchannel);
|
AaruConsole.DebugWriteLine("Image convert command", "--fix-subchannel={0}", fixSubchannel);
|
||||||
AaruConsole.DebugWriteLine("Image convert command", "--fix-subchannel-crc={0}", fixSubchannelCrc);
|
AaruConsole.DebugWriteLine("Image convert command", "--fix-subchannel-crc={0}", fixSubchannelCrc);
|
||||||
AaruConsole.DebugWriteLine("Image convert command", "--generate-subchannels={0}", generateSubchannels);
|
AaruConsole.DebugWriteLine("Image convert command", "--generate-subchannels={0}", generateSubchannels);
|
||||||
|
AaruConsole.DebugWriteLine("Image convert command", "--aaru-metadata={0}", aaruMetadata);
|
||||||
|
|
||||||
Dictionary<string, string> parsedOptions = Core.Options.Parse(options);
|
Dictionary<string, string> parsedOptions = Core.Options.Parse(options);
|
||||||
AaruConsole.DebugWriteLine("Image convert command", UI.Parsed_options);
|
AaruConsole.DebugWriteLine("Image convert command", UI.Parsed_options);
|
||||||
@@ -294,15 +302,44 @@ sealed class ConvertImageCommand : Command
|
|||||||
Metadata sidecar = null;
|
Metadata sidecar = null;
|
||||||
MediaType mediaType;
|
MediaType mediaType;
|
||||||
|
|
||||||
var xs = new XmlSerializer(typeof(CICMMetadataType));
|
if(aaruMetadata != null)
|
||||||
|
|
||||||
if(cicmXml != null)
|
if(File.Exists(aaruMetadata))
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var fs = new FileStream(aaruMetadata, FileMode.Open);
|
||||||
|
|
||||||
|
sidecar = JsonSerializer.Deserialize<MetadataJson>(fs, new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||||
|
PropertyNameCaseInsensitive = true
|
||||||
|
})?.AaruMetadata;
|
||||||
|
|
||||||
|
fs.Close();
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
AaruConsole.ErrorWriteLine(UI.Incorrect_metadata_sidecar_file_not_continuing);
|
||||||
|
AaruConsole.DebugWriteLine("Image conversion", $"{ex}");
|
||||||
|
|
||||||
|
return (int)ErrorNumber.InvalidSidecar;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AaruConsole.ErrorWriteLine(UI.Could_not_find_metadata_sidecar);
|
||||||
|
|
||||||
|
return (int)ErrorNumber.NoSuchFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(cicmXml != null)
|
||||||
if(File.Exists(cicmXml))
|
if(File.Exists(cicmXml))
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var xs = new XmlSerializer(typeof(CICMMetadataType));
|
||||||
|
|
||||||
var sr = new StreamReader(cicmXml);
|
var sr = new StreamReader(cicmXml);
|
||||||
|
|
||||||
//sidecar = (CICMMetadataType)xs.Deserialize(sr);
|
sidecar = (CICMMetadataType)xs.Deserialize(sr);
|
||||||
sr.Close();
|
sr.Close();
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
@@ -319,15 +356,31 @@ sealed class ConvertImageCommand : Command
|
|||||||
return (int)ErrorNumber.NoSuchFile;
|
return (int)ErrorNumber.NoSuchFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
xs = new XmlSerializer(typeof(Resume));
|
|
||||||
|
|
||||||
if(resumeFile != null)
|
if(resumeFile != null)
|
||||||
|
{
|
||||||
if(File.Exists(resumeFile))
|
if(File.Exists(resumeFile))
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sr = new StreamReader(resumeFile);
|
if(resumeFile.EndsWith(".metadata.json", StringComparison.CurrentCultureIgnoreCase))
|
||||||
resume = (Resume)xs.Deserialize(sr);
|
{
|
||||||
sr.Close();
|
var fs = new FileStream(resumeFile, FileMode.Open);
|
||||||
|
|
||||||
|
resume = JsonSerializer.Deserialize<ResumeJson>(fs, new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||||
|
PropertyNameCaseInsensitive = true
|
||||||
|
})?.Resume;
|
||||||
|
|
||||||
|
fs.Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var xs = new XmlSerializer(typeof(Resume));
|
||||||
|
var sr = new StreamReader(resumeFile);
|
||||||
|
resume = (Resume)xs.Deserialize(sr);
|
||||||
|
sr.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
@@ -336,12 +389,14 @@ sealed class ConvertImageCommand : Command
|
|||||||
|
|
||||||
return (int)ErrorNumber.InvalidResume;
|
return (int)ErrorNumber.InvalidResume;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AaruConsole.ErrorWriteLine(UI.Could_not_find_resume_file);
|
AaruConsole.ErrorWriteLine(UI.Could_not_find_resume_file);
|
||||||
|
|
||||||
return (int)ErrorNumber.NoSuchFile;
|
return (int)ErrorNumber.NoSuchFile;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var filtersList = new FiltersList();
|
var filtersList = new FiltersList();
|
||||||
IFilter inputFilter = null;
|
IFilter inputFilter = null;
|
||||||
@@ -601,7 +656,7 @@ sealed class ConvertImageCommand : Command
|
|||||||
return (int)ErrorNumber.CannotCreateFormat;
|
return (int)ErrorNumber.CannotCreateFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
var metadata = new ImageInfo
|
var imageInfo = new ImageInfo
|
||||||
{
|
{
|
||||||
Application = "Aaru",
|
Application = "Aaru",
|
||||||
ApplicationVersion = Version.GetVersion(),
|
ApplicationVersion = Version.GetVersion(),
|
||||||
@@ -621,7 +676,7 @@ sealed class ConvertImageCommand : Command
|
|||||||
MediaTitle = mediaTitle ?? inputFormat.Info.MediaTitle
|
MediaTitle = mediaTitle ?? inputFormat.Info.MediaTitle
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!outputFormat.SetImageInfo(metadata))
|
if(!outputFormat.SetImageInfo(imageInfo))
|
||||||
{
|
{
|
||||||
if(!force)
|
if(!force)
|
||||||
{
|
{
|
||||||
@@ -633,7 +688,7 @@ sealed class ConvertImageCommand : Command
|
|||||||
AaruConsole.ErrorWriteLine(Localization.Core.Error_0_setting_metadata, outputFormat.ErrorMessage);
|
AaruConsole.ErrorWriteLine(Localization.Core.Error_0_setting_metadata, outputFormat.ErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
Metadata aaruMetadata = inputFormat.AaruMetadata;
|
Metadata metadata = inputFormat.AaruMetadata;
|
||||||
List<DumpHardware> dumpHardware = inputFormat.DumpHardware;
|
List<DumpHardware> dumpHardware = inputFormat.DumpHardware;
|
||||||
|
|
||||||
foreach(MediaTagType mediaTag in inputFormat.Info.ReadableMediaTags.Where(mediaTag =>
|
foreach(MediaTagType mediaTag in inputFormat.Info.ReadableMediaTags.Where(mediaTag =>
|
||||||
@@ -1433,8 +1488,8 @@ sealed class ConvertImageCommand : Command
|
|||||||
|
|
||||||
ret = false;
|
ret = false;
|
||||||
|
|
||||||
if(sidecar != null ||
|
if(sidecar != null ||
|
||||||
aaruMetadata != null)
|
metadata != null)
|
||||||
{
|
{
|
||||||
Core.Spectre.ProgressSingleSpinner(ctx =>
|
Core.Spectre.ProgressSingleSpinner(ctx =>
|
||||||
{
|
{
|
||||||
@@ -1442,8 +1497,8 @@ sealed class ConvertImageCommand : Command
|
|||||||
|
|
||||||
if(sidecar != null)
|
if(sidecar != null)
|
||||||
ret = outputFormat.SetMetadata(sidecar);
|
ret = outputFormat.SetMetadata(sidecar);
|
||||||
else if(aaruMetadata != null)
|
else if(metadata != null)
|
||||||
ret = outputFormat.SetMetadata(aaruMetadata);
|
ret = outputFormat.SetMetadata(metadata);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(ret)
|
if(ret)
|
||||||
|
|||||||
@@ -218,6 +218,11 @@ sealed class DumpMediaCommand : Command
|
|||||||
"--dimensions"
|
"--dimensions"
|
||||||
}, () => 1080, UI.Dump_graph_dimensions_argument_help));
|
}, () => 1080, UI.Dump_graph_dimensions_argument_help));
|
||||||
|
|
||||||
|
Add(new Option<string>(new[]
|
||||||
|
{
|
||||||
|
"--aaru-metadata", "-m"
|
||||||
|
}, () => null, "Take metadata from existing Aaru Metadata sidecar."));
|
||||||
|
|
||||||
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
|
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +233,7 @@ sealed class DumpMediaCommand : Command
|
|||||||
bool fixSubchannelPosition, bool retrySubchannel, bool fixSubchannel,
|
bool fixSubchannelPosition, bool retrySubchannel, bool fixSubchannel,
|
||||||
bool fixSubchannelCrc, bool generateSubchannels, bool skipCdiReadyHole, bool eject,
|
bool fixSubchannelCrc, bool generateSubchannels, bool skipCdiReadyHole, bool eject,
|
||||||
uint maxBlocks, bool useBufferedReads, bool storeEncrypted, bool titleKeys,
|
uint maxBlocks, bool useBufferedReads, bool storeEncrypted, bool titleKeys,
|
||||||
uint ignoreCdrRunOuts, bool createGraph, uint dimensions)
|
uint ignoreCdrRunOuts, bool createGraph, uint dimensions, string aaruMetadata)
|
||||||
{
|
{
|
||||||
MainClass.PrintCopyright();
|
MainClass.PrintCopyright();
|
||||||
|
|
||||||
@@ -299,6 +304,7 @@ sealed class DumpMediaCommand : Command
|
|||||||
AaruConsole.DebugWriteLine("Dump-Media command", "--ignore-cdr-runouts={0}", ignoreCdrRunOuts);
|
AaruConsole.DebugWriteLine("Dump-Media command", "--ignore-cdr-runouts={0}", ignoreCdrRunOuts);
|
||||||
AaruConsole.DebugWriteLine("Dump-Media command", "--create-graph={0}", createGraph);
|
AaruConsole.DebugWriteLine("Dump-Media command", "--create-graph={0}", createGraph);
|
||||||
AaruConsole.DebugWriteLine("Dump-Media command", "--dimensions={0}", dimensions);
|
AaruConsole.DebugWriteLine("Dump-Media command", "--dimensions={0}", dimensions);
|
||||||
|
AaruConsole.DebugWriteLine("Dump-Media command", "--aaru-metadata={0}", aaruMetadata);
|
||||||
|
|
||||||
// TODO: Disabled temporarily
|
// TODO: Disabled temporarily
|
||||||
//AaruConsole.DebugWriteLine("Dump-Media command", "--raw={0}", raw);
|
//AaruConsole.DebugWriteLine("Dump-Media command", "--raw={0}", raw);
|
||||||
@@ -468,7 +474,6 @@ sealed class DumpMediaCommand : Command
|
|||||||
string outputPrefix = Path.Combine(Path.GetDirectoryName(outputPath), responseLine);
|
string outputPrefix = Path.Combine(Path.GetDirectoryName(outputPath), responseLine);
|
||||||
|
|
||||||
Resume resumeClass = null;
|
Resume resumeClass = null;
|
||||||
var xs = new XmlSerializer(typeof(Resume));
|
|
||||||
|
|
||||||
if(resume)
|
if(resume)
|
||||||
{
|
{
|
||||||
@@ -491,6 +496,7 @@ sealed class DumpMediaCommand : Command
|
|||||||
// DEPRECATED: To be removed in Aaru 7
|
// DEPRECATED: To be removed in Aaru 7
|
||||||
else if(File.Exists(outputPrefix + ".resume.xml") && resume)
|
else if(File.Exists(outputPrefix + ".resume.xml") && resume)
|
||||||
{
|
{
|
||||||
|
var xs = new XmlSerializer(typeof(Resume));
|
||||||
var sr = new StreamReader(outputPrefix + ".resume.xml");
|
var sr = new StreamReader(outputPrefix + ".resume.xml");
|
||||||
resumeClass = (Resume)xs.Deserialize(sr);
|
resumeClass = (Resume)xs.Deserialize(sr);
|
||||||
sr.Close();
|
sr.Close();
|
||||||
@@ -522,16 +528,48 @@ sealed class DumpMediaCommand : Command
|
|||||||
return (int)ErrorNumber.AlreadyDumped;
|
return (int)ErrorNumber.AlreadyDumped;
|
||||||
}
|
}
|
||||||
|
|
||||||
Metadata sidecar = null;
|
Metadata sidecar = null;
|
||||||
var sidecarXs = new XmlSerializer(typeof(CICMMetadataType));
|
|
||||||
|
|
||||||
if(cicmXml != null)
|
if(aaruMetadata != null)
|
||||||
|
if(File.Exists(aaruMetadata))
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var fs = new FileStream(aaruMetadata, FileMode.Open);
|
||||||
|
|
||||||
|
sidecar = JsonSerializer.Deserialize<MetadataJson>(fs, new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||||
|
PropertyNameCaseInsensitive = true
|
||||||
|
})?.AaruMetadata;
|
||||||
|
|
||||||
|
fs.Close();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
AaruConsole.ErrorWriteLine(UI.Incorrect_metadata_sidecar_file_not_continuing);
|
||||||
|
|
||||||
|
if(isResponse)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return (int)ErrorNumber.InvalidSidecar;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AaruConsole.ErrorWriteLine(UI.Could_not_find_metadata_sidecar);
|
||||||
|
|
||||||
|
if(isResponse)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return (int)ErrorNumber.NoSuchFile;
|
||||||
|
}
|
||||||
|
else if(cicmXml != null)
|
||||||
if(File.Exists(cicmXml))
|
if(File.Exists(cicmXml))
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sr = new StreamReader(cicmXml);
|
var sr = new StreamReader(cicmXml);
|
||||||
|
var sidecarXs = new XmlSerializer(typeof(CICMMetadataType));
|
||||||
|
|
||||||
//sidecar = (CICMMetadataType)sidecarXs.Deserialize(sr);
|
sidecar = (CICMMetadataType)sidecarXs.Deserialize(sr);
|
||||||
sr.Close();
|
sr.Close();
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|||||||
Reference in New Issue
Block a user