Fix yt-dlp issues with youtube and embed thumbnails/metadata in video downloads
This commit is contained in:
		
							parent
							
								
									121d451982
								
							
						
					
					
						commit
						dcf670070d
					
				
							
								
								
									
										59
									
								
								.aliases
									
									
									
									
									
								
							
							
						
						
									
										59
									
								
								.aliases
									
									
									
									
									
								
							| 
						 | 
					@ -437,6 +437,9 @@ download_youtube_vid() {
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    printf "${BOLD}${RED}USING TEMP FIX FOR YOUTUBE FORMAT ISSUES BY SETTING THE CLIENT TO tv_simply. SEE https://github.com/yt-dlp/yt-dlp/issues/13930\n\n${NORMAL}"
 | 
				
			||||||
 | 
					    opts+=" --extractor-args youtube:player-client=default,tv_simply"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ $shortname == "1" || $transcribe == "1" ]]; then
 | 
					    if [[ $shortname == "1" || $transcribe == "1" ]]; then
 | 
				
			||||||
        printf "${BOLD}Downloading Youtube vid "
 | 
					        printf "${BOLD}Downloading Youtube vid "
 | 
				
			||||||
        if [[ $shortname == "1" ]];  then printf "| ${YELLOW}using short name${NORMAL}${BOLD} "; fi
 | 
					        if [[ $shortname == "1" ]];  then printf "| ${YELLOW}using short name${NORMAL}${BOLD} "; fi
 | 
				
			||||||
| 
						 | 
					@ -448,13 +451,10 @@ download_youtube_vid() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ $format == "" ]]; then
 | 
					    if [[ $format == "" ]]; then
 | 
				
			||||||
        printf "${BOLD}No format given; using best available.${NORMAL}\n"
 | 
					        printf "${BOLD}No format given; using best available.${NORMAL}\n"
 | 
				
			||||||
        # Download best mp4 video.
 | 
					        # Download best mp4 video, best audio then merge.
 | 
				
			||||||
        format="bv*[ext=mp4]+ba[ext=m4a]"
 | 
					        format="bv[ext=mp4]+ba[ext=m4a]"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # We're assuming we'll always have an mp4 video only and audio track to merge.
 | 
					 | 
				
			||||||
    opts+=" --merge-output-format mp4 --write-subs --sub-lang en --embed-subs"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if [[ $make_folder == "1" ]]; then
 | 
					    if [[ $make_folder == "1" ]]; then
 | 
				
			||||||
        make_vid_dir_and_cd_into $url ""
 | 
					        make_vid_dir_and_cd_into $url ""
 | 
				
			||||||
        if [[ $? -ne 0 ]]; then
 | 
					        if [[ $? -ne 0 ]]; then
 | 
				
			||||||
| 
						 | 
					@ -474,6 +474,9 @@ download_youtube_vid() {
 | 
				
			||||||
    printf "filename: $filename\n"
 | 
					    printf "filename: $filename\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Download the video.
 | 
					    # Download the video.
 | 
				
			||||||
 | 
					    # We're assuming we'll always have an mp4 video only and audio track to merge.
 | 
				
			||||||
 | 
					    opts+=" --merge-output-format mp4 --write-subs --sub-lang en --embed-subs --embed-thumbnail --embed-metadata"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
 | 
					    local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
 | 
				
			||||||
    eval $cmd   # Need to eval in order to preserve the quotes wrapping the filename format string.
 | 
					    eval $cmd   # Need to eval in order to preserve the quotes wrapping the filename format string.
 | 
				
			||||||
    error=$?
 | 
					    error=$?
 | 
				
			||||||
| 
						 | 
					@ -508,20 +511,22 @@ download_youtube_playlist() {
 | 
				
			||||||
    local url="$2"
 | 
					    local url="$2"
 | 
				
			||||||
    local dir_name="$3"
 | 
					    local dir_name="$3"
 | 
				
			||||||
    shift 3
 | 
					    shift 3
 | 
				
			||||||
    local opts="$@ --write-sub --sub-lang en --embed-subs"
 | 
					    local opts="$@"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ $url == "" || $dir_name == "" ]]; then
 | 
					    if [[ $url == "" || $dir_name == "" ]]; then
 | 
				
			||||||
        error "Usage: <url> <directory name> <optional args>"
 | 
					        error "Usage: <url> <directory name> <optional args>"
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    printf "${BOLD}${RED}USING TEMP FIX FOR YOUTUBE FORMAT ISSUES BY SETTING THE CLIENT TO tv_simply. SEE https://github.com/yt-dlp/yt-dlp/issues/13930\n\n${NORMAL}"
 | 
				
			||||||
 | 
					    opts+=" --extractor-args youtube:player-client=default,tv_simply"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    printf "${BOLD}Downloading Youtube playlist\n\n${NORMAL}"
 | 
					    printf "${BOLD}Downloading Youtube playlist\n\n${NORMAL}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ $format == "" ]]; then
 | 
					    if [[ $format == "" ]]; then
 | 
				
			||||||
        printf "${BOLD}No format given; using best available.${NORMAL}\n"
 | 
					        printf "${BOLD}No format given; using best available.${NORMAL}\n"
 | 
				
			||||||
        # Download best mp4 video and best m4a audio, then merge.
 | 
					        # Download best mp4 video, best audio then merge.
 | 
				
			||||||
        format="bv*[ext=mp4]+ba[ext=m4a]"
 | 
					        format="bv[ext=mp4]+ba[ext=m4a]"
 | 
				
			||||||
        opts+=" --merge-output-format mp4"
 | 
					 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    make_vid_dir_and_cd_into $url "$dir_name"
 | 
					    make_vid_dir_and_cd_into $url "$dir_name"
 | 
				
			||||||
