Skip to content

Instantly share code, notes, and snippets.

@milnak
Last active February 11, 2024 14:50
Show Gist options
  • Save milnak/0a834e2d268f0d4b290a4e8b0680e34e to your computer and use it in GitHub Desktop.
Save milnak/0a834e2d268f0d4b290a4e8b0680e34e to your computer and use it in GitHub Desktop.
qBitTorrent ipfilter file updater
@ECHO OFF
REM qBittorrent IP Filter updater.
REM 9:45 AM Sunday, January 24, 2010. Updated 2016-03-15
REM To enable in qBittorrent:
REM Settings - Connection - IP Filtering - Filter path - %APPDATA%\qBittorrent\ipfilter.dat
SETLOCAL
REM https://www.iblocklist.com/lists
REM https://www.ipfilter.app : https://github.com/DavidMoore/ipfilter/releases/download/lists/ipfilter.dat.gz
REM level1 (Bluetack):
SET IPFILTERURL="http://list.iblocklist.com/?list=ydxerpxkpcfqjaybcssw&fileformat=dat&archiveformat=gz"
REM --- Will save to %AppData%\qBittorrent\ipfilter.dat ---
SET IPFILTERFILENAME=ipfilter.dat
SET IPFILTERDIR=%AppData%\qBittorrent
SET IPFILTERFILE=%IPFILTERDIR%\%IPFILTERFILENAME%
SET LMFILENAME=%IPFILTERFILENAME%.lastmodified
SET LMFILE=%IPFILTERDIR%\%LMFILENAME%
SET TEMPIPFILTERFILE=%TEMP%\%IPFILTERFILENAME%
SET TEMPLMFILE=%TEMP%\%LMFILENAME%
IF NOT EXIST "%IPFILTERDIR%" (
ECHO ERROR: Can't find '%IPFILTERDIR%'.
GOTO :EOF
)
ECHO Getting last modified date of '%IPFILTERFILENAME%' on server.
curl.exe --location --silent --head %IPFILTERURL% | findstr /c:"Last-Modified:" >"%TEMPLMFILE%"
IF ERRORLEVEL 1 ( ECHO Can't find ipfilter.dat on server & GOTO :EOF )
type "%TEMPLMFILE%"
IF NOT EXIST "%LMFILE%" GOTO :START
ECHO Comparing against '%LMFILE%'.
type "%LMFILE%"
fc.exe "%LMFILE%" "%TEMPLMFILE%" >NUL
IF ERRORLEVEL 1 GOTO :START
ECHO File is up to date. Nothing to do.
GOTO :EOF
:START
ECHO Downloading new ipfilter.dat to "%TEMPIPFILTERFILE%.gz".
curl.exe --location --progress-bar --output "%TEMPIPFILTERFILE%.gz" %IPFILTERURL%
IF ERRORLEVEL 1 ( ECHO ERROR! & GOTO :EOF )
ECHO Decompressing . . .
gzip.exe --decompress "%TEMPIPFILTERFILE%.gz"
IF ERRORLEVEL 1 ( ECHO ERROR! & GOTO :EOF )
move /Y "%TEMPIPFILTERFILE%" "%IPFILTERFILE%" >NUL
move /Y "%TEMPLMFILE%" "%LMFILE%" >NUL
ECHO Done! Set P2P file to: '%IPFILTERFILE%'
ECHO qBitTorrent: Options - Connection - IP Filtering
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment