Enchance weblog
This commit is contained in:
@@ -829,7 +829,7 @@ class OptimizedTelegramScraper:
|
|||||||
|
|
||||||
self.state['channels'][channel] = last_message_id
|
self.state['channels'][channel] = last_message_id
|
||||||
self.save_state()
|
self.save_state()
|
||||||
print(f"\nCompleted scraping channel {channel}")
|
print(f"Completed scraping channel {channel}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error with channel {channel}: {e}")
|
print(f"Error with channel {channel}: {e}")
|
||||||
@@ -843,10 +843,10 @@ class OptimizedTelegramScraper:
|
|||||||
channel_name = self.state.get('channel_names', {}).get(channel, 'Unknown')
|
channel_name = self.state.get('channel_names', {}).get(channel, 'Unknown')
|
||||||
|
|
||||||
if not message_ids:
|
if not message_ids:
|
||||||
print(f"No media files to reprocess for {channel_name} (ID: {channel})")
|
# print(f"No media files to reprocess for {channel_name} (ID: {channel})")
|
||||||
return
|
return
|
||||||
|
|
||||||
print(f"📥 Reprocessing {len(message_ids)} media files for {channel_name} (ID: {channel})")
|
# print(f"📥 Reprocessing {len(message_ids)} media files for {channel_name} (ID: {channel})")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
entity = await self._resolve_entity(channel)
|
entity = await self._resolve_entity(channel)
|
||||||
@@ -881,10 +881,10 @@ class OptimizedTelegramScraper:
|
|||||||
filled_length = int(bar_length * completed_media // len(message_ids))
|
filled_length = int(bar_length * completed_media // len(message_ids))
|
||||||
bar = '█' * filled_length + '░' * (bar_length - filled_length)
|
bar = '█' * filled_length + '░' * (bar_length - filled_length)
|
||||||
|
|
||||||
sys.stdout.write(f"\r🔄 Rescrape: [{bar}] {progress:.1f}% ({completed_media}/{len(message_ids)})")
|
# sys.stdout.write(f"\r🔄 Rescrape: [{bar}] {progress:.1f}% ({completed_media}/{len(message_ids)})")
|
||||||
sys.stdout.flush()
|
# sys.stdout.flush()
|
||||||
|
|
||||||
print(f"\n✅ Media reprocessing complete! ({successful_downloads}/{len(message_ids)} successful)")
|
# print(f"\n✅ Media reprocessing complete! ({successful_downloads}/{len(message_ids)} successful)")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error reprocessing media: {e}")
|
print(f"Error reprocessing media: {e}")
|
||||||
@@ -1306,7 +1306,8 @@ class OptimizedTelegramScraper:
|
|||||||
await self.client.disconnect()
|
await self.client.disconnect()
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
print("✅ Already authenticated!")
|
pass
|
||||||
|
# print("✅ Already authenticated!")
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
+6
-3
@@ -589,7 +589,9 @@ class ContinuousScrapeManager:
|
|||||||
if not channels:
|
if not channels:
|
||||||
self._log("No channels configured for continuous scraping.")
|
self._log("No channels configured for continuous scraping.")
|
||||||
else:
|
else:
|
||||||
self._log(f"Starting iteration for {len(channels)} channel(s).")
|
self._log("=" * 50)
|
||||||
|
self._log(f"🚀 Starting iteration for {len(channels)} channel(s).")
|
||||||
|
self._log("-" * 50)
|
||||||
buffer = io.StringIO()
|
buffer = io.StringIO()
|
||||||
try:
|
try:
|
||||||
with (
|
with (
|
||||||
@@ -605,7 +607,8 @@ class ContinuousScrapeManager:
|
|||||||
self.status["last_iteration_at"] = utc_now_iso()
|
self.status["last_iteration_at"] = utc_now_iso()
|
||||||
self.status["last_finished_at"] = utc_now_iso()
|
self.status["last_finished_at"] = utc_now_iso()
|
||||||
self.status["last_error"] = None
|
self.status["last_error"] = None
|
||||||
self._log("Iteration finished.")
|
self._log("-" * 50)
|
||||||
|
self._log("✅ Iteration finished.")
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
output = buffer.getvalue().strip()
|
output = buffer.getvalue().strip()
|
||||||
if output:
|
if output:
|
||||||
@@ -616,7 +619,7 @@ class ContinuousScrapeManager:
|
|||||||
self.status["last_error"] = str(exc)
|
self.status["last_error"] = str(exc)
|
||||||
|
|
||||||
sleep_seconds = max(5, interval_minutes * 60)
|
sleep_seconds = max(5, interval_minutes * 60)
|
||||||
self._log(f"Sleeping for {interval_minutes} minute(s).")
|
self._log(f"💤 Sleeping for {interval_minutes} minute(s).")
|
||||||
interrupted = self.stop_event.wait(timeout=sleep_seconds)
|
interrupted = self.stop_event.wait(timeout=sleep_seconds)
|
||||||
if interrupted:
|
if interrupted:
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user