# -*- coding: utf-8 -*-
import clr
import sys
import System

sys.path.append(UI.StartupPath+'\Script\Module\dll')
clr.AddReferenceToFile("EasyScript.dll")
from EasyScript import *
EasyScript = EasyScript()

UI.UpdateLog("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※")
UI.UpdateLog("※【免空科學研究所 　ｔｉｇｅｒｍａｘ．ｄｙｎｄｎｓ．ｏｒｇ】※")
UI.UpdateLog("※～㊣　　　　　　　　 　　傻Ｂ　　製作分享　　　　　　　㊣～※")
UI.UpdateLog("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※")
UI.UpdateLog("【腳本更新】：2013.03.13")
UI.UpdateLog("【下載空間】：http://sync.hamicloud.net/")
UI.UpdateLog("【下載大小】：無")
UI.UpdateLog("【砍檔時間】：無")
UI.UpdateLog("【腳本功能】：手動驗證下載")
UI.UpdateLog("＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝",2)
UI.UpdateLog("檔案連結 = "+UI.Link,2)
HOST=EasyScript.GetstrToVariable(UI.Link,'http://','/',1)
HTML=HTTP.GetURL(UI.Link)
verify_code_key=EasyScript.GetstrToVariable(HTML,"verify_code_key' value='","'",1)
verify_code_checksum=EasyScript.GetstrToVariable(HTML,"verify_code_checksum' value='","'",1)
click_ad_key=EasyScript.GetstrToVariable(HTML,"click_ad_key' value='","'",1)
AD=EasyScript.GetstrToVariable(HTML,"http://"+HOST+"/_oops/@AD","'",1)
AD_LINK="http://"+HOST+"/_oops/@AD"+AD
UI.UpdateLog("點擊廣告 = "+AD_LINK,2)
UI.FileName=EasyScript.GetstrToVariable(HTML,'檔案名稱： <b>','<',1)
UI.FileSize=EasyScript.GetstrToVariable(HTML,'檔案大小： <b>','<',1)
UI.UpdateLog("檔案名稱 = "+UI.FileName,2)
UI.UpdateLog("檔案大小 = "+UI.FileSize,2)
UI.UpdateLog("＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝",2)
HTTP.GetURL(AD_LINK)
Captcha="http://"+HOST+"/@verify?"+verify_code_key+"&"+verify_code_checksum
UI.PromptCaptcha(Captcha)
HTTP.AddPostParam("verify_code_key",verify_code_key)
HTTP.AddPostParam("verify_code_checksum",verify_code_checksum)
HTTP.AddPostParam("click_ad_key",click_ad_key)
HTTP.AddPostParam("verify_code_value",UI.CaptchaValue)
Post_Link=UI.Link+"?download"
HTML=HTTP.PostURL(Post_Link,HTTP.PostData)
DL_LINK=EasyScript.GetstrToVariable(HTML,"top.location.replace('","'",1)
UI.UpdateLog("下載網址 = "+DL_LINK,2)
UI.DownloadURL(DL_LINK)
if Status==True:
    UI.UpdateLog("下載成功",3)
else:
    UI.UpdateLog("下載失敗",2)