Skip to content

Commit

Permalink
Merge pull request #223 from burningmantech/index
Browse files Browse the repository at this point in the history
Add options for indexer. Default to adding new files.
  • Loading branch information
wsanchez authored Jan 21, 2025
2 parents 27bdf63 + 01c0528 commit 7925080
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/transmissions/indexer/_indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,13 @@ def transmissions(self) -> Iterable[Transmission]:
)
for filename in filenames:
path = Path(dirpath) / filename
self.log.debug("Found audio file: {path}", path=path)
self.log.debug("Found file: {path}", path=path)
try:
yield self._transmissionFromFile(path)
except InvalidFileError as e:
self.log.error("{error}", error=e)
except Exception as e: # noqa: BLE001
self.log.error("Error: {error}", error=e)

async def _addDuration(
self,
Expand Down Expand Up @@ -416,7 +418,7 @@ async def indexIntoStore(
self,
store: TXDataStore,
*,
existingOnly: bool = True,
existingOnly: bool = False,
computeChecksum: bool = True,
computeTranscription: bool = True,
computeDuration: bool = True,
Expand Down
16 changes: 14 additions & 2 deletions src/transmissions/run/_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,14 @@ def main(ctx: Context, config: str) -> None: # noqa: ARG001


@main.command()
@option("--new/--no-new", default=True, help="Search for new transmissions")
@option("--checksum/--no-checksum", default=True, help="Compute checksums")
@option("--duration/--no-duration", default=True, help="Compute durations")
@option("--transcript/--no-transcript", default=True, help="Compute transcripts")
@pass_context
def index(ctx: Context) -> None:
def index(
ctx: Context, new: bool, checksum: bool, duration: bool, transcript: bool
) -> None:
"""
Index audio files.
"""
Expand All @@ -256,7 +262,13 @@ def index(ctx: Context) -> None:
async def app(store: TXDataStore) -> None:
for event, sourcePath in configuredEvents:
indexer = Indexer(event=event, root=sourcePath)
await indexer.indexIntoStore(store)
await indexer.indexIntoStore(
store,
existingOnly=not new,
computeChecksum=checksum,
computeDuration=duration,
computeTranscription=transcript,
)

run(ctx, app)

Expand Down

0 comments on commit 7925080

Please sign in to comment.