今天没事干给RPi写了个脚本,扔 crontab 里面用来检查PT站点小货车里面的种子,下载的种子可被 transmission-daemon 抓到并自动添加自动下载。已经上机2小时了,没发现什么问题。无心插柳作品问题多多,欢迎各种拍砖。
参数脚本里都写了,按照说明配置即可
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #!/bin/bash # PT site's RSS checker # By Bill Haofei Gong on 5th Jan, 2013 # # This script is for checking the RSS cart from a PT site and download added torrents # to specified folder. Therefore transmission-daemon will be able to add those torre- # nts and start to download. # # Replace value of RSS_URI to the address of your RSS feed. If the feed uses a diffe- # rent keyword to describe links, you may need to change RSS_PATTERN and SED_PATTERN # to fit the pattern of torrents in feed. # # To make transmission-daemon watches folder and add automatically, you need to: # 1. create a folder for torrents and give owner and group as "debian-transmission" # 2. add/modify following parameters to your transmission settings file: # "start-added-torrents": true, # "trash-original-torrent-files": false, # "watch-dir": "YOUR-TORRENT-FOLDER", # "watch-dir-enabled": true # 3. add this script to crontab to check RSS feed at a regular time. # for example, to check RSS feed every 15 minutes, add following: # */15 * * * * "LOCATION-OF-THIS-SCRIPT" # # Steps above will set transmission-daemon not to delete old torrents after added. T- # herefore in this script, wget will not re-download exist torrents. This will incre- # ase the speed of each check. TEMP_FILE_LOCATION="/tmp/rss-checker.tmp" DESTINATION_DIR="YOUR-TORRENT-FOLDER" RSS_URI="YOUR-RSS-FEED-URI" # Following patterns are for TTG.im, that may not apply to other feeds. RSS_PATTERN="rssdd.php" SED_PATTERN='s/<link>//g;s/<\/link>/,/g' # Create temp file touch $TEMP_FILE_LOCATION # Download and parse the RSS from TTG curl $RSS_URI | grep $RSS_PATTERN | sed $SED_PATTERN > $TEMP_FILE_LOCATION # Use wget to download each of those torrents wget --content-disposition -i $TEMP_FILE_LOCATION --directory-prefix=$DESTINATION_DIR -nc # Clean up the temp file rm $TEMP_FILE_LOCATION |
狂击这里下载
版权所有但盗版不究,遵守CC3.0随便来好了~
Update:
更新了一下,使用说明见前一个版本。Changelog 在文件头,请自行查看。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #!/bin/bash # PT site's RSS checker # By Bill Haofei Gong on 5th Jan, 2013 # # UPDATE 01 on 6th Jan, 2013: # Clean up the script, and implemented diff checker to avoid unnecessary download. # UPDATE 02 on 8th Jan, 2013: # Updated comment and replace useless echos to logger so result will be shown on syslog. # UPDATE 03 on 8th Jan, 2013: # Added empty RSS check and remove unnecessary comment. TEMP_FILE_LOCATION="/tmp/rss-checker.tmp" DESTINATION_DIR="HERE-IS-DESTINATION-FOLDER" RSS_URI="HERE-IS-RSS-URI" RSS_PATTERN="rssdd.php" SED_PATTERN='s/<link>//g;s/<\/link>/,/g' # Download and parse the RSS from TTG curl $RSS_URI | grep $RSS_PATTERN | sed $SED_PATTERN > $TEMP_FILE_LOCATION # Determin if the RSS is empty if [ -s $TEMP_FILE_LOCATION ]; then # Determine if nothing is changed if ! diff -q $DESTINATION_DIR/.rss_store $TEMP_FILE_LOCATION; then cp -f $TEMP_FILE_LOCATION $DESTINATION_DIR/.rss_store wget --content-disposition -i $DESTINATION_DIR/.rss_store --directory-prefix=$DESTINATION_DIR -nc logger "RSS-Checker: New torrent is added. " fi fi # Clean up the temp file rm -f $TEMP_FILE_LOCATION |
狂击这里下载此更新