2023-07-30 21:27:02 -04:00
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace SabreTools.DatFiles.Formats
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents parsing a Archive.org file list
|
|
|
|
|
/// </summary>
|
|
|
|
|
internal partial class ArchiveDotOrg : DatFile
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public override void ParseFile(string filename, int indexId, bool keep, bool statsOnly = false, bool throwOnError = false)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Deserialize the input file
|
2023-09-11 01:20:21 -04:00
|
|
|
var files = new Serialization.Files.ArchiveDotOrg().Deserialize(filename);
|
2024-03-09 21:34:26 -05:00
|
|
|
var metadata = new Serialization.CrossModel.ArchiveDotOrg().Serialize(files);
|
2023-07-30 21:27:02 -04:00
|
|
|
|
2024-03-10 00:24:16 -05:00
|
|
|
// Convert to the internal format
|
2024-03-10 22:49:15 -04:00
|
|
|
ConvertMetadata(metadata, filename, indexId, keep, statsOnly);
|
2023-07-30 21:27:02 -04:00
|
|
|
}
|
|
|
|
|
catch (Exception ex) when (!throwOnError)
|
|
|
|
|
{
|
|
|
|
|
string message = $"'{filename}' - An error occurred during parsing";
|
|
|
|
|
logger.Error(ex, message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|