File size: 1,289 Bytes
329ba5e
7828f10
329ba5e
 
229de8b
fc1c86d
229de8b
 
 
 
 
 
 
329ba5e
 
229de8b
329ba5e
 
229de8b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fc1c86d
329ba5e
229de8b
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
40
41
42
43
44
45
46
47
import cloudinary.api
import requests
# Assuming you have already configured Cloudinary with your credentials

def download_file():
    save_path = "downloaded.mp3"
    cloudinary.config( 
      cloud_name = "djepbidi1", 
      api_key = "531731913696587", 
      api_secret = "_5ePxVQEECYYOukhSroYXq7eKL0" 
    )

    public_id = 'test'

# Fetch the asset's details
    asset_details = cloudinary.api.resource(public_id, resource_type='video')

# Extract the secure URL of the asset
    asset_url = asset_details.get('secure_url')

    print("Asset URL:", asset_url)


    """
    Download a file from a given URL and save it to the specified local path.

    Parameters:
    - url: The URL of the file to download.
    - save_path: The local path where the file should be saved.
    """
    response = requests.get(asset_url, stream=True)
    
    # Check if the request was successful
    if response.status_code == 200:
        with open(save_path, 'wb') as f:
            for chunk in response.iter_content(chunk_size=128):
                f.write(chunk)
        print(f"File downloaded successfully: {save_path}")
    else:
        print(f"Failed to download file. Status code: {response.status_code}")

# Example usage
#cloudinary_url = "YOUR_CLOUDINARY_FILE_URL"


download_file()