-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcoub-dl
More file actions
executable file
·21 lines (14 loc) · 806 Bytes
/
coub-dl
File metadata and controls
executable file
·21 lines (14 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash
set -e
echo "Fetching video id..."
VIDEO_ID="$(yt-dlp --cookies-from-browser chrome --get-id "$1")"
# Download video
yt-dlp --cookies-from-browser chrome --ignore-errors --prefer-ffmpeg --recode-video mp4 --embed-thumbnail --add-metadata -f 'html5-video-high' -o "$VIDEO_ID.mp4" "$1"
# Get video duration
AUDIO_DURATION="$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 -sexagesimal "$VIDEO_ID.mp4")"
# Download audio and trim to duration
yt-dlp --cookies-from-browser chrome --ignore-errors --prefer-ffmpeg -f 'html5-audio-high' -o "$VIDEO_ID.mp3" "$1"
# Merge video and audio
ffmpeg -i "$VIDEO_ID.mp4" -i "$VIDEO_ID.mp3" -c:v copy -c:a copy -to "$AUDIO_DURATION" "$VIDEO_ID.c.mp4"
# Remove old files
rm -f "$VIDEO_ID.mp4" "$VIDEO_ID.mp3"