32 lines
754 B
Python
Executable File
32 lines
754 B
Python
Executable File
#!/usr/bin/env python3
|
|
# /// script
|
|
# requires-python = ">=3.12"
|
|
# dependencies = [
|
|
# "instagram-dlpy",
|
|
# ]
|
|
# ///
|
|
from pathlib import Path
|
|
from typing import Annotated
|
|
from instagramdl.api import get_post_data # type: ignore
|
|
from instagramdl.parser import parse_api_response # type: ignore
|
|
import typer
|
|
|
|
app = typer.Typer()
|
|
|
|
|
|
@app.command()
|
|
def download(
|
|
post_url: Annotated[str, typer.Argument(help="post url")],
|
|
download: Annotated[bool, typer.Option()] = True,
|
|
):
|
|
raw_data = get_post_data(post_url)
|
|
parsed_data = parse_api_response(raw_data)
|
|
if download:
|
|
print(parsed_data.download(download_path=Path("~/Downloads").expanduser()))
|
|
else:
|
|
print(parsed_data.video_url)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app()
|