24游戏-网络单机游戏GM工具论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 515|回复: 0

官方补丁批量下载器 Python

[复制链接]

87

主题

43

回帖

1895

积分

金牌会员

Rank: 6Rank: 6

积分
1895

救世者之树-邮件龙之谷三系-泡点剑灵M赞助商-200奥拉蛋赞助商-item奥拉蛋赞助商-CDK

发表于 2023-2-16 13:12:57 | 显示全部楼层 |阅读模式
[如何使用
  • 输入网址提示
  • 输入范围的第一个数字
  • 输入范围的第二个数字
  • 等到所有下载完成



  1. DATA HOSTED WITH ♥ BY PASTEBIN.COM - DOWNLOAD RAW - SEE ORIGINAL
  2. import requests
  3. import os
  4. import time
  5. from clint.textui import progress

  6. def downloadPak(url, file):
  7.     data = requests.get(url, stream=True)
  8.     with open(file, 'wb') as download:
  9.         length = int(data.headers.get('content-length'))
  10.         for chunk in progress.bar(data.iter_content(chunk_size = 1024), expected_size=(length / 1024) + 1):
  11.             if chunk:
  12.                 download.write(chunk)
  13.                 download.flush()

  14. def downloadMD5(url, file):
  15.     data = requests.get(url, stream=True)
  16.     with open(file, 'wb') as download:
  17.         length = int(data.headers.get('content-length'))
  18.         for chunk in progress.bar(data.iter_content(chunk_size = 1024), expected_size=(length / 1024) + 1):
  19.             if chunk:
  20.                 download.write(chunk)
  21.                 download.flush()

  22. def downloadTxt(url, file):
  23.     data = requests.get(url, stream=True)
  24.     with open(file, 'wb') as download:
  25.         length = int(data.headers.get('content-length'))
  26.         for chunk in progress.bar(data.iter_content(chunk_size = 1024), expected_size=(length / 1024) + 1):
  27.             if chunk:
  28.                 download.write(chunk)
  29.                 download.flush()

  30. def main():
  31.     url = input("Enter URL: ")
  32.     num = input("Download Patch Starting From: ")
  33.     num2 = input("Up to: ")
  34.     print('\n')
  35.    
  36.     for i in range(int(num), int(num2) + 1):
  37.         num_len = len(num)
  38.         num2_len = len(num2)
  39.       
  40.         if num_len == 1 or num2_len == 1:
  41.             directory = f'0000000{i}'
  42.             url_pak = f'{url}0000000{i}/Patch0000000{i}.pak'
  43.             file_pak = f'0000000{i}\\Patch0000000{i}.pak'
  44.             url_md5 = f'{url}0000000{i}/Patch0000000{i}.pak.MD5'
  45.             file_md5 = f'0000000{i}\\Patch0000000{i}.pak.MD5'
  46.             url_txt = f'{url}0000000{i}/Patch0000000{i}.txt'
  47.             file_txt = f'0000000{i}\\Patch0000000{i}.txt'
  48.         elif num_len == 2 or num2_len == 2:
  49.             directory = f'000000{i}'
  50.             url_pak = f'{url}000000{i}/Patch000000{i}.pak'
  51.             file_pak = f'000000{i}\\Patch000000{i}.pak'
  52.             url_md5 = f'{url}000000{i}/Patch000000{i}.pak.MD5'
  53.             file_md5 = f'000000{i}\\Patch000000{i}.pak.MD5'
  54.             url_txt = f'{url}000000{i}/Patch000000{i}.txt'
  55.             file_txt = f'000000{i}\\Patch000000{i}.txt'
  56.         elif num_len == 3 or num2_len == 3:
  57.             directory = f'00000{i}'
  58.             url_pak = f'{url}00000{i}/Patch00000{i}.pak'
  59.             file_pak = f'00000{i}\\Patch00000{i}.pak'
  60.             url_md5 = f'{url}00000{i}/Patch00000{i}.pak.MD5'
  61.             file_md5 = f'00000{i}\\Patch00000{i}.pak.MD5'
  62.             url_txt = f'{url}00000{i}/Patch00000{i}.txt'
  63.             file_txt = f'00000{i}\\Patch00000{i}.txt'
  64.         elif num_len == 4 or num2_len == 4:
  65.             directory = f'0000{i}'
  66.             url_pak = f'{url}0000{i}/Patch0000{i}.pak'
  67.             file_pak = f'0000{i}\\Patch0000{i}.pak'
  68.             url_md5 = f'{url}0000{i}/Patch0000{i}.pak.MD5'
  69.             file_md5 = f'0000{i}\\Patch0000{i}.pak.MD5'
  70.             url_txt = f'{url}0000{i}/Patch0000{i}.txt'
  71.             file_txt = f'0000{i}\\Patch0000{i}.txt'
  72.       
  73.         os.mkdir(directory)
  74.         print(f'Directory {directory} created')
  75.       
  76.         downloadPak(url_pak, file_pak)
  77.         print(f'Downloaded Patch00000{i}.pak')
  78.         downloadMD5(url_md5, file_md5)
  79.         print(f'Downloaded Patch00000{i}.pak.MD5')
  80.         downloadTxt(url_txt, file_txt)
  81.         print(f'Downloaded Patch00000{i}.txt')
  82.         print('\n\n')

  83. if __name__ == '__main__':
  84.     main()
复制代码



*滑块验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|Archiver|手机版|小黑屋|24游戏论坛

GMT+8, 2024-5-5 22:52 , Processed in 0.603606 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表