Advertisement
Shuraken007

wo_ror_addons

Nov 2nd, 2023 (edited)
958
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. #!/usr/bin/python3.3
  2. import os.path
  3. import urllib.request
  4. import zipfile
  5. from bs4 import BeautifulSoup
  6. import requests
  7. import re
  8. import os
  9.  
  10. TMP_DIR = "C:\\tmp"
  11. DOWNLOADS_DIR_UNZIPPED = "C:\\Games\\WOROR\\Interface\\AddOns"
  12. url = 'https://tools.idrinth.de/addons/'
  13.  
  14. if not os.path.exists(TMP_DIR):
  15.     os.makedirs(TMP_DIR)
  16.  
  17. reqs = requests.get(url)
  18. soup = BeautifulSoup(reqs.text, 'html.parser')
  19. urls = []
  20. links = [ 'https://tools.idrinth.de/' + x.get('href') for x in soup.find_all(href=re.compile("/download/"))]
  21.  
  22. for link in links:
  23.     link = link.strip()
  24.     print('Link: ' + link)
  25.     name = link.rsplit('/', 4)[-4]
  26.  
  27.     filename = os.path.join(TMP_DIR, name)
  28.  
  29.     if not os.path.isfile(filename):
  30.         try:
  31.             urllib.request.urlretrieve(link, filename + '.zip')
  32.             with zipfile.ZipFile(filename + '.zip', 'r') as zip_ref:
  33.                 print('Downloading: ' + DOWNLOADS_DIR_UNZIPPED + '/' + name)
  34.                 zip_ref.extractall(DOWNLOADS_DIR_UNZIPPED)
  35.         except Exception as inst:
  36.             print(inst)
  37.             print('  Encountered unknown error. Continuing.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement