feat: Optimize channel iteration
This commit is contained in:
parent
11d3594121
commit
f38bd73bf8
1 changed files with 49 additions and 46 deletions
|
@ -63,9 +63,12 @@ url="https://www.youtube.com/@${channel}"
|
|||
if [[ "${channel}" = "subscriptions" ]]; then
|
||||
url="https://www.youtube.com/feed/subscriptions"
|
||||
fi
|
||||
for full_url in "${url}/videos" "${url}/shorts" "${url}/streams"; do
|
||||
echo "${full_url}"
|
||||
if [[ -f "${cookies}" || "${channel}" = "subscriptions" ]]; then
|
||||
#for section_url in "${url}/videos" "${url}/shorts" "${url}/streams"; do
|
||||
#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 available, you can use the cookies from your browser directly. Substitute
|
||||
# --cookies "${cookies}"
|
||||
#for the below, substituting for your browser of choice:
|
||||
|
@ -79,9 +82,9 @@ for full_url in "${url}/videos" "${url}/shorts" "${url}/streams"; do
|
|||
#including the backslash so the multiline command keeps working.
|
||||
"${python}" "${ytdl}" "${full_url}" \
|
||||
--cookies "${cookies}" \
|
||||
--extractor-args "youtubetab:approximate_date" \
|
||||
--skip-download --download-archive "${archive}" \
|
||||
--dateafter "${breaktime}" \
|
||||
--extractor-args "youtubetab:approximate_date,youtubetab:skip=webpage" \
|
||||
--break-on-reject --lazy-playlist --write-info-json \
|
||||
--sleep-requests "${sleeptime}" \
|
||||
--parse-metadata "video::(?P<formats>)" \
|
||||
|
@ -92,11 +95,11 @@ for full_url in "${url}/videos" "${url}/shorts" "${url}/streams"; do
|
|||
--parse-metadata "video::(?P<heatmap>)" \
|
||||
--parse-metadata "video::(?P<tags>)" \
|
||||
--parse-metadata "video::(?P<categories>)"
|
||||
else
|
||||
else
|
||||
"${python}" "${ytdl}" "${full_url}" \
|
||||
--extractor-args "youtubetab:approximate_date" \
|
||||
--skip-download --download-archive "${archive}" \
|
||||
--dateafter "${breaktime}" \
|
||||
--extractor-args "youtubetab:approximate_date,youtubetab:skip=webpage" \
|
||||
--break-on-reject --lazy-playlist --write-info-json \
|
||||
--sleep-requests "${sleeptime}" \
|
||||
--parse-metadata "video::(?P<formats>)" \
|
||||
|
@ -107,8 +110,8 @@ for full_url in "${url}/videos" "${url}/shorts" "${url}/streams"; do
|
|||
--parse-metadata "video::(?P<heatmap>)" \
|
||||
--parse-metadata "video::(?P<tags>)" \
|
||||
--parse-metadata "video::(?P<categories>)"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
#done
|
||||
if [[ ${enablecsv} = 1 ]]; then
|
||||
if [[ -f "${tmpcsv}" ]]; then
|
||||
rm -rf "${tmpcsv}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue