//public static void Test_telecharger_pdf_search_01() //{ // Trace.WriteLine("Test_telecharger_pdf_search_01"); // string url = "http://telecharger-pdf.com/"; // HtmlXmlReader.CurrentHtmlXmlReader.Load(url); //} //public static void Test_telecharger_pdf_view_01() //{ // Trace.WriteLine("Test_telecharger_pdf_view_01"); // HtmlXmlReader.CurrentHtmlXmlReader.ReadSelect("//article:.:EmptyRow", ".//h1/@class:.:EmptyRow", ".//a/text()"); //} //public static void Test_magazine3k_search_01() //{ // Trace.WriteLine("Test_magazine3k_search_01"); // string url = "http://magazine3k.com/search/?q=l%27express&as_occt=title&as_ordb=relevance&sitesearch=magazine3k.com"; // HtmlXmlReader.CurrentHtmlXmlReader.Load(url); // //wr.Select("/xml/html/body/div[2]//table//tr"); // //wr.Select("//div[@class='res']"); // //wr.Select("//div"); // //wr.Select("//div[@class]"); // //wr.Select("//div[@class = \"res_data\"]"); // //wr.Select("//div[@class='res']:.:EmptyRow"); // //XmlNode[] nodes = wr.SelectNodes("//div[@class='res']"); // //wr.Select(xpath); // DataTable data = HtmlXmlReader.CurrentHtmlXmlReader.ReadSelect("//div[@class='res']", "@class", ".//a/@href:.:n(href)", ".//a//text():.:n(label1)", // ".//span[1]//text():.:n(info1)", ".//span[2]//text():.:n(info2)", ".//span[3]//text():.:n(info3)", ".//span[4]//text():.:n(info4)", // ".//img/@src:.:n(img)", ".//div[@class='justi']//text():.:n(label2):Concat()", ".//div[@class='cat']/text():.:n(category)"); // if (data.Rows.Count == 0) return; // DataRow row; // if (data.Rows.Count >= 4) // row = data.Rows[3]; // else // row = data.Rows[0]; // HtmlXmlReader.CurrentHtmlXmlReader.Load("http://magazine3k.com/", (string)row["href"]); //} //public static void Test_magazine3k_search_02() //{ // Trace.WriteLine("Test_magazine3k_search_01"); // string url = "http://magazine3k.com/search/?q=l%27express&as_occt=title&as_ordb=relevance&sitesearch=magazine3k.com"; // HtmlXmlReader.CurrentHtmlXmlReader.Load(url); // //DataTable data = hxr.ReadSelect("//div[@class='res']", "@class", ".//a/@href:.:n(href)", ".//a//text():.:n(label1)", // // ".//span[1]//text():.:n(info1)", ".//span[2]//text():.:n(info2)", ".//span[3]//text():.:n(info3)", ".//span[4]//text():.:n(info4)", // // ".//img/@src:.:n(img)", ".//div[@class='justi']//text():.:n(label2):Concat()", ".//div[@class='cat']/text():.:n(category)"); // XmlSelect select = HtmlXmlReader.CurrentHtmlXmlReader.Select("//div[@class='res']", "@class", ".//a/@href:.:n(href)", ".//a//text():.:n(label1)", // ".//span[1]//text():.:n(info1)", ".//span[2]//text():.:n(info2):int", ".//span[3]//text():.:n(info3)", ".//span[4]//text():.:n(info4)", // ".//img/@src:.:n(img)", ".//div[@class='justi']//text():.:n(label2):Concat()", ".//div[@class='cat']/text():.:n(category)"); // DataTable dt = zdt.Create("node, txt, href, label1, info1, info2 int, info3, info4, img, label2, category"); // while (select.Get()) // { // DataRow row = dt.NewRow(); // row["node"] = select.TranslatedPathCurrentNode; // row["txt"] = select[0]; // row["href"] = select["href"]; // row["label1"] = select["label1"]; // row["info1"] = select["info1"]; // row["info2"] = select["info2"]; // row["info3"] = select["info3"]; // row["info4"] = select["info4"]; // row["img"] = select["img"]; // row["label2"] = select["label2"]; // row["category"] = select["category"]; // dt.Rows.Add(row); // } // RunSource.CurrentRunSource.Result = dt; //} //public static void Test_magazine3k_search_03(bool detail = false) //{ // Trace.WriteLine("Test_magazine3k_search_03"); // string url = "http://magazine3k.com/search/?q=l%27express&as_occt=title&as_ordb=relevance&sitesearch=magazine3k.com"; // RunSource.CurrentRunSource.View(magazine3k_01.search(url, detail)); //} //public static void Test_telecharger_pdf_search_02(bool detail = false) //{ // Trace.WriteLine("Test_telecharger_pdf_search_02"); // //string url = "http://telecharger-pdf.com/"; // //string url = "http://telecharger-pdf.com/?paged=4"; // string dir = @"c:\pib\dev_data\exe\wrun\test\model\telecharger-pdf\"; // string url = dir + "0935_telecharger-pdf.com_01_01.html"; // telecharger_pdfPrint[] prints = telecharger_pdf.search(url, detail); // Trace.WriteLine("load {0} prints", prints.Length); // //_wr.View(prints); // Trace.WriteLine(prints.ToString()); //} //public static void Test_magazine3k_print_01() //{ // Trace.WriteLine("Test_magazine3k_print_01"); // string url = "http://magazine3k.com/magazine/other/31496/lexpress-lexpress-styles-3180-13-au-19-juin-2012.html"; // HtmlXmlReader.CurrentHtmlXmlReader.Load(url); // // Base64.encrypt(Base64.decode('TFlwdFg6Sldvb0ZMLjNRaWRJOFBFSHMuUjZGY3c/P01PeDZKOXZrQjdNQmtOVFY=')) = "http://www.mediafire.com/??k538in7yh0p3kqb" // // Base64.decode('TFlwdFg6Sldvb0ZMLjNRaWRJOFBFSHMuUjZGY3c/P01PeDZKOXZrQjdNQmtOVFY=') = "LYptX:JWooFL.3QidI8PEHs.R6Fcw??MOx6J9vkB7MBkNTV" // // Base64.encrypt(Base64.decode('d2pTV3M6UFF1dUROLjFTZ2ZLK05HRnUudkU3aU8/T09sNFE0LzFOcWZidUJoWA==')) = "http://www.mediafire.com/?k7h85gphvn4vskr" // // Base64.decode('d2pTV3M6UFF1dUROLjFTZ2ZLK05HRnUudkU3aU8/T09sNFE0LzFOcWZidUJoWA==') = "wjSWs:PQuuDN.1SgfK+NGFu.vE7iO?OOl4Q4/1NqfbuBhX" // // Base64.encrypt(Base64.decode('d2pTV3M6VkswMFpYLkJtVXIrSzV5eGEuaEsxc0E/VVlZcUI1MUlVcVBLZmZ4UQ==')) = "http://www.mediafire.com/?5qbpvmkbxgv5a98" // // Base64.decode('d2pTV3M6VkswMFpYLkJtVXIrSzV5eGEuaEsxc0E/VVlZcUI1MUlVcVBLZmZ4UQ==') = "wjSWs:VK00ZX.BmUr+K5yxa.hK1sA?UYYqB51IUqPKffxQ" // //test_javascript_01(); // // print title : L'Express + L'Express Styles 3180 - 13 au 19 Juin 2012 // //wr.Select("//div[@class='headline']:.:EmptyRow", ".//text()"); // string title = HtmlXmlReader.CurrentHtmlXmlReader.SelectValue("//div[@class='headline']", ".//text()"); // Trace.WriteLine("title : \"{0}\"", title); // // Downloads:, 604, Updated:, 13-06-2012 // //wr.Select("//div[@class='res_data']:.:EmptyRow", ".//span[1]//text():.:n(info1)", ".//span[2]//text():.:n(info2)", ".//span[3]//text():.:n(info3)", ".//span[4]//text():.:n(info4)"); // //wr.Select("//div[@class='res_data']//text():.:EmptyRow"); // string[] infos = HtmlXmlReader.CurrentHtmlXmlReader.SelectValues("//div[@class='res_data']//text()"); // Trace.WriteLine("infos : {0}", infos.zToStringValues()); // // url image : http://image2.magazine3k.com/data_images/2012/06/13/1339572260_medium.jpeg // //wr.Select("//div[@class='res_image']:.:EmptyRow", ".//img/@src"); // string imageUrl = HtmlXmlReader.CurrentHtmlXmlReader.SelectValue("//div[@class='res_image']//img/@src"); // Trace.WriteLine("image url : \"{0}\"", imageUrl); // // French | 140+96 pages | HQ PDF | 129+79 MB // // vous offre un autre regard sur l'actualité commentée en mots et en images. vous emmène à la découverte de la mode, de la déco, de l'insolite... // //wr.Select("//div[@class='justi']:.:EmptyRow", ".//div/text()", ".//div/following-sibling::text()"); // // ".//div/text()", // XmlNode node = HtmlXmlReader.CurrentHtmlXmlReader.SelectNode("//div[@class='justi']:.:EmptyRow"); // string info = HtmlXmlReader.CurrentHtmlXmlReader.SelectValue(node, ".//div/text()"); // Trace.WriteLine("info : \"{0}\"", info); // string comment = HtmlXmlReader.CurrentHtmlXmlReader.SelectValue(node, ".//div/following-sibling::text()"); // Trace.WriteLine("comment : \"{0}\"", comment); // // script containing download url // //var url; url = Base64.encrypt(Base64.decode('cy9PS3c6V0pZbFBGOC9OalUuelluK3ovMlBMMzVxOVkzaUJuVmlTJ0FxREJaYVU1XzZuZlh3Xy1fUU5ZX0d0aF91NW1faWFuaVdfMnJiWTkucUJ5Uys=')); // //var url; url = Base64.encrypt(Base64.decode('QVRpbWM6dndoYzI4RkcwYXQuVS9BWlVZUm9zUTV1Y2ExRzR0eUYxJzlYKzhrbnBFX3FLa3psbUZfQmNrc0xfLV9RTllfUzUxX01iRV9zVXBzWV9QU2loRS5sTzlkeA==')); // //var url; url = Base64.encrypt(Base64.decode('NXFiZmw6YkU2NlhaLkFuVnEvTDR6d2IuWXpNVjU/UVE3bU9taHJUMEJGd2YvSg==')); // //var url; url = Base64.encrypt(Base64.decode('RVhtaVk6azdGRm9tLkZpUXY2TzkyMWUuOFhveGQ/WlZWbk0wNEZabkNIU1M4ZA==')); // //wr.Select("//div[@class='download_top']/following-sibling::div", "./script/text()"); // string[] scriptLinks = HtmlXmlReader.CurrentHtmlXmlReader.SelectValues("//div[@class='download_top']/following-sibling::div", "./script/text()"); // Regex rg = new Regex(@"Base64\.encrypt\(Base64\.decode\('([^']*)'\)\)", RegexOptions.Compiled); // foreach (string scriptLink in scriptLinks) // { // Trace.WriteLine("script link : \"{0}\"", scriptLink); // Match match = rg.Match(scriptLink); // if (match.Success) // { // string code = match.Groups[1].Value; // Trace.WriteLine("code : \"{0}\"", code); // string link = magazine3kPrint_01.DecodeDownloadLink(code); // Trace.WriteLine("download link : \"{0}\"", link); // } // else // Trace.WriteLine("code not found"); // } //} //public static void Test_magazine3k_print_02() //{ // Trace.WriteLine("Test_magazine3k_print_02"); // //wr.Load(@"c:\pib\dev_data\exe\wrun\test\magazine3k\magazine3k.com_print_02_02.html"); // HtmlXmlReader.CurrentHtmlXmlReader.LoadXml(@"c:\pib\dev_data\exe\wrun\test\magazine3k\magazine3k.com_print_02_02_02.html.xml"); // HtmlXmlReader.CurrentHtmlXmlReader.ReadSelect("//div[@class='download_top']/following-sibling::div:.:EmptyRow"); //} //public static void Test_magazine3k_print_03() //{ // Trace.WriteLine("Test_magazine3k_print_03"); // string url = "http://magazine3k.com/magazine/other/31496/lexpress-lexpress-styles-3180-13-au-19-juin-2012.html"; // magazine3kPrint_01 print = magazine3k_01.loadPrint(url); // Trace.WriteLine("language : \"{0}\"", print.language); // Trace.WriteLine("title : \"{0}\"", print.title); // Trace.WriteLine("downloads : \"{0}\"", print.downloads); // Trace.WriteLine("updated : {0:dd/MM/yyyy}", print.updated); // Trace.WriteLine("imageUrl : \"{0}\"", print.imageUrl); // Trace.WriteLine("infos : {0}", print.infos.zToStringValues()); // Trace.WriteLine("comment : \"{0}\"", print.comment); // Trace.WriteLine("download links nb : \"{0}\"", print.downloadLinks.Length); // foreach (string links in print.downloadLinks) // { // Trace.WriteLine("download link : \"{0}\"", links); // } //} public static void Test_PrintDirectoryManager_01(string directory) { PrintDirectoryManager printDirectoryManager = new PrintDirectoryManager(new string[] { ".01_quotidien", ".02_hebdo", ".03_mensuel", ".04_autre", ".05_new_print", ".06_unknow_print", ".07_lettres" }); Trace.WriteLine("PrintDirectoryManager.GetDirectories() : \"{0}\"", directory); Trace.WriteLine(printDirectoryManager.GetDirectories(directory).zToJson()); }
private PrintDirectoryDateStorage GetPrintDirectoryDateStorage() { if (_directoryDateStorage == null) { _directoryDateStorage = PrintDirectoryManager.GetDirectoryDateStorage(_destinationDirectory); } return(_directoryDateStorage); }
public static void ManageDirectories(IEnumerable <string> sourceDirectories, string destinationDirectory, string bonusDirectory = null, bool usePrintDirectories = true, bool simulate = true, bool moveFiles = false, bool moveInfoFiles = false, Func <string, bool> directoryFilter = null) { PrintFileManager_v2 printFileManager = CreatePrintFileManager_v2(simulate: simulate, moveFiles: moveFiles, moveInfoFiles: moveInfoFiles); PrintDirectoryManager printDirectoryManager = CreatePrintDirectoryManager(); foreach (string sourceDirectory in sourceDirectories) { foreach (EnumDirectoryInfo directory in CreatePrintDirectoryManager().GetDirectories(sourceDirectory, usePrintDirectories: usePrintDirectories)) { if (directoryFilter != null) { if (!directoryFilter(directory.SubDirectory)) { continue; } } printFileManager.ManageDirectory(directory.Directory, zPath.Combine(destinationDirectory, directory.SubDirectory), bonusDirectory); //directory.Directory.zTrace(); //zPath.Combine(destinationDirectory, directory.SubDirectory).zTrace(); //"".zTrace(); } } }
// book example : // destinationDirectory : g:\pib\media\ebook\book\unsorted_verified\Les météores // : g:\pib\media\ebook\book\bonus private void _MoveFiles_v1(IEnumerable <FileGroup_v2> files, string destinationDirectory) { // directory : g:\\pib\\media\\ebook\\print //Trace.WriteLine("_MoveFiles() directory \"{0}\"", directory); int n = 0; //Dictionary<int, int> fileNumbers = GetDestinationFileNumbers(files); List <string> moveFiles = new List <string>(); PrintDirectoryDateStorage directoryDateStorage = null; bool first = true; string directory2 = null; foreach (FileGroup_v2 file in files) { // file : (book) // Directory : "g:\pib\media\ebook\_dl\_dl_pib\book\10\book\Les fées cuisinent et les lutins dînent" // SubDirectory : "Les fées cuisinent et les lutins dînent" // File : "g:\pib\media\ebook\_dl\_dl_pib\book\10\book\Les fées cuisinent et les lutins dînent\Les fées cuisinent et les lutins dînent\Fees-Lutins.pdf" // BaseFilename : "Fees-Lutins.pdf" // Number : 0 // BadFile : false // DestinationDirectoryFile : false // // file : (print) // fileGroup.DirectoryGroup.BaseDirectory // fileGroup.DirectoryInfo.Directory : g:\\pib\\media\\ebook\\print\\.02_hebdo\\01 net // g:\\pib\\media\\ebook\\_dl\\_dl_pib\\01\\print\\.02_hebdo\\01 net // fileGroup.DirectoryInfo.SubDirectory : .02_hebdo\\01 net // fileGroup.SubDirectory : 2014 // fileGroup.File : g:\\pib\\media\\ebook\\print\\.02_hebdo\\01 net\\2014\\01 net - 2014-10-16 - no 806(1).pdf // fileGroup.BaseFilename : 01 net - 2014-10-16 - no 806.pdf // fileGroup.Number : 1 if (first) { first = false; //Trace.WriteLine("_MoveFiles() SubDirectory \"{0}\"", fileGroup.DirectoryInfo.SubDirectory); directory2 = destinationDirectory; //if (file.SubDirectory != null && useSubdirectory) // directory2 = zPath.Combine(destinationDirectory, file.SubDirectory); //Trace.WriteLine("_MoveFiles() directory \"{0}\"", directory2); directoryDateStorage = PrintDirectoryManager.GetDirectoryDateStorage(directory2); } string pathFile = directory2; string filename = zPath.GetFileNameWithoutExtension(file.BaseFilename); if (!file.BadFile) { PrintInfo printInfo = PrintIssue.GetPrintInfo(filename); //Trace.WriteLine("_MoveFiles() filename \"{0}\" date \"{1}\"", filename, printInfo != null ? printInfo.Date.ToString() : "null"); if (printInfo != null && printInfo.Date != null) { string subDirectory = directoryDateStorage.GetDirectory((Date)printInfo.Date); if (subDirectory != null) { pathFile = zPath.Combine(pathFile, subDirectory); } } else if (!file.DestinationDirectoryFile) { if (file.SubDirectory != null) { pathFile = zPath.Combine(pathFile, file.SubDirectory); } } //else if (file.File.StartsWith(destinationDirectory)) else // if (file.DestinationDirectoryFile) { // dont move unknow file of destination directory if (n <= file.Number) { n = file.Number + 1; } continue; // pas de continue sinon n n'est pas incrémenté // keep directory file //file = fileGroup.DirectoryInfo.Directory; } } else { pathFile = zPath.Combine(pathFile, __badFileDirectory); } pathFile = zPath.Combine(pathFile, filename); if (n > 0) { pathFile += string.Format("[{0}]", n); } pathFile += zPath.GetExtension(file.BaseFilename); if (file.File != pathFile) { moveFiles.Add(pathFile); Trace.WriteLine("move file \"{0}\"", file.File); Trace.WriteLine(" to \"{0}\"", pathFile + ".tmp"); if (!_simulate) { zfile.CreateFileDirectory(pathFile); zFile.Move(file.File, pathFile + ".tmp"); } } //if (fileGroup.Number != n || fileGroup.DirectoryInfo.Directory != directory) //{ // string file = zPath.Combine(directory, fileGroup.DirectoryInfo.SubDirectory, zPath.GetFileNameWithoutExtension(fileGroup.BaseFilename)); // if (n > 0) // file += string.Format("[{0}]", n); // file += zPath.GetExtension(fileGroup.BaseFilename); // files.Add(file); // Trace.WriteLine("move file \"{0}\" to \"{1}\"", fileGroup.File, file + ".tmp"); // if (!_simulate) // { // zfile.CreateFileDirectory(file); // File.Move(fileGroup.File, file + ".tmp"); // } //} n++; } foreach (string file in moveFiles) { Trace.WriteLine("rename tmp file \"{0}\"", file + ".tmp"); Trace.WriteLine(" to \"{0}\"", file); if (!_simulate) { zFile.Move(file + ".tmp", file); } } }
private void _MoveFiles(IEnumerable <FileGroup> fileGroups, string directory, bool useSubdirectory = true) { // directory : g:\\pib\\media\\ebook\\print //Trace.WriteLine("_MoveFiles() directory \"{0}\"", directory); int n = 0; List <string> files = new List <string>(); PrintDirectoryDateStorage directoryDateStorage = null; bool first = true; string directory2 = null; foreach (FileGroup fileGroup in fileGroups) { // fileGroup.DirectoryGroup.BaseDirectory // fileGroup.DirectoryInfo.Directory : g:\\pib\\media\\ebook\\print\\.02_hebdo\\01 net // g:\\pib\\media\\ebook\\_dl\\_dl_pib\\01\\print\\.02_hebdo\\01 net // fileGroup.DirectoryInfo.SubDirectory : .02_hebdo\\01 net // fileGroup.SubDirectory : 2014 // fileGroup.File : g:\\pib\\media\\ebook\\print\\.02_hebdo\\01 net\\2014\\01 net - 2014-10-16 - no 806(1).pdf // fileGroup.BaseFilename : 01 net - 2014-10-16 - no 806.pdf // fileGroup.Number : 1 if (first) { first = false; //Trace.WriteLine("_MoveFiles() SubDirectory \"{0}\"", fileGroup.DirectoryInfo.SubDirectory); directory2 = directory; if (fileGroup.DirectoryInfo.SubDirectory != null && useSubdirectory) { directory2 = zPath.Combine(directory, fileGroup.DirectoryInfo.SubDirectory); } //Trace.WriteLine("_MoveFiles() directory \"{0}\"", directory2); directoryDateStorage = PrintDirectoryManager.GetDirectoryDateStorage(directory2); } string file = directory2; string filename = zPath.GetFileNameWithoutExtension(fileGroup.BaseFilename); if (!fileGroup.BadFile) { PrintInfo printInfo = PrintIssue.GetPrintInfo(filename); //Trace.WriteLine("_MoveFiles() filename \"{0}\" date \"{1}\"", filename, printInfo != null ? printInfo.Date.ToString() : "null"); if (printInfo != null && printInfo.Date != null) { string subDirectory = directoryDateStorage.GetDirectory((Date)printInfo.Date); if (subDirectory != null) { file = zPath.Combine(file, subDirectory); } } else if (fileGroup.File.StartsWith(directory)) { // dont move unknow file of destination directory if (n <= fileGroup.Number) { n = fileGroup.Number + 1; } continue; // pas de continue sinon n n'est pas incrémenté // keep directory file //file = fileGroup.DirectoryInfo.Directory; } } else { file = zPath.Combine(file, __badFileDirectory); } file = zPath.Combine(file, filename); if (n > 0) { file += string.Format("[{0}]", n); } file += zPath.GetExtension(fileGroup.BaseFilename); if (fileGroup.File != file) { files.Add(file); Trace.WriteLine("move file \"{0}\"", fileGroup.File); Trace.WriteLine(" to \"{0}\"", file + ".tmp"); if (!_simulate) { zfile.CreateFileDirectory(file); zFile.Move(fileGroup.File, file + ".tmp"); } } //if (fileGroup.Number != n || fileGroup.DirectoryInfo.Directory != directory) //{ // string file = zPath.Combine(directory, fileGroup.DirectoryInfo.SubDirectory, zPath.GetFileNameWithoutExtension(fileGroup.BaseFilename)); // if (n > 0) // file += string.Format("[{0}]", n); // file += zPath.GetExtension(fileGroup.BaseFilename); // files.Add(file); // Trace.WriteLine("move file \"{0}\" to \"{1}\"", fileGroup.File, file + ".tmp"); // if (!_simulate) // { // zfile.CreateFileDirectory(file); // File.Move(fileGroup.File, file + ".tmp"); // } //} n++; } foreach (string file in files) { Trace.WriteLine("rename tmp file \"{0}\"", file + ".tmp"); Trace.WriteLine(" to \"{0}\"", file); if (!_simulate) { zFile.Move(file + ".tmp", file); } } }