20260403

オーディオ・メディアのジャンル分け番号と表示名の取得


オーディオ・メディアのジャンル分け番号と表示名の取得

ダウンロードはこちらから
NOTE記事一覧ですnote.com

【スクリプトエディタで開く】 |

GET Spotlight Schemaジャンル.scpt
ソース
001#!/usr/bin/env osascript
002#coding: utf-8
003----+----1----+----2----+-----3----+----4----+----5----+----6----+----7--
004(*
005GET Spotlight Schema.applescript
006SpotlightのスキーマをMDテーブルに出力します
007出力結果見本はこちら
008https://gist.github.com/force4u/5674c7c3b441fc70434ba98fabed1b35
009
010ダウンロードはこちら
011https://note.com/quicktimer/n/n5cd4fb9d872d
012
013com.cocolog-nifty.quicktimer.icefloe *)
014----+----1----+----2----+-----3----+----4----+----5----+----6----+----7--
015use AppleScript version "2.8"
016use framework "Foundation"
017use framework "AppKit"
018use scripting additions
019property refMe : a reference to current application
020#GET LANG CODE
021set appLocale to refMe's NSLocale's currentLocale()
022set strLangID to (appLocale's objectForKey:(refMe's NSLocaleLanguageCode)) as text
023#schema plist
024set strFilePath to ("/System/Library/Spotlight/CoreMedia.mdimporter/Contents/Resources/FigSpotlightPlugIn.loctable") as text
025set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
026set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
027set ocidFilePathURL to refMe's NSURL's fileURLWithPath:(ocidFilePath) isDirectory:(false)
028
029set listResponse to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidFilePathURL) |error|:(reference)
030set ocidPlistDict to (first item of listResponse)
031#AllKeys=LangIDs
032set ocidAllKeys to ocidPlistDict's allKeys()
033set boolContain to ocidAllKeys's containsObject:(strLangID)
034if boolContain is false then
035   set strLangID to ("en") as text
036end if
037#SchemaDICT
038set ocidSchemaDict to ocidPlistDict's objectForKey:(strLangID)
039set ocidAllKeys to ocidSchemaDict's allKeys()
040set ocidSortedAllKeys to ocidAllKeys's sortedArrayUsingSelector:("localizedStandardCompare:")
041set ocidSchemaEnDict to ocidPlistDict's objectForKey:("en")
042#FOR OUTPUTSTRING
043set ocidMDString to refMe's NSMutableString's alloc()'s init()
044ocidMDString's appendString:("| NO | KEY | VALUE ja | VALUE en |")
045ocidMDString's appendString:(linefeed)
046ocidMDString's appendString:("|:-----|:-----|:-----|:-----|")
047ocidMDString's appendString:(linefeed)
048#Line COUNTER
049set numCntLine to 1 as integer
050#REPEAT
051repeat with itemKey in ocidSortedAllKeys
052   set ocidValue to (ocidSchemaDict's objectForKey:(itemKey))
053   set ocidValueEn to (ocidSchemaEnDict's objectForKey:(itemKey))
054   (ocidMDString's appendString:("| " & (numCntLine as text) & " | " & itemKey & " | " & ocidValue & " | " & ocidValueEn & " |"))
055   (ocidMDString's appendString:(linefeed))
056   set numCntLine to (numCntLine + 1) as integer
057end repeat
058return (return & ocidMDString & return) as text
059
AppleScriptで生成しました