ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
130.9k stars 9.89k forks source link

--exec doesn't run when --skip-download is specified #26859

Closed Fetchinator7 closed 3 years ago

Fetchinator7 commented 3 years ago

Checklist

Verbose log

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-o', u'%(title)s.%(ext)s', u'https://youtu.be/QH2-TGUlwu4', u'--write-thumbnail', u'--skip-download', u'--exec', u'ffmpeg -i {} {}.jpg', u'-v']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2020.09.20
[debug] Python version 2.7.15 (CPython) - Darwin-19.6.0-x86_64-i386-64bit
[debug] exe versions: ffmpeg 4.3.1, ffprobe 4.3.1, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] QH2-TGUlwu4: Downloading webpage
[debug] Default format spec: bestvideo+bestaudio/best
[youtube] QH2-TGUlwu4: Downloading thumbnail ...
[youtube] QH2-TGUlwu4: Writing thumbnail to: Nyan Cat [original].jpg

Description

When --skip-download is an argument --exec doesn't run which creates issues when --exec is used in conjunction with other options like --write-thumbnail.

I want to download just the thumbnail for videos and change the thumbnail extension to .jpg since sometimes the thumbnails come through as .webp . The simplest solution would be getting the path and converting it right after it downloads, but currently that's not possible since --exec doesn't run.

Fetchinator7 commented 3 years ago

I wrote a bash script to work around this problem which I'll provide incase anyone else wants it. (bash comes with git incase you don't already have bash on Windows 10). You run it from the command line like this: path/to/script/file.sh "https://youtu.be/QH2-TGUlwu4"

#!/bin/bash
# Get the command line input.
LINK_STR="$1"
TITLE_TEMPLATE="%(title)s.%(ext)s"
# Path to the folder you want to download to.
# This could be substituted with "$2" then you'd include the output folder as the second argument when executing this file.
OUTPUT_PATH="/example/path"
cd $OUTPUT_PATH

# Download the thumbnail.
youtube-dl -o $TITLE_TEMPLATE --write-thumbnail --skip-download $LINK_STR
# Get the title of the video that was downloaded to search for in the output folder.
OUTPUT_TITLE="$(youtube-dl -o $TITLE_TEMPLATE --get-title $LINK_STR)"

# Get the full path to the thumbnail file.
DOWNLOADED_THUMBNAIL_PATH="$(find $OUTPUT_PATH -type f -name "$OUTPUT_TITLE.*")"

# Change thumbnail extension to .jpg with ffmpeg.
ffmpeg -i "$DOWNLOADED_THUMBNAIL_PATH" "${DOWNLOADED_THUMBNAIL_PATH%.*}.jpg" -hide_banner
rm "$DOWNLOADED_THUMBNAIL_PATH"
dstftw commented 3 years ago

This is expected behavior.