« 2013年1月 | トップページ | 2013年3月 »

[YouTube]PDFにYouTubeを埋め込む方法(スクリプト修正)


[Adobe Acrobat]PDF上でYouTubeを再生する - YouTube


元の記事はこちらです

スクリプト部だけ訂正
youtu.beドメインのショートURLに対応した

(*
YouTubeのビデオをPDFに埋め込む時に利用するスクリプト
YouTubeWidgetForAcrobat.swfを利用する場合のエンベッドコードに整形します
youtu.beドメインのショートURLに対応
*)


--------------------------ダイアログを出して
display dialog "ShareからコピーしたURLを入力" default answer "" with icon 1 default button 2
--------------------------ダイアログの戻り値を格納
set theGetUrl to text returned of the result as Unicode text
--------------------------ダイアログで取得したURLに含まれる文字を確認
set theYoutubeResult to theGetUrl contains "youtube.com"
set theYoutuResult to theGetUrl contains "youtu.be"
--------------------------ドメイン別でビデオIDの取得方法がちょっと違う
if theYoutuResult is true then
--------------------------youtu.beの場合
set theVidCom to "echo " & quoted form of theGetUrl & "| awk -F \"youtu.be/\" '{print($2)}' |awk -F \"&\" '{print($1)}' " as text
set theVid to do shell script theVidCom as text
log theVid
else if theYoutubeResult is true then
--------------------------youtube.comの場合
set theVidCom to "echo " & quoted form of theGetUrl & "| awk -F \"v=\" '{print($2)}' |awk -F \"&\" '{print($1)}' " as text
set theVid to do shell script theVidCom as text
log theVid
end if
--------------------------エンベッドコードの縦横サイズ 任意
set h_width to "640" as number
set v_hight to "390" as integer
--------------------------ここからエンベッドコード
set HTMLtag to "" as Unicode text
set HTMLtag to HTMLtag & "" as Unicode text
set HTMLtag to HTMLtag & "<object width=\"" & h_width & "\" height=\"" & v_hight & "\">" as Unicode text
set HTMLtag to HTMLtag & "<param name=\"movie\" value=\"http://www.youtube.com/v/" & theVid as Unicode text
set HTMLtag to HTMLtag & "&hl=en_US&feature=player_embedded&version=2\"></param>" as Unicode text
set HTMLtag to HTMLtag & "<param name=\"allowFullScreen\" value=\"true\"></param>" as Unicode text
set HTMLtag to HTMLtag & "<param name=\"allowScriptAccess\" value=\"always\"></param>" as Unicode text
set HTMLtag to HTMLtag & "<embed src=\"http://www.youtube.com/v/" & theVid as Unicode text
set HTMLtag to HTMLtag & "&hl=en_US&feature=player_embedded&version=2\" " as Unicode text
set HTMLtag to HTMLtag & "type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" " as Unicode text
set HTMLtag to HTMLtag & "allowScriptAccess=\"always\" width=\"" & h_width as Unicode text
set HTMLtag to HTMLtag & "\" height=\"" & v_hight & "\"></embed>" as Unicode text
set HTMLtag to HTMLtag & "</object>" as Unicode text

--------------------------最後に出来上がったコードをダイアログで表示
display dialog "タグが出来ましたコピーしてください" default answer HTMLtag with icon 1 default button 1

log HTMLtag


「PDF_on_youtube_V2.zip」をダウンロード


|

[Adobe]『SourceCodePro』『Source Sans Pro』

Home Project for Open @ Adobe / Home / Projects


わりと読みやすい

Website_image20130226_05704


|

[Excel]Google Refine(エクセルファイルの中身をチョロっと確認)

エクセルの中身を確認出来る
ちょっと面白いと思っただけですが


Website_image20130223_171759

エクセルのxlsxファイルもOK

Website_image20130223_173420


XMPなんかの
XMLも中身を見るなら 簡単です。

Website_image20130223_173606


JSON filesのテキストの整形が良い感じです。

Website_image20130223_173828


|

Accessible EPUB 3


accessible_epub_3-20120425.epub - epub-samples - O'Reilly Accessible EPUB 3 - EPUB 3 Sample Documents - Google Project Hosting


|

[AppleScript]YouTubeのBloggerボタンの代わり【Google Chrome専用-その2】

(*
YouTubeBloggerボタンのサムネイルイメージのリング版
YoutubeBloggerボタンがFlashのエンベットなので作りましたのよ
*)
--------------------------全面のURLを取得
tell application "Google Chrome"
activate
--------------URLの取得
set theURL to URL of active tab of window 1 as text
--------------タイトルの取得
set theTitle to title of active tab of window 1 as text
end tell
--------------アンカー等に使われる不要な文字をURLから削除
set theURL to my replace(theURL, "#!", "") as text
set theURL to my replace(theURL, "#", "") as text
set theURL to my replace(theURL, "!", "") as text
--------------VideoIDを取得
set theVidCom to "echo " & quoted form of theURL & "| awk -F \"v=\" '{print($2)}' |awk -F \"&\" '{print($1)}' " as text
set theVid to do shell script theVidCom as text
--------------設定項目:bloggerのポスト用のURL
set theBloggerUrl to "http://www.blogger.com/blog-this.g?"


