Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

69 linhas
2.1 KiB

  1. #!/bin/bash
  2. ########################################################################
  3. # Copyright (C) 2017 Max Mehl <mail [at] mehl [dot] mx>
  4. ########################################################################
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Affero General Public License as
  8. # published by the Free Software Foundation, either version 3 of the
  9. # License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public
  17. # License along with this program. If not, see
  18. # <http://www.gnu.org/licenses/>.
  19. #
  20. ########################################################################
  21. #
  22. #
  23. #
  24. ########################################################################
  25. # Test if config.cfg exists and set needed variables
  26. if [ ! -e config.cfg ]; then echo "Missing config.cfg file. Edit and rename config.cfg.sample"; exit 1; fi
  27. source config.cfg
  28. LINK=$1
  29. if [ "$1" == "" ]; then
  30. exit 1
  31. fi
  32. CONTENT=$(wget -qO - "$LINK")
  33. TWIMG=$(echo $CONTENT | grep -Pio "https://pbs.twimg.com/media/[a-z0-9-_]{8,}\.(jpg|png|jpeg)" | head -1)
  34. if [ ! -e "$DIR" ]; then
  35. mkdir $DIR
  36. fi
  37. TWFILE=$(basename $TWIMG)
  38. EXT="${TWFILE##*.}"
  39. DBCHECK=$(grep "^$TWFILE;" $DB)
  40. if [ "$DBCHECK" != "" ]; then # file has already been downloaded
  41. echo $DBCHECK | cut -d";" -f2
  42. else # file hasn't been downloaded yet
  43. ok="n"
  44. while [ "$ok" != "y" ]; do
  45. RAND=$(openssl rand -hex 3)
  46. if [ ! -e "$DIR/$RAND.$EXT" ]; then
  47. ok="y"
  48. fi
  49. done
  50. LCIMG="$DIR/$RAND.$EXT"
  51. LCLINK="$DOMAIN/$LCIMG"
  52. SLLINK=$(curl -K .userpass.txt -s "$SLSERV" -d "link=$LCLINK" -A "Mozilla" | grep -P -io "$SLGREP1" | sed -e 's/<[^>]*>//g' | grep -Eo "$SLGREP2")
  53. echo "$TWFILE;$SLLINK;$LCLINK" >> "$DB"
  54. wget -O "$LCIMG" "$TWIMG"
  55. echo "$SLLINK"
  56. fi