Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

49 rader
1.5 KiB

  1. #! /bin/sh
  2. # Importuje artykuły z Micropedii i SclaviniaWiki z listy podanej na
  3. # standardowym wejściu.
  4. # Copyright © 2017 Paulina Laura Emilia <vilene@posteo.net>
  5. #
  6. # This program is free software. It comes without any warranty, to
  7. # the extent permitted by applicable law. You can redistribute it
  8. # and/or modify it under the terms of the Do What The Fuck You Want
  9. # To Public License, Version 2, as published by Sam Hocevar. See the
  10. # COPYING file for more details.
  11. set -C
  12. # Sprawdź czy skrypt mediawiki2ency.sh jest w ścieżce wyszukiwania lub
  13. # w bieżącym katalogu.
  14. if ! mediawiki2ency=$(PATH=$PATH:. command -v "mediawiki2ency.sh"); then
  15. printf '%s: %s %s\n' "$0" 'Nie znaleziono skryptu mediawiki2ency.sh w' \
  16. 'bieżącym katalogu bądź ścieżce wyszukiwania.' >&2
  17. exit 1
  18. fi
  19. # Wybierz prefiks URL-a stron w zależności od źródła.
  20. case $1 in
  21. --sclavinia)
  22. prefix=http://vonthorn.sarmacja.org/wiki/index.php/
  23. ;;
  24. *)
  25. prefix=http://micropedia.wikia.com/wiki/
  26. esac
  27. # Czytaj listę ze standardowego wejścia.
  28. while IFS= read -r name; do
  29. urlname=$(printf '%s\n' "$name" | sed -e 's/ /_/g')
  30. filename=Encyklopedia::$urlname.txt
  31. if [ -e "$filename" ]; then
  32. printf '%s: %s: %s\n' "$0" "$filename" 'Plik już istnieje.' >&2
  33. continue
  34. fi
  35. if ! curl -fso "$filename.tmp" "$prefix$urlname?action=raw"; then
  36. printf '%s: %s: %s\n' "$0" "$name" \
  37. 'Nie udało się pobrać artykułu.' >&2
  38. continue
  39. fi
  40. "$mediawiki2ency" "$@" "$filename.tmp" "$name" > "$filename"
  41. rm -f "$filename.tmp"
  42. done