0

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

1 Answer 1

0

The problem you're facing is caused by the way the files are being saved. The ffmpeg command in the script is creating the files in the current working directory, rather than in the folder specified by "$folder_name".

To fix this issue, you can change the ffmpeg command to specify the output directory with the -y option, like this:

ffmpeg -i "$file_path.fdash-video=6157520.mp4" -i "$file_path.fdash-audio_eng=160000.m4a" -c copy -y "$folder_name/$(echo $file_path | cut -f1 -d '.').mp4"

This will save the output files directly in the folder specified by $folder_name and with the desired filename.

Additionally, you don't need to move the file from it's location in the command mv "$file_path" "$folder_name/$(echo $file_path | cut -f1 -d '.').mp4" anymore.

By making these changes to the script, you should now be able to download the files into their respective folders, as the ffmpeg command will save the files directly into the folder specified by $folder_name.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.