aboutsummaryrefslogtreecommitdiff
path: root/units/ib_original.zsh
blob: 13a69307199e95111331faa74e6b6ddac90c932b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Copyright (C) 2024-2025 Maria Lisina
# Copyright (C) 2024-2025 Danil Lisin
# SPDX-License-Identifier: Apache-2.0

ib_file_size="$(jq -r ".${ib_iarray}[0].${ib_isize}" "${ib_file}")"
ib_file_url="$(jq -r ".${ib_iarray}[0].${ib_ifile}" "${ib_file}")"

source "${units}/ib_size.zsh"

if [[ -n "${ib_file_url}" && "${ib_file_url}" != "null" ]]
then
    ib_sample_url="$(jq -r ".${ib_iarray}[0].${ib_isample}" "${ib_file}")"
    ib_preview_url="$(jq -r ".${ib_iarray}[0].${ib_ipreview}" "${ib_file}")"
    ib_width="$(jq -r ".${ib_iarray}[0].${ib_iwidth}" "${ib_file}")"
    ib_height="$(jq -r ".${ib_iarray}[0].${ib_iheight}" "${ib_file}")"

    source "${units}/ib_meta.zsh"
else
    output_text="No original file found"
    return 0
fi

if [[ -n "${ib_file_size}" && "${ib_file_size}" != "null" && ${ib_file_size} -gt 0 ]]
then
    if [[ ${ib_file_size} -gt 20971520 ]]
    then
        output_text="File size is too large"
    fi
else
    output_text="Failed to get file size"
fi