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,33 +56,36 @@ 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
if [[ -f "${cookies}" && "${channel}" = "subscriptions" ]]; then for full_url in "${url}/videos" "${url}/shorts" "${url}/streams"; do
#If available, you can use the cookies from your browser directly. Substitute echo "${full_url}"
# --cookies "${cookies}" if [[ -f "${cookies}" && "${channel}" = "subscriptions" ]]; then
#for the below, substituting for your browser of choice: #If available, you can use the cookies from your browser directly. Substitute
# --cookies-from-browser "firefox" # --cookies "${cookies}"
#In case this still fails, you can resort to a PO Token. Follow the instructions at #for the below, substituting for your browser of choice:
# https://github.com/yt-dlp/yt-dlp/wiki/PO-Token-Guide # --cookies-from-browser "firefox"
#and add a new variable with the contents of the PO Token in the form #In case this still fails, you can resort to a PO Token. Follow the instructions at
# potoken="INSERTYOURPOTOKENHERE" # https://github.com/yt-dlp/yt-dlp/wiki/PO-Token-Guide
#then substitute the "--extractor-args" line below with #and add a new variable with the contents of the PO Token in the form
# --extractor-args "youtubetab:approximate_date,youtube:player-client=default,mweb;po_token=mweb.gvs+${potoken}" \ # potoken="INSERTYOURPOTOKENHERE"
#including the backslash so the multiline command keeps working. #then substitute the "--extractor-args" line below with
"${python}" "${ytdl}" "${url}" \ # --extractor-args "youtubetab:approximate_date,youtube:player-client=default,mweb;po_token=mweb.gvs+${potoken}" \
--cookies "${cookies}" \ #including the backslash so the multiline command keeps working.
--extractor-args "youtubetab:approximate_date" \ "${python}" "${ytdl}" "${full_url}" \
--skip-download --download-archive "${archive}" \ --cookies "${cookies}" \
--dateafter "${breaktime}" \ --extractor-args "youtubetab:approximate_date" \
--break-on-reject --lazy-playlist --write-info-json \ --skip-download --download-archive "${archive}" \
--sleep-requests "${sleeptime}" --dateafter "${breaktime}" \
else --break-on-reject --lazy-playlist --write-info-json \
"${python}" "${ytdl}" "${url}" \ --sleep-requests "${sleeptime}"
--extractor-args "youtubetab:approximate_date" \ else
--skip-download --download-archive "${archive}" \ "${python}" "${ytdl}" "${full_url}" \
--dateafter "${breaktime}" \ --extractor-args "youtubetab:approximate_date" \
--break-on-reject --lazy-playlist --write-info-json \ --skip-download --download-archive "${archive}" \
--sleep-requests "${sleeptime}" --dateafter "${breaktime}" \
fi --break-on-reject --lazy-playlist --write-info-json \
--sleep-requests "${sleeptime}"
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}"