File size: 597 Bytes
b1cded8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os
import requests

def pixeldrain(url, output_dir):
    try:
        response = requests.get(f"https://pixeldrain.com/api/file/{url.split('pixeldrain.com/u/')[1]}")

        if response.status_code == 200:
            file_path = os.path.join(
                output_dir, 
                response.headers.get("Content-Disposition").split("filename=")[-1].strip('";')
            )

            with open(file_path, "wb") as newfile:
                newfile.write(response.content)

            return file_path

        return None
    except Exception as e:
        raise RuntimeError(e)