Mes extraits de code

Transformer les iframe youtube en iframe invidious dans Miniflux

UPDATE entries SET content = regexp_replace(content, 'youtube-nocookie.com', 'invidious.fdn.fr') WHERE content LIKE '%youtube-nocookie.com/embed%';

Récupérer de manière structurée les assets de Minecraft

#!/bin/env bash

INDEX_FILE="./indexes/1.18.json"
REGEX_EXTRACT="^minecraft/sounds/records/"
OBJECTS_DIR="./objects/"
OUTPUT_DIR="./output/"

echo "Starting extraction..."

if [[ ! -f "${INDEX_FILE}" ]]
then
	echo "ERROR: Index file doesn't exist!"
	exit 1
fi

if [[ ! -d "${OBJECTS_DIR}" ]]
then
	echo "ERROR: Objects directory doesn't exist!"
	exit 1
fi

if [[ ! -d "${OUTPUT_DIR}" ]]
then
	echo "WARNING: Output directory doesn't exist! Creating a new one."
	mkdir -p "${OUTPUT_DIR}"
fi

for FILE in $(jq -r '.objects | keys[]' "${INDEX_FILE}" | grep "${REGEX_EXTRACT}")
do
	HASH="$(jq -r .objects.\"${FILE}\".hash "${INDEX_FILE}")"
	PATH_ORIGIN="${OBJECTS_DIR}/${HASH:0:2}/${HASH}"
	DIR_DEST="${OUTPUT_DIR}/$(dirname ${FILE})"
	PATH_DEST="${OUTPUT_DIR}/${FILE}"

	if [[ ! -f "${PATH_ORIGIN}" ]]
	then
		echo "ERROR: File ${PATH_ORIGIN} (${FILE}) doesn't exist!"
		exit 1
	fi

	if [[ ! -d "${DIR_DEST}" ]]
	then
		echo "WARNING: ${DIR_DEST} doesn't exist! Creating."
		mkdir -p ${DIR_DEST}
	fi

	cp -f ${PATH_ORIGIN} ${PATH_DEST}
done

echo "Done!"

exit 0

Mettre à jour Miniflux

MVERSION="2.0.35"; MDIR="/DATA/miniflux"; NEWBIN="${MDIR}/versions/miniflux-${MVERSION}"; curl -L "https://github.com/miniflux/v2/releases/download/${MVERSION}/miniflux-linux-amd64" -o "${NEWBIN}"; chmod +x "${NEWBIN}"; ln -sf "${NEWBIN}" "${MDIR}/miniflux-latest"; "${NEWBIN}" -c "${MDIR}/config" -migrate

Mettre à jour Gitea

VERSION_DIR="/DATA/gitea/versions"; VERSION="1.15.10"; SYMLINK_PATH="/DATA/gitea/gitea-latest"; curl -sSL -o "${VERSION_DIR}/gitea-${VERSION}" "https://dl.gitea.io/gitea/${VERSION}/gitea-$VERSION-linux-amd64" && chmod +x "${VERSION_DIR}/gitea-${VERSION}" && ln -sf "${VERSION_DIR}/gitea-${VERSION}" "${SYMLINK_PATH}"

^