0
def download_video(url, save_path):
    loader = instaloader.Instaloader()
    try:
        post = instaloader.Post.from_shortcode(loader.context, url.split("/")[-2])
        video_url = post.video_url

        response = requests.get(video_url, stream=True)
        if response.status_code == 200:
            with open(save_path, 'wb') as file:
                response.raw.decode_content = True
                shutil.copyfileobj(response.raw, file)
                print("Video downloaded successfully!")
        else:
            print("Failed to download the video.")
    except Exception as e:
        print("Failed to download the video:", str(e))

I created this function to download Instagram video from its url, I add this on my website. Problem: Its was working fine when I wasn't using on my website, I want it available for everyone online

Error : Failed to download the video:
[Errno 13] Permission denied.

How can I fix it so that it can download in users downloads folder and on mobile?

xyres
  • 20,487
  • 3
  • 56
  • 85

1 Answers1

0

I don't understand what your asking that well, but this may be of aid if your trying to find the downloads folder of the users computer:

import os
os.path.join( os.getenv('USERPROFILE'), 'Downloads')

This may not work on mobile, as python isn't very commonly used in mobile app development, but it's worth a shot.

  • Failed to download the video: [Errno 13] Permission denied: 'C:\\Users\\Myusername\\Downloads' – AHSAN USMAN Jul 06 '23 at 10:45
  • https://snapinsta.app/ When I enter the URL it downloads the video in my download folder I want this on my site – AHSAN USMAN Jul 06 '23 at 10:58
  • The file must attempting to download in the servers downloads directory. You should instead send the file using https POST to the javascript and use javascript to handle downloading. – M1dnightGMR Jul 06 '23 at 19:32