The little things give you away... A collection of various small helper stuff
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

youtube-normalise 862 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. while read -r url
  3. do
  4. if [[ "${url}" =~ ^https?://(www\.)?youtube\.com/ ]]
  5. then
  6. if [[ "${url}" == *'?'* ]]
  7. then
  8. rurl="${url}&disable_polymer=1"
  9. else
  10. rurl="${url}?disable_polymer=1"
  11. fi
  12. page="$(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' "${rurl}")"
  13. canonical="$(grep -Po '<link itemprop="url" href="http://www\.youtube\.com/\Kuser/[^"]+' <<< "${page}")"
  14. if [[ "${canonical}" ]]
  15. then
  16. echo "https://www.youtube.com/${canonical}"
  17. else
  18. canonical="$(grep -Po '<link itemprop="url" href="http://www\.youtube\.com/\Kchannel/[^"]+' <<< "${page}")"
  19. if [[ "${canonical}" ]]
  20. then
  21. echo "https://www.youtube.com/${canonical}"
  22. else
  23. echo "${url}"
  24. fi
  25. fi
  26. else
  27. echo "${url}"
  28. fi
  29. done