The little things give you away... A collection of various small helper stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

18 lines
712 B

  1. #!/bin/bash
  2. # Takes a list of YouTube URLs on stdin. URLs for autogenerated channels are written to FD 3, all other URLs go to stdout.
  3. while read -r url
  4. do
  5. if [[ "${url}" == */channel/* ]]
  6. then
  7. header="$(curl -4sL -A 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36' -H 'Accept-Language: en-US,en;q=0.5' "${url}?disable_polymer=1" | \
  8. tr -d '\n' | \
  9. grep -Po '<div\s([^>]*\s)?class="([^"]* )?channel-header( [^"]*)?".*?<div\s([^>]*\s)?id="channel-subheader"')"
  10. if grep -qP '<span\s([^>]*\s)?class="([^"]+ )?yt-channel-title-autogenerated[ "]' <<<"${header}"
  11. then
  12. echo "${url}" >&3
  13. continue
  14. fi
  15. fi
  16. echo "${url}"
  17. done