Auto-download attachments from URL in properties

What I’m trying to do

Creating my own movie data base. I’ve adapted the movie.js script by chhoumann, to import from Tmdb instead of Omdb. It’s basically done, but I cannot figure out how to auto-download the pictures from Tmdb into obsidian.

I’ve got the base URL:

const TMDB_BASE_URL = "https://www.themoviedb.org/movie/";

Things I have tried

Researched and asked Chat-GPT with no successful run.
Tried to run the script without creating the note and use quickadd for that.
Use the “Download attachments from current file”, which runs into no files in current note - seems to not recognise the attachment in the properties.

My script looks like this at the moment, I have had variations.

 coverUrl: selectedShow.poster_path ? TMDB_IMAGE_BASE_URL + selectedShow.poster_path : "Kein Cover verfügbar",

I tried this too, but then it’s not specific where to download from

coverUrl: `Sonstiges/Bildersammlung/${replaceIllegalFileNameCharactersInString(selectedShow.title || selectedShow.name)}-poster.jpg`, // Angepasster Pfad zum Ordner

I guess what I’m missing is the right line for specifying the URL and then force a download to the folder Sonstiges/Bildersammlung while replacing the URL with the local file name.

If anyone has ideas how to achieve this, please tell me.