yt-dlp in action #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: yt-dlp in action | |
on: | |
workflow_dispatch: | |
inputs: | |
video_url: | |
description: 'video url to be download, comma seperated' | |
required: true | |
default: 'foo,bar,too' | |
audio_only: | |
description: 'audio only' | |
required: false | |
default: 'false' | |
# push: | |
# branches: | |
# - dev_yt_dlp_action | |
jobs: | |
downloadYoutubeVideo: | |
name: download video from youtube | |
continue-on-error: false | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Setup yt-dlp | |
uses: AnimMouse/setup-yt-dlp@v1 | |
with: | |
with-ffmpeg: true | |
- name: show ffmpeg info | |
shell: bash | |
run: | | |
ffmpeg -version | |
- name: show availbale download options for this video | |
shell: bash | |
run: | | |
# yt-dlp -F ${{ github.event.inputs.video_url }} | |
bash scripts/download_youtube_videos.sh -u ${{ github.event.inputs.video_url }} -a 2 | |
- name: actual download | |
shell: bash | |
run: | | |
# yt-dlp --downloader aria2c -S "+codec:av01" https://www.youtube.com/watch?v=rkM-dTr89kQ | |
echo "began downloading ${{ github.event.inputs.video_url }} " | |
# yt-dlp -f 22 ${{ github.event.inputs.video_url }} // based on -F outputs | |
# yt-dlp --downloader aria2c -S "+codec:av01" ${{ github.event.inputs.video_url }} | |
# yt-dlp --downloader aria2c -S "+codec:av01" https://www.youtube.com/watch?v=FCPdIvXo2rU | |
if [[ ${{ inputs.audio_only }} == 'true' ]]; then | |
echo "audio only" | |
bash scripts/download_youtube_videos.sh -u ${{ github.event.inputs.video_url }} -a 1 | |
# yt-dlp -f "ba" ${{ github.event.inputs.video_url }} -o "%(title)s.f%(format_id)s.%(ext)s" | |
else | |
echo "video and audio with best format" | |
bash scripts/download_youtube_videos.sh -u ${{ github.event.inputs.video_url }} -a 0 | |
# yt-dlp ${{ github.event.inputs.video_url }} -o "%(title)s.f%(format_id)s.%(ext)s" | |
fi | |
# - name: convert all video file to av1 format | |
# shell: bash | |
# run: | | |
# bash scripts/convert_video_to_av1.sh | |
- name: move video assets to folder and archive | |
shell: bash | |
run: | | |
ls -alSh | |
mkdir -p dist | |
find . -type f \( -name "*.mp4" -o -name "*.mkv" -o -name "*.webm" -o -name "*.m4a" \) -exec mv {} dist/ \; | |
- name: show layouts | |
shell: bash | |
run: | | |
tree -L 2 | |
ls -al | |
- name: figure out video name | |
shell: bash | |
id: video-name | |
run: | | |
cd dist | |
find . -type f \( -name "*.mp4" -o -name "*.mkv" -o -name "*.webm" -o -name "*.m4a" \) -exec basename {} \; | |
# echo "vname=${find . -type f \( -name "*.mp4" -o -name "*.mkv" -o -name "*.webm" -o -name "*.m4a" \) -exec basename {} \;}" >> $GITHUB_OUTPUT | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: video-assets-${{ github.run_id }} | |
path: dist | |
if-no-files-found: error | |
retention-days: 1 | |