Ñò ô\¾Lc @s$ddkZddkZddkZddkZddkZddkZddkZeidƒZe e_ ei i ei i eidƒƒZ hdd6ZeieƒZeieeiƒZeieƒd„Zed„Zed„Zd „Zd d „Zed joed ƒndS( iÿÿÿÿNs'/var/www/simplecd.old/verycd.sqlite3.dbishttp://localhost:3128thttpcCs“y…tt|ƒdƒ}tt|ƒddƒ}tt|ƒdƒ}td|||f}tii|ƒoti|ƒnWnnXdS(Ni idiès/idcache/%s/%s/%s.html(tstrtlongtpathtostexiststremove(tidtl1tl2tl3t cachefile((s/var/www/simplecd.old/douban.pyt clear_idcachesc Cs§d}d}d}d|||f}|GHddk}ti|ƒiƒ}|i|ƒ}x1|ddiƒD]}|G|dd|GHqoW|dddd GHdS( Nt 047ca5407fe8b8a40d75efc17fba29ecs å¹¸è¿æ˜ŸtmoviesUhttp://api.douban.com/%s/subjects?q=%s&start-index=1&max-results=1&alt=json&apikey=%siÿÿÿÿtentryittitles$t(tjsonturllib2turlopentreadtloadstkeys( RtconntapikeyRtcatturlRtdbjtx((s/var/www/simplecd.old/douban.pyt doubanapi!s c Cs¹dG|GHt|ƒ}|iƒ}|id|fƒ|iƒ\}}}}|iƒtidƒi|ƒ}tidƒi|ƒ}|o|idƒ}n|GH|d jp|od GHt |ƒdS|i d ƒd jo |} n$||i d ƒd|i dƒ!} |djod| d} n(|od|d} nd| d} | i ddƒ} dG| GH| GHyt i | ƒiƒ} Wn dGHdSXtidtiƒi| ƒ} | p dGHdS|i dƒ} d| idƒ| idƒ| idƒf}| d jo||}n|| d ||| d}|iƒ}y.|id||fƒ|iƒ|iƒWn!|iƒ|iƒdGHdSXdG|GHt |ƒtS(!NtupdatingsAselect title,category1,brief,content from verycd where verycdid=?s Douban\d+s#http://www\.imdb\.com/title/(tt\d+)is电影s音ä¹s剧集s动漫s综艺s...not movie or already updateds《iÿÿÿÿis》s1http://www.douban.com/subject_search?search_text=s &cat=1003s &cat=1002t t+s...fetching douban pages...fetch errors<href=".*?/subject/(\d+)/".*?"rating_nums">([0-9.]+)<.*?(\d+)s ...not foundsvotes)sDouban%s:%s(%s votes)iis*update verycd set brief=? where verycdid=?s...db update failures ...updated(s电影s音ä¹s剧集s动漫s综艺(RtcursortexecutetfetchonetclosetretcompiletsearchtgroupR tfindtreplaceRRRtDOTALLtcommittTrue(RRtcRRtbrieftcontenttdbedtimdbidtnametdurltdstdbscoretinstdbb((s/var/www/simplecd.old/douban.pytdouban.sj      #  .       cCsbtiƒ}|idƒ|iƒ}x6|D].}t|dƒ}|otidƒq,q,WdS(Ns\select verycdid from verycd where category1="电影" and verycdid>6000 order by updtime descii(tdbR!R"tfetchallR9ttimetsleep(R.tidsRtupdate((s/var/www/simplecd.old/douban.pyt updateallqs   icCsNtiƒ}|id|fƒ|iƒ}x|D]}t|dƒq2WdS(Ns9select verycdid from verycd order by updtime desc limit ?i(R:R!R"R;R9(tnumR.R>R((s/var/www/simplecd.old/douban.pyR?{s   t__main__(RturllibR%tsqlite3RtsysR<tconnectR:Rt text_factoryRtdirnametrealpathtargvtproxiest ProxyHandlert proxy_supportt build_openert HTTPHandlertopenertinstall_openerR RR9R@R?t__name__(((s/var/www/simplecd.old/douban.pyts$    %   C