feat: Optimize channel iteration
This commit is contained in:
parent
11d3594121
commit
f38bd73bf8
1 changed files with 49 additions and 46 deletions
|
@ -63,52 +63,55 @@ 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
|
||||||
if [[ -f "${cookies}" || "${channel}" = "subscriptions" ]]; then
|
full_url=$(yt-dlp -I0 --print "playlist:https://www.youtube.com/playlist?list=UU%(channel_id.2:)s" "${url}")
|
||||||
#If available, you can use the cookies from your browser directly. Substitute
|
#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")
|
||||||
# --cookies "${cookies}"
|
echo "${url} = ${full_url}"
|
||||||
#for the below, substituting for your browser of choice:
|
if [[ -f "${cookies}" || "${channel}" = "subscriptions" ]]; then
|
||||||
# --cookies-from-browser "firefox"
|
#If available, you can use the cookies from your browser directly. Substitute
|
||||||
#In case this still fails, you can resort to a PO Token. Follow the instructions at
|
# --cookies "${cookies}"
|
||||||
# https://github.com/yt-dlp/yt-dlp/wiki/PO-Token-Guide
|
#for the below, substituting for your browser of choice:
|
||||||
#and add a new variable with the contents of the PO Token in the form
|
# --cookies-from-browser "firefox"
|
||||||
# potoken="INSERTYOURPOTOKENHERE"
|
#In case this still fails, you can resort to a PO Token. Follow the instructions at
|
||||||
#then substitute the "--extractor-args" line below with
|
# https://github.com/yt-dlp/yt-dlp/wiki/PO-Token-Guide
|
||||||
# --extractor-args "youtubetab:approximate_date,youtube:player-client=default,mweb;po_token=mweb.gvs+${potoken}" \
|
#and add a new variable with the contents of the PO Token in the form
|
||||||
#including the backslash so the multiline command keeps working.
|
# potoken="INSERTYOURPOTOKENHERE"
|
||||||
"${python}" "${ytdl}" "${full_url}" \
|
#then substitute the "--extractor-args" line below with
|
||||||
--cookies "${cookies}" \
|
# --extractor-args "youtubetab:approximate_date,youtube:player-client=default,mweb;po_token=mweb.gvs+${potoken}" \
|
||||||
--extractor-args "youtubetab:approximate_date" \
|
#including the backslash so the multiline command keeps working.
|
||||||
--skip-download --download-archive "${archive}" \
|
"${python}" "${ytdl}" "${full_url}" \
|
||||||
--dateafter "${breaktime}" \
|
--cookies "${cookies}" \
|
||||||
--break-on-reject --lazy-playlist --write-info-json \
|
--skip-download --download-archive "${archive}" \
|
||||||
--sleep-requests "${sleeptime}" \
|
--dateafter "${breaktime}" \
|
||||||
--parse-metadata "video::(?P<formats>)" \
|
--extractor-args "youtubetab:approximate_date,youtubetab:skip=webpage" \
|
||||||
--parse-metadata "video::(?P<thumbnails>)" \
|
--break-on-reject --lazy-playlist --write-info-json \
|
||||||
--parse-metadata "video::(?P<subtitles>)" \
|
--sleep-requests "${sleeptime}" \
|
||||||
--parse-metadata "video::(?P<automatic_captions>)" \
|
--parse-metadata "video::(?P<formats>)" \
|
||||||
--parse-metadata "video::(?P<chapters>)" \
|
--parse-metadata "video::(?P<thumbnails>)" \
|
||||||
--parse-metadata "video::(?P<heatmap>)" \
|
--parse-metadata "video::(?P<subtitles>)" \
|
||||||
--parse-metadata "video::(?P<tags>)" \
|
--parse-metadata "video::(?P<automatic_captions>)" \
|
||||||
--parse-metadata "video::(?P<categories>)"
|
--parse-metadata "video::(?P<chapters>)" \
|
||||||
else
|
--parse-metadata "video::(?P<heatmap>)" \
|
||||||
"${python}" "${ytdl}" "${full_url}" \
|
--parse-metadata "video::(?P<tags>)" \
|
||||||
--extractor-args "youtubetab:approximate_date" \
|
--parse-metadata "video::(?P<categories>)"
|
||||||
--skip-download --download-archive "${archive}" \
|
else
|
||||||
--dateafter "${breaktime}" \
|
"${python}" "${ytdl}" "${full_url}" \
|
||||||
--break-on-reject --lazy-playlist --write-info-json \
|
--skip-download --download-archive "${archive}" \
|
||||||
--sleep-requests "${sleeptime}" \
|
--dateafter "${breaktime}" \
|
||||||
--parse-metadata "video::(?P<formats>)" \
|
--extractor-args "youtubetab:approximate_date,youtubetab:skip=webpage" \
|
||||||
--parse-metadata "video::(?P<thumbnails>)" \
|
--break-on-reject --lazy-playlist --write-info-json \
|
||||||
--parse-metadata "video::(?P<subtitles>)" \
|
--sleep-requests "${sleeptime}" \
|
||||||
--parse-metadata "video::(?P<automatic_captions>)" \
|
--parse-metadata "video::(?P<formats>)" \
|
||||||
--parse-metadata "video::(?P<chapters>)" \
|
--parse-metadata "video::(?P<thumbnails>)" \
|
||||||
--parse-metadata "video::(?P<heatmap>)" \
|
--parse-metadata "video::(?P<subtitles>)" \
|
||||||
--parse-metadata "video::(?P<tags>)" \
|
--parse-metadata "video::(?P<automatic_captions>)" \
|
||||||
--parse-metadata "video::(?P<categories>)"
|
--parse-metadata "video::(?P<chapters>)" \
|
||||||
fi
|
--parse-metadata "video::(?P<heatmap>)" \
|
||||||
done
|
--parse-metadata "video::(?P<tags>)" \
|
||||||
|
--parse-metadata "video::(?P<categories>)"
|
||||||
|
fi
|
||||||
|
#done
|
||||||
if [[ ${enablecsv} = 1 ]]; then
|
if [[ ${enablecsv} = 1 ]]; then
|
||||||
if [[ -f "${tmpcsv}" ]]; then
|
if [[ -f "${tmpcsv}" ]]; then
|
||||||
rm -rf "${tmpcsv}"
|
rm -rf "${tmpcsv}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue