diff --git a/Src/A69WD/A69WD.csproj.user b/Src/A69WD/A69WD.csproj.user
index e0be25f..56fd5d8 100644
--- a/Src/A69WD/A69WD.csproj.user
+++ b/Src/A69WD/A69WD.csproj.user
@@ -1,6 +1,6 @@
- ShowAllFiles
+ ProjectFiles
\ No newline at end of file
diff --git a/Src/A69WD/Data/DBTools.cs b/Src/A69WD/Data/DBTools.cs
index 27abf0d..816b6b0 100644
--- a/Src/A69WD/Data/DBTools.cs
+++ b/Src/A69WD/Data/DBTools.cs
@@ -32,7 +32,7 @@ namespace A69WD {
public System.Data.SQLite.SQLiteConnection cn { get; set; }
///
- /// Indicatore che il DB è ready
+ /// Indicatore che il DB è ready
///
public bool DB_ok { get; set; }
@@ -314,6 +314,39 @@ namespace A69WD {
}
+ public bool IsPresent(string url, int timeOffset = 0) {
+ lock (objLock) {
+ try {
+ string query = timeOffset != 0 ?
+ "SELECT Status FROM LinksLog WHERE LinkURL=@LinkURL AND LastUpdate>=@LastUpdate LIMIT 1" :
+ "SELECT Status FROM LinksLog WHERE LinkURL=@LinkURL LIMIT 1" ;
+ System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand();
+ cmd.Connection = cn;
+ cmd.CommandText = query;
+ cmd.CommandType = System.Data.CommandType.Text;
+ System.Data.SQLite.SQLiteParameter param = new System.Data.SQLite.SQLiteParameter();
+ param.ParameterName = "@LinkURL";
+ param.DbType = global::System.Data.DbType.String;
+ param.SourceColumn = "LinkURL";
+ cmd.Parameters.Add(param);
+ param = new System.Data.SQLite.SQLiteParameter();
+ param.ParameterName = "@LastUpdate";
+ param.DbType = global::System.Data.DbType.DateTime;
+ param.SourceColumn = "LastUpdate";
+ cmd.Parameters.Add(param);
+ cmd.Parameters[0].Value = url;
+ cmd.Parameters[1].Value = DateTime.Now.AddHours(timeOffset);
+ object obj = cmd.ExecuteScalar();
+ if (obj != null) return true;
+ return false;
+ } catch (Exception ex) {
+ Logger.Log(new object[] { "Error Code: DB06521", string.Format("MyDownloader.DBTools.GetStateByURL({0})", url), ex });
+ return false;
+ }
+ }
+ }
+
+
///
/// Aggiorna il log relativo al link nel DB.
///
diff --git a/Src/A69WD/Net/cLink_A69.cs b/Src/A69WD/Net/cLink_A69.cs
index a3ea3f2..08249b0 100644
--- a/Src/A69WD/Net/cLink_A69.cs
+++ b/Src/A69WD/Net/cLink_A69.cs
@@ -29,7 +29,17 @@ namespace A69WD.Net {
public string FilePath { get => filepath; }
- public bool Validate => true;
+ public bool Validate {
+ get {
+ if (URL.StartsWith("https://www.annunci69.it/racconti-erotici/racconti_lista.php?genere=")) {
+ // URL di tipo Idx, devo lavorare i link nuovo o rilavorare i link più obsoleti di 6 ore.
+ return !App.DB.IsPresent(URL, -6);
+ } else {
+ // URL di tipo Rac, devo lavorare solo i link nuovi
+ return !App.DB.IsPresent(URL);
+ }
+ }
+ }
public eLinkState Status { get => status; set { status = value; } }
@@ -86,8 +96,8 @@ namespace A69WD.Net {
// Logger.Error("Errore inserendo A69 Start Link - " + ex.Message);
// return false;
//}
- string url = LinkIdxBase.Replace("{Categoria}", "trio").Replace("{ID}", "1");
- string name = "_A69_trio_0001.html";
+ string url = LinkIdxBase.Replace("{Categoria}", "altro").Replace("{ID}", "1"); //LinkIdxBase.Replace("{Categoria}", "trio").Replace("{ID}", "1");
+ string name = "_A69_altro_0001.html"; //"_A69_trio_0001.html";
service.EnqueueUrl(new cLink_A69(url, name));
return true;
}
diff --git a/Src/A69WD/Net/eLinkState.cs b/Src/A69WD/Net/eLinkState.cs
index 21f7f27..ed55418 100644
--- a/Src/A69WD/Net/eLinkState.cs
+++ b/Src/A69WD/Net/eLinkState.cs
@@ -20,7 +20,7 @@ namespace A69WD.Net {
///
ToDownload = 2,
///
- /// Indica un iLink che è in download
+ /// Indica un iLink che è in download
///
OnDownload = 3,
///
@@ -28,7 +28,7 @@ namespace A69WD.Net {
///
ToAnalize = 4,
///
- /// Indica un iLink in cui si è concluso il lavoro.
+ /// Indica un iLink in cui si è concluso il lavoro.
///
End = 5,
///
@@ -36,11 +36,11 @@ namespace A69WD.Net {
///
Error = 6,
///
- /// Indica un iLink il cui download/analisi è stato abortito
+ /// Indica un iLink il cui download/analisi è stato abortito
///
Abort = 7,
///
- /// Indica un iLink il cui download/analisi è stato cancellato
+ /// Indica un iLink il cui download/analisi è stato cancellato
///
Cancel = 8,
diff --git a/Src/A69WD/Service/Service_Crawler.cs b/Src/A69WD/Service/Service_Crawler.cs
index fb4f2dc..d33bcf2 100644
--- a/Src/A69WD/Service/Service_Crawler.cs
+++ b/Src/A69WD/Service/Service_Crawler.cs
@@ -22,7 +22,7 @@ namespace A69WD.Service {
private readonly BlockingCollection _urlQueue = new BlockingCollection(new ConcurrentQueue());
// Semaforo per limitare il numero massimo di download simultanei
- private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(99);
+ private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(9);
// Contatori
private int _inCorso = 0;
@@ -91,7 +91,15 @@ namespace A69WD.Service {
try {
List urls = await _site.CrawlPageAsync(link);
Logger.Information("ProcessQueue: end url " + link.FileName + " - URL trovati: " + urls.Count.ToString("000"));
- foreach (iLink url in urls) { _urlQueue.Add(url); }
+ foreach (iLink url in urls) {
+ if (url.Validate) {
+ // Logger.Warning("URL Validato: " + url.FileName);
+ App.DB.LinkLog(url);
+ _urlQueue.Add(url);
+ //} else {
+ // Logger.Warning("URL NON Validato: " + url.FileName);
+ }
+ }
} catch (Exception ex) {
Interlocked.Increment(ref _errori);
Logger.Error($"Errore su {link}: {ex.Message}");
diff --git a/Src/A69WD/Site/cSite_A69.cs b/Src/A69WD/Site/cSite_A69.cs
index 2077f8f..5d2a816 100644
--- a/Src/A69WD/Site/cSite_A69.cs
+++ b/Src/A69WD/Site/cSite_A69.cs
@@ -104,20 +104,24 @@ namespace A69WD.Site {
HtmlDocument tdoc = null;
#region ToConfirm
+ //if (lk.Status == eLinkState.ToConfirm) {
+ // // Eseguo la verifica se link da downloadare
+ // eLinkState tstate = App.DB.GetStateByURL(lk.URL);
+ // if (
+ // (tstate == eLinkState.ToConfirm) ||
+ // (tstate == eLinkState.ToDownload) ||
+ // (tstate == eLinkState.Error)
+ // ) {
+ // lk.Status = eLinkState.ToDownload;
+ // App.DB.LinkLog(lk);
+ // } else {
+ // lk.Status = eLinkState.End;
+ // App.DB.LinkLog(lk);
+ // }
+ //}
if (lk.Status == eLinkState.ToConfirm) {
// Eseguo la verifica se link da downloadare
- eLinkState tstate = App.DB.GetStateByURL(lk.URL);
- if (
- (tstate == eLinkState.ToConfirm) ||
- (tstate == eLinkState.ToDownload) ||
- (tstate == eLinkState.Error)
- ) {
- lk.Status = eLinkState.ToDownload;
- App.DB.LinkLog(lk);
- } else {
- lk.Status = eLinkState.End;
- App.DB.LinkLog(lk);
- }
+ lk.Status = eLinkState.ToDownload;
}
#endregion