Qi28 commited on
Commit
d07c1be
·
verified ·
1 Parent(s): 0375b54

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -9
main.py CHANGED
@@ -13,8 +13,6 @@ print('--------------远程执行---------------------')
13
  import os
14
  import subprocess
15
 
16
-
17
-
18
  def install_aria2():
19
  try:
20
  # 检查 aria2c 是否已安装
@@ -64,22 +62,24 @@ mode_url = [
64
 
65
  def download_aria2(file_name, download_dir, url):
66
  download_path = os.path.join(download_dir, file_name)
 
67
  # 检查文件是否已存在
68
  if os.path.exists(download_path):
69
- print(f'文件 {file_name} 已存在, URL: {url}')
70
- return
 
 
71
 
72
  aria2_args = (
73
  f'aria2c --dir {download_dir} --out {file_name} '
74
- '--console-log-level=error'
75
- '-c -x 16 -s 16'
76
  '{url}'
77
  )
78
 
79
  try:
80
- print(f'aria2c --dir {download_dir} --out {file_name} --max-connection-per-server=10 --split=10 --min-split-size=1M --max-overall-download-limit=0 --max-download-limit=0 --continue=true {url}')
81
- os.system(f'aria2c --dir {download_dir} --out {file_name} --max-connection-per-server=10 --split=10 --min-split-size=1M --max-overall-download-limit=0 --max-download-limit=0 --continue=true {url}')
82
- # os.system(aria2_args)
83
  print(f'已成功下载: {file_name}')
84
  except Exception as e:
85
  print(f'下载 {url} 失败: {e}')
 
13
  import os
14
  import subprocess
15
 
 
 
16
  def install_aria2():
17
  try:
18
  # 检查 aria2c 是否已安装
 
62
 
63
  def download_aria2(file_name, download_dir, url):
64
  download_path = os.path.join(download_dir, file_name)
65
+
66
  # 检查文件是否已存在
67
  if os.path.exists(download_path):
68
+ # 检查文件大小是否正确
69
+ if os.path.getsize(download_path) > 0:
70
+ print(f'文件 {file_name} 已存在, URL: {url}')
71
+ return
72
 
73
  aria2_args = (
74
  f'aria2c --dir {download_dir} --out {file_name} '
75
+ '--console-log-level=error '
76
+ '-c -x 16 -s 16 '
77
  '{url}'
78
  )
79
 
80
  try:
81
+ # print(f'aria2c --dir {download_dir} --out {file_name} --max-connection-per-server=10 --split=10 --min-split-size=1M --max-overall-download-limit=0 --max-download-limit=0 --continue=true {url}')
82
+ os.system(aria2_args.format(url=url))
 
83
  print(f'已成功下载: {file_name}')
84
  except Exception as e:
85
  print(f'下载 {url} 失败: {e}')