diff --git a/Source/MediaInfo/MediaInfo_Inform.cpp b/Source/MediaInfo/MediaInfo_Inform.cpp index 40bc3bd30..b41d505e3 100644 --- a/Source/MediaInfo/MediaInfo_Inform.cpp +++ b/Source/MediaInfo/MediaInfo_Inform.cpp @@ -302,12 +302,14 @@ Ztring MediaInfo_Internal::Inform() #if defined(MEDIAINFO_XML_YES) || defined(MEDIAINFO_JSON_YES) Node* Node_Main=NULL; Node* Node_MI=NULL; + Node* Node_Tracks=NULL; #endif //MEDIAINFO_XML_YES || MEDIAINFO_JSON_YES Ztring Retour; bool HTML=false; bool XML=false; bool XML_0_7_78_MA=false; bool XML_0_7_78_MI=false; + bool OLDJSON=false; bool JSON=false; bool CSV=false; #if defined(MEDIAINFO_HTML_YES) @@ -322,9 +324,14 @@ Ztring MediaInfo_Internal::Inform() if (MediaInfoLib::Config.Inform_Get()==__T("MIXML") || MediaInfoLib::Config.Inform_Get()==__T("XML")) XML_0_7_78_MI=true; #endif //defined(MEDIAINFO_XML_YES) - #if defined(MEDIAINFO_JSON_YES) + #if defined(MEDIAINFO_JSON_YES) if (MediaInfoLib::Config.Inform_Get()==__T("JSON")) JSON=true; + if (MediaInfoLib::Config.Inform_Get()==__T("OLDJSON")) + { + JSON=true; + OLDJSON=true; + } #endif //defined(MEDIAINFO_JSON_YES) #if defined(MEDIAINFO_CSV_YES) if (MediaInfoLib::Config.Inform_Get()==__T("CSV")) @@ -334,7 +341,7 @@ Ztring MediaInfo_Internal::Inform() if (HTML) Retour+=__T("\n\n\n\n\n"); #if defined(MEDIAINFO_XML_YES) || defined(MEDIAINFO_JSON_YES) - if (XML_0_7_78_MA || XML_0_7_78_MI || JSON) + if (XML_0_7_78_MA || XML_0_7_78_MI || OLDJSON) { Node_Main=new Node("media"); Ztring Options=Get(Stream_General, 0, General_CompleteName, Info_Options); @@ -357,6 +364,17 @@ Ztring MediaInfo_Internal::Inform() else Node_Main=new Node("File"); } + if (JSON && !OLDJSON) + { + Node_Main=new Node("Media"); + Ztring Options=Get(Stream_General, 0, General_CompleteName, Info_Options); + if (InfoOption_ShowInInformAdd_Attribute("Ref", Get(Stream_General, 0, General_CompleteName)); + if (Info && !Info->ParserName.empty()) + Node_Main->Add_Attribute("Parser", Info->ParserName); + + Node_Tracks=Node_Main->Add_Child("Tracks"); + } #endif //defined(MEDIAINFO_XML_YES) || defined(MEDIAINFO_JSON_YES) for (size_t StreamKind=(size_t)Stream_General; StreamKind\n\n

"); #if defined(MEDIAINFO_XML_YES) || defined(MEDIAINFO_JSON_YES) Node* Node_Current=NULL; - if (XML || XML_0_7_78_MA || XML_0_7_78_MI || JSON) Node_Current=Node_MI?Node_MI->Add_Child("track", true):Node_Main->Add_Child("track", true); + if (XML || XML_0_7_78_MA || XML_0_7_78_MI || OLDJSON) Node_Current=Node_MI?Node_MI->Add_Child("track", true):Node_Main->Add_Child("track", true); #endif //defined(MEDIAINFO_XML_YES) || defined(MEDIAINFO_JSON_YES) Ztring A=Get((stream_t)StreamKind, StreamPos, __T("StreamKind/String")); Ztring B=Get((stream_t)StreamKind, StreamPos, __T("StreamKindPos")); @@ -386,7 +404,7 @@ Ztring MediaInfo_Internal::Inform() } if (HTML) Retour+=__T("