| 
						 | 
					@ -529,6 +534,9 @@ download_youtube_playlist() {
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # We're assuming we'll always have an mp4 video only and audio track to merge.
 | 
				
			||||||
 | 
					    opts+=" --merge-output-format mp4 --write-subs --sub-lang en --embed-subs --embed-thumbnail --embed-metadata"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    local cmd="yt-dlp.exe -f $format -o \"%(playlist_index)03d--%(upload_date>%Y-%m-%d)s-%(title)s-yt-%(id)s.%(ext)s\" $opts $url"
 | 
					    local cmd="yt-dlp.exe -f $format -o \"%(playlist_index)03d--%(upload_date>%Y-%m-%d)s-%(title)s-yt-%(id)s.%(ext)s\" $opts $url"
 | 
				
			||||||
    eval $cmd   # Need to eval in order to preserve the quotes wrapping the filename format string.
 | 
					    eval $cmd   # Need to eval in order to preserve the quotes wrapping the filename format string.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -598,6 +606,9 @@ function download_youtube_audio() {
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    printf "${BOLD}${RED}USING TEMP FIX FOR YOUTUBE FORMAT ISSUES BY SETTING THE CLIENT TO tv_simply. SEE https://github.com/yt-dlp/yt-dlp/issues/13930\n\n${NORMAL}"
 | 
				
			||||||
 | 
					    opts+=" --extractor-args youtube:player-client=default,tv_simply"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    printf "${BOLD}Downloading Youtube audio\n\n${NORMAL}"
 | 
					    printf "${BOLD}Downloading Youtube audio\n\n${NORMAL}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ $make_folder == "1" ]]; then
 | 
					    if [[ $make_folder == "1" ]]; then
 | 
				
			||||||
| 
						 | 
					@ -680,7 +691,7 @@ download_twitch_chat() {
 | 
				
			||||||
#   `tw-1080p60 <url> --cookies /c/<cookie_path>/twitch_cookies.txt`
 | 
					#   `tw-1080p60 <url> --cookies /c/<cookie_path>/twitch_cookies.txt`
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# To extract a portion of a video, you have to first download the entire file and then use the
 | 
					# To extract a portion of a video, you have to first download the entire file and then use the
 | 
				
			||||||
# `trim-video` or `compress-video-and-trim` scripts.
 | 
					# `trim-video` or `compress-video' with a time range.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
download_twitch_vid() {
 | 
					download_twitch_vid() {
 | 
				
			||||||
    local format="$1"
 | 
					    local format="$1"
 | 
				
			||||||
| 
						 | 
					@ -758,6 +769,8 @@ download_twitch_vid() {
 | 
				
			||||||
        local cmd="streamlink.exe --twitch-low-latency --twitch-disable-ads --twitch-disable-hosting --force --progress=force $opts $url $streamlink_format -O | ffmpeg -i pipe:0 -c copy \"$filename\""
 | 
					        local cmd="streamlink.exe --twitch-low-latency --twitch-disable-ads --twitch-disable-hosting --force --progress=force $opts $url $streamlink_format -O | ffmpeg -i pipe:0 -c copy \"$filename\""
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        printf "${YELLOW}${BOLD}\nUsing yt-dlp to download...${NORMAL}\n"
 | 
					        printf "${YELLOW}${BOLD}\nUsing yt-dlp to download...${NORMAL}\n"
 | 
				
			||||||
 | 
					        opts+=" --embed-thumbnail --embed-metadata"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        local cmd="yt-dlp.exe -f $yt_dlp_format -o \"$filename\" $opts $url"
 | 
					        local cmd="yt-dlp.exe -f $yt_dlp_format -o \"$filename\" $opts $url"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -810,10 +823,13 @@ download_vimeo_vid() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ $format == "" ]]; then
 | 
					    if [[ $format == "" ]]; then
 | 
				
			||||||
        printf "${BOLD}No format given; using best available.${NORMAL}\n"
 | 
					        printf "${BOLD}No format given; using best available.${NORMAL}\n"
 | 
				
			||||||
        # Download best mp4 video.
 | 
					        # Download best mp4 video, best audio then merge.
 | 
				
			||||||
        format="bv*[ext=mp4]+ba[ext=m4a]"
 | 
					        format="bv[ext=mp4]+ba[ext=m4a]"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # We're assuming we'll always have an mp4 video only and audio track to merge.
 | 
				
			||||||
 | 
					    opts+=" --merge-output-format mp4 --write-subs --sub-lang en --embed-subs --embed-thumbnail --embed-metadata"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ $shortname == "1" || $compress == "1" || $transcribe == "1" ]]; then
 | 
					    if [[ $shortname == "1" || $compress == "1" || $transcribe == "1" ]]; then
 | 
				
			||||||
        printf "${BOLD}Downloading Vimeo vid "
 | 
					        printf "${BOLD}Downloading Vimeo vid "
 | 
				
			||||||
        if [[ $shortname == "1" ]];  then printf "| ${YELLOW}using short name${NORMAL}${BOLD} "; fi
 | 
					        if [[ $shortname == "1" ]];  then printf "| ${YELLOW}using short name${NORMAL}${BOLD} "; fi
 | 
				
			||||||
| 
						 | 
					@ -926,6 +942,7 @@ download_twitter_vid() {
 | 
				
			||||||
    printf "filename: $filename\n"
 | 
					    printf "filename: $filename\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Download the video.
 | 
					    # Download the video.
 | 
				
			||||||
 | 
					    opts+=" --embed-thumbnail --embed-metadata"
 | 
				
			||||||
    local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
 | 
					    local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
 | 
				
			||||||
    eval $cmd   # Need to eval in order to preserve the quotes wrapping the filename format string.
 | 
					    eval $cmd   # Need to eval in order to preserve the quotes wrapping the filename format string.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -990,6 +1007,7 @@ download_instagram_vid() {
 | 
				
			||||||
    printf "filename: $filename\n"
 | 
					    printf "filename: $filename\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Download the video.
 | 
					    # Download the video.
 | 
				
			||||||
 | 
					    opts+=" --embed-thumbnail --embed-metadata"
 | 
				
			||||||
    local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
 | 
					    local cmd="yt-dlp.exe -f $format -o \"$filename\" $opts $url"
 | 
				
			||||||
    eval $cmd   # Need to eval in order to preserve the quotes wrapping the filename format string.
 | 
					    eval $cmd   # Need to eval in order to preserve the quotes wrapping the filename format string.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1247,28 +1265,13 @@ alias download-audio-from-m3u8='echo Use download-audio-from-stream instead.'
 | 
				
			||||||
# Video Compression
 | 
					# Video Compression
 | 
				
			||||||
####################################################################################################
 | 
					####################################################################################################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function _compress_video_hard() {
 | 
					 | 
				
			||||||
    local crf=35
 | 
					 | 
				
			||||||
    local name="$1"
 | 
					 | 
				
			||||||
    local out="$2"
 | 
					 | 
				
			||||||
    if [[ name == "" || out == "" ]]; then
 | 
					 | 
				
			||||||
        error "Usage: cmd <source> <dest>"
 | 
					 | 
				
			||||||
        return
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
    # 0=cpu, 1=gpu
 | 
					 | 
				
			||||||
    compress-video-with-crf $crf "$name" "$out" 0
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
alias compress-video-hard='_compress_video_hard'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
alias cv='compress-video'
 | 
					alias cv='compress-video'
 | 
				
			||||||
alias cvh='compress-video-hard'
 | 
					 | 
				
			||||||
alias jv='join-video'
 | 
					alias jv='join-video'
 | 
				
			||||||
alias av='analyze-volume'
 | 
					alias av='analyze-volume'
 | 
				
			||||||
alias aa='analyze-volume'
 | 
					alias aa='analyze-volume'
 | 
				
			||||||
alias nv='normalize-volume'
 | 
					alias nv='normalize-volume'
 | 
				
			||||||
alias na='normalize-volume'
 | 
					alias na='normalize-volume'
 | 
				
			||||||
alias tv='trim-video-vbr'
 | 
					alias tv='echo can just do a cv with a time range...' #trim-video-vbr'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
####################################################################################################
 | 
					####################################################################################################
 | 
				
			||||||
# Git
 | 
					# Git
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user