Fix reading filename written using --write-pages
parent
906701a152
commit
ebc70c0128
|
@ -158,7 +158,15 @@ if [[ "${get_data[v]}" ]]; then
|
|||
fi
|
||||
strings[description]=$(jq -r '.description' <<< "$video" | sed -E 's/$/<br>/g')
|
||||
|
||||
vid="$(cat "temp/${get_data[v]}_https_-_"*"watch"*".dump")"
|
||||
# youtube-dl modifies the filename when writing with --write-pages
|
||||
# params restricted=True, is_id=False to https://github.com/ytdl-org/youtube-dl/blob/70d0d4f9beba0e5b6d95ee50ad62ae7ab5be9be1/youtube_dl/utils.py#L2079
|
||||
# this accurately replicates the algorithm without as much complexity
|
||||
written_id="$(sed -E -e 's/__+/_/g' \
|
||||
-e 's/^_*(-_)?//' \
|
||||
-e 's/^-/_/' \
|
||||
<<< "${get_data[v]}")"
|
||||
echo "Written id $written_id"
|
||||
vid="$(cat "temp/${written_id}_https_-_"*"watch"*".dump")"
|
||||
vid_json="$(tr -d '\n' <<< "$vid" | grep -Poh "ytInitialData.*?</script>" | sed 's/ytInitialData = //;s/<\/script>//')"
|
||||
|
||||
strings[recommended]=$(jq -r '.contents.twoColumnWatchNextResults.secondaryResults.secondaryResults.results[] | .compactAutoplayRenderer.contents[0].compactVideoRenderer, .compactVideoRenderer | if .videoId != null then "<div><a href='"'"'/watch?v="+.videoId+"'"'"'><img src='"'"'https://i.ytimg.com/vi/"+.videoId+"/mqdefault.jpg'"'"'>"+.title.simpleText+"</a></div>" else empty end' <<< "$vid_json")
|
||||
|
|
Loading…
Reference in New Issue