mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-04-20 15:54:42 +01:00
wip
This commit is contained in:
44
utils/movpkg-to-vlc/parse/boot.ts
Normal file
44
utils/movpkg-to-vlc/parse/boot.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { XMLParser } from "fast-xml-parser";
|
||||
|
||||
export interface Boot {
|
||||
Version: string;
|
||||
HLSMoviePackageType: string;
|
||||
Streams: {
|
||||
Stream: Stream[];
|
||||
};
|
||||
MasterPlaylist: {
|
||||
NetworkURL: string;
|
||||
};
|
||||
DataItems: {
|
||||
Directory: string;
|
||||
DataItem: DataItem;
|
||||
};
|
||||
}
|
||||
|
||||
export interface Stream {
|
||||
ID: string;
|
||||
NetworkURL: string;
|
||||
Path: string;
|
||||
Complete: string; // "YES" or "NO"
|
||||
}
|
||||
|
||||
export interface DataItem {
|
||||
ID: string;
|
||||
Category: string;
|
||||
Name: string;
|
||||
DescriptorPath: string;
|
||||
DataPath: string;
|
||||
Role: string;
|
||||
}
|
||||
|
||||
export async function parseBootXML(xml: string): Promise<Boot> {
|
||||
const parser = new XMLParser({
|
||||
ignoreAttributes: false,
|
||||
attributeNamePrefix: "",
|
||||
parseAttributeValue: true,
|
||||
});
|
||||
const jsonObj = parser.parse(xml);
|
||||
const b = jsonObj.HLSMoviePackage as Boot;
|
||||
console.log(b.Streams);
|
||||
return jsonObj.HLSMoviePackage as Boot;
|
||||
}
|
||||
45
utils/movpkg-to-vlc/parse/streamInfoBoot.ts
Normal file
45
utils/movpkg-to-vlc/parse/streamInfoBoot.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { XMLParser } from "fast-xml-parser";
|
||||
|
||||
export interface StreamInfo {
|
||||
Version: string;
|
||||
Complete: string;
|
||||
PeakBandwidth: number;
|
||||
Compressable: string;
|
||||
MediaPlaylist: MediaPlaylist;
|
||||
Type: string;
|
||||
MediaSegments: {
|
||||
SEG: SEG[];
|
||||
};
|
||||
EvictionPolicy: string;
|
||||
MediaBytesStored: number;
|
||||
}
|
||||
|
||||
export interface MediaPlaylist {
|
||||
NetworkURL: string;
|
||||
PathToLocalCopy: string;
|
||||
}
|
||||
|
||||
export interface SEG {
|
||||
Dur: number;
|
||||
Len: number;
|
||||
Off: number;
|
||||
PATH: string;
|
||||
SeqNum: number;
|
||||
Tim: number;
|
||||
URL: string;
|
||||
}
|
||||
|
||||
export async function parseStreamInfoXml(xml: string): Promise<StreamInfo> {
|
||||
const parser = new XMLParser({
|
||||
ignoreAttributes: false,
|
||||
attributeNamePrefix: "",
|
||||
parseAttributeValue: true,
|
||||
isArray: (tagName, jPath) => {
|
||||
// Force SEG elements to always be an array
|
||||
if (jPath === "StreamInfo.MediaSegments.SEG") return true;
|
||||
return false;
|
||||
},
|
||||
});
|
||||
const jsonObj = parser.parse(xml);
|
||||
return jsonObj.StreamInfo as StreamInfo;
|
||||
}
|
||||
Reference in New Issue
Block a user