Skip to content

cli

callback

callback(version: Annotated[bool | None, typer.Option(--version, callback=version_callback, is_eager=True)] = None)

TODO: add description

Source code in src/torah_dl/cli.py
66
67
68
69
70
71
72
73
74
75
76
@app.callback(invoke_without_command=True)
def callback(
    version: Annotated[
        bool | None,
        typer.Option("--version", callback=version_callback, is_eager=True),
    ] = None,
):
    """
    TODO: add description
    """
    pass

download_url

download_url(url: Annotated[str, typer.Argument(help='URL to download')], output_path: Annotated[Path, typer.Argument(help='Path to save the downloaded file')] = Path('audio'))

Download a file from a URL and show progress.

Source code in src/torah_dl/cli.py
45
46
47
48
49
50
51
52
53
54
@app.command(name="download")
def download_url(
    url: Annotated[str, typer.Argument(help="URL to download")],
    output_path: Annotated[Path, typer.Argument(help="Path to save the downloaded file")] = Path("audio"),
):
    """Download a file from a URL and show progress."""
    with console.status("Extracting URL..."):
        extraction = extract(url)
    with console.status("Downloading file..."):
        download(extraction.download_url, output_path)

extract_url

extract_url(url: str, url_only: Annotated[bool, typer.Option(--url - only, help='Only output the download URL')] = False)

Extract information from a given URL

Source code in src/torah_dl/cli.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
@app.command(name="extract")
def extract_url(
    url: str,
    url_only: Annotated[bool, typer.Option("--url-only", help="Only output the download URL")] = False,
):
    """
    Extract information from a given URL
    """
    try:
        extraction = extract(url)
    except ExtractorNotFoundError:
        typer.echo(f"Extractor not found for URL: {url}", err=True)
        raise typer.Exit(1) from None

    table = Table(box=None, pad_edge=False)
    table.add_column("Title", style="cyan")
    table.add_column("Download URL", style="green")
    table.add_row(extraction.title, extraction.download_url)
    if url_only:
        typer.echo(extraction.download_url)
    else:
        console.print(table)

version_callback

version_callback(value: bool)

print version information to shell

Source code in src/torah_dl/cli.py
57
58
59
60
61
62
63
def version_callback(value: bool):
    """
    print version information to shell
    """
    if value:
        typer.echo(f"torah-dl version: {__version__}")
        raise typer.Exit()