Katılım
3 Aralık 2023
Mesajlar
15.077
Makaleler
104
Çözümler
1.590
Beğeniler
45.768
Yer
İstanbul
Hepsini cekmeye yarayan scripti yazacak bir babayigit cikar mi?

Kullanmanızı önermem. Öylesine bir deneyeyim dedim 10-15 dosyada 6 GB falan yaptı. Kapattım hemen.

Python:
import os
import requests
from concurrent.futures import ThreadPoolExecutor

base_url = "http://download.tplinkcloud.com/"
list_file = "tplinkclouds.txt"
output_dir = "TPLink_Downloads"

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
}

def download_file(file_path):
    file_path = file_path.strip().lstrip("/")
    if not file_path:
        return

    full_url = base_url + file_path
    local_path = os.path.join(output_dir, file_path)
    

    os.makedirs(os.path.dirname(local_path), exist_ok=True)

    if os.path.exists(local_path):
        return

    try:
        with requests.get(full_url, stream=True, timeout=15, headers=headers) as r:
            r.raise_for_status()
            with open(local_path, 'wb') as f:
                for chunk in r.iter_content(chunk_size=1024 * 64):
                    if chunk:
                        f.write(chunk)
        print(f"[BAŞARILI] {file_path}")
    except Exception as e:
        print(f"[HATA] {file_path}: {e}")

def main():
    if not os.path.exists(list_file):
        print(f"Hata: {list_file} dosyası script ile aynı klasörde olmalı!")
        return

    with open(list_file, 'r', encoding='utf-8') as f:
        paths = [line.strip() for line in f if line.strip()]

    print(f"{len(paths)} dosya kontrol ediliyor/indiriliyor...")
    
    with ThreadPoolExecutor(max_workers=20) as executor:
        executor.map(download_file, paths)

if __name__ == "__main__":
    main()