\n "); #if defined(MEDIAINFO_XML_YES) || defined(MEDIAINFO_JSON_YES) - if (XML || XML_0_7_78_MA || XML_0_7_78_MI || JSON) + if (XML || XML_0_7_78_MA || XML_0_7_78_MI || OLDJSON) { Node_Current->Add_Attribute("type", A); if (!B.empty()) Node_Current->Add_Attribute("typeorder", B); @@ -394,6 +412,19 @@ Ztring MediaInfo_Internal::Inform() Track->RawContent=Inform((stream_t)StreamKind, StreamPos, false).To_UTF8(); Node_Current->Childs.push_back(Track); } + else if (JSON && !OLDJSON) + { + Node_Current=Node_Tracks->Add_Child(A.To_UTF8(), true); + + Node* Track=new Node(); + Ztring TrackContent=Inform((stream_t)StreamKind, StreamPos, false); + if (!TrackContent.empty()) + { + if (!B.empty()) Track->RawContent="\"Typeorder\": \"" + B.To_UTF8() + "\",\n"; + Track->RawContent+=TrackContent.To_UTF8(); + Node_Current->Childs.push_back(Track); + } + } else #endif //defined(MEDIAINFO_XML_YES) || defined(MEDIAINFO_JSON_YES) { @@ -476,6 +507,7 @@ Ztring MediaInfo_Internal::Inform (stream_t StreamKind, size_t StreamPos, bool I #if defined(MEDIAINFO_XML_YES) || defined(MEDIAINFO_JSON_YES) bool XML=false; bool XML_0_7_78=false; + bool OLDJSON=false; bool JSON=false; std::vector Nodes; #endif //MEDIAINFO_XML_YES || MEDIAINFO_JSON_YES @@ -490,7 +522,13 @@ Ztring MediaInfo_Internal::Inform (stream_t StreamKind, size_t StreamPos, bool I XML=true; #endif //defined(MEDIAINFO_XML_YES) #if defined(MEDIAINFO_JSON_YES) - JSON=MediaInfoLib::Config.Inform_Get()==__T("JSON")?true:false; + if (MediaInfoLib::Config.Inform_Get()==__T("JSON")) + JSON=true; + if (MediaInfoLib::Config.Inform_Get()==__T("OLDJSON")) + { + JSON=true; + OLDJSON=true; + } #endif //defined(MEDIAINFO_JSON_YES) #if defined(MEDIAINFO_CSV_YES) bool CSV=MediaInfoLib::Config.Inform_Get()==__T("CSV")?true:false; @@ -553,7 +591,7 @@ Ztring MediaInfo_Internal::Inform (stream_t StreamKind, size_t StreamPos, bool I if ((XML_0_7_78 || JSON) && !IsExtra && Champ_Pos>=Stream[StreamKind][StreamPos].size()) { IsExtra=true; - Node* Node_Extra=new Node("extra"); + Node* Node_Extra=new Node((XML_0_7_78 || OLDJSON)?"extra":"Extra"); Fields.push_back(Node_Extra); } #endif //defined(MEDIAINFO_XML_YES || MEDIAINFO_JSON_YES @@ -700,7 +738,7 @@ Ztring MediaInfo_Internal::Inform (stream_t StreamKind, size_t StreamPos, bool I #if defined(MEDIAINFO_XML_YES) || defined(MEDIAINFO_JSON_YES) for (size_t Field=0; Field < Fields.size(); Field++) { - if (Fields[Field]->Name == "extra") + if (Fields[Field]->Name == "extra" || Fields[Field]->Name == "Extra") { std::string TmpRetour; for (size_t Field2=0; Field2 < Fields[Field]->Childs.size(); Field2++) if (XML) diff --git a/Source/MediaInfo/MediaInfo_Internal.cpp b/Source/MediaInfo/MediaInfo_Internal.cpp index 7b5ed3cad..dd58fdec8 100644 --- a/Source/MediaInfo/MediaInfo_Internal.cpp +++ b/Source/MediaInfo/MediaInfo_Internal.cpp @@ -2279,7 +2279,7 @@ Ztring MediaInfo_Internal::Inform(std::vector& Info) else #endif //defined(MEDIAINFO_XML_YES) #if defined(MEDIAINFO_JSON_YES) - if (MediaInfoLib::Config.Inform_Get()==__T("JSON")) + if (MediaInfoLib::Config.Inform_Get()==__T("JSON") || MediaInfoLib::Config.Inform_Get()==__T("OLDJSON")) { if (Info.size() > 1) Result+=__T("[")+MediaInfoLib::Config.LineSeparator_Get();