-------ディレクトリ名用に日付と時間を取得
set nowTime to do shell script "date '+%Y%m%d%H%M%S'" as text
-------テンポラリ用のディレクトリを作ります
do shell script "mkdir -pv /tmp/Sandbox/" & nowTime
------------サムネイル用の画像サイズの判定用
try
do shell script "curl -f -o '/tmp/Sandbox/curl.jpg' 'http://i4.ytimg.com/vi/" & theVid & "/maxresdefault.jpg' > /tmp/Sandbox/curl.txt"
--1576x885--
-------エラーが無い=maxresdefault.jpgがある=エラーにならない場合はそのまま大きい画像をサムネイルに指定
set theImgUrl to "http://i4.ytimg.com/vi/" & theVid & "/maxresdefault.jpg"
-------エラーが発生した場合
on error theErrorMes number theErrorNumber
log theErrorMes
-------エラー番号404がエラーメッセージに含まれるか?を判定します
set theCurlResult to theErrorMes contains "eturned error: 404"
-------true404なので大きいサイズの画像maxresdefault.jpgが無かった事になりますので
log theCurlResult
if theCurlResult is true then
--360x480--
-------一回り小さいサイズの画像をサムネイルとして指定します。
set theImgUrl to "http://i4.ytimg.com/vi/" & theVid & "/hqdefault.jpg"
else
--180x320--
set theImgUrl to "http://i4.ytimg.com/vi/" & theVid & "/mqdefault.jpg"
--90x120--
--set theImgUrl to "http://i4.ytimg.com/vi/" & theVid & "/default.jpg"
end if
end try


--------------短縮URL
set theShortUrl to "http://youtu.be/" & theVid
--------------タグを用意 ここはお好みで エスケープの\\\\

set theHtmlLine1 to "<div style=\\\"display: block; margin: auto;\\\">"
set theHtmlLine2 to "<a rel=\\\"nofollow\\\" href=\\\"" & theShortUrl & "\\\" class=\\\"youtubelink\\\" title=\\\"" & theTitle & "\\\">"
set theHtmlLine3 to "<img src=\\\"" & theImgUrl & "\\\" border=\\\"0\\\" class=\\\"youtubelinkimg\\\" alt=\\\"" & theTitle & "\\\" /></a>"
set theHtmlLine4 to "</div>"

--------------HTMLタグを整形
set theHtmlLine to (theHtmlLine1 & theHtmlLine2 & theHtmlLine3 & theHtmlLine4) as text

