
# First, if github,codeberg,gitee, it will download the raw data, or using API if set
# Second, using links-dumps/curl to download data as source

# dump-source + md ?
# Third, using curl + ??? to get the clean data
# Compare and use the best solution

# --ai dump-source + ai
# Fourth, using links + AI

# How to judge which is better ?

___x_cmd_links_autoget(){
    local using_ai=""
    local using_markitdown=""

    while [ $# -gt 0 ]; do
        case "$1" in
            --ai)           using_ai=1 ;;
            --markitdown)   using_markitdown=1 ;;
            *)              break ;;
        esac
        shift
    done

    local url="$1"

    local x_=""

    ___x_cmd_links_codeurl_ "$url"

    local data

    if data="$(___x_cmd curl --fail "$x_")"; then
        printf "%s\n" "$data"
    else
        ___x_cmd links source "$url"
        # Consider using trafi ? readable ?
    fi
}

