From 336951e4bd98caad9ad69f0c1224e49e51618a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Sol=C3=ADs?= Date: Mon, 16 Jun 2025 17:21:36 +0000 Subject: [PATCH] fix: Optimize temporary file generation --- youtube-download-channel.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/youtube-download-channel.sh b/youtube-download-channel.sh index f2a4c8f..154a040 100755 --- a/youtube-download-channel.sh +++ b/youtube-download-channel.sh @@ -85,6 +85,7 @@ for full_url in "${url}/videos" "${url}/shorts" "${url}/streams"; do --sleep-requests "${sleeptime}" \ --parse-metadata "video::(?P)" \ --parse-metadata "video::(?P)" \ + --parse-metadata "video::(?P)" \ --parse-metadata "video::(?P)" \ --parse-metadata "video::(?P)" \ --parse-metadata "video::(?P)" @@ -97,6 +98,7 @@ for full_url in "${url}/videos" "${url}/shorts" "${url}/streams"; do --sleep-requests "${sleeptime}" \ --parse-metadata "video::(?P)" \ --parse-metadata "video::(?P)" \ + --parse-metadata "video::(?P)" \ --parse-metadata "video::(?P)" \ --parse-metadata "video::(?P)" \ --parse-metadata "video::(?P)" @@ -120,17 +122,19 @@ total=$(find "${temporary}" -type f -iname "*.info.json" | wc -l) find "${temporary}" -type f -iname "*.info.json" | while read -r x; do count=$((count + 1)) ( - jq '.formats="" | .automatic_captions="" | .thumbnails="" | .tags=""' "${x}" >"${x}.tmp" && mv "${x}.tmp" "${x}" if [[ -f "${x}" && "${channel}" != "subscriptions" && $(jq -rc ".uploader_id" "${x}") != "@${channel}" ]]; then - echo "Video ${x} not uploaded from ${channel}, removing..." && rm "${x}" + echo "${count}/${total} ${x} not uploaded from ${channel}, removing..." && rm "${x}" fi if [[ -f "${x}" && "${breaktime}" =~ ^[0-9]+$ ]]; then file_timestamp=$(jq -rc '.timestamp' "${x}") if [[ "${breaktime_timestamp}" -ge "${file_timestamp}" ]]; then - echo "Video ${x} uploaded before ${breaktime}, removing..." && rm "${x}" + echo "${count}/${total} ${x} uploaded before ${breaktime}, removing..." && rm "${x}" fi fi if [[ -f "${x}" ]]; then + if [[ $(stat -c%s "${x}") -gt 4096 ]]; then + jq '.formats="" | .automatic_captions="" | .subtitles="" | .thumbnails="" | .tags=""' "${x}" >"${x}.tmp" && mv "${x}.tmp" "${x}" + fi echo "youtube $(jq -cr '.id' "${x}")" >>"${temporary}/${channel}.txt" if [[ ${enablecsv} = "1" ]]; then jq -c '[.upload_date, .timestamp, .uploader , .title, .webpage_url]' "${x}" | while read -r i; do