ytools-search only prints "No videos found." recently
codesoap opened this issue · 4 comments
codesoap commented
At first it appeared sporadic, but now I'm not getting any results from ytools-search
anymore. All I get is the No videos found.
message. YouTube seemingly changed the structure of the HTML it returns and ytools should adapt to these changes.
codesoap commented
The new HTML contains some JSON, which seems to contain all needed info. It can be inspected like this:
curl -s 'https://www.youtube.com/results?search_query=Daniel%20Deluxe' | \
grep 'window..ytInitialData.. =' | \
sed -e 's/^[^=]*. *//' -e 's/; *$//' | \
jq '.'
codesoap commented
I can get the video IDs like this:
curl -s 'https://www.youtube.com/results?search_query=Daniel%20Deluxe' | \
grep 'window..ytInitialData.. =' | \
sed -e 's/^[^=]*. *//' -e 's/; *$//' | \
jq '.. | .videoRenderer? | select(type != "null") .videoId'
And the titles like this:
curl -s 'https://www.youtube.com/results?search_query=Daniel%20Deluxe' | \
grep 'window..ytInitialData.. =' | \
sed -e 's/^[^=]*. *//' -e 's/; *$//' | \
jq '.. | .videoRenderer? | select(type != "null") .title.runs[0].text'
codesoap commented
codesoap commented
Seems to work well for me. Closing...