Добавлен merge дорожек и переснос видео
This commit is contained in:
parent
af823f79fd
commit
cdf7a5ddcc
79
load.sh
79
load.sh
|
@ -10,15 +10,13 @@ download() {
|
||||||
DOWNLOAD_LINK="${1}"
|
DOWNLOAD_LINK="${1}"
|
||||||
SAVE_PATH="${2}"
|
SAVE_PATH="${2}"
|
||||||
|
|
||||||
# cd "${SAVE_PATH}"
|
|
||||||
|
|
||||||
${YTDLP} -o "${SAVE_PATH}/%(id)s.%(ext)s" \
|
${YTDLP} -o "${SAVE_PATH}/%(id)s.%(ext)s" \
|
||||||
-f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' \
|
-f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' \
|
||||||
--write-auto-subs --write-subs --sub-lang en,ru --convert-subs srt --sub-format txt \
|
--write-auto-subs --write-subs --sub-lang en,ru --convert-subs srt --sub-format vtt \
|
||||||
${DOWNLOAD_LINK}
|
${DOWNLOAD_LINK}
|
||||||
}
|
}
|
||||||
|
|
||||||
create_structure() {
|
download_playlist() {
|
||||||
PLAYLIST="${1}"
|
PLAYLIST="${1}"
|
||||||
JSON="$(${YTDLP} --flat-playlist -j "${PLAYLIST}" 2>/dev/null)"
|
JSON="$(${YTDLP} --flat-playlist -j "${PLAYLIST}" 2>/dev/null)"
|
||||||
TITLE="$(echo ${JSON} | ${JQ} -r '.playlist_title' | head -n 1)"
|
TITLE="$(echo ${JSON} | ${JQ} -r '.playlist_title' | head -n 1)"
|
||||||
|
@ -41,6 +39,58 @@ create_structure() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
merge() {
|
||||||
|
MP3="${1}"
|
||||||
|
MP4="${2}"
|
||||||
|
SRT_EN="${3}"
|
||||||
|
SRT_RU="${4}"
|
||||||
|
CURRENT_PATH="${5}"
|
||||||
|
OUTPUT="$(basename "${CURRENT_PATH}")"
|
||||||
|
|
||||||
|
cd "${CURRENT_PATH}"
|
||||||
|
|
||||||
|
${FFMPEG} -i "${MP4}" -i "${MP3}" -i "${SRT_RU}" -i "${SRT_EN}" \
|
||||||
|
-map 0 -map 1 -map 2 -map 3 \
|
||||||
|
-c:v copy -c:a copy -metadata:s:a:0 language=eng -metadata:s:a:1 language=rus \
|
||||||
|
-c:s mov_text -metadata:s:s:0 language=rus -metadata:s:s:1 language=eng -disposition:s:0 default -disposition:s:1 default \
|
||||||
|
"${OUTPUT}.mp4"
|
||||||
|
}
|
||||||
|
|
||||||
|
merge_mp3() {
|
||||||
|
SRCDIR="$(realpath "${1}")"
|
||||||
|
|
||||||
|
for DIR in "${SRCDIR}"/*
|
||||||
|
do
|
||||||
|
for FILE in $(ls "${DIR}")
|
||||||
|
do
|
||||||
|
if [[ "${FILE}" == *".mp3" ]]; then
|
||||||
|
MP3="${FILE}"
|
||||||
|
elif [[ "${FILE}" == *".en.srt" ]]; then
|
||||||
|
SRT_EN="${FILE}"
|
||||||
|
elif [[ "${FILE}" == *".ru.srt" ]]; then
|
||||||
|
SRT_RU="${FILE}"
|
||||||
|
elif [[ "${FILE}" == *".mp4" ]]; then
|
||||||
|
MP4="${FILE}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
[ ! -z "${MP3}" ] && [ ! -z "${SRT_EN}" ] && [ ! -z "${SRT_RU}" ] && [ ! -z "${MP4}" ] || continue
|
||||||
|
merge "${MP3}" "${MP4}" "${SRT_EN}" "${SRT_RU}" "${DIR}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
move_mp4() {
|
||||||
|
SRCDIR="$(realpath "${1}")"
|
||||||
|
DSTDIR="${2}"
|
||||||
|
|
||||||
|
mkdir -p "${DSTDIR}"
|
||||||
|
|
||||||
|
for DIR in "${SRCDIR}"/*
|
||||||
|
do
|
||||||
|
FILE="$(basename "${DIR}").mp4"
|
||||||
|
mv -v "${DIR}/${FILE}" "${DSTDIR}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
COMMAND="${1}"
|
COMMAND="${1}"
|
||||||
[ ! -z ${COMMAND} ] && shift
|
[ ! -z ${COMMAND} ] && shift
|
||||||
|
@ -53,6 +103,14 @@ main() {
|
||||||
PLAYLIST="${VALUE}"
|
PLAYLIST="${VALUE}"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-s|--source)
|
||||||
|
SRCDIR="${VALUE}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-d|--destination)
|
||||||
|
DSTDIR="${VALUE}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -60,9 +118,18 @@ main() {
|
||||||
done
|
done
|
||||||
|
|
||||||
case "${COMMAND}" in
|
case "${COMMAND}" in
|
||||||
create)
|
download)
|
||||||
[ -z "${PLAYLIST}" ] && echo "Playlist link unknown" && exit 1
|
[ -z "${PLAYLIST}" ] && echo "Playlist link unknown" && exit 1
|
||||||
create_structure "${PLAYLIST}"
|
download_playlist "${PLAYLIST}"
|
||||||
|
;;
|
||||||
|
merge)
|
||||||
|
[ -z "${SRCDIR}" ] && echo "Source directory not set" && exit 1
|
||||||
|
merge_mp3 "${SRCDIR}"
|
||||||
|
;;
|
||||||
|
move)
|
||||||
|
[ -z "${SRCDIR}" ] && echo "Source directory not set" && exit 1
|
||||||
|
[ -z "${DSTDIR}" ] && echo "Destination directory not set" && exit 1
|
||||||
|
move_mp4 "${SRCDIR}" "${DSTDIR}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in New Issue