';
}
echo '';
}
}
}
?>
```
タイトルを動画パッケージの題名から取得するように変更したので、
以下のAppleScriptは不要になりました。
AppleScript
Podcast音声配信用カスタムhtml作成.scpt
```
-- =========================================================
-- Podcast & 動画パッケージ用 カスタムHTML自動生成スクリプト
-- =========================================================
on run
-- 1 タイトルの入力(デフォルト値を「XXXXXX図書館Podcast」に設定)
set inputTitle to text returned of (display dialog "1 タイトル(題名)を入れてください:" default answer "XXXXXX図書館Podcast" buttons {"キャンセル", "OK"} default button "OK")
-- 2 動画パッケージURLの入力(基本URL形式)
set inputPackageURL to text returned of (display dialog "2 この音声を再生する動画パッケージURLを入れてください:\n(例: https://XXXXXX.com/mu1?drid=m51)" default answer "https://XXXXXX.com/mu1?drid=m51" buttons {"キャンセル", "OK"} default button "OK")
-- 3 画像URLの入力(変更不要・空欄の場合はデフォルト画像を設定)
set inputImageURL to text returned of (display dialog "3 サイドバーのリンク画像を変更したい場合はURLを入れてください:\n(変更不要・空欄の場合はそのまま「OK」を押してください)" default answer "" buttons {"キャンセル", "OK"} default button "OK")
-- 画像URLのトリム&空欄判定(未入力・スペースのみの場合はデフォルト画像を設定)
set trimmedImageURL to do shell script "python3 -c 'import sys; print(sys.argv[1].strip())' " & quoted form of inputImageURL
if trimmedImageURL is "" then
set finalImageURL to "https://XXXXXX.com/rd.php?id=bIPRIe5d.png"
else
set finalImageURL to trimmedImageURL
end if
-- ▼ 内部で /mu1? を /mu1emd_autoplay/? へ自動置換し、&frag=1 を補完する処理 ▼
set convertedURL to inputPackageURL
if convertedURL contains "/mu1?" then
set convertedURL to my replaceText(convertedURL, "/mu1?", "/mu1emd_autoplay/?")
else if convertedURL contains "/mu1/?" then
set convertedURL to my replaceText(convertedURL, "/mu1/?", "/mu1emd_autoplay/?")
end if
-- frag=1 パラメータの自動付与
if convertedURL contains "frag=1" is false then
if convertedURL contains "?" then
set convertedURL to convertedURL & "&frag=1"
else
set convertedURL to convertedURL & "?frag=1"
end if
end if
-- タイトル文字列をURLエンコード(Python3を使用)
set encodedTitle to do shell script "python3 -c 'import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))' " & quoted form of inputTitle
-- 動画パッケージURLへ &title= を自動付与
set finalPackageURL to convertedURL
if finalPackageURL contains "title=" is false then
if finalPackageURL contains "?" then
set finalPackageURL to finalPackageURL & "&title=" & encodedTitle
else
set finalPackageURL to finalPackageURL & "?title=" & encodedTitle
end if
end if
-- カスタムHTMLの組み上げ(画像・左詰めテキスト・スマホフリーズ防止JS)
set customHTML to "
"
-- クリップボードへ一括保存
set the clipboard to customHTML
-- 完了ダイアログの表示
display dialog "カスタムHTMLの生成が完了し、クリップボードにコピーしました!\nWordPressの「カスタムHTML」にそのまま貼り付けてご使用ください。" buttons {"OK"} default button "OK" with icon note
end run
-- テキスト置換用サブルーチン
on replaceText(originalText, searchString, replacementString)
set AppleScript's text item delimiters to searchString
set textItems to text items of originalText
set AppleScript's text item delimiters to replacementString
set replacedText to textItems as text
set AppleScript's text item delimiters to ""
return replacedText
end replaceText
```