--------------HTMLurlエンコード
set theUrlDecodeHtml to do shell script "php -r 'echo urlencode(\"" & theHtmlLine & "\");'"
--------------イメージのURLをエンコード
set theUrlDecodeImgUrl to do shell script "php -r 'echo urlencode(\"" & theImgUrl & "\");'"
--------------タイトルをエンコード
set theUrlDecodeTitle to do shell script "php -r 'echo urlencode(\"" & theTitle & "\");'"
--------------ダイアログ用に\\\になっているエスケープを\に戻す
set theHtmlLine to my replace(theHtmlLine, "\\", "") as text
--------------開く用のURLを整形
set theBloggerUrl to theBloggerUrl & "n=" & theUrlDecodeTitle & "&b=" & theUrlDecodeHtml & "&eurl=" & theUrlDecodeImgUrl
--------------クロームで開く
tell application "Google Chrome"
activate
make new window
tell window 1
tell active tab
open location theBloggerUrl
end tell
end tell
end tell
--------------その後でダイアログにHTML部分だけ表示する
tell application "Finder"
activate
display dialog "HTMLが出来ました" default answer the theHtmlLine with icon 1 with title "HTMLが出来ました" default button 1
end tell
--------------文字の置き換えサブルーチン
to replace(theText, orgStr, newStr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newStr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end replace

「YouTubeBloggerUrlGoogleChromev2.scpt.zip」をダウンロード

  
「YouTubeBloggerUrlGoogleChromev2.rtf」をダウンロード

少し直した
 
20130211_220732

サムネイルのサイズ判定を入れて
出来るだけ大きいサイズを使うようにした
エラー制御を使ったトリックになりますね。
 
 
20130211_221443

 
本当はGoogleApi+Jsonが今風なのでしょうが
APIキーが必要になるので
気が進まなかったのでCURLで画像をダウンロードする事で
大きいサイズの有無を確認する方法にした。

  


|

[AppleScript]YouTubeのBloggerボタンの代わり【Google Chrome専用】

20130211_043335


↑このボタンの代わりです
ここのBloggerボタンで記事を書こうとすると
FlashPlayerのiflameタイプのHTMLになるので
これをサムネイル画像と通常リンクに変えます

ポイントはここ

20130211_062018


URLエンコードに渡す値(HTMLのタグ)ですが
\バックスラッシュのエスケープを\\\と3つにする所かな?たぶん


(*
YouTubeBloggerボタンのサムネイルイメージのリング版
YoutubeBloggerボタンがFlashのエンベットなので作りましたのよ
*)
--------------------------全面のURLを取得
tell application "Google Chrome"
activate
--------------URLの取得
set theURL to URL of active tab of window 1 as text
--------------タイトルの取得
set theTitle to title of active tab of window 1 as text
end tell

--------------VideoIDを取得
set theVidCom to "echo " & quoted form of theURL & "| awk -F \"v=\" '{print($2)}' |awk -F \"&\" '{print($1)}' " as text
set theVid to do shell script theVidCom as text
--------------設定項目:bloggerのポスト用のURL
set theBloggerUrl to "http://www.blogger.com/blog-this.g?"
--------------画像ファイルのURL お好みで
--90x120--set theImgUrl to "http://i4.ytimg.com/vi/" & theVid & "/default.jpg"
--180x320--set theImgUrl to "http://i4.ytimg.com/vi/" & theVid & "/mqdefault.jpg"
--360x480
set theImgUrl to "http://i4.ytimg.com/vi/" & theVid & "/hqdefault.jpg"
--maxresdefault.jpgは取得出来ないビデオ(ちょっと古いアップロードな物)があります
----set theImgUrl to "http://i4.ytimg.com/vi/" & theVid & "/maxresdefault.jpg"
--------------短縮URL
set theShortUrl to "http://youtu.be/" & theVid
--------------タグを用意 ここはお好みで エスケープの\\\\
set theHtmlLine1 to "<div style=\\\"display: block; margin: auto;\\\">"
set theHtmlLine2 to "<a rel=\\\"nofollow\\\" href=\\\"" & theShortUrl & "\\\" class=\\\"youtubelink\\\" title=\\\"" & theTitle & "\\\">"
set theHtmlLine3 to "<img src=\\\"" & theImgUrl & "\\\" border=\\\"0\\\" class=\\\"youtubelinkimg\\\" alt=\\\"" & theTitle & "\\\" /></a>"
set theHtmlLine4 to "</div>"
--------------HTMLタグを整形
set theHtmlLine to (theHtmlLine1 & theHtmlLine2 & theHtmlLine3 & theHtmlLine4) as text
--------------HTMLurlエンコード
set theUrlDecodeHtml to do shell script "php -r 'echo urlencode(\"" & theHtmlLine & "\");'"
--------------イメージのURLをエンコード
set theUrlDecodeImgUrl to do shell script "php -r 'echo urlencode(\"" & theImgUrl & "\");'"
--------------タイトルをエンコード
set theUrlDecodeTitle to do shell script "php -r 'echo urlencode(\"" & theTitle & "\");'"
--------------ダイアログ用に\\\になっているエスケープを\にする
set theHtmlLine to my replace(theHtmlLine, "\\", "") as text
--------------開く用のURLを整形
set theBloggerUrl to theBloggerUrl & "n=" & theUrlDecodeTitle & "&b=" & theUrlDecodeHtml & "&eurl=" & theUrlDecodeImgUrl
--------------クロームで開く
tell application "Google Chrome"
activate
make new window
tell window 1
tell active tab
open location theBloggerUrl
end tell
end tell
end tell
--------------その後でダイアログにHTML部分だけ表示する
tell application "Finder"
activate
display dialog "HTMLが出来ました" default answer the theHtmlLine with icon 1 with title "HTMLが出来ました" default button 1
end tell
--------------文字の置き換えサブルーチン
to replace(theText, orgStr, newStr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newStr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end replace


 

 
「YouTubeBloggerUrlGoogleChromev1.rtf」をダウンロード


 
 「YouTubeBloggerUrlGoogleChromev1.scpt.zip」をダウンロード

  

 

|

[AppleScript]ユニコードエスケープをデコードする【その2:pythonを使う】


Json等でよく使われるUnicode16進エスケープ形式の文字列を
テキストにデコードします。

その1はphpを使いました

その2ではpythonを使います

ながれはこんな感じ
\の処理が面倒でAppleScriptから使うのはちょっと無理があったかな
phpの方が良いですね

Website_image20130210_193115


--------ターミナルをあらかじめ起動しておく
tell application "Terminal"
end tell
(*
サンプルテキスト
君が好き feat.SAKURA,K2C SUNSHINE BAND - ミトカツユキ
*)
set theResultText to "\\u685c\\u821e\\u3044\\u6563\\u308b\\u5b63\\u7bc0\\u306b\\u3000\\u4e8c\\u4eba\\u64ae\\u3063\\u305f\\u5199\\u771f\",\"\\n\\u4eca\\u3082\\u5b9d\\u7269\\u3060\\u3088\\u3000\\u5e78\\u305b\\u3060\\u3063\\u305f\\u304b\\u3089\",\"\\n\",\"\\n\\u4e8c\\u4eba\\u3082\\u3046\\u4e00\\u5ea6\\u3000\\u7d20\\u76f4\\u306b\\u3000\\u4eca\\u3000\\u5bc4\\u308a\\u6dfb\\u3048\\u305f\\u306a\\u3089\",\"\\n\\u306d\\u3048\\u3082\\u3046\\u4e8c\\u5ea6\\u3068\\u96e2\\u308c\\u306a\\u3044\\u3000\\u4eca\\u3082\\u3042\\u306a\\u305f\\u304c\\u597d\\u304d\",\"\\n\",\"\\n\\u6b62\\u307e\\u306a\\u3044\\u96e8\\u306b\\u554f\\u3044\\u304b\\u3051\\u3066\\u3082\",\"\\n\\u3053\\u306e\\u8ddd\\u96e2\\u3000\\u5909\\u308f\\u3089\\u306a\\u3044\\u304b\\u3089\",\"\\n\\u541b\\u304c\\u597d\\u304d\\u3060\\u3068\\u8a00\\u3063\\u3066\",\"\\n\\u3042\\u306a\\u305f\\u306e\\u53e3\\u304b\\u3089\\u8a00\\u3063\\u3066\",\"\\n\\u3082\\u3046\\u8ff7\\u3044\\u306f\\u3057\\u306a\\u3044\\u304b\\u3089\",\"\\n\",\"\\n\\u4e8c\\u4eba\\u3082\\u3046\\u4e00\\u5ea6\\u3000\\u7d20\\u76f4\\u306b\\u3000\\u4eca\\u3000\\u8a31\\u3057\\u3042\\u3048\\u305f\\u306a\\u3089\",\"\\n\\u306f\\u3050\\u3089\\u304b\\u3055\\u305a\\u306b\\u3000\\u3046\\u3051\\u3068\\u3081\\u3066\\u3000\\u4eca\\u3082\\u3042\\u306a\\u305f\\u304c\\u597d\\u304d\",\"\\n\",\"\\n\\u4eca\\u3082\\u541b\\u304c\\u597d\\u304d" as text

--------ダイアログを表示
display dialog "変換するテキストをペースト" default answer theResultText
--------返り値を格納
set theResultText to text returned of the result as text
----------不要な文字を削除 ここはお好みで
set theResultText to my replace(theResultText, ",", "") as text
set theResultText to my replace(theResultText, "\"", "") as text
set theResultText to my replace(theResultText, "(", "") as text
set theResultText to my replace(theResultText, ")", "") as text
set theResultText to my replace(theResultText, ";", "") as text
set theResultText to my replace(theResultText, "[", "") as text
set theResultText to my replace(theResultText, "]", "") as text
set theResultText to my replace(theResultText, "draw", "") as text
set theResultText to my replace(theResultText, "\\n", " ") as text
set theResultText to my replace(theResultText, "\\r", " ") as text

------ディレクトリ名用に日付と時間を取得
set nowTime to do shell script "date '+%Y%m%d%H%M%S'" as text
------pythonスクリプトを使ってユーザーテンポラリーのディレクトリを取得します
-------スクリプトとキャッシュクリア用のディレクトリを作ります
do shell script "mkdir -pv /tmp/python/" & nowTime
--------スクリプト用のファイルを作成
do shell script "touch /tmp/python/" & nowTime & "/unicode_escape.py"
------結果用のファイルを作成
do shell script "touch /tmp/python/" & nowTime & "/unicode_escape.txt"
---------1行目を書き込み
do shell script "echo 'import sys' > /tmp/python/" & nowTime & "/unicode_escape.py "
---------2行目を書き込み
do shell script "echo 'import tempfile' >> /tmp/python/" & nowTime & "/unicode_escape.py "
---------3行目を書き込み
do shell script "echo 'print \"" & theResultText & "\".decode(\"unicode_escape\")' >> /tmp/python/" & nowTime & "/unicode_escape.py"
---------ターミナルに渡す用にパスを整形
set theScriptFile to ("/tmp/python/" & nowTime & "/unicode_escape.py") as text
---------ターミナルで実行する
tell application "Terminal"
do script "python " & theScriptFile
end tell

---------文字の置き換えサブルーチン
to replace(theText, orgStr, newStr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newStr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end replace

 

 
「unicode_escape.py.rtf」をダウンロード


「unicode_escape.py.scpt.zip」をダウンロード


|

[AppleScript]ユニコードエスケープをデコードする【その1:phpを使う】

Json等でよく使われるUnicode16進エスケープ形式の文字列を
テキストにデコードします。

こんな流れになります

Website_image20130210_185841


一旦
CharacterEntityへ変換してから
CharacterEntityをテキストに戻します。


(*
サンプルテキスト
君が好き feat.SAKURA,K2C SUNSHINE BAND - ミトカツユキ
*)

set theResultText to "\\u685c\\u821e\\u3044\\u6563\\u308b\\u5b63\\u7bc0\\u306b\\u3000\\u4e8c\\u4eba\\u64ae\\u3063\\u305f\\u5199\\u771f\",\"\\n\\u4eca\\u3082\\u5b9d\\u7269\\u3060\\u3088\\u3000\\u5e78\\u305b\\u3060\\u3063\\u305f\\u304b\\u3089\",\"\\n\",\"\\n\\u4e8c\\u4eba\\u3082\\u3046\\u4e00\\u5ea6\\u3000\\u7d20\\u76f4\\u306b\\u3000\\u4eca\\u3000\\u5bc4\\u308a\\u6dfb\\u3048\\u305f\\u306a\\u3089\",\"\\n\\u306d\\u3048\\u3082\\u3046\\u4e8c\\u5ea6\\u3068\\u96e2\\u308c\\u306a\\u3044\\u3000\\u4eca\\u3082\\u3042\\u306a\\u305f\\u304c\\u597d\\u304d\",\"\\n\",\"\\n\\u6b62\\u307e\\u306a\\u3044\\u96e8\\u306b\\u554f\\u3044\\u304b\\u3051\\u3066\\u3082\",\"\\n\\u3053\\u306e\\u8ddd\\u96e2\\u3000\\u5909\\u308f\\u3089\\u306a\\u3044\\u304b\\u3089\",\"\\n\\u541b\\u304c\\u597d\\u304d\\u3060\\u3068\\u8a00\\u3063\\u3066\",\"\\n\\u3042\\u306a\\u305f\\u306e\\u53e3\\u304b\\u3089\\u8a00\\u3063\\u3066\",\"\\n\\u3082\\u3046\\u8ff7\\u3044\\u306f\\u3057\\u306a\\u3044\\u304b\\u3089\",\"\\n\",\"\\n\\u4e8c\\u4eba\\u3082\\u3046\\u4e00\\u5ea6\\u3000\\u7d20\\u76f4\\u306b\\u3000\\u4eca\\u3000\\u8a31\\u3057\\u3042\\u3048\\u305f\\u306a\\u3089\",\"\\n\\u306f\\u3050\\u3089\\u304b\\u3055\\u305a\\u306b\\u3000\\u3046\\u3051\\u3068\\u3081\\u3066\\u3000\\u4eca\\u3082\\u3042\\u306a\\u305f\\u304c\\u597d\\u304d\",\"\\n\",\"\\n\\u4eca\\u3082\\u541b\\u304c\\u597d\\u304d" as text

--------ダイアログを表示
display dialog "変換するテキストをペースト" default answer theResultText
--------返り値を格納
set theResultText to text returned of the result as text
----------不要な文字を削除 ここはお好みで
set theResultText to my replace(theResultText, ",", "") as text
set theResultText to my replace(theResultText, "\"", "") as text
set theResultText to my replace(theResultText, "(", "") as text
set theResultText to my replace(theResultText, ")", "") as text
set theResultText to my replace(theResultText, ";", "") as text
set theResultText to my replace(theResultText, "[", "") as text
set theResultText to my replace(theResultText, "]", "") as text
set theResultText to my replace(theResultText, "draw", "") as text
set theResultText to my replace(theResultText, "callback", "") as text
----------改行を半角スペースに変換 ここもお好みで
set theResultText to my replace(theResultText, "\\n", "\\u20") as text
set theResultText to my replace(theResultText, "\\ud", "\\u20") as text
----------まずマルチバイトの4桁コードをCharacterEntityに変換
set thePregReplace to "php -r 'echo preg_replace(\"/\\\\\\u([0-9abcdef]{4})/\", \"&#x$1;\", \"" & theResultText & "\");'"
set theResultText to do shell script thePregReplace
----------その後でシングルバイトの2桁コードをCharacterEntityに変換
set thePregReplace to "php -r 'echo preg_replace(\"/\\\\\\u([0-9abcdef]{2})/\", \"&#x$1;\", \"" & theResultText & "\");'"
set theResultText to do shell script thePregReplace
----------デコード本処理
set theMbConvertEncoding to "php -r 'echo mb_convert_encoding(\"" & theResultText & "\", \"UTF-8\", \" HTML-ENTITIES \");'"
set theResultText to do shell script theMbConvertEncoding

----------出来上がりを戻す
display dialog "変換出来ました" default answer theResultText


---------文字の置き換えサブルーチン
to replace(theText, orgStr, newStr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newStr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end replace

「UniEsc2Text.rtf」をダウンロード
「UniEsc2Text.scpt.zip」をダウンロード


|

[AppleScript]Flash Player をアンインストール

Flash Player をアンインストールは
Adobe純正のアンインストールで


Flash Player をアンインストールする方法


ほとんどの場合再インストールが可能になるのですが

先日
お客様の環境でダメだった時のメモ
リモート許可もらえなかったので
スクリプトの実行をお願いして再インストールOKとなった



------------設定項目 sudo パスワード
set theSudoPassWord to "" as text


------------ディレクトリ名用に日付と時間を取得
set nowTime to do shell script "date '+%Y%m%d%H%M%S'" as text
------------pythonスクリプトを使ってユーザーテンポラリーのディレクトリを取得します
------------スクリプトとキャッシュクリアに使う移動先用のディレクトリを作ります
do shell script "mkdir -pv /tmp/" & nowTime
do shell script "mkdir -pv /tmp/" & nowTime & "/2"
do shell script "mkdir -pv /tmp/" & nowTime & "/3"
------------/library
set theLibraryPath to POSIX path of (the path to library folder from local domain) as text
------------削除する各ファイルを定義
set theXptPath to quoted form of (theLibraryPath & "Internet Plug-Ins/Flash Player.plugin") as text
set thePluginPath to quoted form of (theLibraryPath & "Internet Plug-Ins/flashplayer.xpt") as text
set theInstallManagerPath to quoted form of (theLibraryPath & "Application Support/Adobe/Flash Player Install Manager") as text
set theFlashPlayerPath to quoted form of (theLibraryPath & "Application Support/Adobe/Flash Player") as text
set thePreferencesath to quoted form of ((POSIX path of (the path to preferences folder from user domain)) & "Macromedia/Flash Player") as text
set theCachesath to quoted form of ((POSIX path of (the path to library folder from user domain)) & "Caches/Adobe/Flash Player") as text
------------エラー避けにタッチしておく
do shell script "sudo touch -f " & theXptPath password theSudoPassWord with administrator privileges
do shell script "sudo touch -f " & thePluginPath password theSudoPassWord with administrator privileges
do shell script "sudo touch -f " & theInstallManagerPath password theSudoPassWord with administrator privileges
do shell script "sudo touch -f " & theFlashPlayerPath password theSudoPassWord with administrator privileges
do shell script "touch -f " & thePreferencesath
do shell script "touch -f " & theCachesath
------------最初に作ったフォルダへ全て移動
do shell script "sudo mv -f -v " & theXptPath & " '/tmp/" & nowTime & "/'" password theSudoPassWord with administrator privileges
do shell script "sudo mv -f -v " & thePluginPath & " '/tmp/" & nowTime & "/'" password theSudoPassWord with administrator privileges
do shell script "sudo mv -f -v " & theInstallManagerPath & " '/tmp/" & nowTime & "/'" password theSudoPassWord with administrator privileges
do shell script "sudo mv -f -v " & theFlashPlayerPath & " '/tmp/" & nowTime & "/2/'" password theSudoPassWord with administrator privileges
do shell script "mv -fv " & thePreferencesath & " '/tmp/" & nowTime & "/'"
do shell script "mv -fv " & theCachesath & " '/tmp/" & nowTime & "/3/'"
------------移動したファイルについてはお客様に任せるため移動先を開く
------------ファイルの削除を「良し」としてくれるお客様の場合はこの処理は不要
set theOpenFolder to POSIX path of "/private/tmp/" & nowTime & "/"
set theOpenFolder to (POSIX file theOpenFolder)
tell application "Finder"
open folder theOpenFolder
activate
end tell


「UninstallFlashPlayer.rtf」をダウンロード

「UninstallFlashPlayer.scpt.zip」をダウンロード


|

[AppleScripts]GoogleMapのURLからBridge用のGPS用の値を作る【最終回】


こちら
https://force4u.cocolog-nifty.com/skywalker/2013/12/applescriptsgoo.html に
修正版を公開しました

----------

GoogleMapのURLからGPSデータを取得して
XMPファイルにかき出し
Adobe Bridgeで適応するって流れ用です。

制限事項があります。
必ず地図のセンタリングを行なってからURLを取得してください

20130209_120124

URLは
この場所のを使います


20130209_120633


出来上がったXMPファイルは
Bridgeで適応します

20130209_121551


高度については処理していませんので
高度は0になります

Website_image20130209_120857


  


--------------デフォルトアンサー用に東京タワーのURL
set theOrgGoogleMapUrl to "https://maps.google.com/maps?q=%E6%9D%B1%E4%BA%AC%E3%82%BF%E3%83%AF%E3%83%BC&hl=en&ie=UTF8&ll=35.658595,139.745439" as text

--------------URLをペーストするダイアログを出す
display dialog "GoogleMapURLをペーストしてください" default answer the theOrgGoogleMapUrl with icon 1 with title "GoogleMapURLをペーストしてください" default button 1
--------------リザルトをリスト形式で格納
copy the result as list to {the theOrgGoogleMapUrl, BottPressNo}
--------------東経と北緯のLLの値を取り出す
set theAwkComLL to "echo " & quoted form of theOrgGoogleMapUrl & "| awk -F \"ll=\" '{print($2)}' |awk -F \"&\" '{print($1)}' " as text
set theAwkComQ to "echo " & quoted form of theOrgGoogleMapUrl & "| awk -F \"q=\" '{print($2)}' |awk -F \"&\" '{print($1)}' " as text

--------------エラー制御
try
set theGoogleLlNo to do shell script theAwkComLL as text
if theGoogleLlNo is "" then
display alert "GPSデータを取得出来ませんでした"
end if
on error
set theGoogleLlNo to do shell script theAwkComQ as text
if theGoogleLlNo is "" then
display alert "GPSデータを取得出来ませんでした"
end if
end try
--------------llの値をリスト形式に整形
set AppleScript's text item delimiters to {","}
set theGoogleLlNoList to every text item of theGoogleLlNo as list
--------------Latitude60進数の処理
set theLatitude to item 1 of theGoogleLlNoList as text
set theIntegerLatitude to theLatitude div 1 as text
set theLatitude to (text 2 thru 8 of (((theLatitude mod 1) as string) & "000000") as string)
set theLatitude to theIntegerLatitude & theLatitude
set theDecimalLatitudeA to (((theLatitude as number) - (theIntegerLatitude as number)) as number) * 60
set theIntegerDecimalLatitudeA to theDecimalLatitudeA div 1 as text
set theDecimalLatitudeB to (((theDecimalLatitudeA as number) - (theIntegerDecimalLatitudeA as number)) as number) * 100 as integer
set theLatitude to theIntegerLatitude & "," & theIntegerDecimalLatitudeA & "." & theDecimalLatitudeB & "N" as text
--------------Longitude60進数の処理
set theLongitude to item 2 of theGoogleLlNoList as text
set theIntegerLongitude to theLongitude div 1 as text
set theLongitude to (text 2 thru 8 of (((theLongitude mod 1) as string) & "000000") as string)
set theLongitude to theIntegerLongitude & theLongitude
set theDecimalLongitudeA to (((theLongitude as number) - (theIntegerLongitude as number)) as number) * 60
set theIntegerDecimalLongitudeA to theDecimalLongitudeA div 1 as text
set theDecimalLongitudeB to (((theDecimalLongitudeA as number) - (theIntegerDecimalLongitudeA as number)) as number) * 100 as integer
set theLongitude to theIntegerLongitude & "," & theIntegerDecimalLongitudeA & "." & theDecimalLongitudeB & "E" as text
--------------ダイアログ用に改行を入れて整形しておく
set tneAns to theLatitude & "\n" & theLongitude
--------------出来上がりデータをダイアログで表示
display dialog "Bridge用のGPSの値です" default answer the tneAns with icon 1 with title "Adobe Bridge GPS" default button 1 buttons {"XMPファイルも作る", " 終了 "}
--------------XMPファイルも作る場合の始まり
if button returned of the result is "XMPファイルも作る" then
--------------XMPファイルとBridgeの関連づけの確認
do shell script "date > /tmp/ApplicationChk.xmp"
set theTmpXmpFile to (the path to startup disk as string) & "tmp:ApplicationChk.xmp" as alias
set theFileInfo to default application of (info for theTmpXmpFile) as text
--------------Bridgeが未インストールの可能性のエラー制御
if (theFileInfo contains "Bridge") is false then
display alert "XMPファイルがAdobe Bridgeに関連づけられていません"
--------------XMPファイル作成の本処理のはじまり
else if (theFileInfo contains "Bridge") is true then
--------------XMPファイルの保存先ディレクトリを取得
set theSaveXmpPath to (the path to application support from user domain as text) & "Adobe:XMP:Metadata Templates:"
--------------東経と北緯データの再取得(ここは別な方法があったかな)
set theGoogleLlNoQ to do shell script theAwkComQ as text
--------------qの値=検索語句の有無
if theGoogleLlNoQ is "" then
--------------qの値=検索語句が無い場合はファイル名を日付にするため日付の処理
set theDateTime to (do shell script "date +'%Y%m%d_%H%M%S'" as string)
set theXmpFileName to (theLatitude & "_" & theLongitude & "_" & theDateTime & ".xmp") as text
set theXmpFileName to my replace(theXmpFileName, ",", ".") as text
set theGooogleMapQ to theLatitude & " " & theLongitude
else
--------------検索語句がある場合はデコードしてファイル名にする
set theGooogleMapQ to my decodeURL(theGoogleLlNoQ)
set theXmpFileName to (theGooogleMapQ & ".xmp") as text
end if
--------------XMPファイルの保存先を作成
set theDistPathXmpFile to (POSIX path of ((theSaveXmpPath & theXmpFileName) as text)) as text
--------------ファイルを作っておく(既に同名がある場合は上書きになる)
do shell script "touch " & quoted form of theDistPathXmpFile
--------------パスを格納
set theDistFileXmpFile to (POSIX file theDistPathXmpFile) as alias
-----------------------------------------------ここからXMPファイルの作成
-------------XMPファイルの最初の1行
set theXMPline to "<?xpacket begin=\"\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?>"
do shell script "echo " & quoted form of theXMPline & " > " & quoted form of theDistPathXmpFile
-------------XMPファイル
set theXMPline to "<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"Adobe XMP Core 5.3-c011 66.145661, 2012/02/06-14:56:27\">"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
-------------宣言
set theXMPline to "<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to "<rdf:Description rdf:about=\"\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " xmlns:dc=\"http://purl.org/dc/elements/1.1/\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " xmlns:photoshop=\"http://ns.adobe.com/photoshop/1.0/\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " xmlns:Iptc4xmpCore=\"http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " xmlns:Iptc4xmpExt=\"http://iptc.org/std/Iptc4xmpExt/2008-02-29/\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " xmlns:exif=\"http://ns.adobe.com/exif/1.0/\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
-------------photoshop
set theXMPline to " photoshop:Instructions=\"" & theGooogleMapQ & "\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
-------------Iptc4xmpCore
set theXMPline to " Iptc4xmpCore:Location=\"" & theGooogleMapQ & "\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
-------------exif:
set theXMPline to " exif:GPSLatitude=\"" & theLatitude & "\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " exif:GPSProcessingMethod=\"MANUAL\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " exif:GPSAltitude=\"0.00 m\""
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " exif:GPSLongitude=\"" & theLongitude & "\">"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
-------------dc
set theXMPline to " <dc:subject>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " <rdf:Bag>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " <rdf:li>" & theGooogleMapQ & "</rdf:li>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " </rdf:Bag>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " </dc:subject>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
-------------Iptc4xmpExt
set theXMPline to " <Iptc4xmpExt:LocationShown>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " <rdf:Bag>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " <rdf:li"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " Iptc4xmpExt:Sublocation=\"" & theGooogleMapQ & "\"/>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " </rdf:Bag>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " </Iptc4xmpExt:LocationShown>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
-------------XMPの終了
set theXMPline to " </rdf:Description>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to " </rdf:RDF>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to "</x:xmpmeta>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile
set theXMPline to "<?xpacket end=\"w\"?>"
do shell script "echo " & quoted form of theXMPline & " >> " & quoted form of theDistPathXmpFile

-------------出来上がったXMPファイルにラベルを塗って保存したフォルダを開く
tell application "Finder"
set label index of alias (((theSaveXmpPath & theXmpFileName))) to 5
open folder theSaveXmpPath
activate
end tell
end if
else if button returned of the result is "終了" then
end if





--------------------------------------------------#ここからサブルーチン

to replace(theText, orgStr, newStr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newStr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end replace

on decodeURL(str)
set scpt to "php -r 'echo urldecode(\"" & str & "\");'"
return do shell script scpt
end decodeURL

「GoogleMap2Bridgev1.rtf」をダウンロード


「GoogleMap2Bridgev1.scpt.zip」をダウンロード

|

[AppleScript]quicklookを再起動する

再起動時に
キャッシュ(サムネイルキャッシュ)の再作成を行なうように
古いキャッシュファイルは/tmpへ移動させるようにしています。

20130208_005136


 
 
 
 
 



--------まずはランチコントロールでクイックルックを停止
try
do shell script "launchctl stop com.apple.quicklook"
delay 1
end try
-----ディレクトリ名用に日付と時間を取得
set nowTime to do shell script "date '+%Y%m%d%H%M%S'" as text
------pythonスクリプトを使ってユーザーテンポラリーのディレクトリを取得します
-------スクリプトとキャッシュクリア用のディレクトリを作ります
do shell script "mkdir -pv /tmp/python/" & nowTime
--------スクリプト用のファイルを作成
do shell script "touch /tmp/python/" & nowTime & "/gettmpdir.py"
---------1行目を書き込み
do shell script "echo 'import tempfile' > /tmp/python/" & nowTime & "/gettmpdir.py"
---------2行目を書き込み
do shell script "echo 'print tempfile.gettempdir()\n' >> /tmp/python/" & nowTime & "/gettmpdir.py "
---------pythonスクリプトを実行
set theTmpFolderDIr to do shell script "python /tmp/python/" & nowTime & "/gettmpdir.py " as text
------TmpCachesに置き換えてCachesフォルダへのパスを取得
set theCachesFolderDIr to my replace(theTmpFolderDIr, "-Tmp-", "-Caches-") as text
------クイックルックのサムネイルキャッシュファイルを移動(次回起動時に削除されます)
do shell script "mv -f -v '" & theCachesFolderDIr & "/com.apple.QuickLook.thumbnailcache" & "' '/tmp/python/" & nowTime & "/'"
-----フォルダの移動を1秒まつ
delay 1
------新しくクイックルック用のディレクトリを作成
do shell script "mkdir -pv '" & theCachesFolderDIr & "/com.apple.QuickLook.thumbnailcache'"
-----クイックルックを起動する
try
do shell script "launchctl start com.apple.quicklook"
end try


--------------------------------------------------#文字の置き換えサブルーチン

to replace(theText, orgStr, newStr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newStr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end replace


「restart4QuickLook.rtf」をダウンロード

「restart4QuickLook.scpt.zip」をダウンロード

|

[AppleScripts]GoogleMapのURLからBridge用のGPS用の値を作る【その5】

その5
東経 北緯 の値を取得して
GPS用の値に変換する所までは出来ましたので
XMPファイルを作ります。


Website_image20130206_222403


とまぁ考えるに
UTF8で保存する所が面倒なAppleScripts

Website_image20130206_222456


一行づつ書いていくしかないのかな


 

|

evermap


Software Solutions for Adobe® Acrobat®

プラットフォームがWINDOWSのみなのでちょい残念


 


|

LiteSpeed Web Server


LiteSpeed Web Server Downloads

製品版もありますが
無料のライト版もあります。
PPC対応版もあるWEBサーバー。
時間を見つけてためしてみようかな。


|

« 2013年1月 | トップページ | 2013年3月 »