Advertisement
Guest User

qutebrowser userscript to save webpage offline

a guest
Nov 5th, 2024
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.35 KB | None | 0 0
  1. @ECHO off
  2. SETLOCAL EnableDelayedExpansion
  3.  
  4. SET "Script=?:\???????\script_Batch_Remove_Special_Invalid_characters.py"
  5. SET "Single_File_Cli=?:\???????\SingleFile CLI webpage downloader\single-file.exe"
  6. SET "TimeNow=!time:~0,-3!"
  7. SET "TimeNow=!TimeNow::=-!"
  8. SET "DateTime=!date!_!TimeNow: =0!"
  9. SET "Special=!QUTE_TITLE!"
  10. SET "Dir=?:\???????\webpages"
  11. SET "LogFilePath=C:\Users\???????\AppData\Roaming\qutebrowser\config\userscripts"
  12. SET "LogFileName=\log_save-page.txt"
  13.  
  14. REM Call Python script
  15.     CALL :ESCAPE_V "the script" "%Special%"
  16.  
  17. REM Read output from tempfile
  18.     FOR /F "tokens=*" %%i IN (temp__batch_remove_invalid.txt) DO SET Validated=%%i
  19.     DEL temp__batch_remove_invalid.txt
  20.     SET "Filename=[!DateTime!] !Validated!.html"
  21.     REM CALL ECHO result: !Filename! && EXIT
  22.  
  23. REM Pass arguments
  24.     "!Single_File_Cli!" !QUTE_URL! "!Filename!" --output-directory "!Dir!"
  25.     ECHO "!Single_File_Cli!" !QUTE_URL! "!Filename!" --output-directory "!Dir!" > !LogFilePath!!LogFileName!
  26.     ECHO :message-info 'Script Ended, save-page' >> !QUTE_FIFO!
  27.     REM explorer "!Dir!"
  28. GOTO:EOF
  29.  
  30.  
  31. :ESCAPE_V
  32.     SetLocal DisableDelayedExpansion
  33.     ECHO %~1
  34.     ECHO     L1. Start
  35.     SET "escaped=%~2"
  36.     SET "escaped=%escaped:|=^|%"
  37.     SET "escaped=%escaped:"=%"
  38.     ECHO     L2. Ended: %escaped%
  39.  
  40.     CALL "%Script%" -d ^"%escaped%^"
  41.  
  42.     SetLocal EnableDelayedExpansion
  43. GOTO:EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement