mirror of
https://github.com/bellingcat/auto-archiver.git
synced 2026-06-11 04:38:29 +03:00
* Removes (partly) the ArchivingOrchestrator * Removes the cli_feeder module, and makes it the 'default', allowing you to pass URLs directly on the command line, without having to use the cumbersome --cli_feeder.urls. Just do auto-archiver https://my.url.com * More unit tests * Improved error handling
23 lines
830 B
Python
23 lines
830 B
Python
from loguru import logger
|
|
import csv
|
|
|
|
from auto_archiver.core import Feeder
|
|
from auto_archiver.core import Metadata, ArchivingContext
|
|
from auto_archiver.utils import url_or_none
|
|
|
|
class CSVFeeder(Feeder):
|
|
|
|
def __iter__(self) -> Metadata:
|
|
url_column = self.column or 0
|
|
for file in self.files:
|
|
with open(file, "r") as f:
|
|
reader = csv.reader(f)
|
|
first_row = next(reader)
|
|
if not(url_or_none(first_row[url_column])):
|
|
# it's a header row, skip it
|
|
logger.debug(f"Skipping header row: {first_row}")
|
|
for row in reader:
|
|
url = row[0]
|
|
logger.debug(f"Processing {url}")
|
|
yield Metadata().set_url(url)
|
|
ArchivingContext.set("folder", "cli") |