feat: Optimize channel iteration

This commit is contained in:
Carlos Solís 2025-07-01 15:01:09 +00:00
parent 11d3594121
commit f38bd73bf8

View file

@ -63,8 +63,11 @@ url="https://www.youtube.com/@${channel}"
if [[ "${channel}" = "subscriptions" ]]; then if [[ "${channel}" = "subscriptions" ]]; then
url="https://www.youtube.com/feed/subscriptions" url="https://www.youtube.com/feed/subscriptions"
fi fi
for full_url in "${url}/videos" "${url}/shorts" "${url}/streams"; do #for section_url in "${url}/videos" "${url}/shorts" "${url}/streams"; do
echo "${full_url}" #Via https://github.com/yt-dlp/yt-dlp/issues/13573#issuecomment-3020152141
full_url=$(yt-dlp -I0 --print "playlist:https://www.youtube.com/playlist?list=UU%(channel_id.2:)s" "${url}")
#full_url=$(curl "${url}" | tr -d "\n\r" | xmlstarlet fo -R -n -H 2>/dev/null | xmlstarlet sel -t -v "/html" -n | grep "/channel/UC" | sed -e "s/var .* = //g" -e "s/\};/\}/g" -e "s/channel\/UC/playlist\?list=UU/g" | jq -r ".metadata .channelMetadataRenderer .channelUrl")
echo "${url} = ${full_url}"
if [[ -f "${cookies}" || "${channel}" = "subscriptions" ]]; then if [[ -f "${cookies}" || "${channel}" = "subscriptions" ]]; then
#If available, you can use the cookies from your browser directly. Substitute #If available, you can use the cookies from your browser directly. Substitute
# --cookies "${cookies}" # --cookies "${cookies}"
@ -79,9 +82,9 @@ for full_url in "${url}/videos" "${url}/shorts" "${url}/streams"; do
#including the backslash so the multiline command keeps working. #including the backslash so the multiline command keeps working.
"${python}" "${ytdl}" "${full_url}" \ "${python}" "${ytdl}" "${full_url}" \
--cookies "${cookies}" \ --cookies "${cookies}" \
--extractor-args "youtubetab:approximate_date" \
--skip-download --download-archive "${archive}" \ --skip-download --download-archive "${archive}" \
--dateafter "${breaktime}" \ --dateafter "${breaktime}" \
--extractor-args "youtubetab:approximate_date,youtubetab:skip=webpage" \
--break-on-reject --lazy-playlist --write-info-json \ --break-on-reject --lazy-playlist --write-info-json \
--sleep-requests "${sleeptime}" \ --sleep-requests "${sleeptime}" \
--parse-metadata "video::(?P<formats>)" \ --parse-metadata "video::(?P<formats>)" \
@ -94,9 +97,9 @@ for full_url in "${url}/videos" "${url}/shorts" "${url}/streams"; do
--parse-metadata "video::(?P<categories>)" --parse-metadata "video::(?P<categories>)"
else else
"${python}" "${ytdl}" "${full_url}" \ "${python}" "${ytdl}" "${full_url}" \
--extractor-args "youtubetab:approximate_date" \
--skip-download --download-archive "${archive}" \ --skip-download --download-archive "${archive}" \
--dateafter "${breaktime}" \ --dateafter "${breaktime}" \
--extractor-args "youtubetab:approximate_date,youtubetab:skip=webpage" \
--break-on-reject --lazy-playlist --write-info-json \ --break-on-reject --lazy-playlist --write-info-json \
--sleep-requests "${sleeptime}" \ --sleep-requests "${sleeptime}" \
--parse-metadata "video::(?P<formats>)" \ --parse-metadata "video::(?P<formats>)" \
@ -108,7 +111,7 @@ for full_url in "${url}/videos" "${url}/shorts" "${url}/streams"; do
--parse-metadata "video::(?P<tags>)" \ --parse-metadata "video::(?P<tags>)" \
--parse-metadata "video::(?P<categories>)" --parse-metadata "video::(?P<categories>)"
fi fi
done #done
if [[ ${enablecsv} = 1 ]]; then if [[ ${enablecsv} = 1 ]]; then
if [[ -f "${tmpcsv}" ]]; then if [[ -f "${tmpcsv}" ]]; then
rm -rf "${tmpcsv}" rm -rf "${tmpcsv}"