Migliorata formattazione dei testi e dei tags #8

Merged
Mrk merged 1 commits from mrk/Upgrade format AGit into master 2026-01-05 16:26:35 +01:00
5 changed files with 227 additions and 688 deletions

No files matched your search

+130 -54
View File
@@ -1,13 +1,14 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
namespace A69WD {
public class cTools {
@@ -476,7 +477,7 @@ namespace A69WD {
/// <param name="txt">Testo da formattare</param>
/// <param name="eliminaTagHtml">Abilitare l'eliminazione di tutti i generici tag </param>
/// <returns>Testo formattato</returns>
public static string FormattaTesto(string txt, bool eliminaTagHtml) {
public static string FormattaTesto(string txt, bool eliminaTagHtml = true) {
try {
// Analisi dei tag prima di levarli:
string testo = Regex.Replace(txt, @"<P>", "\r\n", RegexOptions.IgnoreCase);
@@ -503,6 +504,20 @@ namespace A69WD {
}
// Special Entities dal sito https://www.htmlhelp.com/reference/html40/entities/special.html
// More can be added, see http://hotwired.lycos.com/webmonkey/reference/special_characters/
// Correggo risultato togliendo doppie linee e caratteri html:
testo = Regex.Replace(testo, @"&nbsp;", " ", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&bull;", " * ", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&hellip;", "…", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&trade;", "(tm)", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&copy;", "(c)", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&reg;", "(r)", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&frasl;", "/", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&agrave;", "à", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&egrave;", "è", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&igrave;", "ì", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&ograve;", "ò", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&ugrave;", "ù", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&quot;", "\"", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&amp;", "&", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&lt;", "<", RegexOptions.IgnoreCase);
@@ -527,8 +542,13 @@ namespace A69WD {
testo = Regex.Replace(testo, @"&euro;", "€", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#34;", "\"", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#38;", "&", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#39;", "'", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#60;", "<", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#62;", ">", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#268;", "Č", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#269;", "č", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#282;", "Ě", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#283;", "ě", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#339;", "œ", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#353;", "š", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#376;", "Ÿ", RegexOptions.IgnoreCase);
@@ -543,10 +563,13 @@ namespace A69WD {
testo = Regex.Replace(testo, @"&#8221;", "”", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8222;", "„", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8224;", "†", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8230;", "…", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8232;", " ", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8240;", "‰", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8249;", "‹", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8250;", "›", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8364;", "€", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#61516;", " ", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#x22;", "\"", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#x26;", "&", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#x3C;", "<", RegexOptions.IgnoreCase);
@@ -570,58 +593,17 @@ namespace A69WD {
testo = Regex.Replace(testo, @"&#x203A;", "›", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#x20AC;", "€", RegexOptions.IgnoreCase);
// Correggo risultato togliendo doppie linee e caratteri html:
testo = Regex.Replace(testo, @"&nbsp;", " ", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&bull;", " * ", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&lt;", "<", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&rsaquo;", " > ", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&gt;", ">", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&trade;", "(tm)", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&copy;", "(c)", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&reg;", "(r)", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&frasl;", "/", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&agrave;", "à", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&egrave;", "è", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&igrave;", "ì", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&ograve;", "ò", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&ugrave;", "ù", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8211;", "–", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8212;", "—", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8216;", "‘", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8217;", "’", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8220;", "“", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8221;", "”", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8230;", "…", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#268;", "Č", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#269;", "č", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#282;", "Ě", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#283;", "ě", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#8232;", " ", RegexOptions.IgnoreCase);
testo = Regex.Replace(testo, @"&#61516;", " ", RegexOptions.IgnoreCase);
// // Remove all others. More can be added, see
// // http://hotwired.lycos.com/webmonkey/reference/special_characters/
// testo = Regex.Replace(testo, @"&(.{2,6});", string.Empty, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
//// Correggo accenti per formati sbagliati:
//while (testo.Contains("à")) { testo = testo.Replace("à", "à"); }
//while (testo.Contains("è")) { testo = testo.Replace("è", "è"); }
//while (testo.Contains("é")) { testo = testo.Replace("é", "é"); }
//while (testo.Contains("ì")) { testo = testo.Replace("ì", "ì"); }
//while (testo.Contains("ò")) { testo = testo.Replace("ò", "ò"); }
//while (testo.Contains("ù")) { testo = testo.Replace("ù", "ù"); }
//while (testo.Contains("’")) { testo = testo.Replace("’", "'"); }
// Correggo accenti per formati sbagliati:
while (testo.Contains("à")) { testo = testo.Replace("à", "à"); }
while (testo.Contains("è")) { testo = testo.Replace("è", "è"); }
while (testo.Contains("é")) { testo = testo.Replace("é", "é"); }
while (testo.Contains("ì")) { testo = testo.Replace("ì", "ì"); }
while (testo.Contains("ò")) { testo = testo.Replace("ò", "ò"); }
while (testo.Contains("ù")) { testo = testo.Replace("ù", "ù"); }
while (testo.Contains("’")) { testo = testo.Replace("’", "'"); }
// Correggo scritto:
testo = testo.Replace("&#038;egrave", "è");
testo = testo.Replace("&amp;", "&");
testo = testo.Replace("&hellip;", "…");
testo = testo.Replace("\r", "");
testo = testo.Replace("\r", "\n");
while (testo.Contains("\t")) { testo = testo.Replace("\t", " "); }
while (testo.Contains("...")) { testo = testo.Replace("...", "…"); }
while (testo.Contains("….")) { testo = testo.Replace("….", "…"); }
@@ -637,8 +619,6 @@ namespace A69WD {
public static bool WriteStyleSheet(string FullFileName) {
try {
StringBuilder sb = new StringBuilder();
@@ -653,6 +633,102 @@ namespace A69WD {
public static void Insert_Format_Tags(ref List<string> dst, List<string> items) {
try {
// // Rimuove duplicati e ordina alfabeticamente
// items = items
// .OrderBy(s => s) // ordina alfabeticamente
// .Distinct() // elimina duplicati
// .ToList();
if (dst is null) { dst = new List<string>(); }
// Ordino ed elimino duplicati
items.Sort();
string tmp = "";
foreach (string item in items) {
string it = item.Trim().ToLower();
if (tmp != it) {
#region switch per formattare il testo
switch (it) {
case "altro": // Src: Old_Milu
dst.Add("Altro");
break;
case "autoerotismo": // Src: Old_Milu
dst.Add("Masturbazione");
break;
case "bdsm": // Src: A69
dst.Add("BDSM");
break;
case "cuckold": // Src: Old_Milu
dst.Add("Cuckold");
break;
case "dominazione": // Src: Old_Milu
dst.Add("Dominazione");
break;
case "gay": // Src: Old_Milu
dst.Add("Gay");
break;
case "gay & bisex": // Src: A69
dst.Add("Bisex");
dst.Add("Gay");
break;
case "incesto": // Src: A69, Old_Milu
dst.Add("Incesto");
break;
case "lesbo": // Src: A69
case "saffico": // Src: Old_Milu
dst.Add("Lesbo");
break;
case "lirica": // Src: Old_Milu
dst.Add("Lirica");
break;
case "lui & lei": // Src: A69
case "etero": // Src: Old_Milu
dst.Add("Etero");
break;
case "orge": // Src: A69
case "orgia": // Src: Old_Milu
dst.Add("Orge");
break;
case "poesia": // Src: Old_Milu
dst.Add("Poesia");
break;
case "prime esperienze": // Src: A69
dst.Add("Prime Esperienze");
break;
case "scambio di coppia": // Src: A69
dst.Add("Scambismo");
break;
case "sensazioni": // Src: Old_Milu
dst.Add("Sensazioni");
break;
case "tradimenti": // Src: A69
dst.Add("Tradimenti");
break;
case "trans": // Src: A69, Old_Milu
dst.Add("Trans");
break;
case "trio": // Src: A69, Old_Milu
dst.Add("trio");
break;
//case "":
// dst.Add("");
// break;
default:
dst.Add(item);
break;
}
#endregion
tmp = it;
}//if
}//foreach
} catch (Exception ex) {
Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00040", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message));
} finally {
if (dst.Count == 0) dst.Add("_None_");
}
}//function
} // class Tools
+7 -272
View File
@@ -250,7 +250,9 @@ namespace A69WD.Net {
.OrderBy(s => s) // ordina alfabeticamente
.Distinct() // elimina duplicati
.ToList();
Format_Insert_Tags(rac, items); // rac.Tags = items;
List<string> tmpTags = new List<string>();
cTools.Insert_Format_Tags(ref tmpTags, items);
rac.Tags = tmpTags;
} catch (Exception ex) { Logger.Warning(string.Format("Fallita estrazione Tags dal file {0}\r\n{1}", FileName, ex.Message)); return null; }
#endregion
@@ -425,7 +427,10 @@ namespace A69WD.Net {
.OrderBy(s => s) // ordina alfabeticamente
.Distinct() // elimina duplicati
.ToList();
Format_Insert_Tags(rac, items); // rac.Tags = items;
//Format_Insert_Tags(rac, items); // rac.Tags = items;
List<string> tmpTags = new List<string>();
cTools.Insert_Format_Tags(ref tmpTags, items);
rac.Tags = tmpTags;
} catch (Exception ex) { Logger.Warning(string.Format("Fallita estrazione Tags dal file {0}\r\n{1}", FileName, ex.Message)); return null; }
#endregion
@@ -464,276 +469,6 @@ namespace A69WD.Net {
return rac;
}
protected virtual void Format_Insert_Tags(Data.cRac rac, List<string> items) {
// Per ora riporto tutti i tag rilevati, mentre in futuro dovrò:
// - parsare la lista e formattare correttamente i tag
// - ordinare la lista dei tag formattati ed eliminare i duplicati
// - se non sono rimasti tag, inserisco il tag generale per indicare che non vi sono tag
// - altrimenti inserisco tutti i tag rimasti.
rac.Tags = new List<string>();
try {
items.Sort();
string tmp = "";
foreach (string item in items) {
string it = item.Trim().ToLower();
if (tmp != it) {
#region switch per formattare il testo
switch (it) {
//case "racconti 69":
// rac.Tags.Add("69");
// break;
//case "abusi":
// rac.Tags.Add("Abusi");
// break;
//case "camgirl":
//case "chat e siti di incontri…":
//case "fiche":
// rac.Tags.Add("Altro");
// break;
//case "amatoriali":
// rac.Tags.Add("Amatoriali");
// break;
//case "anale":
// rac.Tags.Add("Anale");
// break;
//case "audio libri erotici":
//case "audio racconti erotici":
// rac.Tags.Add("Audio");
// break;
//case "bdsm":
// rac.Tags.Add("BDMS");
// break;
//case "bisex":
//case "bisex ♀":
//case "bisex ♂":
// rac.Tags.Add("Bisex");
// break;
//case "bondage":
// rac.Tags.Add("Bondage");
// break;
//case "bondage e sadomaso":
// rac.Tags.Add("Bondage");
// rac.Tags.Add("Sadomaso");
// break;
//case "bukkake":
// rac.Tags.Add("Bukkake");
// break;
//case "comici":
//case "comunità":
// rac.Tags.Add("Comico");
// break;
//case "concorso estate 2019":
//case "concorso natale 2018":
//case "decameron 2020":
// rac.Tags.Add("Concorso");
// break;
//case "confessioni":
// rac.Tags.Add("Confessioni");
// break;
//case "coppie":
//case "scambio di coppia":
//case "scambio di coppie":
// rac.Tags.Add("Coppie");
// break;
//case "cuckold":
//case "racconti cuckold":
// rac.Tags.Add("Cuckold");
// break;
//case "curiosità":
//case "curiosità sul sesso":
// rac.Tags.Add("Curiosità");
// break;
//case "dominazione":
//case "racconti di dominazione":
//case "schiavi&amp;padroni":
// rac.Tags.Add("Dominazione");
// break;
//case "doppia penetrazione":
// rac.Tags.Add("Doppia Penetrazione");
// break;
//case "esibizionismo":
// rac.Tags.Add("Esibizionismo");
// break;
//case "etero":
//case "lui & lei":
//case "racconti erotici etero":
// rac.Tags.Add("Etero");
// break;
//case "feticismo":
// rac.Tags.Add("Feticismo");
// break;
//case "fisting":
// rac.Tags.Add("Fisting");
// break;
//case "gang bang":
// rac.Tags.Add("Gang Bang");
// break;
//case "gay":
//case "racconti gay":
// rac.Tags.Add("Gay");
// break;
//case "gay & bisex":
//case "gay e bisex":
// rac.Tags.Add("Gay");
// rac.Tags.Add("Bisex");
// break;
//case "gay - travestiti":
// rac.Tags.Add("Gay");
// rac.Tags.Add("Trans");
// break;
//case "incesti":
//case "incesto":
//case "racconti erotici sull'incesto":
// rac.Tags.Add("Incesto");
// break;
//case "interviste":
//case "interviste erotiche":
// rac.Tags.Add("Intervista");
// break;
//case "lesbo":
//case "racconti erotici lesbo":
//case "saffico":
// rac.Tags.Add("Lesbo");
// break;
//case "autoerotismo":
//case "masturbazione":
//case "masturbazioni":
//case "racconti sull'autoerotismo":
// rac.Tags.Add("Masturbazione");
// break;
//case "milf":
// rac.Tags.Add("MILF");
// break;
//case "nudismo":
// rac.Tags.Add("Nudismo");
// break;
//case "orge":
//case "orgia":
//case "sesso di gruppo":
// rac.Tags.Add("Orge");
// break;
//case "pissing":
// rac.Tags.Add("Pissing");
// break;
//case "lirica erotica":
//case "poesia erotica":
//case "poesie":
//case "poesie erotiche":
// rac.Tags.Add("Poesia");
// break;
//case "pompini":
// rac.Tags.Add("Pompini");
// break;
//case "giochi erotici":
//case "prime esperienze":
//case "prime volte":
// rac.Tags.Add("Prime Esperienze");
// break;
//case "pulp":
// rac.Tags.Add("Pulp");
// break;
//case "sadomaso":
// rac.Tags.Add("Sadomaso");
// break;
//case "sensazioni":
//case "sentimentali":
// rac.Tags.Add("Sentimentali");
// break;
//case "cornuti":
//case "tradimenti":
//case "tradimento":
// rac.Tags.Add("Tradimento");
// break;
//case "racconti con trans":
//case "racconti trans":
//case "trans":
//case "trans e travestiti":
// rac.Tags.Add("Trans");
// break;
//case "trasgressivo":
// rac.Tags.Add("Trasgressivo");
// break;
//case "trio":
// rac.Tags.Add("Trio");
// break;
//case "uncategorized":
// rac.Tags.Add("Uncategorized");
// break;
//case "voyeur":
//case "voyeurismo":
// rac.Tags.Add("Voyeur");
// break;
//case "animali":
//case "zoofilia":
// rac.Tags.Add("Zoofilia");
// break;
//case "Gay":
// rac.Tags.Add("Gay");
// break;
//case "Racconti bisex":
// rac.Tags.Add("Bisex");
// break;
//case "Racconti etero":
// rac.Tags.Add("Etero");
// break;
//case "Racconti fetish":
// rac.Tags.Add("Feticismo");
// break;
//case "Racconti incesto":
// rac.Tags.Add("Incesto");
// break;
//case "Racconti lesbo":
// rac.Tags.Add("Lesbo");
// break;
//case "Racconti masturbazione":
// rac.Tags.Add("Masturbazione");
// break;
//case "Racconti mature":
// rac.Tags.Add("Mature");
// break;
//case "Racconti orge":
// rac.Tags.Add("Orge");
// break;
//case "Racconti prima volta":
// rac.Tags.Add("Prime Esperienze");
// break;
//case "Racconti ricatto":
// rac.Tags.Add("Ricatto");
// break;
//case "Racconti scambio di coppia":
// rac.Tags.Add("Coppie");
// break;
//case "Racconti sottomissione":
// rac.Tags.Add("Dominazione");
// break;
//case "Racconti tradimenti":
// rac.Tags.Add("Tradimento");
// break;
//case "Racconti trav":
//case "Trans":
// rac.Tags.Add("Trans");
// break;
default:
rac.Tags.Add(item);
break;
}
#endregion
tmp = it;
}//if
}//foreach
} catch (Exception ex) {
Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00040", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message));
} finally {
if (rac.Tags.Count == 0) rac.Tags.Add("_None_");
}
}//function
#region Gestione Sito A69
+4 -69
View File
@@ -275,7 +275,10 @@ namespace A69WD.Net {
.OrderBy(s => s) // ordina alfabeticamente
.Distinct() // elimina duplicati
.ToList();
Format_Insert_Tags(rac, items); // rac.Tags = items;
//Format_Insert_Tags(rac, items); // rac.Tags = items;
List<string> tmpTags = new List<string>();
cTools.Insert_Format_Tags(ref tmpTags, items);
rac.Tags = tmpTags;
} catch (Exception ex) { Logger.Warning(string.Format("Fallita estrazione Tags dal file {0}\r\n{1}", FileName, ex.Message)); return null; }
#endregion
@@ -317,74 +320,6 @@ namespace A69WD.Net {
protected virtual void Format_Insert_Tags(Data.cRac rac, List<string> items) {
// Per ora riporto tutti i tag rilevati, mentre in futuro dovrò:
// - parsare la lista e formattare correttamente i tag
// - ordinare la lista dei tag formattati ed eliminare i duplicati
// - se non sono rimasti tag, inserisco il tag generale per indicare che non vi sono tag
// - altrimenti inserisco tutti i tag rimasti.
rac.Tags = new List<string>();
try {
items.Sort();
string tmp = "";
foreach (string item in items) {
string it = item.Trim().ToLower();
if (tmp != it) {
#region switch per formattare il testo
switch (it) {
//case "Gay & Bisex":
// rac.Tags.Add("Bisex");
// rac.Tags.Add("Gay");
// break;
//case "tradimenti":
// rac.Tags.Add("Tradimenti");
// break;
//case "Lui & Lei":
// rac.Tags.Add("Lui & Lei");
// break;
//case "trans":
// rac.Tags.Add("Trans");
// break;
//case "Prime Esperienze":
// rac.Tags.Add("Prime Esperienze");
// break;
//case "trio":
// rac.Tags.Add("Trio");
// break;
//case "incesto":
// rac.Tags.Add("Incesto");
// break;
//case "orge":
// rac.Tags.Add("Orge");
// break;
//case "bdsm":
// rac.Tags.Add("BDSM");
// break;
//case "lesbo":
// rac.Tags.Add("Lesbo");
// break;
//case "Scambio di Coppia":
// rac.Tags.Add("Scambio di Coppia");
// break;
default:
rac.Tags.Add(item);
break;
}
#endregion
tmp = it;
}//if
}//foreach
} catch (Exception ex) {
Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00040", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message));
} finally {
if (rac.Tags.Count == 0) rac.Tags.Add("_None_");
}
}//function
#region Gestione Sito eRac
private static HttpClient client = null;
+19 -2
View File
@@ -32,8 +32,25 @@ using System.Runtime.InteropServices;
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
// usando l'asterisco '*' come illustrato di seguito:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.3.1")]
[assembly: AssemblyFileVersion("0.5.3.1")]
[assembly: AssemblyVersion("0.5.3.2")]
[assembly: AssemblyFileVersion("0.5.3.2")]
/*
*
* Vrs 0.5.3.2
*
* Compilata da CSiCoAlm il 2026/01/05
* - Update formattazione testi per eliminare problemi con accenti e caratteri html
* - Update formattazione tags per uniformare quelli di A69 e di Old_Milu
*
*
* ToDo:
* - Aggiungere gestione parallela della FIFO secondo vecchi modello per aumentare il feedback alla UI
* - Inserire anche l'estrazione dei racconti
* - Inserire funzionalità avanzate sul lettore
*
*/
/*
+67 -291
View File
@@ -225,9 +225,21 @@ namespace A69WD.Service {
List<string> origini = null;
List<string> tags = null;
List<cNota> notes = null;
string titolo = string.Empty;
string autore = string.Empty;
DateTime creato = DateTime.Now;
string infoCategories = string.Empty;
string infoPublished = string.Empty;
string infoCharacters = string.Empty;
string infoGenres = string.Empty;
string infoWarnings = string.Empty;
string infoChallenges = string.Empty;
string infoSeries = string.Empty;
string infoChapters = string.Empty;
string infoCompleted = string.Empty;
string infoWordCount = string.Empty;
string infoRead = string.Empty;
#region Info comuni a tutti i capitoli del racconto:
#region Origine
@@ -271,12 +283,11 @@ namespace A69WD.Service {
items.Add(cTools.FormattaTesto(nd.InnerText.Replace("genere", "").Trim(), false));
}
}
//items.Sort();
items = items
.OrderBy(s => s) // ordina alfabeticamente
.Distinct() // elimina duplicati
.ToList();
tags = items;
//items = items
// .OrderBy(s => s) // ordina alfabeticamente
// .Distinct() // elimina duplicati
// .ToList();
cTools.Insert_Format_Tags(ref tags, items);
if (tags.Count<1) {
Logger.Error($"Old Milu - Import - No Tags - {filePathName}");
return null;
@@ -284,25 +295,54 @@ namespace A69WD.Service {
} catch (Exception ex) { Logger.Warning(string.Format("Fallita estrazione Tags dal file {0}\r\n{1}", filePathName, ex.Message)); return null; }
#endregion
#region Creato
#region Creato & Notes
// Estraggo le informazioni generali
// Data estreatta dal testo del nodo <div class="infobox">< div class="content"> fra "Published{Published}Updated:
try {
nodes = root.SelectNodes("//div[@class='infobox']//div[@class='content']");
foreach (HtmlNode nd in nodes) {
string txt = nd.InnerText.Trim().Replace("&nbsp;", "");
int start = txt.LastIndexOf(" Published: ");
int stop = txt.LastIndexOf(" Updated: ");
string strData = txt.Substring(start + 11, stop - start - 11);
CultureInfo culture = CultureInfo.CreateSpecificCulture("it-IT");
DateTimeStyles styles = DateTimeStyles.None;
DateTime tmpDT = DateTime.Now;
if (!DateTime.TryParse(strData.Trim(), culture, styles, out creato)) {
Logger.Error($"Old Milu - Import - No data - {filePathName}");
}
HtmlNode nd = root.SelectSingleNode("//div[@class='infobox']//div[@class='content']");
string txt = nd.InnerText.Trim().Replace("&nbsp;", "");
infoPublished = TxtExtract(txt, "Published: ", "Updated: ");
infoCategories = TxtExtract(txt, "Categories:", "Characters:");
infoCharacters = TxtExtract(txt, "Characters:", "Genres:");
infoGenres = TxtExtract(txt, "Genres:", "Warnings:");
infoWarnings = TxtExtract(txt, "Warnings:", "Challenges:");
infoChallenges = TxtExtract(txt, "Challenges:", "Series:");
infoSeries = TxtExtract(txt, "Series:", "Chapters");
infoChapters = TxtExtract(txt, "Chapters:", "Completed");
infoCompleted = TxtExtract(txt, "Completed:", "Word count:");
infoWordCount = TxtExtract(txt, "Word count:", "Read:");
infoRead = TxtExtract(txt, "Read:", "Published:");
} catch (Exception ex) { Logger.Warning(string.Format("Informazioni generali non riconosciute nel file {0}\r\n{1}", filePathName, ex.Message)); return null; }
// Data del racconto
try {
CultureInfo culture = CultureInfo.CreateSpecificCulture("it-IT");
DateTimeStyles styles = DateTimeStyles.None;
if (!DateTime.TryParse(infoPublished.Trim(), culture, styles, out creato)) {
Logger.Error($"Old Milu - Import - No data - {filePathName}");
}
} catch (Exception ex) { Logger.Warning(string.Format("Data non riconosciuta nel file {0}\r\n{1}", filePathName, ex.Message)); return null; }
// Notes (comuni fra tutti i racconti):
try {
notes = new List<Data.cNota>();
notes.Add(new Data.cNota("SrcFile", System.IO.Path.GetFileName(filePathName)));
notes.Add(new Data.cNota("infoCategories", infoCategories));
notes.Add(new Data.cNota("infoCharacters", infoCharacters));
notes.Add(new Data.cNota("infoGenres", infoGenres));
notes.Add(new Data.cNota("infoWarnings", infoWarnings));
notes.Add(new Data.cNota("infoChallenges", infoChallenges));
notes.Add(new Data.cNota("infoSeries", infoSeries));
notes.Add(new Data.cNota("infoChapters", infoChapters));
notes.Add(new Data.cNota("infoCompleted", infoCompleted));
notes.Add(new Data.cNota("infoWordCount", infoWordCount));
notes.Add(new Data.cNota("infoRead", infoRead));
notes.Add(new Data.cNota("infoPublished", infoPublished));
} catch (Exception ex) { Logger.Warning(string.Format("Notes non riconosciute nel file {0}\r\n{1}", filePathName, ex.Message)); return null; }
#endregion
#endregion
// I vari capitoli dei racconti sono descritti dai nodi <div class='chaptertitle'> e <div class='chapter'> in successione.
try {
HtmlNodeCollection capTitles = root.SelectNodes("//div[@class='chaptertitle']");
@@ -313,7 +353,7 @@ namespace A69WD.Service {
// Creo i racconti:
rac = new cRac();
rac.Title = titolo;
rac.SubTitle = capTitles[i].InnerText.Trim().Replace($"by {autore}","").Trim();
rac.SubTitle = cTools.FormattaTesto(capTitles[i].InnerText.Trim().Replace($"by {autore}","").Trim(),true);
rac.Creato = creato;
rac.Updated = DateTime.Now;
//rac.Trama = cTools.FormattaTesto(capText[i].InnerHtml.Trim(), false);
@@ -323,8 +363,7 @@ namespace A69WD.Service {
rac.Autori.Add(autore);
rac.Tags = tags;
rac.Origini = origini;
rac.Notes = new List<Data.cNota>();
rac.Notes.Add(new Data.cNota("SrcFile", System.IO.Path.GetFileName(filePathName)));
rac.Notes = notes;
// Inserisco il racconto nella collezione
if (rac.Validate()) { racs.Add(rac); }
}
@@ -334,7 +373,6 @@ namespace A69WD.Service {
return null;
}
} catch (Exception ex) { Logger.Warning(string.Format("Fallita estrazione capitolo {0}\r\n{1}", filePathName, ex.Message)); return null; }
#endregion
Logger.Information($"Terminato estrazione racconti dal file: {filePathName}");
@@ -347,274 +385,12 @@ namespace A69WD.Service {
}
protected virtual void Format_Insert_Tags(Data.cRac rac, List<string> items) {
// Per ora riporto tutti i tag rilevati, mentre in futuro dovrò:
// - parsare la lista e formattare correttamente i tag
// - ordinare la lista dei tag formattati ed eliminare i duplicati
// - se non sono rimasti tag, inserisco il tag generale per indicare che non vi sono tag
// - altrimenti inserisco tutti i tag rimasti.
rac.Tags = new List<string>();
try {
items.Sort();
string tmp = "";
foreach (string item in items) {
string it = item.Trim().ToLower();
if (tmp != it) {
#region switch per formattare il testo
switch (it) {
//case "racconti 69":
// rac.Tags.Add("69");
// break;
//case "abusi":
// rac.Tags.Add("Abusi");
// break;
//case "camgirl":
//case "chat e siti di incontri…":
//case "fiche":
// rac.Tags.Add("Altro");
// break;
//case "amatoriali":
// rac.Tags.Add("Amatoriali");
// break;
//case "anale":
// rac.Tags.Add("Anale");
// break;
//case "audio libri erotici":
//case "audio racconti erotici":
// rac.Tags.Add("Audio");
// break;
//case "bdsm":
// rac.Tags.Add("BDMS");
// break;
//case "bisex":
//case "bisex ♀":
//case "bisex ♂":
// rac.Tags.Add("Bisex");
// break;
//case "bondage":
// rac.Tags.Add("Bondage");
// break;
//case "bondage e sadomaso":
// rac.Tags.Add("Bondage");
// rac.Tags.Add("Sadomaso");
// break;
//case "bukkake":
// rac.Tags.Add("Bukkake");
// break;
//case "comici":
//case "comunità":
// rac.Tags.Add("Comico");
// break;
//case "concorso estate 2019":
//case "concorso natale 2018":
//case "decameron 2020":
// rac.Tags.Add("Concorso");
// break;
//case "confessioni":
// rac.Tags.Add("Confessioni");
// break;
//case "coppie":
//case "scambio di coppia":
//case "scambio di coppie":
// rac.Tags.Add("Coppie");
// break;
//case "cuckold":
//case "racconti cuckold":
// rac.Tags.Add("Cuckold");
// break;
//case "curiosità":
//case "curiosità sul sesso":
// rac.Tags.Add("Curiosità");
// break;
//case "dominazione":
//case "racconti di dominazione":
//case "schiavi&amp;padroni":
// rac.Tags.Add("Dominazione");
// break;
//case "doppia penetrazione":
// rac.Tags.Add("Doppia Penetrazione");
// break;
//case "esibizionismo":
// rac.Tags.Add("Esibizionismo");
// break;
//case "etero":
//case "lui & lei":
//case "racconti erotici etero":
// rac.Tags.Add("Etero");
// break;
//case "feticismo":
// rac.Tags.Add("Feticismo");
// break;
//case "fisting":
// rac.Tags.Add("Fisting");
// break;
//case "gang bang":
// rac.Tags.Add("Gang Bang");
// break;
//case "gay":
//case "racconti gay":
// rac.Tags.Add("Gay");
// break;
//case "gay & bisex":
//case "gay e bisex":
// rac.Tags.Add("Gay");
// rac.Tags.Add("Bisex");
// break;
//case "gay - travestiti":
// rac.Tags.Add("Gay");
// rac.Tags.Add("Trans");
// break;
//case "incesti":
//case "incesto":
//case "racconti erotici sull'incesto":
// rac.Tags.Add("Incesto");
// break;
//case "interviste":
//case "interviste erotiche":
// rac.Tags.Add("Intervista");
// break;
//case "lesbo":
//case "racconti erotici lesbo":
//case "saffico":
// rac.Tags.Add("Lesbo");
// break;
//case "autoerotismo":
//case "masturbazione":
//case "masturbazioni":
//case "racconti sull'autoerotismo":
// rac.Tags.Add("Masturbazione");
// break;
//case "milf":
// rac.Tags.Add("MILF");
// break;
//case "nudismo":
// rac.Tags.Add("Nudismo");
// break;
//case "orge":
//case "orgia":
//case "sesso di gruppo":
// rac.Tags.Add("Orge");
// break;
//case "pissing":
// rac.Tags.Add("Pissing");
// break;
//case "lirica erotica":
//case "poesia erotica":
//case "poesie":
//case "poesie erotiche":
// rac.Tags.Add("Poesia");
// break;
//case "pompini":
// rac.Tags.Add("Pompini");
// break;
//case "giochi erotici":
//case "prime esperienze":
//case "prime volte":
// rac.Tags.Add("Prime Esperienze");
// break;
//case "pulp":
// rac.Tags.Add("Pulp");
// break;
//case "sadomaso":
// rac.Tags.Add("Sadomaso");
// break;
//case "sensazioni":
//case "sentimentali":
// rac.Tags.Add("Sentimentali");
// break;
//case "cornuti":
//case "tradimenti":
//case "tradimento":
// rac.Tags.Add("Tradimento");
// break;
//case "racconti con trans":
//case "racconti trans":
//case "trans":
//case "trans e travestiti":
// rac.Tags.Add("Trans");
// break;
//case "trasgressivo":
// rac.Tags.Add("Trasgressivo");
// break;
//case "trio":
// rac.Tags.Add("Trio");
// break;
//case "uncategorized":
// rac.Tags.Add("Uncategorized");
// break;
//case "voyeur":
//case "voyeurismo":
// rac.Tags.Add("Voyeur");
// break;
//case "animali":
//case "zoofilia":
// rac.Tags.Add("Zoofilia");
// break;
//case "Gay":
// rac.Tags.Add("Gay");
// break;
//case "Racconti bisex":
// rac.Tags.Add("Bisex");
// break;
//case "Racconti etero":
// rac.Tags.Add("Etero");
// break;
//case "Racconti fetish":
// rac.Tags.Add("Feticismo");
// break;
//case "Racconti incesto":
// rac.Tags.Add("Incesto");
// break;
//case "Racconti lesbo":
// rac.Tags.Add("Lesbo");
// break;
//case "Racconti masturbazione":
// rac.Tags.Add("Masturbazione");
// break;
//case "Racconti mature":
// rac.Tags.Add("Mature");
// break;
//case "Racconti orge":
// rac.Tags.Add("Orge");
// break;
//case "Racconti prima volta":
// rac.Tags.Add("Prime Esperienze");
// break;
//case "Racconti ricatto":
// rac.Tags.Add("Ricatto");
// break;
//case "Racconti scambio di coppia":
// rac.Tags.Add("Coppie");
// break;
//case "Racconti sottomissione":
// rac.Tags.Add("Dominazione");
// break;
//case "Racconti tradimenti":
// rac.Tags.Add("Tradimento");
// break;
//case "Racconti trav":
//case "Trans":
// rac.Tags.Add("Trans");
// break;
default:
rac.Tags.Add(item);
break;
}
#endregion
tmp = it;
}//if
}//foreach
} catch (Exception ex) {
Logger.Error(string.Format("Error Code: {0} - Errore in {1}.{2}: {3}", "ER00040", System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name, ex.Message));
} finally {
if (rac.Tags.Count == 0) rac.Tags.Add("_None_");
}
}//function
protected string TxtExtract(string src, string start, string end) {
int nstart = src.LastIndexOf(start);
int nstop = src.LastIndexOf(end);
int offset = start.Length;
return src.Substring(nstart + offset, nstop - nstart - offset).Trim();
}
}//class Service_Import_Milu