File size: 1,170 Bytes
6843b9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
30
31
32
33
34
35
36
37
38
39
import os
import requests
from concurrent.futures import ThreadPoolExecutor, as_completed

BASE_URL = "https://ftp.itec.aau.at/datasets/SVD/AVP/"
OUTPUT_DIR = "./videos"
NUM_WORKERS = 32

os.makedirs(OUTPUT_DIR, exist_ok=True)

def download_file(file_id: int):
    file_name = f"{file_id:04d}.mov"
    url = f"{BASE_URL}{file_name}"
    output_path = os.path.join(OUTPUT_DIR, file_name)

    try:
        # Stream download
        with requests.get(url, stream=True, timeout=30) as r:
            r.raise_for_status()
            with open(output_path, "wb") as f:
                for chunk in r.iter_content(chunk_size=8192):
                    if chunk:
                        f.write(chunk)
        return f"✅ {file_name} downloaded"
    except Exception as e:
        return f"❌ {file_name} failed: {e}"

def main():
    file_ids = range(1, 160)  # 0001 to 0159
    results = []

    with ThreadPoolExecutor(max_workers=NUM_WORKERS) as executor:
        future_to_file = {executor.submit(download_file, fid): fid for fid in file_ids}
        for future in as_completed(future_to_file):
            print(future.result())

if __name__ == "__main__":
    main()