|
本帖最后由 w60711 于 2016-10-3 21:05 编辑
小弟是新手 还请多多指教与帮忙
请问有哪位先进知道如何处理谷哥日曆的.ICS文件吗?
我的构想是:
让软件实时与线上同步
然后经由软件处理分析ICS文件
得到 清单一:周次、时间 清单二:课程名 清单三:进阶清单
可以即时查询(以周为单位)单间教室也可以综合(6间)一起呈现,也可以依教室别汇出为课程表(每周)(xls 或 doc)
也可以指定时间范围(省略较旧的活动,如:只要2016年08月12日开始的)
但苦无解析文件的方法
故上来请求各位前辈们帮忙
小弟手拙只写出一个UI...
附上相关文件及半成品
请各位大神帮忙了...
下载ICS文件(bat)@ECHO off& setlocal enabledelayedexpansion
cd %~dp0
cls
color 3F
SET INFO=(下载ICS文件)
SET _line====================================================================
SET line=*******************************************************************
SET NUM=教室课表辅助 v1.0.0
SET batNum=v1.0.0
Rem =-=-=-=-=-=-=-以下为设置时间变数-=-=-=-=-=-=-=
Set h=%time:~0,2%
Set h=%h: =0%
Set Date=%date:~0,4%-%date:~5,2%-%date:~8,2%-%h%-%time:~3,2%-%time:~6,2%
:intercept_right
If "%Date:~-1%"==" " (
Set "Date=%Date:~0,-1%" & goto intercept_right
)
Rem =-=-=-=-=-=-=-以上为设置时间变数-=-=-=-=-=-=-=
title %NUM% %INFO%
REM 检测Admin权限
::%windir%\system32\reg.exe query "HKU\S-1-5-19" >nul 2>&1 || (
::ECHO. ------
::ECHO. *** 警告 ***
::ECHO. ------
::ECHO.
::ECHO.
::ECHO. ADMINISTRATOR PRIVILEGES NOT DETECTED
::ECHO. ___________________________________________________________
::ECHO.
::ECHO. 本工具需系统管理员权限.
::ECHO.
::ECHO. 请按右键,以系统管理员身分执行
::ECHO.
::ECHO.
::ECHO.
::ECHO. 请按任意键退出...
::Pause >nul
::GOTO :eof
::)
REM 检测工具完整性
:Check1
if not exist ".\Tools\sed.exe" (
ECHO. 工具不完整,缺少sed.exe
ECHO. 按下任意键离开本批次
Pause >nul 2>nul
goto exit
) else (
goto Check2
)
:Check2
if not exist ".\Tools\gawk.exe" (
ECHO. 工具不完整,缺少gawk.exe
ECHO. 按下任意键离开本批次
Pause >nul 2>nul
goto exit
) else (
goto Check3
)
:Check3
if not exist ".\Tools\7z.exe" (
ECHO. 工具不完整,缺少7z.exe
ECHO. 按下任意键离开本批次
Pause >nul 2>nul
goto exit
) else (
goto Check4
)
:Check4
if not exist ".\Tools\7z.dll" (
ECHO. 工具不完整,缺少7z.dll
ECHO. 按下任意键离开本批次
Pause >nul 2>nul
goto exit
) else (
goto Check5
)
:Check5
if not exist ".\Tools\wget.exe" (
ECHO. 工具不完整,缺少wget.exe
ECHO. 按下任意键离开本批次
Pause >nul 2>nul
goto exit
) else (
goto Check6
)
:Check6
REM 检查.\Temp资料夹是否存在,以及删除旧资料以免错误
if not exist ".\Temp" (
md .\Temp >nul 2>nul
) else (
rd /s /q .\Temp
md .\Temp >nul 2>nul
)
REM 主程序
:Menu
cd %~dp0
cls
ECHO.
ECHO. --------------------------------------------------------------
ECHO. ★ 电脑教室课表辅助 ☆
ECHO. ★ ☆
ECHO. ★ 作者: ☆
ECHO. ★ ☆
ECHO. ★ 版本 - %batNum% ☆
ECHO. --------------------------------------------------------------
ECHO.
ECHO.本工具方便产生课表
ECHO %_line%
Set cho=
Set /p cho=输入Y执行,输入N离开:
If /i "%cho%"=="y" GOTO Run
If /i "%cho%"=="Y" GOTO Run
If /i "%cho%"=="n" GOTO exit
If /i "%cho%"=="N" GOTO exit
cls
GOTO Menu
:Run
REM 透过WGet下载Google日曆ICAL档(网址在URL.lst)
ECHO.
ECHO 正在下载Google日曆上的课表,请耐心等候...
for /f %%a in (.\URL.lst) do (
.\Tools\wget --no-check-certificate -nv -P .\Temp\ %%a >nul 2>nul
)
REM 建立档案名称清单
findstr /V https:// .\URL.lst >.\name.lst
REM 取得下载之ICAL名称
dir /b /on .\Temp >.\ICAL.lst
REM 将ics档更名
for /f %%a in (.\ICAL.lst) do (
for /f %%b in (.\name.lst) do (
REN .\Temp\%%a %%b.ics >nul 2>nul
)
)
Pause
REM 检验ICAL档数量是否正确
::产生TempQuantity.lst(Temp资料夹中的ics数量)
dir /b /on .\Temp >.\TempQuantity.lst
Move .\ICAL.lst .\Temp >nul 2>nul
Move .\name.lst .\Temp >nul 2>nul
Move .\TempQuantity.lst .\Temp >nul 2>nul
::计算个别(ics)数量
for /f " delims=:" %%a in ('findstr /n .* ".\Temp\name.lst"') do set /a b+=1 >nul 2>nul REM 应有数量
for /f " delims=:" %%c in ('findstr /n .* ".\Temp\TempQuantity.lst"') do set /a d+=1 >nul 2>nul REM 实际数量
REM GTR:等于,EQU:等于
set /a name1=%b%
set /a name2=%d%
if %name1% GTR %name2% echo ICAL档下载不完全,请按任意键离开本程序。 & Pause >nul 2>nul & exit
if %name1% EQU %name2% echo ICAL档下载完成
del /f /q ".\Temp\ICAL.lst" >nul 2>nul
del /f /q ".\Temp\name.lst" >nul 2>nul
:main
Pause
:exit
exit
URL.lst9304
https://calendar.google.com/calendar/ical/vlo0f04kuvurk78v3jbip4glbk%40group.calendar.google.com/public/basic.ics
教室课表查询.au3#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.8.1
Author: XXX
Script Function: Install DEMO
Template AutoIt script.
#ce ----------------------------------------------------------------------------
#NoTrayIcon;不显示托盘图标
#RequireAdmin;使用管理员权限
#AutoIt3Wrapper_icon=icon.ico;更换生成exe的图标
#AutoIt3Wrapper_Res_Comment=教室课表查询;详细信息
#AutoIt3Wrapper_Res_Description=教室课表查询;描述
#AutoIt3Wrapper_Res_Fileversion=v1.0.0.0 2016.09.30;文件版本
#AutoIt3Wrapper_Res_LegalCopyright=Copyright © 2016 XXX 保留一切权利。;版权信息
#AutoIt3Wrapper_Res_Field=教室课表查询;产品名称
#AutoIt3Wrapper_Res_Field=v1.0.0.0;产品版本
#AutoIt3Wrapper_Res_Field=XXX;公司名称
#AutoIt3Wrapper_Res_requestedExecutionLevel=highestAvailable;请求可用的最高权限
FileChangeDir(@ScriptDir);切换起始目录工作目录到脚本所在路径
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiListBox.au3>
#include <GuiComboBox.au3>
#Include <GuiListView.au3>
#include <Array.au3>
#AutoIt3Wrapper_UseX64=n ;;; x86系统应将=y改为=n。;;将程序编译为32位,能完美运行于64位系统中
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=d:\develop\_myfiles\测试\电脑教室课表\aform1.kxf
$Form1_1 = GUICreate("教室课表查询", 625, 442, 193, 115)
;;GUISetBkColor(0x00E0FFFF) ; 将变更背景色彩
GUISetOnEvent($GUI_EVENT_CLOSE, "AForm1_1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "AForm1_1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "AForm1_1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "AForm1_1Restore")
$Label1 = GUICtrlCreateLabel("请选择教室:", 8, 8, 76, 17)
$hInput = GUICtrlCreateCombo("", 8, 32, 76, 21) ; 建一清单方块(ComboBox)控制项
GUICtrlSetData(-1, "9308|9307|9306|9305|9304|讲堂丁", "9304") ; 在清单方块中添加新目,并置一新的默值
GUICtrlSetColor(-1, 0xEE7600);;橘色
$Open = GUICtrlCreateButton("读取", 224, 32, 49, 25, 0)
GUICtrlSetOnEvent(-1, "OpenClick")
$Apply = GUICtrlCreateButton("汇出", 280, 32, 49, 25, 0)
GUICtrlSetOnEvent(-1, "ApplyClick")
GUICtrlSetState(-1, $GUI_FOCUS) ; 焦点将在此按钮上
$Progress1 = GUICtrlCreateProgress(344, 32, 265, 25)
GUICtrlSetData(-1, 25)
$Label2 = GUICtrlCreateLabel("上课时间", 8, 72, 52, 17)
GUICtrlSetOnEvent(-1, "AListView1Click")
$Label3 = GUICtrlCreateLabel("课程名称", 320, 72, 52, 17)
GUICtrlSetOnEvent(-1, "AListView2Click")
$Label4 = GUICtrlCreateLabel("详细资料", 8, 288, 52, 17)
$ListView1 = GUICtrlCreateListView("原始资料 ", 8, 88, 289, 193)
GUICtrlSetData(-1, "")
GUICtrlSetOnEvent(-1, "AListView1Click")
$ListView2 = GUICtrlCreateListView("原始资料 ", 320, 88, 289, 193)
GUICtrlSetData(-1, "")
GUICtrlSetOnEvent(-1, "AListView2Click")
$ListView3 = GUICtrlCreateListView("原始资料 ", 8, 304, 601, 129)
GUICtrlSetData(-1, "")
GUICtrlSetOnEvent(-1, "AListView3Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Sleep(100)
WEnd
Func AForm1_1Close()
Exit
EndFunc ;==>AForm1_1Close
Func AForm1_1Maximize()
EndFunc ;==>AForm1_1Maximize
Func AForm1_1Minimize()
EndFunc ;==>AForm1_1Minimize
Func AForm1_1Restore()
EndFunc ;==>AForm1_1Restore
Func AListView1Click()
EndFunc ;==>AListView1Click
Func AListView2Click()
EndFunc ;==>AListView2Click
Func AListView3Click()
EndFunc ;==>AListView3Click
Func ApplyClick()
$MyDocsFolder = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
$IcsFileSavePath = FileSaveDialog("选择储存位置", $MyDocsFolder, "纯文字档 (*.txt;*.ini)|Word (*.doc)|Excel (*.xls)|所有档 (*.*)" , 2 + 16 , "课表")
FileWrite ($IcsFileSavePath,$listview1)
EndFunc ;==>ApplyClick
Func OpenClick()
$MyDocsFolder = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
$IcsFilePath = FileOpenDialog("选择日曆档案", $MyDocsFolder, "ICalendar (*ics)|文字档 (*.txt)|所有档 (*.*)", 1 + 4)
$IcsFileText = FileOpen($IcsFilePath, 0)
While 1
$Loop = FileReadLine($IcsFileText)
If @error Then ExitLoop
$item1 = GUICtrlCreateListViewItem($Loop, $listview1)
WEnd
FileClose($IcsFilePath)
EndFunc ;==>OpenClick
9304.icsBEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:测试用日历
X-WR-TIMEZONE:Asia/Taipei
X-WR-CALDESC:
BEGIN:VTIMEZONE
TZID:Asia/Taipei
X-LIC-LOCATION:Asia/Taipei
BEGIN:STANDARD
TZOFFSETFROM:+0800
TZOFFSETTO:+0800
TZNAME:CST
DTSTART:19700101T000000
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTART:20150911T233000Z
DTEND:20150912T043000Z
DTSTAMP:20161003T121923Z
UID:jaa30es6bsvjqu2000abob7290@google.com
CREATED:20161003T121759Z
DESCRIPTION:
LAST-MODIFIED:20161003T121759Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:旧活动3
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART:20150910T020000Z
DTEND:20150910T090000Z
DTSTAMP:20161003T121923Z
UID:u8p7m8t24q00nosqgmqkat15g8@google.com
CREATED:20161003T121755Z
DESCRIPTION:
LAST-MODIFIED:20161003T121755Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:旧活动2
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART:20150907T223000Z
DTEND:20150908T100000Z
DTSTAMP:20161003T121923Z
UID:m95afm1oegrqrsuggdjo06mt88@google.com
CREATED:20161003T121750Z
DESCRIPTION:
LAST-MODIFIED:20161003T121750Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:旧活动
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART:20161020T233000Z
DTEND:20161021T020000Z
DTSTAMP:20161003T121923Z
UID:353q897srdp10v3r5id45pblqs@google.com
CREATED:20161003T121716Z
DESCRIPTION:
LAST-MODIFIED:20161003T121716Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:外文
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART;TZID=Asia/Taipei:20161013T130000
DTEND;TZID=Asia/Taipei:20161013T173000
RRULE:FREQ=WEEKLY;COUNT=7;BYDAY=TH
DTSTAMP:20161003T121923Z
UID:oa8vk0dlhal5k19of3gl8j3os4@google.com
CREATED:20161003T121647Z
DESCRIPTION:
LAST-MODIFIED:20161003T121647Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:营队
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART:20161007T050000Z
DTEND:20161007T080000Z
DTSTAMP:20161003T121923Z
UID:i9fv2b94n5oca9dkbvqqntj240@google.com
CREATED:20161003T121551Z
DESCRIPTION:
LAST-MODIFIED:20161003T121551Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:语文
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART;TZID=Asia/Taipei:20161005T073000
DTEND;TZID=Asia/Taipei:20161005T103000
RRULE:FREQ=WEEKLY;COUNT=35;BYDAY=WE
DTSTAMP:20161003T121923Z
UID:j6raak2jolbr7k42bakkqspvls@google.com
CREATED:20161003T121524Z
DESCRIPTION:
LAST-MODIFIED:20161003T121524Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:C++编程
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART:20161004T050000Z
DTEND:20161004T090000Z
DTSTAMP:20161003T121923Z
UID:pmfcpl3196prcb4semsdu4ss1c@google.com
CREATED:20161003T121340Z
DESCRIPTION:
LAST-MODIFIED:20161003T121340Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:AU3编程
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART;TZID=Asia/Taipei:20161003T100000
DTEND;TZID=Asia/Taipei:20161003T120000
RRULE:FREQ=WEEKLY;COUNT=18;BYDAY=MO
DTSTAMP:20161003T121923Z
UID:v7s7nqje7ss6irrni7laet1nhg@google.com
CREATED:20161003T121315Z
DESCRIPTION:
LAST-MODIFIED:20161003T121316Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:计算器概论
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR
|
|