housofusenet.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/bash
  2. PFAD=$(dirname "$(readlink -f "$0")")
  3. function beenden {
  4. rm -f $COOKIEFILE
  5. rm -f landingpage.txt
  6. rm -f searchresults.txt
  7. umount /scripts/housofusenet/mount
  8. exit $1
  9. }
  10. USERAGENT='User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0'
  11. COOKIEFILE="/tmp/hou-cookie.txt"
  12. curl -s -H "${USERAGENT}" 'https://house-of-usenet.com/member.php?action=login' --cookie-jar ${COOKIEFILE} -o ${PFAD}/landingpage.txt
  13. POSTKEY=$(grep -m 1 '<input name="my_post_key"' ${PFAD}/landingpage.txt | cut -d "=" -f 4 | cut -d '"' -f2)
  14. #echo "Postkey: $POSTKEY"
  15. #cat $COOKIEFILE
  16. curl -s -X POST -H "${USERAGENT}" --referer 'https://house-of-usenet.com/member.php?action=login' -b ${COOKIEFILE} --cookie-jar ${COOKIEFILE} -F "username=bla1bla1" -F "password=bla2bla2" -F "action=do_login" -F "my_post_key=${POSTKEY}" -F "remember=yes" 'https://house-of-usenet.com/member.php'
  17. #später curl mit -b cookie benutzen, nachdem eingeloggt
  18. SEARCHPREFIX='https://house-of-usenet.com/search.php?action=do_search&keywords='
  19. SEARCHPOSTFIX='&postthread=2&author=&matchusername=1&findthreadst=1&numreplies=&postdate=0&pddir=1&threadprefix%5B%5D=any&sortby=lastpost&sortordr=desc&showresults=threads&forums%5B%5D=1865&submit=Suche'
  20. mount -t cifs //nhi-to-sw-serv.klenzel.net/Videos$ ${PFAD}/mount -o credentials=${PFAD}/smbcredentials,iocharset=utf8,sec=ntlmssp,vers=2.0,dir_mode=0770
  21. if [ $? -ne 0 ] ; then
  22. echo "Error while mounting"
  23. beenden 1
  24. fi
  25. #find ${PFAD}/mount/Filme/h.264\ -\ 1080p/ -type d -printf '%f\n' | while read FILM; do
  26. #find ${PFAD}/mount/Filme/h.264\ -\ 720p/ -type d -printf '%f\n' | while read FILM; do
  27. find ${PFAD}/mount/Filme/SD/ -type d -printf '%f\n' | while read FILM; do
  28. rm -f ${PFAD}/searchresults.txt
  29. echo "##############################"
  30. sleep 30
  31. #hier werden Wörter mit nur 3 Buchstaben entfernt sowie anschließend doppelte Leerzeichen und Leerzeichen am Anfang/Ende
  32. FILMKURZ=$(echo ${FILM} | sed 's/\<.\{,3\}\>//g' | sed 's/-//g' |awk '{$1=$1};1')
  33. if [ "$FILMKURZ" == "" ] ; then
  34. echo "Name zu kurz, leerer String: ${FILM}"
  35. continue
  36. fi
  37. FILMHTML=$(echo $FILMKURZ | sed -f ${PFAD}/url_escape.sed)
  38. SEARCHURL=${SEARCHPREFIX}${FILMHTML}${SEARCHPOSTFIX}
  39. echo "Aktueller Film: $FILM"
  40. echo $SEARCHURL
  41. curl -s -L -H "${USERAGENT}" -b ${COOKIEFILE} "${SEARCHURL}" -o ${PFAD}/searchresults.txt
  42. grep "keine Ergebnisse gefunden" ${PFAD}/searchresults.txt > /dev/null
  43. if [ $? -eq 0 ] ; then
  44. echo "Nichts gefunden"
  45. continue
  46. fi
  47. grep "kürzer als erlaubt" ${PFAD}/searchresults.txt > /dev/null
  48. if [ $? -eq 0 ] ; then
  49. echo "Suchbegriff zu kurz"
  50. continue
  51. fi
  52. grep "showthread.php" ${PFAD}/searchresults.txt | grep "subject_old" | sed 's@showthread.php@https://house-of-usenet.com/showthread.php@g' | sed ':a;N;$!ba;s/\n/<br>\r\n/g' > "${PFAD}/results/${FILM}.html"
  53. echo "<br>##############################" >> "${PFAD}/results/${FILM}.html"
  54. echo "<br>Filmtitel auf Festplatte: ${FILM}" >> "${PFAD}/results/${FILM}.html"
  55. #echo "##############################"
  56. rm -f ${PFAD}/searchresults.txt
  57. #sleep 60
  58. done
  59. beenden 0