Created
May 16, 2025 07:47
-
-
Save yaasita/0f34013ffd7a13f4eea09b35efd9a322 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
# 引数チェック | |
if [ -z "$1" ]; then | |
echo "Usage: $0 playlist.m3u" | |
exit 1 | |
fi | |
# プレイリストのパス | |
PLAYLIST="$1" | |
# 一時ディレクトリ作成 | |
TMP_DIR=$(mktemp -d) | |
trap "rm -rf $TMP_DIR" EXIT | |
# カウンター初期化 | |
COUNTER=0 | |
# プレイリストからhttpsリンクを抽出し、ダウンロード処理 | |
grep '^https://' "$PLAYLIST" | while read -r URL; do | |
FILE_NAME=$(printf "%04d.ts" $COUNTER) | |
OUTPUT_PATH="$TMP_DIR/$FILE_NAME" | |
echo "Downloading $URL -> $OUTPUT_PATH" | |
curl -s "$URL" | tail -c +9 > "$OUTPUT_PATH" | |
COUNTER=$((COUNTER + 1)) | |
done | |
# ダウンロードしたファイルの結合 | |
cat "$TMP_DIR"/*.ts > "merged_output.ts" | |
echo "Merged output saved as merged_output.ts" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment