Compare commits

...

2 Commits

Author SHA1 Message Date
localhost_frssoft 08c8e52d7b fix link on img no have newline 2023-01-11 19:29:39 +03:00
localhost_frssoft 5d0b79caf0 jj -> jq 2023-01-11 19:27:09 +03:00
1 changed files with 7 additions and 6 deletions

View File

@ -29,14 +29,15 @@ get_Lies_pages()
get_Lies_pages > "$basedir"/response.json
for i in $(jj -l -i "$basedir"/response.json 'data.#.id'); do
for i in $(jq '.["data"] | .[].id' "$basedir"/response.json); do
raw_id=$(echo $i | tr -d '"')
if [ ! -f $baseblogdir/$raw_id.gmi ]; then
entry_json=$(jq ".[\"data\"] | .[] | select(.id==$i)" "$basedir"/response.json)
orig=$(echo $i | sed -e 's/"//g; s|^|https://dybr.ru/blog/liesliasau/|g')
title=$(jj -i "$basedir"/response.json "data.#[id=$i].attributes.title")
published=$(jq -r ".[] | .[] | select(.id==$i) | .attributes[\"created-at\"]" "$basedir"/response.json)
tags=$(jj -l -i "$basedir"/response.json "data.#[id=$i].attributes.tags" | sed -e 's/"//g' | tr '\n' ',')
content=$(jj -i "$basedir"/response.json "data.#[id=$i].attributes.content")
title=$(echo "$entry_json" | jq -r ".attributes[\"title\"]")
published=$(echo "$entry_json" | jq -r ".attributes[\"created-at\"]")
tags=$(echo "$entry_json" | jq -r ".attributes[\"tags\"] | .[]" | tr '\n' ',')
content=$(echo "$entry_json" | jq -r ".attributes[\"content\"]")
links_img=$(echo "$content" | pup 'img attr{src}' | sed 's|^|https://dybr.ru|g')
plain_content=$(echo "$content" | w3m -T text/html -cols 65535 -dump -o display_link_number=1 | sed -e 's|\[MORE=.*\]||g ; s|\[/MORE\]||g ; s|\[S:|~~|g ; s|:S\]|~~|g')
# Unpack inline images...
@ -46,7 +47,7 @@ for i in $(jj -l -i "$basedir"/response.json 'data.#.id'); do
while [ $index -le $pseudo_index ]; do
placeholder=$(echo "$placeholders_img" | sed $index!d | tr -d '[]')
img=$(echo "$links_img" | sed $index!d)
plain_content=$(echo "$plain_content" | sed "s|\[$placeholder\]|=> $img |g")
plain_content=$(echo "$plain_content" | sed "s|\[$placeholder\]|=> $img\n|g")
index=$(expr $index + 1)
done
echo "# $title\n$plain_content\n\ntags: $tags\n=> $orig orig" > $baseblogdir/$raw_id.gmi