Blocklist URL - better with listed urls?

Suggest, post, or discuss plugins for Deluge
Jhet
New User
New User
Posts: 7
Joined: Mon Aug 20, 2007 12:21 pm

Re: Blocklist URL - better with listed urls?

Postby Jhet » Mon Aug 20, 2007 12:40 pm

I wrote a bash script to handle downloading and extracting the blocklist from the peerguardian 7zip archives. (i'm not an advanced script writer, so it might suck)

It requires the p7zip package to be installed (doesn't seem to work with the p7zip-full)

here it is. Copy into a text editor, and save it. Remember to make it executable.

Code: Select all

#! /bin/sh

# This is script to download the latest p2p blocklist from peerguardian. It will then uncompress it, ready for deluge to import.
# SCRIPT REQUIRES THE FOLLOWING: 7zip to be installed (on Ubuntu use synaptic to get it)

# ---------------------------------------------------------Variables-----------------------------------------------------------------------------------
# This is where we want to dump the blocklist to.
dlfold=
# dlfold should be something like /home/{user}/blocklist/ or wherever.

# listurl is the location of the peerguardian p2p.  The p2p.php file seems to link to this, but i do not know if the file gets updated, I am assuming so.
# Shouldn't need changing.
listurl=http://lists1.phoenixlabs.org.nyud.net:8080/level1.7z

# ----------------------------------------------------------End of user configurable variables----------------------------------------------------------

attempt=1
backup=$dlfold/backup
fail=0
ts=$(date)
# ------------------------------------------------------------------------------------------------------------------------------------------------------

# checking download folder exists
if [ -d $dlfold ]; then
  echo Download Directory Already Exists, Using it.
else
  mkdir -p $dlfold
  echo Download Directory Created.
fi

# creating backups just in case file download fails.
if [ -d $backup ]; then
  echo Backup Directory Present, Starting backup
else
  mkdir -p $backup
  echo Backup Directory Created.
fi
cd $backup
# remove old backups
echo "Clearing old backups"
rm level1* >/dev/null
# create new backups
echo "Creating new backups"
cd $dlfold
cp level1* $backup/

sleep 2
# Clear old download files.
echo "Clearing Old Blocklist"
rm level1* >/dev/null
# Now getting blocklist file and extracting.
echo "DOWNLOADING NEW BLOCKLIST..."
echo

while [ $attempt -ne 3 ]; do
  wget --timeout=10 $listurl
  if [ $? = 0 ]; then
    7zr e level1.7z
    if [ $? -ne 0 ]; then
      attempt=$(( attempt + 1 ))
      echo "Extraction Error.  Will redownload and try again"
      sleep 10
      fail=1
    else
      attempt=3
      fail=0
      rm *.7z >/dev/null
    fi
  else
    echo "Error while downloading the list, will wait 10 seconds and try again"
    sleep 10
    attempt=$(( attempt + 1 ))
    fail=1
  fi
done
#restore backups if update fails
if [ $fail = 1 ]; then
  rm level1* >/dev/null
  cp $backup/level1* $dlfold/
  if [ $? = 0 ]; then
    echo "UPDATE FAILED.  BACKUPS RESTORED"
  else
    echo "No Backups To Restore"
  fi
fi

if [ $fail = 1 ]; then
  echo "Update Failed at $ts" >update.log
else
  echo "Update Success at $ts" >update.log
fi

The only thing that needs setting is the dlfold variable. If anyone can see any flaws with it, I'd appreciate the feedback.
When i used the script it sometimes failed to get the file, so i added the timeout to wget, and it'll also only try three times.
If you want to schedule this to run, i downloaded gnome-schedule from the ubuntu repo, and told it to run it every week. I dunno if it has run it though.

To get deluge to import the blocklist simply add the URL in the blocklist importer, something like this

Code: Select all

file:///{where you put the dlfold variable to}/level1.txt
With the peerguardian text (uncompressed) option set, and the download at start checkbox also checked.

I may recreate this to simply write to the blocklist file directly, i'll have to see if that's a better idea.
Primary OS: Windows Vista Business 32bit
Secondary OS: Ubuntu Gutsy

kosak
New User
New User
Posts: 5
Joined: Sat Aug 25, 2007 3:55 am

Re: Blocklist URL - better with listed urls?

Postby kosak » Sat Aug 25, 2007 3:58 am

you can always use moblock.. install it and then cron automatically updates the stuff..

http://moblock.berlios.de/

cb474
Member
Member
Posts: 19
Joined: Sun Sep 16, 2007 12:53 am

Re: Blocklist URL - better with listed urls?

Postby cb474 » Sun Sep 16, 2007 1:10 am

Is there an advantage to using moblock over the deluge blocklist plugin, if deluge is the only p2p software I'm using?


Return to “Plugins”

Who is online

Users browsing this forum: No registered users and 4 guests