➕ Add XML parser
This commit is contained in:
parent
2d55189248
commit
f01a880ae6
4 changed files with 23 additions and 4 deletions
|
@ -4,8 +4,8 @@ import getSolidpkg from './ssn/getSolidpkg';
|
|||
(async () => {
|
||||
//----- PATCHMANIFEST -----
|
||||
//.patchmanifest files contain a single XML file called "manifest.xml"
|
||||
//const patchmanifestXml = await getPatchmanifest('assets_swtor_de_de');
|
||||
//console.log(patchmanifestXml);
|
||||
const patchmanifestJson = await getPatchmanifest('assets_swtor_de_de');
|
||||
console.log(patchmanifestJson);
|
||||
|
||||
//----- SOLIDPKG -----
|
||||
//.solidpkg files contain a single Bencode file called "metafile.solid"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { TextDecoder } from 'util';
|
||||
import * as xmlJs from 'xml-js';
|
||||
import getUrlContents from '../cdn/getUrlContents';
|
||||
import { Product } from '../interfaces/ISettings';
|
||||
import verifyProductName from '../ssn/verifyProductName';
|
||||
|
@ -7,7 +8,7 @@ import readSsnFile from './readSsnFile';
|
|||
|
||||
const Decoder = new TextDecoder('utf-8');
|
||||
|
||||
export default async function getPatchmanifest(product: Product): Promise<string> {
|
||||
export default async function getPatchmanifest(product: Product): Promise<any> {
|
||||
//Verify function arguments
|
||||
if (!verifyProductName(product)) {
|
||||
throw new Error(`"${product}" is not a valid product.`);
|
||||
|
@ -32,5 +33,7 @@ export default async function getPatchmanifest(product: Product): Promise<string
|
|||
const patchmanifestFile = await extractFile(firstFile, [new DataView(ssnFile)]);
|
||||
const patchmanifestXml = Decoder.decode(patchmanifestFile);
|
||||
|
||||
return patchmanifestXml;
|
||||
const patchManifestJson = xmlJs.xml2js(patchmanifestXml);
|
||||
|
||||
return patchManifestJson;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue