【QR】イベント・カレンダー登録用のQRコードを作る(Google Chart利用)
【QR】イベント・カレンダー登録用のQRコードを作る(Google Chart利用)
https://force4u.cocolog-nifty.com/skywalker/2019/07/post-860c14.html
こちらの記事の
php→ python3への対応版(OS11以上用)
ダウンロード - make_qrcode4_eventfile.scpt.zip
iCSファイルを選んで実行すると
iOSの標準カメラでこんな感じ
(*
make_qrcode4_eventfile.scpt
イベント登録用のQRを作成します。
たぶんiOS専用
20190714 初回作成
20190715 phpのエラー処理追加
20220106 phpでの%エンコードの処理をpython3に置き換え
APIの仕様は
https://developers.google.com/chart/infographics/docs/qr_codes
*)
on run
set theWithPrompt to "QRコードを作成します。"
set theDefLoc to path to downloads folder from user domain
set theFileType to "public.vcard,com.apple.ical.ics,public.calendar-event,public.ics,com.apple.ical.vcs" as text
set AppleScript's text item delimiters to {","}
set theFileTypeList to every text item of theFileType
open (choose file default location theDefLoc ¬
with prompt theWithPrompt ¬
of type theFileTypeList ¬
without invisibles)
end run
on open DropObj
set theFilePath to POSIX path of DropObj
set theChl to (do shell script "cat '" & theFilePath & "'") as text
set AppleScript's text item delimiters to "\r"
set listData to (every text item of theChl) as list
set AppleScript's text item delimiters to ""
set numCntList to (count of listData) as number
set numReadList to 1 as number
repeat numCntList times
set theLineData to (item numReadList of listData) as text
----EVENT ITEM
if theLineData contains "LOCATION:" then
set theLocation to theLineData
set theLocation to doReplace(theLocation, "LOCATION:", "")
set theLocation to my encodeURL(theLocation)
end if
if theLineData contains "DESCRIPTION:" then
set theDescription to theLineData
set theDescription to doReplace(theDescription, "DESCRIPTION:", "")
set theDescription to my encodeURL(theDescription)
end if
if theLineData contains "SUMMARY:" then
set theSummary to theLineData
set theSummary to doReplace(theSummary, "SUMMARY:", "")
set theSummary to my encodeURL(theSummary)
end if
if theLineData contains "URL:" then
set theURL to theLineData
set theURL to doReplace(theURL, "URL:", "")
set theURL to my encodeURL(theURL)
else if theLineData contains "URL;" then
set theURL to theLineData
set theURL to doReplace(theURL, "VALUE=URI:", "")
set theURL to doReplace(theURL, "URL;", "")
set theURL to my encodeURL(theURL)
end if
if theLineData contains "DTSTART:" then
set theDTSTART to theLineData
set theDTSTART to doReplace(theDTSTART, "DTSTART:", "")
end if
if theLineData contains "DTEND:" then
set theDTEND to theLineData
set theDTEND to doReplace(theDTEND, "DTEND:", "")
end if
set numReadList to numReadList + 1 as number
end repeat
set theChl to "BEGIN:VEVENT%0ALOCATION:" & theLocation & "%0ADESCRIPTION:" & theDescription & "%0AURL:" & theURL & "%0ASUMMARY:" & theSummary & "%0ADTSTART:" & theDTSTART & "%0ADTEND:" & theDTEND & "%0AEND:VEVENT" as text
--BASE URL
set theApiUrl to "https://chart.googleapis.com/chart?" as text
set theCht to "qr" as text
set theChs to "540x540" as text
set theChoe to "UTF-8" as text
---L M Q R
set theChld to "L" as text
--URLを整形
set theOpenUrl to ("" & theApiUrl & "&cht=" & theCht & "&chs=" & theChs & "&choe=" & theChoe & "&chld=" & theChld & "&chl=" & theChl & "") as text
-----サファリで開く
tell application "Safari"
activate
make new document with properties {name:"QR-CODE by Google API"}
tell window 1
open location theOpenUrl
end tell
end tell
end open
--------------文字の置き換えサブルーチン
to doReplace(theText, theOrgStr, theNewStr)
set theOldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to theOrgStr
set theTmpList to every text item of theText
set AppleScript's text item delimiters to theNewStr
set theReplaceStr to theTmpList as text
set AppleScript's text item delimiters to theOldDelim
return theReplaceStr
end doReplace
---URLエンコードのサブルーチン
on encodeURL(str)
set scpt to ("python3 -c 'import urllib.parse;[print(urllib.parse.quote(\"" & str & "\", safe=\"/:;#!?=\"))]'") as text
return do shell script scpt
end encodeURL
| 固定リンク
「Barcode2D」カテゴリの記事
- [LINE]QRコード各種(2023.08.29)
- 【QR】イベント・カレンダー登録用のQRコードを作る(Google Chart利用)(2022.01.06)
- 【QR】アドレス帳登録用のQRコードを作る(Google Chart利用)(2021.12.06)
- [Wifi]Wifiアクセスポイント用のmobileconfigを作成する(2021.11.02)
- [AppleScripts]WIFIバーコードを作成(データマトリックス)(2021.08.29)