yausername/youtubedl-android

Downloading to a folder other than Downloads?

markosopcic opened this issue · 5 comments

Hi!
Has anyone tried downloading to another folder other dan Downloads? With Scoped Storage from Android 11 I can't seem to be able to download a video with the library to any other folder because i get the following exception: com.yausername.youtubedl_android.YoutubeDLException: ERROR: unable to open for writing: [Errno 1] Operation not permitted:

I'd like to avoid getting the MANAGE_EXTERNAL_STORAGE permission if possible. If I'm not mistaken, the only way to have this work then would be using the MediaStore API, for which I would need access to a Stream of the data and saving it through the MediaStore API instead of the library saving the file itself.

In addition, MediaStore API is used for media and files created in Android Framework and stored in the system media library. In this case, we use native methods/APIs to access the filesystem in the yt-dlp python codes. So the only way to deal with the permission problem is to use SAF.

You also don't like giving permission to access all files? It would let you save anywhere.

You also don't like giving permission to access all files? It would let you save anywhere.

Yes, I didn't request MANAGE_EXTERNAL_STORAGE in Seal, the request for this permission is quite complicated tho. It's not a good practice to request unnecessary permissions.

The simplest way is to download to external cache/storage directory to start with, because, you have access to file api there. Then you move the downloaded content to Mediastore or SAF location, as you wish, you don't need any storage permission to write to mediastore on android 9+