Ztring Language_All_Run () { ZtringListListF Origin; Origin.Load(L"../Source/Resource/Language.csv"); for (int Lang=1; Lang<50; Lang++) { Ztring Name=Origin.Read(L" Language_ISO639", Lang); if (Name.size()>0) { ZtringListListF Dest; int Automatic=0; //count of words in file int Automatic_Language=0; //count of words in file without Language names for (size_t Pos=0; Pos<Origin.size(); Pos++) { Dest(Pos, 0)=Origin(Pos, 0); Dest(Pos, 1)=Origin(Pos, Lang); if (Dest(Pos, 1).size()>0) Automatic++; if (Dest(Pos, 1).size()>0 || Dest(Pos, 0).find(__T("Language_"))==0 || Dest(Pos, 0).find(__T("Genre_"))==0 || Dest(Pos, 0).find(__T("OpenCandy_"))==0) Automatic_Language++; } Dest((L"ZZ_Automatic_Percent"), 1).From_Number(Automatic*100/Origin.size()); Dest((L"ZZ_AutomaticLanguage_Percent"), 1).From_Number(Automatic_Language*100/Origin.size()); Dest.Save(Ztring(L"../Source/Resource/Plugin/Language/")+Name+L".csv"); } } return L"OK"; }
void Run_File(ZtringListListF &Dest, Ztring Language) { //Open Orig ZtringListListF Origin; if (Origin.Load(Ztring(L"../Source/Resource/Plugin/Language/")+Language+L".csv")==Error) return; //Find position in Destination int Lang=0; for (int LangPos=1; LangPos<50; LangPos++) if (Lang==0 && (Dest(L" Language_ISO639", LangPos)==Language || Dest(L" Language_ISO639", LangPos).size()==0)) Lang=LangPos; //Delete BOM characters if present Origin(0, 0)=L" Author_Email"; //Complete for (size_t Pos=0; Pos<Origin.size(); Pos++) { int Dest_Pos=Dest.Find(Origin(Pos, 0), 0, 0, L"==", Ztring_CaseSensitive); if (Dest_Pos==-1) { Dest.push_back(Origin.Read(Pos, 0)); //Append to end of file Dest_Pos=Dest.Find(Origin(Pos, 0), 0, 0, L"==", Ztring_CaseSensitive); } Dest(Dest_Pos, Lang)=Origin(Pos, 1); } }
void TExportF::Export_Run() { //Create text for the file Ztring Text; Ztring Append_Separator=__T("\r\n"); if (Export->ActivePage==Export_CSV) { //Full information bool MediaInfo_Complete; if (CSV_Advanced->Checked) MediaInfo_Complete=true; else MediaInfo_Complete=false; //General ZtringListListF CSV; ZtringListList Parameters; Parameters.Write(MediaInfo::Option_Static(__T("Info_Parameters_CSV"))); int Pos_Start=1; int Pos_End=Parameters.Find(__T("Video"))-1; int CSV_Pos=0; for (int I1=0; I1<Pos_End-Pos_Start; I1++) if (MediaInfo_Complete || ToExport->Get(0, Stream_General, 0, I1, Info_Options)[InfoOption_ShowInInform]==__T('Y')) { CSV(0, CSV_Pos)=Ztring(__T("General "))+Parameters(Pos_Start+I1, 0); for (int FilePos=0; FilePos<ToExport->Count_Get(); FilePos++) CSV(1+FilePos, CSV_Pos)=ToExport->Get(FilePos, Stream_General, 0, I1); CSV_Pos++; } //Video Pos_Start=Pos_End+2; Pos_End=Parameters.Find(__T("Audio"))-1; for (int I1=0; I1<Pos_End-Pos_Start; I1++) { for (int Count=0; Count<CSV_Stream_Video->ItemIndex; Count++) if (MediaInfo_Complete || ToExport->Get(0, Stream_Video, 0, I1, Info_Options)[InfoOption_ShowInInform]==__T('Y')) { CSV(0, CSV_Pos)=Ztring(__T("Video "))+Ztring::ToZtring(Count)+__T(" ")+Parameters(Pos_Start+I1, 0); for (int FilePos=0; FilePos<ToExport->Count_Get(); FilePos++) CSV(1+FilePos, CSV_Pos)=ToExport->Get(FilePos, Stream_Video, 0, I1); CSV_Pos++; } } //Audio Pos_Start=Pos_End+2; Pos_End=Parameters.Find(__T("Text"))-1; for (int Count=0; Count<CSV_Stream_Audio->ItemIndex; Count++) { for (int I1=0; I1<Pos_End-Pos_Start; I1++) if (MediaInfo_Complete || ToExport->Get(0, Stream_Audio, 0, I1, Info_Options)[InfoOption_ShowInInform]==__T('Y')) { CSV(0, CSV_Pos)=Ztring(__T("Audio "))+Ztring::ToZtring(Count)+__T(" ")+Parameters(Pos_Start+I1, 0); for (int FilePos=0; FilePos<ToExport->Count_Get(); FilePos++) CSV(1+FilePos, CSV_Pos)=ToExport->Get(FilePos, Stream_Audio, Count, I1); CSV_Pos++; } } //Text Pos_Start=Pos_End+2; Pos_End=Parameters.Find(__T("Chapters"))-1; for (int Count=0; Count<CSV_Stream_Text->ItemIndex; Count++) { for (int I1=0; I1<Pos_End-Pos_Start; I1++) if (MediaInfo_Complete || ToExport->Get(0, Stream_Text, 0, I1, Info_Options)[InfoOption_ShowInInform]==__T('Y')) { CSV(0, CSV_Pos)=Ztring(__T("Text "))+Ztring::ToZtring(Count)+__T(" ")+Parameters(Pos_Start+I1, 0); for (int FilePos=0; FilePos<ToExport->Count_Get(); FilePos++) CSV(1+FilePos, CSV_Pos)=ToExport->Get(FilePos, Stream_Text, Count, I1); CSV_Pos++; } } //Chapters Pos_Start=Pos_End+2; Pos_End=Parameters.size()-1; for (int Count=0; Count<CSV_Stream_Other->ItemIndex; Count++) { for (int I1=0; I1<Pos_End-Pos_Start; I1++) if (MediaInfo_Complete || ToExport->Get(0, Stream_Other, 0, I1, Info_Options)[InfoOption_ShowInInform]==__T('Y')) { CSV(0, CSV_Pos)=Ztring(__T("Chapters "))+Ztring::ToZtring(Count)+__T(" ")+Parameters(Pos_Start+I1, 0); for (int FilePos=0; FilePos<ToExport->Count_Get(); FilePos++) CSV(1+FilePos, CSV_Pos)=ToExport->Get(FilePos, Stream_Other, Count, I1); CSV_Pos++; } } //Separators Ztring Separator_Col=ZEN_UNICODE(CSV_Separator_Col->Text); if (Separator_Col==__T("(Tab)")) Separator_Col=__T("\t"); Ztring Separator_Line=ZEN_UNICODE(CSV_Separator_Line->Text); if (Separator_Line==__T("(Default)")) #ifdef WIN32 Separator_Line=__T("\r\n"); #else #error #endif //WIN32 Separator_Line.FindAndReplace(__T("\\r"), __T("\r")); Separator_Line.FindAndReplace(__T("\\n"), __T("\n")); Append_Separator=Separator_Line.c_str(); Ztring Quote=ZEN_UNICODE(CSV_Quote->Text); CSV.Separator_Set(0, Separator_Line); CSV.Separator_Set(1, Separator_Col); CSV.Quote_Set(Quote); if (File_Append->Checked) CSV.Delete(0); Text=CSV.Read().c_str(); } else if (Export->ActivePage==Export_Sheet) { ZtringListListF SheetF; //Configure for (size_t Pos=0; Pos<Prefs->Details[Prefs_Sheet].size(); Pos++) { Ztring Z1=__T("Column"); Z1+=Ztring::ToZtring(Pos); //Searching kind of stream stream_t S; ZenLib::Char C=__T('G'); if (Prefs->Details[Prefs_Sheet].Find(Z1)==(size_t)-1) break; C=Prefs->Details[Prefs_Sheet](Z1, 1)[0]; switch (C) { case __T('G'): S=Stream_General; break; case __T('V'): S=Stream_Video; break; case __T('A'): S=Stream_Audio; break; case __T('T'): S=Stream_Text; break; case __T('C'): S=Stream_Other; break; default: S=Stream_General; } SheetF(0, Pos)=ToExport->Get(0, S, Prefs->Details[Prefs_Sheet](Z1, 2).To_int32u(), Prefs->Details[Prefs_Sheet](Z1, 3), Info_Name_Text); if (C!=__T('G')) SheetF(0, Pos)=Prefs->Details[Prefs_Sheet](Z1, 1)+Prefs->Details[Prefs_Sheet](Z1, 2)+__T(" ")+SheetF(0, Pos); } //Show all available files for (int FilePos=0; FilePos<ToExport->Count_Get(); FilePos++) for (size_t Pos=0; Pos<Prefs->Details[Prefs_Sheet].size(); Pos++) { Ztring Z1=__T("Column"); Z1+=Ztring::ToZtring(Pos); //Searching Stream kind stream_t S; ZenLib::Char C=__T('G'); if (Prefs->Details[Prefs_Sheet].Find(Z1)==(size_t)-1) break; C=Prefs->Details[Prefs_Sheet](Z1, 1)[0]; switch (C) { case __T('G'): S=Stream_General; break; case __T('V'): S=Stream_Video; break; case __T('A'): S=Stream_Audio; break; case __T('T'): S=Stream_Text; break; case __T('C'): S=Stream_Other; break; default: S=Stream_General; } //Showing SheetF(1+FilePos, Pos)=ToExport->Get(FilePos, S, Prefs->Details[Prefs_Sheet](Z1, 2).To_int32u(), Prefs->Details[Prefs_Sheet](Z1, 3)); } //Separators Ztring Separator_Col=ZEN_UNICODE(Sheet_Separator_Col->Text); if (Separator_Col==__T("(Tab)")) Separator_Col=__T("\t"); Ztring Separator_Line=ZEN_UNICODE(Sheet_Separator_Line->Text); if (Separator_Line==__T("(Default)")) #ifdef WIN32 Separator_Line=__T("\r\n"); #else #error #endif //WIN32 if (Separator_Line==__T("\\r\\n")) Separator_Line=__T("\r\n"); if (Separator_Line==__T("\\r")) Separator_Line=__T("\r"); if (Separator_Line==__T("\\n")) Separator_Line=__T("\n"); Ztring Quote=ZEN_UNICODE(Sheet_Quote->Text); Append_Separator=Separator_Line.c_str(); SheetF.Separator_Set(0, Separator_Line); SheetF.Separator_Set(1, Separator_Col); SheetF.Quote_Set(Quote); if (File_Append->Checked) SheetF.Delete(0); Text=SheetF.Read().c_str(); } else if (Export->ActivePage==Export_Text) { ToExport->Option_Static(__T("Inform")); Text=ToExport->Inform().c_str(); } else if (Export->ActivePage==Export_HTML) { ToExport->Option_Static(__T("Inform"), __T("HTML")); Text=ToExport->Inform().c_str(); Append_Separator=__T("<hr>\r\n"); } else if (Export->ActivePage==Export_XML) { ToExport->Option_Static(__T("Inform"), __T("XML")); if (Export_XML_SideCar->Checked) { for (size_t Pos=0; Pos<ToExport->Count_Get(); Pos++) { Text=ToExport->Inform(Pos).c_str(); File F; F.Create(Ztring(ToExport->Get(Pos, Stream_General, 0, __T("CompleteName")).c_str())+__T(".mediainfo.xml")); F.Write(Text); } return; } Text=ToExport->Inform().c_str(); } else if (Export->ActivePage==Export_MPEG7) { ToExport->Option_Static(__T("Inform"), __T("MPEG-7")); if (Export_MPEG7_SideCar->Checked) { for (size_t Pos=0; Pos<ToExport->Count_Get(); Pos++) { Text=ToExport->Inform(Pos).c_str(); File F; F.Create(Ztring(ToExport->Get(Pos, Stream_General, 0, __T("CompleteName")).c_str())+__T(".mpeg7.xml")); F.Write(Text); } return; } Text=ToExport->Inform().c_str(); } else if (Export->ActivePage==Export_PBCore) { ToExport->Option_Static(__T("Inform"), __T("PBCore_1.2")); if (Export_PBCore_SideCar->Checked) { for (size_t Pos=0; Pos<ToExport->Count_Get(); Pos++) { Text=ToExport->Inform(Pos).c_str(); File F; F.Create(Ztring(ToExport->Get(Pos, Stream_General, 0, __T("CompleteName")).c_str())+__T(".PBCore.xml")); F.Write(Text); } return; } Text=ToExport->Inform().c_str(); } else if (Export->ActivePage==Export_PBCore2) { ToExport->Option_Static(__T("Inform"), __T("PBCore_2.0")); if (Export_PBCore2_SideCar->Checked) { for (size_t Pos=0; Pos<ToExport->Count_Get(); Pos++) { Text=ToExport->Inform(Pos).c_str(); File F; F.Create(Ztring(ToExport->Get(Pos, Stream_General, 0, __T("CompleteName")).c_str())+__T(".PBCore2.xml")); F.Write(Text); } return; } Text=ToExport->Inform().c_str(); } else if (Export->ActivePage==Export_EBUCore_1_5) { ToExport->Option_Static(__T("Inform"), __T("EBUCore_1.5")); if (Export_EBUCore_1_5_SideCar->Checked) { for (size_t Pos=0; Pos<ToExport->Count_Get(); Pos++) { Text=ToExport->Inform(Pos).c_str(); File F; F.Create(Ztring(ToExport->Get(Pos, Stream_General, 0, __T("CompleteName")).c_str())+__T(".EBUCore.xml")); F.Write(Text); } return; } Text=ToExport->Inform().c_str(); } else if (Export->ActivePage==Export_EBUCore_1_6) { ToExport->Option_Static(__T("Inform"), __T("EBUCore_1.6")); if (Export_EBUCore_1_6_SideCar->Checked) { for (size_t Pos=0; Pos<ToExport->Count_Get(); Pos++) { Text=ToExport->Inform(Pos).c_str(); File F; F.Create(Ztring(ToExport->Get(Pos, Stream_General, 0, __T("CompleteName")).c_str())+__T(".EBUCore.xml")); F.Write(Text); } return; } Text=ToExport->Inform().c_str(); } else if (Export->ActivePage==Export_FIMS_1_1) { ToExport->Option_Static(__T("Inform"), __T("FIMS_1.1")); if (Export_FIMS_1_1_SideCar->Checked) { for (size_t Pos=0; Pos<ToExport->Count_Get(); Pos++) { Text=ToExport->Inform(Pos).c_str(); File F; F.Create(Ztring(ToExport->Get(Pos, Stream_General, 0, __T("CompleteName")).c_str())+__T(".FIMS.xml")); F.Write(Text); } return; } Text=ToExport->Inform().c_str(); } else if (Export->ActivePage==Export_FIMS_1_2) { ToExport->Option_Static(__T("Inform"), __T("FIMS_1.2")); if (Export_FIMS_1_2_SideCar->Checked) { for (size_t Pos=0; Pos<ToExport->Count_Get(); Pos++) { Text=ToExport->Inform(Pos).c_str(); File F; F.Create(Ztring(ToExport->Get(Pos, Stream_General, 0, __T("CompleteName")).c_str())+__T(".FIMS.xml")); F.Write(Text); } return; } Text=ToExport->Inform().c_str(); } else if (Export->ActivePage==Export_FIMS_1_3) { ToExport->Option_Static(__T("Inform"), __T("FIMS_1.3")); if (Export_FIMS_1_3_SideCar->Checked) { for (size_t Pos=0; Pos<ToExport->Count_Get(); Pos++) { Text=ToExport->Inform(Pos).c_str(); File F; F.Create(Ztring(ToExport->Get(Pos, Stream_General, 0, __T("CompleteName")).c_str())+__T(".FIMS.xml")); F.Write(Text); } return; } Text=ToExport->Inform().c_str(); } else if (Export->ActivePage==Export_reVTMD) { ToExport->Option_Static(__T("Inform"), __T("reVTMD")); if (Export_reVTMD_SideCar->Checked) { for (size_t Pos=0; Pos<ToExport->Count_Get(); Pos++) { Text=ToExport->Inform(Pos).c_str(); File F; F.Create(Ztring(ToExport->Get(Pos, Stream_General, 0, __T("CompleteName")).c_str())+__T(".reVTMD.xml")); F.Write(Text); } return; } Text=ToExport->Inform().c_str(); } else if (Export->ActivePage==Export_Custom) { ToExport->Option_Static(__T("Inform"), Prefs->Details[Prefs_Custom].Read()); if (Custom_One->State==cbChecked) { for (int FilePos=0; FilePos<ToExport->Count_Get(); FilePos++) { Ztring Z1=ToExport->Inform(FilePos).c_str(); //Put begin and end of file Z1=Prefs->Details[Prefs_Custom](Stream_Max+2, 1)+Z1; //Begin Z1+=Prefs->Details[Prefs_Custom](Stream_Max+4, 1); //End Z1.FindAndReplace(__T("\\r\\n"),__T( "\r\n"), 0, Ztring_Recursive); Text=Z1.c_str();;//Write file File F; FileName FN=ZEN_UNICODE(Name->Text); FN.Name_Set(FN.Name_Get()+Ztring::ToZtring(FilePos).c_str()); F.Open(FN, File::Access_Write); F.Write(Text); } return; //No need to save the file, already done } else Text=ToExport->Inform().c_str(); } //Writing file File F; if (File_Append->Checked) { F.Open(ZEN_UNICODE(Name->Text), File::Access_Write_Append); F.Write(Append_Separator); } else F.Create(ZEN_UNICODE(Name->Text)); F.Write(Text); }