This question comes from here but is different
ok, I have these urls
https://www.ppppppppppp.com/it/yyyy/911-omicidio-al-telefono/stagione-1-appesa-a-un-filo
https://www.ppppppppppp.com/it/yyyy/avamposti-dispacci-dal-confine/stagione-1-cerignola
https://www.ppppppppppp.com/it/yyyy/belle-da-morire/stagione-1-bellezza-stalking
I try to create these folder with these names
911-omicidio-al-telefono
avamposti-dispacci-dal-confine
belle-da-morire
extracting the name from urls
for example I would like the file from the url
https://www.ppppppppppp.com/it/yyyy/911-omicidio-al-telefono/stagione-1-appesa-a-un-filo
to download directly inside the folder name extracted from the url
911-omicidio-al-telefono
but this seems problematic because no folder names are extracted and each file is downloaded outside their folderURL name
To solve this problem I try do this:
create a script.sh with this code
#!/bin/bash
url=$1
folder_name=$(echo "$url" | sed -E 's/^https:\/\/www\.ppppppppppp\.com\/it\/video\/(.+)\/.*$/\1/')
mkdir -p "$folder_name"
file_path=$(echo "$url" | sed -E "s/^(.+)\.fdash.*$/\1\.mp4/")
ffmpeg -i "$file_path.fdash-video=6157520.mp4" -i "$file_path.fdash-audio_eng=160000.m4a" -c copy "$file_path"
mv "$file_path" "$folder_name/$(echo $file_path | cut -f1 -d '.').mp4"
and then from bash terminal I call it in this way
yt-dlp --referer "https://www.ppppppppppp.com/" --add-header "Cookie:COOKIE" --batch-file links_da_scaricare.txt -o '%(title)s.%(ext)s' --exec "/home/appbox/Downloads/dplay/script.sh {}"
What is the problem?
All files are downloaded in the same folder and not in their folders, in other word are not downloaded in the folders having names extracted from the url from which the files are downloaded