[Python] eyeD3の文字化け対策(ワンライナー時)
オプションで
--to-v2.4 --encoding='utf8'
を
入れればOK
セットアップコマンド用
#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions
set strSetUpCommand to "/usr/bin/python3 -m pip install --user eyeD3"
do shell script strSetUpCommand
set strSetUpCommand to "/usr/bin/python3 -m pip install --upgrade --user eyeD3"
do shell script strSetUpCommand
return "Done"
本体
サンプルは『ファイル名』を『曲名』に設定する例
#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AVFoundation"
use scripting additions
property refMe : a reference to current application
###eyeD3へのパス
set strBinPath to (do shell script "echo $HOME/Library/Python/3.9/bin/eyeD3") as text
###入力
tell application "Finder"
set aliasDefaultLocation to (path to desktop folder from user domain) as alias
end tell
####UTIリスト PDFのみ
set listUTI to {"public.audio"}
##############################
#####ダイアログを前面に出す
##############################
tell current application
set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
tell application "Finder"
activate
end tell
else
tell current application
activate
end tell
end if
####ダイアログを出す
set listFilePath to (choose file with prompt "ミュージックファイルを選んでください" default location (aliasDefaultLocation) of type listUTI with multiple selections allowed without invisibles and showing package contents) as list
repeat with itemFilePath in listFilePath
set strFilePath to (POSIX path of itemFilePath) as text
set ocidFilePathStr to (refMe's NSString's stringWithString:strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false)
set ocidBaseFilePathURL to ocidFilePathURL's URLByDeletingPathExtension()
set strFileName to (ocidBaseFilePathURL's lastPathComponent()) as text
####欧文のみなら
##set strCommandText to "\"" & strBinPath & "\" -t \"" & strFileName & "\" -n 2 \"" & strFilePath & "\"" as text
#####UTF8対応
set strCommandText to "\"" & strBinPath & "\" --to-v2.4 --encoding='utf8' -t \"" & strFileName & "\" -n 2 \"" & strFilePath & "\"" as text
do shell script strCommandText
end repeat
| 固定リンク
「Python eyed3」カテゴリの記事
- [eyeD3]主要メタデータ以外を削除する(クリーニング)(2025.04.19)
- [eyeD3]MP3にジャケットイメージを付与する ちょっと修正(2023.05.22)
- [Python] eyeD3の文字化け対策(ワンライナー時)(2023.05.10)
- [eyeD3]MP3のタイトルをファイル名に設定する(2023.01.28)
- [eyeD3]MP3にジャケットイメージを付与する(2023.01.20)