feat: Fetch livestreams and shorts

This commit is contained in:
Carlos Solís 2025-06-12 14:02:10 +00:00
parent ddb309d21a
commit 24e9e9b427

View file

@ -56,6 +56,8 @@ 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
echo "${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}"
@ -68,7 +70,7 @@ if [[ -f "${cookies}" && "${channel}" = "subscriptions" ]]; then
#then substitute the "--extractor-args" line below with #then substitute the "--extractor-args" line below with
# --extractor-args "youtubetab:approximate_date,youtube:player-client=default,mweb;po_token=mweb.gvs+${potoken}" \ # --extractor-args "youtubetab:approximate_date,youtube:player-client=default,mweb;po_token=mweb.gvs+${potoken}" \
#including the backslash so the multiline command keeps working. #including the backslash so the multiline command keeps working.
"${python}" "${ytdl}" "${url}" \ "${python}" "${ytdl}" "${full_url}" \
--cookies "${cookies}" \ --cookies "${cookies}" \
--extractor-args "youtubetab:approximate_date" \ --extractor-args "youtubetab:approximate_date" \
--skip-download --download-archive "${archive}" \ --skip-download --download-archive "${archive}" \
@ -76,13 +78,14 @@ if [[ -f "${cookies}" && "${channel}" = "subscriptions" ]]; then
--break-on-reject --lazy-playlist --write-info-json \ --break-on-reject --lazy-playlist --write-info-json \
--sleep-requests "${sleeptime}" --sleep-requests "${sleeptime}"
else else
"${python}" "${ytdl}" "${url}" \ "${python}" "${ytdl}" "${full_url}" \
--extractor-args "youtubetab:approximate_date" \ --extractor-args "youtubetab:approximate_date" \
--skip-download --download-archive "${archive}" \ --skip-download --download-archive "${archive}" \
--dateafter "${breaktime}" \ --dateafter "${breaktime}" \
--break-on-reject --lazy-playlist --write-info-json \ --break-on-reject --lazy-playlist --write-info-json \
--sleep-requests "${sleeptime}" --sleep-requests "${sleeptime}"
fi fi
done
if [[ ${enablecsv} = 1 ]]; then if [[ ${enablecsv} = 1 ]]; then
if [[ -f "${csv}" ]]; then if [[ -f "${csv}" ]]; then
rm -rf "${csv}" rm -rf "${csv}"
@ -162,9 +165,13 @@ if [[ ${enablecsv} = "1" ]]; then
fi fi
cd "${temporary}" || exit cd "${temporary}" || exit
tar -cvp -I "zstd -T0" -f "${subfolder}/${channel}.tar.zst" -- *.info.json tar -cvp -I "zstd -T0" -f "${subfolder}/${channel}.tar.zst" -- *.info.json
count=0
total=$(find "${temporary}" -type f -iname "*.info.json" | wc -l)
find "${temporary}" -type f -iname "*.info.json" | while read -r x; do find "${temporary}" -type f -iname "*.info.json" | while read -r x; do
count=$((count + 1))
if [[ -f "${x}" ]]; then if [[ -f "${x}" ]]; then
echo "youtube $(jq -cr '.id' "${x}")" >>"${archive}" echo "youtube $(jq -cr '.id' "${x}")" >>"${archive}"
echo "${count}/${total} ${x}"
fi fi
done done
sort "${archive}" | uniq >"/tmp/${channel}.txt" && mv "/tmp/${channel}.txt" "${archive}" sort "${archive}" | uniq >"/tmp/${channel}.txt" && mv "/tmp/${channel}.txt" "${archive}"