fetch-station-logos.sh 630 B

12345678910111213141516
  1. #!/bin/sh
  2. for rdf in "$(dirname "${0}")"/../htdocs/stations/*/about.rdf
  3. do
  4. # ls -l "${rdf}"
  5. # http://stackoverflow.com/a/8266075
  6. # /bin/echo -e "setns foaf=http://xmlns.com/foaf/0.1/\nsetns rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#\nxpath /rdf:RDF/rdf:Description['.'=@rdf:about]/foaf:logo/@rdf:resource" | xmllint --shell "${rdf}"
  7. # as long as there's no & in url:
  8. logo_url="$(fgrep 'foaf:logo' "${rdf}" | head -n 1 | cut -d '"' -f 2)"
  9. # echo "${logo_url}"
  10. curl --silent --location --output "$(dirname "${rdf}")/app/logo.svg" "${logo_url}"
  11. done
  12. ls -Al "$(dirname "${0}")"/../htdocs/stations/*/app/logo.svg