First commit
This commit is contained in:
commit
29db82a8de
8
README.txt
Normal file
8
README.txt
Normal file
@ -0,0 +1,8 @@
|
||||
DESCRIPTION:
|
||||
A BASH script playing around youtube-dl. Will download the highest available video and audio quiality as mp4 files and then merge them together. Can be used to obtain high quality videos from youtube. You can also pass a list of URLs separated by a space.
|
||||
|
||||
NOTE:
|
||||
This script works around the youtube-dl utility meaning you will need to have the package installed on your system.
|
||||
|
||||
AUTHOR:
|
||||
96-fromsofia - 2A9-7CC@96-fromsofia.net || August 2021
|
||||
41
youtube-dl-batch.sh
Normal file
41
youtube-dl-batch.sh
Normal file
@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Promot for a URL
|
||||
printf "************************************************************************************************************\n## Please provide the youtube URL of the movie you want to download ##\n************************************************************************************************************\n"
|
||||
read -a list
|
||||
|
||||
# Download and merge files for each URL provided
|
||||
for i in "${list[@]}" ; do
|
||||
printf "************************************************************************************************************\n## Please wait while the audio and video formats are being downloaded and the media has been merged.. ##\n## Currently downloading: $i ##\n************************************************************************************************************\n"
|
||||
|
||||
#get the youtube-dl format codes for both the audio and video files
|
||||
audio_code=$(youtube-dl -F $i | grep "m4a" | sort -k7n,7 | tail -1 | awk '{print $1}')
|
||||
video_code=$(youtube-dl -F $i | grep "video only" | grep "mp4" | sort -k3n,3 | tail -1 | awk '{print $1}')
|
||||
|
||||
# download the audio and video formats and save the output to above created temp file
|
||||
movie_tmp=/tmp/movie_tmp.txt
|
||||
youtube-dl -f $audio_code,$video_code $i -o '%(title)s.%(ext)s' &> $movie_tmp
|
||||
|
||||
# generate file names from above said temp file
|
||||
audio_file=$(grep "\[download\]\ Destination:" $movie_tmp | cut -c 25- | grep m4a)
|
||||
video_file=$(grep "\[download\]\ Destination:" $movie_tmp | cut -c 25- | grep mp4)
|
||||
movie_name=$(echo $audio_file | rev | cut -c 5- | rev)
|
||||
|
||||
# allows to store strings with spaces in variables and then use mv/mkdir/rm on these
|
||||
IFS='
|
||||
'
|
||||
# make the movie directory and merge audio + video into the movie
|
||||
mkdir $movie_name
|
||||
cd $movie_name
|
||||
ffmpeg -loglevel error -i "../$video_file" -i "../$audio_file" -strict -2 -codec copy "$movie_name.mp4"
|
||||
|
||||
# clear no longer needed files
|
||||
rm $movie_tmp ../$audio_file ../$video_file
|
||||
|
||||
printf "************************************************************************************************************\n## The movie $movie_name has now been saved: ##\n$(date ; hostname ; pwd ; du -sh *)\n************************************************************************************************************"
|
||||
|
||||
# resturn to directory user was prior to initiating this script.
|
||||
cd ..
|
||||
done
|
||||
|
||||
exit
|
||||
Loading…
Reference in New Issue
Block a user