# -*- coding: utf-8 -*-

import re

#簡易正規表達式
def Simple_Regular(RegularStr,String,index=0):
    STR=re.search(RegularStr,String)
    if STR is None:
        return False
    else:
        return STR.group(index)
    
UI.UpdateLog("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※")
UI.UpdateLog("※　　　【免空科學研究所　ｔｉｇｅｒｍａｘ．ｄｙｎｄｎｓ．ｏｒｇ】　　　※")
UI.UpdateLog("※　　　～㊣　　　　　　　　　ＺＫＭ　　製作分享　　　　　　　㊣～　　　※")
UI.UpdateLog("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※")
UI.UpdateLog("【腳本更新】：2013.03.13 panda0305 撰寫腳本",2)
UI.UpdateLog("【上傳空間】：ZippyShare.com",2)
UI.UpdateLog("【上傳大小】：200MB",2)
UI.UpdateLog("【砍檔時間】：未知",2)
UI.UpdateLog("【腳本功能】：無帳號上傳",2)
UI.UpdateLog("【腳本備註】：支援各32/64位元Windows系列",1)
UI.UpdateLog("=========================================",2)
UI.UpdateLog("建構上傳參數....")
sHTML=HTTP.GetURL("http://www.zippyshare.com/")
server=Simple_Regular("var server = '(.+?)';",sHTML,1)
UPID=Simple_Regular("var uploadId = '(.+?)'",sHTML,1)
Host="http://"+server+".zippyshare.com/upload?uploadId="+UPID

#Host="http://"+server+".zippyshare.com/upload"
if Host!=False and UPID!=False:
  UI.UpdateLog("Host="+Host,2)
  UI.UpdateLog("UPID="+UPID,2)
  UI.UpdateLog("開始上傳....",4)
  HTTP.Referer=Host
  HTTP.AddUpParam("Filename",UI.FileName)
  HTTP.AddUpParam("notprivate","false")
  HTTP.AddUpParam("folder","/")
  HTTP.AddUpParam("Upload","Submit Query")
  HTTP.AddFileReference("Filedata")
  HTTP.SetCookie(HTTP.GetCookie)
  HTML=UI.UpFile(Host)
  #UI.UpdateLog(HTML)
  DownloadLink=Simple_Regular('<a target="top" href="(.+?)"',HTML,1)
  if DownloadLink!=False:
      UI.UpdateLog("原始連結->"+DownloadLink,4)
      UI.AddShareLink(DownloadLink)
      UI.ProceSuccess()
  else:
      UI.UpdateLog("無法取得連結網址",3)
      UI.ProceFalse()
else:
  UI.UpdateLog("找不到上傳參數",3)
  UI.ProceFalse()