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