housofusenet.sh 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. rm -f ${PFAD}/searchresults.txt
  27. FILMHTML=$(echo $FILM | sed -f ${PFAD}/url_escape.sed)
  28. SEARCHURL=${SEARCHPREFIX}${FILMHTML}${SEARCHPOSTFIX}
  29. echo $FILMHTML
  30. echo $SEARCHURL
  31. curl -s -L -H "${USERAGENT}" -b ${COOKIEFILE} "${SEARCHURL}" -o ${PFAD}/searchresults.txt
  32. grep "keine Ergebnisse gefunden" ${PFAD}/searchresults.txt > /dev/null
  33. if [ $? -eq 0 ] ; then
  34. echo "Nichts gefunden"
  35. continue
  36. fi
  37. grep "kürzer als erlaubt" ${PFAD}/searchresults.txt > /dev/null
  38. if [ $? -eq 0 ] ; then
  39. echo "Suchbegriff zu kurz"
  40. continue
  41. fi
  42. grep "showthread.php" ${PFAD}/searchresults.txt | grep "subject_old" | sed 's@showthread.php@https://house-of-usenet.com/showthread.php@g' > "${PFAD}/results/${FILM}.html"
  43. echo "##############################" >> "${PFAD}/results/${FILM}.html"
  44. echo "Filmtitel auf Festplatte: ${FILM}" >> "${PFAD}/results/${FILM}.html"
  45. echo "##############################"
  46. rm -f ${PFAD}/searchresults.txt
  47. sleep 60
  48. done
  49. beenden 0