File size: 802 Bytes
23aa8f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import jmcomic
import os

base_path = os.getcwd()

for album_id in range(1, 10_000_000):
    # 计算当前的文件夹编号,比如 1-100, 101-200 ...
    folder_start = ((album_id - 1) // 100) * 100 + 1
    folder_end = folder_start + 99
    folder_name = f'{folder_start}-{folder_end}'
    folder_path = os.path.join(base_path, folder_name)

    # 创建文件夹(如果不存在)
    if not os.path.exists(folder_path):
        os.mkdir(folder_path)

    # 进入该文件夹
    os.chdir(folder_path)

    try:
        print(f'Downloading album {album_id} to {folder_name}...')
        jmcomic.download_album(str(album_id))
    except Exception as e:
        print(f'Error downloading album {album_id}: {e}')

    # 切回基础目录(可选,确保环境一致)
    os.chdir(base_path)