├── miniaxel ├── README.rst ├── miniaxel │ └── __init__.py ├── miniaxel.ini.example ├── setup.py ├── test.py ├── config.py └── .gitignore ├── douban ├── libs │ ├── pyoauth2 │ │ ├── libs │ │ │ ├── __init__.py │ │ │ ├── base.py │ │ │ ├── connection.py │ │ │ ├── password.py │ │ │ ├── auth_code.py │ │ │ ├── response.py │ │ │ ├── multipart.py │ │ │ └── access_token.py │ │ ├── __init__.py │ │ └── client.py │ └── douban_client │ │ ├── __init__.py │ │ ├── api │ │ ├── music.py │ │ ├── guess.py │ │ ├── book.py │ │ ├── movie.py │ │ ├── error.py │ │ ├── subject.py │ │ ├── review.py │ │ ├── comment.py │ │ ├── user.py │ │ ├── photo.py │ │ ├── discussion.py │ │ ├── base.py │ │ ├── doumail.py │ │ ├── album.py │ │ ├── __init__.py │ │ ├── note.py │ │ ├── event.py │ │ ├── miniblog.py │ │ └── online.py │ │ └── client.py ├── __init__.py ├── test.py ├── mydouban.py ├── .gitignore └── douban_movie_search.py ├── .gitignore ├── edict ├── edict.ini ├── online_dict.py └── edict.py ├── bt ├── 16.txt ├── 17.txt ├── 18.txt ├── 19.txt ├── qll.py ├── 6.txt ├── btparser.py ├── 13.txt └── 3.txt ├── dllive ├── __init__.py ├── dllive.ini.example ├── config.py ├── .gitignore └── dllive.py ├── dlmusic ├── __init__.py ├── config.ini.example ├── xiami_dl.py ├── songsdb.py └── .gitignore ├── dlvideo ├── __init__.py ├── parsers │ ├── base_types.py │ ├── util.py │ ├── __init__.py │ ├── youku.py │ ├── w56.py │ ├── flvcd.py │ ├── yytingting.py │ ├── sohu.py │ └── iqiyi.py ├── dlvideo.ini.example ├── setup.py ├── test.py ├── config.py ├── utils.py ├── .gitignore └── dlvideo.py ├── backup ├── dump.bak.zip ├── over_write_config.sh ├── wait4transfer.sh ├── clean_db_shm.sh ├── backup2dp.json.example ├── excel_merge.vba ├── deploy.sh ├── zipTodayFiles.py ├── renamefiles.py └── .gitignore ├── gaehelper ├── www │ ├── inc │ │ ├── dbtb │ │ │ └── images │ │ │ │ ├── favicon.ico │ │ │ │ ├── sort_asc.png │ │ │ │ ├── sort_both.png │ │ │ │ ├── sort_desc.png │ │ │ │ ├── Sorting icons.psd │ │ │ │ ├── back_disabled.png │ │ │ │ ├── back_enabled.png │ │ │ │ ├── forward_disabled.png │ │ │ │ ├── forward_enabled.png │ │ │ │ ├── back_enabled_hover.png │ │ │ │ ├── sort_asc_disabled.png │ │ │ │ ├── sort_desc_disabled.png │ │ │ │ └── forward_enabled_hover.png │ │ ├── visualize │ │ │ ├── images │ │ │ │ ├── chartbg.png │ │ │ │ └── chartbg-vanilla.png │ │ │ ├── js │ │ │ │ ├── example.js │ │ │ │ ├── example-filtering.js │ │ │ │ └── example-editable.js │ │ │ ├── css │ │ │ │ ├── basic.css │ │ │ │ ├── visualize-light.css │ │ │ │ ├── visualize-dark.css │ │ │ │ └── visualize.css │ │ │ ├── vanilla.html │ │ │ ├── index.html │ │ │ ├── editable.html │ │ │ └── filtering.html │ │ └── common.js │ ├── index.html │ └── ip_info.html ├── dnslib │ ├── test │ │ ├── google.com-AAAA │ │ ├── facebook.com-AAAA │ │ ├── _sip._udp.sipgate.co.uk-SRV │ │ ├── google.com-SOA │ │ ├── in-addr.arpa-PTR │ │ ├── google.com-TXT │ │ ├── e164.org-NAPTR │ │ ├── google.com-MX │ │ ├── sip2sip.info-NAPTR │ │ ├── dig │ │ │ ├── google.com-A.dig │ │ │ └── google.com-ANY.dig │ │ ├── sip2sip.info-ANY │ │ ├── google.com-A │ │ ├── sipgate.co.uk-ANY │ │ └── microsoft.com-ANY │ ├── bimap.py │ ├── ranges.py │ ├── bit.py │ ├── buffer.py │ └── fixedresolver.py ├── pac │ └── __init__.py └── httpServer.py ├── README.md ├── z7z8 ├── pyfile_template.py ├── ziputil.py └── convertfile2utf8.py ├── weibo └── .gitignore └── js └── common.js /miniaxel/README.rst: -------------------------------------------------------------------------------- 1 | simple one. -------------------------------------------------------------------------------- /douban/libs/pyoauth2/libs/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | edict/online_dict.pyc -------------------------------------------------------------------------------- /edict/edict.ini: -------------------------------------------------------------------------------- 1 | [default] 2 | outpath = 3 | 4 | -------------------------------------------------------------------------------- /bt/16.txt: -------------------------------------------------------------------------------- 1 | 机构名称,机构地址,区县,机构电话,基本医保点,医保编码,新农合定点,邮政编码, 2 | -------------------------------------------------------------------------------- /bt/17.txt: -------------------------------------------------------------------------------- 1 | 机构名称,机构地址,区县,机构电话,基本医保点,医保编码,新农合定点,邮政编码, 2 | -------------------------------------------------------------------------------- /bt/18.txt: -------------------------------------------------------------------------------- 1 | 机构名称,机构地址,区县,机构电话,基本医保点,医保编码,新农合定点,邮政编码, 2 | -------------------------------------------------------------------------------- /bt/19.txt: -------------------------------------------------------------------------------- 1 | 机构名称,机构地址,区县,机构电话,基本医保点,医保编码,新农合定点,邮政编码, 2 | -------------------------------------------------------------------------------- /dllive/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | -------------------------------------------------------------------------------- /dlmusic/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | -------------------------------------------------------------------------------- /dlvideo/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | -------------------------------------------------------------------------------- /backup/dump.bak.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkhopper/scripts/HEAD/backup/dump.bak.zip -------------------------------------------------------------------------------- /dlmusic/config.ini.example: -------------------------------------------------------------------------------- 1 | [main] 2 | email= 3 | password= 4 | song_list= 5 | db= 6 | out_path= 7 | -------------------------------------------------------------------------------- /douban/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import sys 5 | import getopt 6 | -------------------------------------------------------------------------------- /miniaxel/miniaxel/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | __version__ = '0.1' 5 | -------------------------------------------------------------------------------- /gaehelper/www/inc/dbtb/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkhopper/scripts/HEAD/gaehelper/www/inc/dbtb/images/favicon.ico -------------------------------------------------------------------------------- /gaehelper/www/inc/dbtb/images/sort_asc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkhopper/scripts/HEAD/gaehelper/www/inc/dbtb/images/sort_asc.png -------------------------------------------------------------------------------- /gaehelper/www/inc/dbtb/images/sort_both.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkhopper/scripts/HEAD/gaehelper/www/inc/dbtb/images/sort_both.png -------------------------------------------------------------------------------- /gaehelper/www/inc/dbtb/images/sort_desc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkhopper/scripts/HEAD/gaehelper/www/inc/dbtb/images/sort_desc.png -------------------------------------------------------------------------------- /douban/libs/douban_client/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from .client import DoubanClient 3 | 4 | VERSION = __version__ = '0.0.6' 5 | -------------------------------------------------------------------------------- /gaehelper/www/inc/dbtb/images/Sorting icons.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkhopper/scripts/HEAD/gaehelper/www/inc/dbtb/images/Sorting icons.psd -------------------------------------------------------------------------------- /gaehelper/www/inc/dbtb/images/back_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkhopper/scripts/HEAD/gaehelper/www/inc/dbtb/images/back_disabled.png -------------------------------------------------------------------------------- /gaehelper/www/inc/dbtb/images/back_enabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkhopper/scripts/HEAD/gaehelper/www/inc/dbtb/images/back_enabled.png -------------------------------------------------------------------------------- /gaehelper/www/inc/visualize/images/chartbg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkhopper/scripts/HEAD/gaehelper/www/inc/visualize/images/chartbg.png -------------------------------------------------------------------------------- /gaehelper/www/inc/dbtb/images/forward_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkhopper/scripts/HEAD/gaehelper/www/inc/dbtb/images/forward_disabled.png -------------------------------------------------------------------------------- /gaehelper/www/inc/dbtb/images/forward_enabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkhopper/scripts/HEAD/gaehelper/www/inc/dbtb/images/forward_enabled.png -------------------------------------------------------------------------------- /gaehelper/www/inc/dbtb/images/back_enabled_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkhopper/scripts/HEAD/gaehelper/www/inc/dbtb/images/back_enabled_hover.png -------------------------------------------------------------------------------- /gaehelper/www/inc/dbtb/images/sort_asc_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkhopper/scripts/HEAD/gaehelper/www/inc/dbtb/images/sort_asc_disabled.png -------------------------------------------------------------------------------- /gaehelper/www/inc/dbtb/images/sort_desc_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkhopper/scripts/HEAD/gaehelper/www/inc/dbtb/images/sort_desc_disabled.png -------------------------------------------------------------------------------- /gaehelper/www/inc/dbtb/images/forward_enabled_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkhopper/scripts/HEAD/gaehelper/www/inc/dbtb/images/forward_enabled_hover.png -------------------------------------------------------------------------------- /gaehelper/www/inc/visualize/images/chartbg-vanilla.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pkhopper/scripts/HEAD/gaehelper/www/inc/visualize/images/chartbg-vanilla.png -------------------------------------------------------------------------------- /douban/libs/pyoauth2/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from client import Client 4 | from libs.access_token import AccessToken 5 | 6 | VERSION = '0.0.6' 7 | -------------------------------------------------------------------------------- /miniaxel/miniaxel.ini.example: -------------------------------------------------------------------------------- 1 | [default] 2 | outpath = 3 | retrans = True 4 | tmin = 5 5 | tmax = 10 6 | npf = 5 7 | log_level = debug 8 | log_file = ./miniaxel.log 9 | 10 | [proxy] 11 | enable = false 12 | addr = 13 | -------------------------------------------------------------------------------- /douban/libs/douban_client/api/music.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .subject import Subject 4 | 5 | 6 | class Music(Subject): 7 | 8 | target = 'music' 9 | 10 | def __repr__(self): 11 | return '' 12 | -------------------------------------------------------------------------------- /douban/libs/douban_client/api/guess.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .base import DoubanAPIBase, DEFAULT_START, DEFAULT_COUNT 4 | 5 | 6 | class Guess(DoubanAPIBase): 7 | 8 | def __repr__(self): 9 | return '' 10 | -------------------------------------------------------------------------------- /backup/over_write_config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | SRC_PATH=./eee_linuxserver 5 | DEST_PATH=./linuxserver 6 | CLS_PATH=./linuxserver/XCLS/cls_cfg.txt 7 | 8 | cp -rf ${SRC_PATH}/* ${DEST_PATH} 9 | 10 | sed -i '/addr4Client\s=[^:]*/s/addr4Client\s=[^:]*/addr4Client = localhost/g' ${CLS_PATH} 11 | -------------------------------------------------------------------------------- /douban/libs/pyoauth2/libs/base.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -* 2 | 3 | class Base(object): 4 | 5 | def __init__(self, client): 6 | self.client = client 7 | 8 | @property 9 | def client_params(self): 10 | return { 'client_id': self.client.id, 'client_secret': self.client.secret } 11 | -------------------------------------------------------------------------------- /douban/libs/douban_client/api/book.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .subject import Subject 4 | 5 | 6 | class Book(Subject): 7 | 8 | target = 'book' 9 | 10 | def __repr__(self): 11 | return '' 12 | 13 | def isbn(self, isbn_id): 14 | return self._get('/v2/book/isbn/%s' % isbn_id) 15 | -------------------------------------------------------------------------------- /gaehelper/www/inc/visualize/js/example.js: -------------------------------------------------------------------------------- 1 | // Run the script on DOM ready: 2 | $(function(){ 3 | $('table').visualize({type: 'pie', height: '300px', width: '420px'}); 4 | $('table').visualize({type: 'bar', width: '420px'}); 5 | $('table').visualize({type: 'area', width: '420px'}); 6 | $('table').visualize({type: 'line', width: '420px'}); 7 | }); -------------------------------------------------------------------------------- /backup/wait4transfer.sh: -------------------------------------------------------------------------------- 1 | TMP="./xxxtransferdata.zip" 2 | URL=https://raw.githubusercontent.com/pkhopper/vavava/master/vavava/transfer.py 3 | 4 | if [ ! -f "./transfer.py" ]; then 5 | curl $URL -o "./transfer.py" 6 | fi 7 | 8 | if [! -f "$TMP" ]; then 9 | rm $TMP 10 | fi 11 | 12 | chmod +x "./transfer.py" 13 | 14 | python transfer.py --force --server --ip 0.0.0.0 --port 1239 --outputfile $TMP 15 | 16 | unzip $TMP 17 | -------------------------------------------------------------------------------- /dllive/dllive.ini.example: -------------------------------------------------------------------------------- 1 | [default] 2 | outpath = 3 | channel = 4 | liveurl = http://live.3gv.ifeng.com/live/zhongwen.m3u8 5 | addrfile = address.txt 6 | log = dllive.log 7 | log_level = info 8 | ; n parts per file 9 | npf=3 10 | freq=6 11 | 12 | [network] 13 | tmin = 10 14 | tmax = 20 15 | 16 | [proxy] 17 | enable = false 18 | addr = 19 | 20 | [favorites] 21 | pptv = http://web-play.pptv.com/web-m3u8-301228.m3u8?type=m3u8.web.pad -------------------------------------------------------------------------------- /dlvideo/parsers/base_types.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | class VidParserBase: 5 | def info(self, url, vidfmt): 6 | """ 7 | return [urls], title, ext, multi-thread, referer 8 | multi-thread: bool, can download by multi-thread each url. 9 | """ 10 | raise NotImplementedError(url) 11 | 12 | class PlayListFilterBase: 13 | def info(self, url): 14 | raise NotImplementedError(url) 15 | -------------------------------------------------------------------------------- /douban/libs/douban_client/api/movie.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .subject import Subject 4 | 5 | 6 | class Movie(Subject): 7 | 8 | target = 'movie' 9 | 10 | def __repr__(self): 11 | return '' 12 | 13 | def celebrity(self, celebrity_id): 14 | return self._get('/v2/movie/celebrity/%s' % celebrity_id) 15 | 16 | def imdb(self, imdb_id): 17 | return self._get('/v2/movie/imdb/%s' % imdb_id) 18 | -------------------------------------------------------------------------------- /backup/clean_db_shm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | SRC_PATH=./eee_linuxserver 5 | DEST_PATH=./linuxserver 6 | CLS_PATH=./linuxserver/XCLS/cls_cfg.txt 7 | DB_PATH=./db 8 | SHM_DUMP_PATH=./linuxserver/XSHMSVR/Dump 9 | DATE="`date +%Y-%m-%d_%H-%M-%S`" 10 | 11 | NEW_DB_PATH="${DB_PATH}_${DATE}" 12 | NEW_SHM_DUMP_PATH="${SHM_DUMP_PATH}_${DATE}" 13 | 14 | 15 | mv ${NEW_DB_PATH} ${NEW_DB_PATH} 16 | mv ${SHM_DUMP_PATH} ${NEW_SHM_DUMP_PATH} 17 | 18 | ipcs 19 | 20 | 需要手动删除共享残留内存 21 | 22 | -------------------------------------------------------------------------------- /douban/libs/pyoauth2/libs/connection.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import urllib 3 | 4 | class Connection(object): 5 | 6 | def __repr__(self): 7 | return '' 8 | 9 | @classmethod 10 | def build_url(cls, url, path='', params={}): 11 | params = urllib.urlencode(params) 12 | params = '?%s'%params if params else '' 13 | url = path if path.startswith('http') else '%s%s'%(url, path) 14 | return '%s%s'%(url, params) 15 | -------------------------------------------------------------------------------- /dlvideo/dlvideo.ini.example: -------------------------------------------------------------------------------- 1 | [default] 2 | outpath = ./ 3 | vidfmt = 2 4 | log = dlvideo.log 5 | log_level = debug 6 | dlmethod = wget 7 | ; n parts per file 8 | npf=5 9 | tmin=5 10 | tmax=8 11 | 12 | [u2b] 13 | u2b_cmd = 14 | u2b_proxy = 15 | u2b_cache = .u2cache 16 | u2b_create_dir = false 17 | u2b_title_format = %(title)s-%(id)s.%(ext)s 18 | 19 | [flvcd] 20 | default = true 21 | sohu.com = false 22 | youku.com = true 23 | 56.com = false 24 | tudou.com = false 25 | iqiyi.com = false 26 | -------------------------------------------------------------------------------- /backup/backup2dp.json.example: -------------------------------------------------------------------------------- 1 | { 2 | "outpath": "%(home)/Dropbox/autobackup", 3 | "settings": [ 4 | { 5 | "name": "output_name", 6 | "path": "%(home)/.bash_profile", 7 | // optional 8 | "linkfile": true 9 | // optional 10 | "ignore": [".log", ".svn"] 11 | // optional (regex) 12 | "selects": ["\.py$", "\.c$"] 13 | }, 14 | ], 15 | "includes": [ 16 | "folder_path_or_file" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ##scripts 2 | 3 | --- 4 | 5 | - backup:备份系统配置到dropbox 6 | - bt:bt种子解析 7 | - dllive:在线直播视频下载(支持M3u8、ts流),require:vavava,miniaxel 8 | - dlmusic:下载虾米音乐文件 9 | - dlvideo:(多线程)解析、下载、合并多段视频,支持youku,~~土豆~~,56,sina,a站,b站等。,require:vavava,miniaxel 10 | - douban:豆瓣部分登陆代码(auth2),for st plugin 11 | - edict:本地英语词典、笔记 12 | - gaehelper:goagent助手 13 | - miniaxel:http分段、多线程下载库 14 | - weibo:微博登陆部分 15 | - z7z8: 16 | 17 | **TODO**: 18 | - ~~python file template~~ 19 | - backup folders for cyber 20 | - ip scanner -------------------------------------------------------------------------------- /douban/libs/douban_client/api/error.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | 4 | class DoubanBaseError(Exception): 5 | def __str__(self): 6 | return "***%s (%s)*** %s" % (self.status, self.reason, self.msg) 7 | 8 | 9 | class DoubanOAuthError(DoubanBaseError): 10 | def __init__(self, status, reason, msg={}): 11 | self.status = status 12 | self.reason = reason 13 | self.msg = {} 14 | 15 | 16 | class DoubanAPIError(DoubanBaseError): 17 | 18 | def __init__(self, resp): 19 | self.status = resp.status 20 | self.reason = resp.reason 21 | self.msg = resp.parsed 22 | -------------------------------------------------------------------------------- /douban/libs/pyoauth2/libs/password.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .base import Base 4 | 5 | class Password(Base): 6 | 7 | def authorize_url(self): 8 | return NotImplementedError('The authorization endpoint is not used in this strategy') 9 | 10 | def get_token(self, username, password, **opts): 11 | params = {'grant_type': 'password', 12 | 'username': username, 13 | 'password': password, 14 | } 15 | params.update(self.client_params) 16 | opts.update(params) 17 | return self.client.get_token(**opts) 18 | 19 | -------------------------------------------------------------------------------- /gaehelper/www/inc/visualize/js/example-filtering.js: -------------------------------------------------------------------------------- 1 | // Run the script on DOM ready: 2 | $(function(){ 3 | //filtered chart 4 | $('table') 5 | .visualize({ 6 | rowFilter: ':not(:last)', 7 | colFilter: ':not(:last-child)' 8 | }) 9 | .before("

B) Charted with filters to exclude totals data

$('table').visualize({rowFilter: ':not(:last)', colFilter: ':not(:last-child)'});
"); 10 | 11 | $('table') 12 | .visualize() 13 | .before("

A) Charted without row/col filtering (not ideal with this table)

$('table').visualize();
") 14 | }); -------------------------------------------------------------------------------- /z7z8/pyfile_template.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import sys 5 | import getopt 6 | 7 | 8 | 9 | def usage(): 10 | print \ 11 | """ 12 | usage: 13 | cmd [-h] [c configfile] 14 | """ 15 | 16 | if __name__ == "__main__": 17 | config = '' 18 | opts, args = getopt.getopt(sys.argv[1:], "c:h", ["--long-one"]) 19 | for k, v in opts: 20 | if k in ("-h"): 21 | usage() 22 | exit(0) 23 | elif k in ("-c"): 24 | config = v 25 | elif k in ("--long-one"): 26 | pass 27 | else: 28 | usage() 29 | exit(0) 30 | -------------------------------------------------------------------------------- /douban/libs/pyoauth2/libs/auth_code.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from .base import Base 3 | 4 | class AuthCode(Base): 5 | 6 | def __repr__(self): 7 | return '' % self.client.id 8 | 9 | def authorize_params(self, **params): 10 | params.update({'response_type': 'code', 'client_id': self.client.id}) 11 | return params 12 | 13 | def authorize_url(self, **params): 14 | params = self.authorize_params(**params) 15 | return self.client.authorize_url(params) 16 | 17 | def get_token(self, code, **opts): 18 | params = {'grant_type': 'authorization_code', 'code': code} 19 | params.update(self.client_params) 20 | opts.update(params) 21 | return self.client.get_token(**opts) 22 | -------------------------------------------------------------------------------- /gaehelper/dnslib/test/google.com-AAAA: -------------------------------------------------------------------------------- 1 | ;; Sending: 2 | ;; QUERY: 21590100000100000000000006676f6f676c6503636f6d00001c0001 3 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8537 4 | ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 5 | ;; QUESTION SECTION: 6 | ;google.com. IN AAAA 7 | 8 | ;; Got answer: 9 | ;; RESPONSE: 21598180000100010000000006676f6f676c6503636f6d00001c0001c00c001c00010000009100102a001450400908050000000000001000 10 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8537 11 | ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 12 | ;; QUESTION SECTION: 13 | ;google.com. IN AAAA 14 | ;; ANSWER SECTION: 15 | google.com. 145 IN AAAA 2a00:1450:4009:805::1000 16 | 17 | -------------------------------------------------------------------------------- /gaehelper/www/inc/visualize/js/example-editable.js: -------------------------------------------------------------------------------- 1 | 2 | //make table editable, refresh charts on blur$(function(){ 3 | $(function(){ 4 | $('table').visualize({type: 'pie', height: '300px', width: '420px'}); 5 | 6 | $('table td') 7 | .click(function(){ 8 | if( !$(this).is('.input') ){ 9 | $(this).addClass('input') 10 | .html('') 11 | .find('input').focus() 12 | .blur(function(){ 13 | //remove td class, remove input 14 | $(this).parent().removeClass('input').html($(this).val() || 0); 15 | //update charts 16 | $('.visualize').trigger('visualizeRefresh'); 17 | }); 18 | } 19 | }) 20 | .hover(function(){ $(this).addClass('hover'); },function(){ $(this).removeClass('hover'); }); 21 | }); -------------------------------------------------------------------------------- /dlvideo/parsers/util.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import re 5 | 6 | def r1(pattern, text, flag=0): 7 | m = re.search(pattern, text, flag) 8 | if m: 9 | return m.group(1) 10 | 11 | def r0(pattern, text, flag=0): 12 | m = re.search(pattern, text, flag) 13 | if m: 14 | return m.group(0) 15 | 16 | def unescape_html(html): 17 | import xml.sax.saxutils 18 | html = xml.sax.saxutils.unescape(html) 19 | html = re.sub(r'&#(\d+);', lambda x: unichr(int(x.group(1))), html) 20 | return html 21 | 22 | def escape_file_path(path): 23 | path = path.replace('/', '_') 24 | path = path.replace('\\', '_') 25 | path = path.replace('*', '_') 26 | path = path.replace('?', '_') 27 | path = path.replace('\'', '_') 28 | return path 29 | -------------------------------------------------------------------------------- /gaehelper/dnslib/test/facebook.com-AAAA: -------------------------------------------------------------------------------- 1 | ;; Sending: 2 | ;; QUERY: 520a010000010000000000000866616365626f6f6b03636f6d00001c0001 3 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21002 4 | ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 5 | ;; QUESTION SECTION: 6 | ;facebook.com. IN AAAA 7 | 8 | ;; Got answer: 9 | ;; RESPONSE: 520a818000010001000000000866616365626f6f6b03636f6d00001c0001c00c001c00010000022100102a0328802110df07faceb00c00000001 10 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21002 11 | ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 12 | ;; QUESTION SECTION: 13 | ;facebook.com. IN AAAA 14 | ;; ANSWER SECTION: 15 | facebook.com. 545 IN AAAA 2a03:2880:2110:df07:face:b00c:0:1 16 | 17 | -------------------------------------------------------------------------------- /gaehelper/dnslib/test/_sip._udp.sipgate.co.uk-SRV: -------------------------------------------------------------------------------- 1 | ;; Sending: 2 | ;; QUERY: 923001000001000000000000045f736970045f756470077369706761746502636f02756b0000210001 3 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37424 4 | ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 5 | ;; QUESTION SECTION: 6 | ;_sip._udp.sipgate.co.uk. IN SRV 7 | 8 | ;; Got answer: 9 | ;; RESPONSE: 923081800001000100000000045f736970045f756470077369706761746502636f02756b0000210001c00c002100010000017800150000000013c4077369706761746502636f02756b00 10 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37424 11 | ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 12 | ;; QUESTION SECTION: 13 | ;_sip._udp.sipgate.co.uk. IN SRV 14 | ;; ANSWER SECTION: 15 | _sip._udp.sipgate.co.uk. 376 IN SRV 0 0 5060 sipgate.co.uk. 16 | 17 | -------------------------------------------------------------------------------- /douban/libs/douban_client/api/subject.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .base import DoubanAPIBase, DEFAULT_START, DEFAULT_COUNT 4 | from .review import Review 5 | 6 | 7 | class Subject(DoubanAPIBase): 8 | 9 | target = None 10 | 11 | def get(self, id): 12 | return self._get('/v2/%s/%s' % (self.target, id)) 13 | 14 | def search(self, q='', tag='', start=DEFAULT_START, count=DEFAULT_COUNT): 15 | return self._get('/v2/%s/search' % self.target, 16 | q=q, tag=tag, start=start, count=count) 17 | 18 | def tags(self, id): 19 | return self._get('/v2/%s/%s/tags' % (self.target, id)) 20 | 21 | def tagged_list(self, id): 22 | return self._get('/v2/%s/user_tags/%s' % (self.target, id)) 23 | 24 | @property 25 | def review(self): 26 | return Review(self.access_token, self.target) 27 | -------------------------------------------------------------------------------- /gaehelper/dnslib/test/google.com-SOA: -------------------------------------------------------------------------------- 1 | ;; Sending: 2 | ;; QUERY: 4cce0100000100000000000006676f6f676c6503636f6d0000060001 3 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19662 4 | ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 5 | ;; QUESTION SECTION: 6 | ;google.com. IN SOA 7 | 8 | ;; Got answer: 9 | ;; RESPONSE: 4cce8180000100010000000006676f6f676c6503636f6d0000060001c00c000600010000545f0026036e7331c00c09646e732d61646d696ec00c780b88a800001c2000000708001275000000012c 10 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19662 11 | ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 12 | ;; QUESTION SECTION: 13 | ;google.com. IN SOA 14 | ;; ANSWER SECTION: 15 | google.com. 21599 IN SOA ns1.google.com. dns-admin.google.com. 2014021800 7200 1800 1209600 300 16 | 17 | -------------------------------------------------------------------------------- /dlvideo/parsers/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import sys 5 | reload(sys).setdefaultencoding("utf8") 6 | import tudou 7 | import sohu 8 | import w56 9 | import iqiyi 10 | import youku 11 | import flvcd 12 | import yytingting 13 | 14 | def getVidPageParser(url): 15 | if url.find('sohu.com') > 0: 16 | return sohu.Sohu() 17 | elif url.find('tudou.com') > 0: 18 | return tudou.Tudou() 19 | elif url.find('56.com') > 0: 20 | return w56.W56() 21 | elif url.find('iqiyi.com') > 0: 22 | return iqiyi.Iqiyi() 23 | elif url.find('yytingting.com') > 0: 24 | return yytingting.Yytingting() 25 | else: 26 | return flvcd.FLVCD() 27 | 28 | def getPlayListParser(url): 29 | if url.find('youku.com') > 0: 30 | return youku.YoukuPlaylist() 31 | if url.find('sohu.com') > 0: 32 | return sohu.SohuPlaylist() 33 | -------------------------------------------------------------------------------- /gaehelper/www/inc/visualize/css/basic.css: -------------------------------------------------------------------------------- 1 | /* page styles */ 2 | body { font-family: "Segoe UI", Frutiger,Tahoma,Helvetica,"Helvetica Neue", Arial, sans-serif; } 3 | table { border-collapse: collapse; } 4 | td, th { 5 | text-align: center; 6 | border: 1px solid #ddd; 7 | padding:2px 5px; 8 | } 9 | 10 | caption {margin: 0 0 .5em; font-weight: bold; } 11 | /* Logo */ 12 | .header { 13 | background: #247201 url(http://filamentgroup.com/images/headerbg-new.jpg) no-repeat bottom left; 14 | } 15 | #fg-logo { 16 | text-indent: -9999px; 17 | margin: 0 auto; 18 | width: 287px; 19 | height: 52px; 20 | background-image: url(http://filamentgroup.com/images/fg-logo-icon.png); 21 | } 22 | @media (-webkit-min-device-pixel-ratio: 1.5), (min-device-pixel-ratio: 1.5){ 23 | #fg-logo { 24 | background-size: 287px 52px; 25 | background-image: url(http://filamentgroup.com/images/fg-logo-icon-lrg.png); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /gaehelper/dnslib/test/in-addr.arpa-PTR: -------------------------------------------------------------------------------- 1 | ;; Sending: 2 | ;; QUERY: 815d01000001000000000000033130330239310332343902363607696e2d61646472046172706100000c0001 3 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33117 4 | ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 5 | ;; QUESTION SECTION: 6 | ;103.91.249.66.in-addr.arpa. IN PTR 7 | 8 | ;; Got answer: 9 | ;; RESPONSE: 815d81800001000100000000033130330239310332343902363607696e2d61646472046172706100000c0001c00c000c00010000542b002d20726174652d6c696d697465642d70726f78792d36362d3234392d39312d31303306676f6f676c6503636f6d00 10 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33117 11 | ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 12 | ;; QUESTION SECTION: 13 | ;103.91.249.66.in-addr.arpa. IN PTR 14 | ;; ANSWER SECTION: 15 | 103.91.249.66.in-addr.arpa. 21547 IN PTR rate-limited-proxy-66-249-91-103.google.com. 16 | 17 | -------------------------------------------------------------------------------- /gaehelper/dnslib/test/google.com-TXT: -------------------------------------------------------------------------------- 1 | ;; Sending: 2 | ;; QUERY: 0cbe0100000100000000000006676f6f676c6503636f6d0000100001 3 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3262 4 | ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 5 | ;; QUESTION SECTION: 6 | ;google.com. IN TXT 7 | 8 | ;; Got answer: 9 | ;; RESPONSE: 0cbe8180000100010000000006676f6f676c6503636f6d0000100001c00c0010000100000e0f004c4b763d7370663120696e636c7564653a5f7370662e676f6f676c652e636f6d206970343a3231362e37332e39332e37302f3331206970343a3231362e37332e39332e37322f3331207e616c6c 10 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3262 11 | ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 12 | ;; QUESTION SECTION: 13 | ;google.com. IN TXT 14 | ;; ANSWER SECTION: 15 | google.com. 3599 IN TXT "v=spf1 include:_spf.google.com ip4:216.73.93.70/31 ip4:216.73.93.72/31 ~all" 16 | 17 | -------------------------------------------------------------------------------- /douban/libs/douban_client/api/review.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .base import DoubanAPIBase 4 | 5 | 6 | class Review(DoubanAPIBase): 7 | 8 | def __init__(self, access_token, target): 9 | self.access_token = access_token 10 | self.target = target 11 | 12 | def new(self, target_id, title, content, rating=''): 13 | data = {self.target: target_id, 14 | 'title': title, 15 | 'content': content, 16 | 'rating': rating, } 17 | return self._post('/v2/%s/reviews' % self.target, **data) 18 | 19 | def update(self, id, title, content, rating=''): 20 | data = {self.target: id, 21 | 'title': title, 22 | 'content': content, 23 | 'rating': rating, } 24 | return self._put('/v2/%s/review/%s' % (self.target, id), **data) 25 | 26 | def delete(self, id): 27 | return self._delete('/v2/%s/review/%s' % (self.target, id)) 28 | -------------------------------------------------------------------------------- /gaehelper/dnslib/test/e164.org-NAPTR: -------------------------------------------------------------------------------- 1 | ;; Sending: 2 | ;; QUERY: 1235010000010000000000000130013001300130013101310131013301390133013001310138013701380465313634036f72670000230001 3 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4661 4 | ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 5 | ;; QUESTION SECTION: 6 | ;0.0.0.0.1.1.1.3.9.3.0.1.8.7.8.e164.org. IN NAPTR 7 | 8 | ;; Got answer: 9 | ;; RESPONSE: 1235818000010001000000000130013001300130013101310131013301390133013001310138013701380465313634036f72670000230001c00c002300010000540200320064000a0175074532552b53495022215e5c2b3f282e2a2924217369703a5c5c31406677642e70756c7665722e636f6d2100 10 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4661 11 | ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 12 | ;; QUESTION SECTION: 13 | ;0.0.0.0.1.1.1.3.9.3.0.1.8.7.8.e164.org. IN NAPTR 14 | ;; ANSWER SECTION: 15 | 0.0.0.0.1.1.1.3.9.3.0.1.8.7.8.e164.org. 21506 IN NAPTR 100 10 "u" "E2U+SIP" "!^\\+?(.*)$!sip:\\\\1@fwd.pulver.com!" . 16 | 17 | -------------------------------------------------------------------------------- /douban/libs/douban_client/api/comment.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .base import DoubanAPIBase, DEFAULT_START, DEFAULT_COUNT 4 | 5 | 6 | class Comment(DoubanAPIBase): 7 | 8 | def __init__(self, access_token, target): 9 | self.access_token = access_token 10 | self.target = target 11 | 12 | def __repr__(self): 13 | return '' 14 | 15 | def list(self, target_id, start=DEFAULT_START, count=DEFAULT_COUNT): 16 | return self._get('/v2/%s/%s/comments' % (self.target, target_id), 17 | start=start, count=count) 18 | 19 | def new(self, target_id, content): 20 | return self._post('/v2/%s/%s/comments' % (self.target, target_id), 21 | content=content) 22 | 23 | def get(self, target_id, id): 24 | return self._get('/v2/%s/%s/comment/%s' % (self.target, target_id, id)) 25 | 26 | def delete(self, target_id, id): 27 | return self._delete('/v2/%s/%s/comment/%s' % (self.target, target_id, id)) 28 | -------------------------------------------------------------------------------- /dlvideo/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding = utf-8 3 | 4 | from setuptools import setup, find_packages 5 | 6 | PACKAGE = "vavava" 7 | NAME = "vavava" 8 | DESCRIPTION = "tools" 9 | AUTHOR = "vavava" 10 | AUTHOR_EMAIL = "pk13610@gmail.com" 11 | URL = "http://www.github.com/pkhopper" 12 | VERSION = __import__(PACKAGE).__version__ 13 | 14 | setup( 15 | name = NAME, 16 | version = VERSION, 17 | description = DESCRIPTION, 18 | long_description = open("README.rst").read(), 19 | author = AUTHOR, 20 | author_email = AUTHOR_EMAIL, 21 | license = "BSD", 22 | url = URL, 23 | packages = find_packages(exclude = ["test.*", "test"]), 24 | # package_data = [], 25 | classifiers = [ 26 | "Development Status :: 3 - Alpha", 27 | "Environment :: Web Environment", 28 | "Intended Audience :: Developers", 29 | "License :: OSI Approved :: BSD License", 30 | "Operating System :: OS Independent", 31 | "Programming Language :: Python", 32 | "Framework :: Django", 33 | ], 34 | zip_safe = False, 35 | # requires = [] 36 | ) 37 | -------------------------------------------------------------------------------- /miniaxel/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding = utf-8 3 | 4 | from setuptools import setup, find_packages 5 | 6 | PACKAGE = "miniaxel" 7 | NAME = "miniaxel" 8 | DESCRIPTION = "tools" 9 | AUTHOR = "vavava" 10 | AUTHOR_EMAIL = "pk13610@gmail.com" 11 | URL = "http://www.github.com/pkhopper" 12 | VERSION = __import__(PACKAGE).__version__ 13 | 14 | setup( 15 | name = NAME, 16 | version = VERSION, 17 | description = DESCRIPTION, 18 | long_description = open("README.rst").read(), 19 | author = AUTHOR, 20 | author_email = AUTHOR_EMAIL, 21 | license = "BSD", 22 | url = URL, 23 | packages = find_packages(exclude = ["test.*", "test"]), 24 | # package_data = [], 25 | classifiers = [ 26 | "Development Status :: 3 - Alpha", 27 | "Environment :: Web Environment", 28 | "Intended Audience :: Developers", 29 | "License :: OSI Approved :: BSD License", 30 | "Operating System :: OS Independent", 31 | "Programming Language :: Python", 32 | "Framework :: Django", 33 | ], 34 | zip_safe = False, 35 | requires = ['vavava'] 36 | ) 37 | -------------------------------------------------------------------------------- /dlmusic/xiami_dl.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | # -*- coding: utf-8 -*- 3 | 4 | import urllib2 5 | import subprocess 6 | import sys 7 | 8 | 9 | def get_downloader(name=None): 10 | if not name: 11 | name = { 12 | 'win32': 'urllib2' 13 | }.get(sys.platform, 'wget') 14 | 15 | return { 16 | 'urllib2': urllib2_downloader, 17 | 'wget': wget_downloader 18 | }.get(name, None) 19 | 20 | 21 | def urllib2_downloader(url, dest, headers): 22 | request = urllib2.Request(url) 23 | for h in headers: 24 | request.add_header(h, headers[h]) 25 | try: 26 | response = urllib2.urlopen(request) 27 | with open(dest, 'wb') as output: 28 | output.write(response.read()) 29 | except IOError as e: 30 | print e 31 | except urllib2.URLError as e: 32 | print e 33 | 34 | 35 | def wget_downloader(url, dest, headers): 36 | wget_opts = ['wget', url, '-O', dest] 37 | for h in headers: 38 | wget_opts.append('--header=%s:%s' % (h, headers[h])) 39 | exit_code = subprocess.call(wget_opts) 40 | if exit_code != 0: 41 | raise Exception('wget exited abnormaly') 42 | -------------------------------------------------------------------------------- /douban/libs/douban_client/api/user.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .base import DoubanAPIBase, DEFAULT_START, DEFAULT_COUNT 4 | 5 | 6 | class User(DoubanAPIBase): 7 | 8 | def __repr__(self): 9 | return '' 10 | 11 | def get(self, id): 12 | return self._get('/v2/user/%s' % id) 13 | 14 | @property 15 | def me(self): 16 | return self.get('~me') 17 | 18 | def search(self, q, start=DEFAULT_START, count=DEFAULT_COUNT): 19 | return self._get('/v2/user', q=q, start=start, count=count) 20 | 21 | def follow(self, id): 22 | return self._post('/shuo/v2/friendships/create', user_id=id) 23 | 24 | def unfollow(self, id): 25 | return self._post('/shuo/v2/friendships/destroy', user_id=id) 26 | 27 | def following(self, id, start=DEFAULT_START, count=DEFAULT_COUNT): 28 | page = start / count 29 | return self._get('/shuo/v2/users/%s/following' % id, page=page, count=count) 30 | 31 | def followers(self, id, start=DEFAULT_START, count=DEFAULT_COUNT): 32 | page = start / count 33 | return self._get('/shuo/v2/users/%s/followers' % id, page=page, count=count) 34 | -------------------------------------------------------------------------------- /douban/libs/douban_client/api/photo.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .base import DoubanAPIBase, DEFAULT_START, DEFAULT_COUNT 4 | from .comment import Comment 5 | 6 | 7 | class Photo(DoubanAPIBase): 8 | 9 | target = 'photo' 10 | 11 | def __repr__(self): 12 | return '' 13 | 14 | def get(self, id): 15 | return self._get('/v2/photo/%s' % id) 16 | 17 | def new(self, album_id, image, desc=''): 18 | return self._post('/v2/album/%s' % album_id, 19 | desc=desc, files={'image': image}) 20 | 21 | def update(self, id, desc): 22 | return self._put('/v2/photo/%s' % id, desc=desc) 23 | 24 | def delete(self, id): 25 | return self._delete('/v2/photo/%s' % id) 26 | 27 | def like(self, id): 28 | return self._post('/v2/photo/%s/like' % id) 29 | 30 | def unlike(self, id): 31 | return self._delete('/v2/photo/%s/like' % id) 32 | 33 | def comments(self, id, start=DEFAULT_START, count=DEFAULT_COUNT): 34 | return Comment(self.access_token, self.target).list(id, start=start, count=count) 35 | 36 | @property 37 | def comment(self): 38 | return Comment(self.access_token, self.target) 39 | -------------------------------------------------------------------------------- /z7z8/ziputil.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import sys 5 | import getopt 6 | import zipfile 7 | import os 8 | 9 | 10 | def usage(): 11 | print \ 12 | """ 13 | usage: 14 | cmd [-h] [c configfile] 15 | """ 16 | 17 | def xxxx(): 18 | print "Processing File " + sys.argv[1] 19 | file=zipfile.ZipFile(sys.argv[1],"r"); 20 | for name in file.namelist(): 21 | utf8name=name.decode('gbk') 22 | print "Extracting " + utf8name 23 | pathname = os.path.dirname(utf8name) 24 | if not os.path.exists(pathname) and pathname!= "": 25 | os.makedirs(pathname) 26 | data = file.read(name) 27 | if not os.path.exists(utf8name): 28 | fo = open(utf8name, "w") 29 | fo.write(data) 30 | fo.close 31 | file.close() 32 | 33 | if __name__ == "__main__": 34 | config = '' 35 | opts, args = getopt.getopt(sys.argv[1:], "c:h", ["--long-one"]) 36 | for k, v in opts: 37 | if k in ("-h"): 38 | usage() 39 | exit(0) 40 | elif k in ("-c"): 41 | config = v 42 | elif k in ("--long-one"): 43 | pass 44 | else: 45 | usage() 46 | exit(0) 47 | -------------------------------------------------------------------------------- /gaehelper/dnslib/test/google.com-MX: -------------------------------------------------------------------------------- 1 | ;; Sending: 2 | ;; QUERY: c1e20100000100000000000006676f6f676c6503636f6d00000f0001 3 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49634 4 | ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 5 | ;; QUESTION SECTION: 6 | ;google.com. IN MX 7 | 8 | ;; Got answer: 9 | ;; RESPONSE: c1e28180000100050000000006676f6f676c6503636f6d00000f0001c00c000f0001000001fa0011001404616c7431056173706d78016cc00cc00c000f0001000001fa0009002804616c7433c02fc00c000f0001000001fa0009003204616c7434c02fc00c000f0001000001fa0009001e04616c7432c02fc00c000f0001000001fa0004000ac02f 10 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49634 11 | ;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 0 12 | ;; QUESTION SECTION: 13 | ;google.com. IN MX 14 | ;; ANSWER SECTION: 15 | google.com. 506 IN MX 20 alt1.aspmx.l.google.com. 16 | google.com. 506 IN MX 40 alt3.aspmx.l.google.com. 17 | google.com. 506 IN MX 50 alt4.aspmx.l.google.com. 18 | google.com. 506 IN MX 30 alt2.aspmx.l.google.com. 19 | google.com. 506 IN MX 10 aspmx.l.google.com. 20 | 21 | -------------------------------------------------------------------------------- /gaehelper/www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 11 | 15 | 16 | 22 | 23 | 24 | 25 |
26 | 27 |
28 |
29 |
30 | 31 |
32 |
33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /gaehelper/dnslib/test/sip2sip.info-NAPTR: -------------------------------------------------------------------------------- 1 | ;; Sending: 2 | ;; QUERY: d78201000001000000000000077369703273697004696e666f0000230001 3 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55170 4 | ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 5 | ;; QUESTION SECTION: 6 | ;sip2sip.info. IN NAPTR 7 | 8 | ;; Got answer: 9 | ;; RESPONSE: d78281800001000300000000077369703273697004696e666f0000230001c00c0023000100000dce0027001e00640173075349502b44325500045f736970045f756470077369703273697004696e666f00c00c0023000100000dce002900050064017308534950532b44325400055f73697073045f746370077369703273697004696e666f00c00c0023000100000dce0027000a00640173075349502b44325400045f736970045f746370077369703273697004696e666f00 10 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55170 11 | ;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0 12 | ;; QUESTION SECTION: 13 | ;sip2sip.info. IN NAPTR 14 | ;; ANSWER SECTION: 15 | sip2sip.info. 3534 IN NAPTR 30 100 "s" "SIP+D2U" "" _sip._udp.sip2sip.info. 16 | sip2sip.info. 3534 IN NAPTR 5 100 "s" "SIPS+D2T" "" _sips._tcp.sip2sip.info. 17 | sip2sip.info. 3534 IN NAPTR 10 100 "s" "SIP+D2T" "" _sip._tcp.sip2sip.info. 18 | 19 | -------------------------------------------------------------------------------- /dlvideo/parsers/youku.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | from bs4 import BeautifulSoup 5 | from base_types import PlayListFilterBase 6 | from vavava.httputil import HttpUtil 7 | 8 | 9 | class YoukuPlaylist(PlayListFilterBase): 10 | def __items(self, html, soup): 11 | ul = soup.find('ul', attrs={'class': 'items'}) 12 | lis = ul.findAll('li', attrs={'class': 'item'}) 13 | return [li.a['href'] for li in lis] 14 | 15 | def __title(self, html, soup): 16 | h1 = soup.find("h1", attrs={'class': 'title'}) 17 | title = h1.find('a') 18 | if title: 19 | title = title.text 20 | else: 21 | title = soup.find('h3', attrs={'class': 'title'}) 22 | title = title.find('a').text 23 | return title 24 | 25 | def info(self, url): 26 | if url.find('youku.com') < 0: 27 | raise ValueError('not a youku.com video url') 28 | html = HttpUtil().get(url) 29 | soup = BeautifulSoup(html) 30 | self.title = self.__title(html, soup) 31 | self.items = self.__items(html, soup) 32 | return self.title, self.items 33 | 34 | if __name__ == "__main__": 35 | url = r'http://www.youku.com/show_page/id_zcbfdc4cc962411de83b1.html' 36 | YoukuPlaylist().info(url) 37 | 38 | -------------------------------------------------------------------------------- /gaehelper/dnslib/test/dig/google.com-A.dig: -------------------------------------------------------------------------------- 1 | 2 | ; <<>> DiG 9.8.5-P1 <<>> +qr google.com 3 | ;; global options: +cmd 4 | ;; Sending: 5 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23706 6 | ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 7 | 8 | ;; QUESTION SECTION: 9 | ;google.com. IN A 10 | 11 | ;; Got answer: 12 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23706 13 | ;; flags: qr rd ra; QUERY: 1, ANSWER: 16, AUTHORITY: 0, ADDITIONAL: 0 14 | 15 | ;; QUESTION SECTION: 16 | ;google.com. IN A 17 | 18 | ;; ANSWER SECTION: 19 | google.com. 299 IN A 62.252.169.183 20 | google.com. 299 IN A 62.252.169.152 21 | google.com. 299 IN A 62.252.169.172 22 | google.com. 299 IN A 62.252.169.177 23 | google.com. 299 IN A 62.252.169.157 24 | google.com. 299 IN A 62.252.169.153 25 | google.com. 299 IN A 62.252.169.182 26 | google.com. 299 IN A 62.252.169.168 27 | google.com. 299 IN A 62.252.169.178 28 | google.com. 299 IN A 62.252.169.162 29 | google.com. 299 IN A 62.252.169.187 30 | google.com. 299 IN A 62.252.169.167 31 | google.com. 299 IN A 62.252.169.148 32 | google.com. 299 IN A 62.252.169.173 33 | google.com. 299 IN A 62.252.169.158 34 | google.com. 299 IN A 62.252.169.163 35 | 36 | ;; Query time: 42 msec 37 | ;; SERVER: 10.0.1.1#53(10.0.1.1) 38 | ;; WHEN: Mon May 05 12:01:30 BST 2014 39 | ;; MSG SIZE rcvd: 284 40 | 41 | -------------------------------------------------------------------------------- /douban/libs/douban_client/api/discussion.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .base import DoubanAPIBase, DEFAULT_START, DEFAULT_COUNT 4 | from .comment import Comment 5 | 6 | 7 | class Discussion(DoubanAPIBase): 8 | 9 | target = 'discussion' 10 | 11 | def __repr__(self): 12 | return '' 13 | 14 | def get(self, id): 15 | return self._get('/v2/discussion/%s' % id) 16 | 17 | def new(self, target, target_id, title, content): 18 | return self._post('/v2/%s/%s/discussions' % (target, target_id), 19 | title=title, content=content) 20 | 21 | def list(self, target, target_id, start=DEFAULT_START, count=DEFAULT_COUNT): 22 | return self._get('/v2/%s/%s/discussions' % (target, target_id), 23 | start=start, count=count) 24 | 25 | def update(self, id, title, content): 26 | return self._put('/v2/discussion/%s' % id, 27 | title=title, content=content) 28 | 29 | def delete(self, id): 30 | return self._delete('/v2/discussion/%s' % id) 31 | 32 | def comments(self, id, start=DEFAULT_START, count=DEFAULT_COUNT): 33 | return Comment(self.access_token, self.target).list(id, start=start, count=count) 34 | 35 | @property 36 | def comment(self): 37 | return Comment(self.access_token, self.target) 38 | -------------------------------------------------------------------------------- /dlvideo/parsers/w56.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import json 4 | 5 | from base_types import * 6 | from util import * 7 | from vavava.httputil import HttpUtil 8 | 9 | 10 | def w56_download_by_id(id, refer, vidfmt=0, merge=True): 11 | html = HttpUtil().get('http://vxml.56.com/json/%s/?src=site'%id) 12 | info = json.loads(html)['info'] 13 | title = info['Subject'] 14 | # assert title 15 | # hd = info['hd'] 16 | # assert hd in (0, 1, 2) 17 | # type = ['normal', 'clear', 'super'][hd] 18 | assert vidfmt in (0, 1, 2) 19 | type = ['normal', 'clear', 'super'][vidfmt] 20 | files = [x for x in info['rfiles'] if x['type'] == type] 21 | assert len(files) == 1 22 | size = int(files[0]['filesize']) 23 | url = files[0]['url'] 24 | ext = r1(r'\.([^.]+)\?', url) 25 | assert ext in ('flv', 'mp4') 26 | return [url], title, str(ext), 1, None 27 | 28 | def w56_download(url, vidfmt): 29 | # id = r1(r'http://www.56.com/u\d+/v_(\w+).html', url) 30 | id = r1(r'[-|_]+(\w+).html', url) 31 | return w56_download_by_id(id, url, vidfmt=vidfmt) 32 | 33 | class W56(VidParserBase): 34 | def info(self, url, vidfmt=0): 35 | return w56_download(url, vidfmt=vidfmt) 36 | 37 | if __name__ == '__main__': 38 | url = r'http://www.56.com/u92/v_NDgzNzQ3Mzc.html' 39 | url = r'http://www.56.com/w99/play_album-aid-9904987_vid-NjgxODA5NTI.html' 40 | print W56().info(url) 41 | -------------------------------------------------------------------------------- /backup/excel_merge.vba: -------------------------------------------------------------------------------- 1 | Sub merge() 2 | ' last row count is: .UsedRange.Rows.Count + .UsedRange.Row - 1 3 | ' ref: https://www.mrexcel.com/forum/excel-questions/693294-activesheet-usedrange-rows-count-returning-wrong-value.html 4 | Dim MyPath, MyName, AWbName 5 | Dim Wb As Workbook, WbN As String 6 | Dim G As Long 7 | Dim Num As Long 8 | Dim BOX As String 9 | Application.ScreenUpdating = False 10 | MyPath = ActiveWorkbook.Path 11 | MyName = Dir(MyPath & "\" & "*.xls") 12 | AWbName = ActiveWorkbook.Name 13 | 14 | Num = 0 15 | Do While MyName <> "" 16 | If MyName <> AWbName Then 17 | Set Wb = Workbooks.Open(MyPath & "\" & MyName) 18 | Num = Num + 1 19 | With Workbooks(1).ActiveSheet 20 | next_row = .UsedRange.Rows.Count + .UsedRange.Row 21 | .Cells(next_row, 1) = Left(MyName, Len(MyName) - 4) 22 | For G = 1 To Sheets.Count 23 | next_row = .UsedRange.Rows.Count + .UsedRange.Row 24 | Wb.Sheets(G).UsedRange.Copy .Cells(next_row, 1) 25 | Next 26 | WbN = WbN & Chr(13) & Wb.Name 27 | Wb.Close False 28 | End With 29 | End If 30 | MyName = Dir 31 | Loop 32 | Range("B1").Select 33 | Application.ScreenUpdating = True 34 | MsgBox "" & Num & "" & Chr(13) & WbN, vbInformation, "" 35 | End Sub 36 | -------------------------------------------------------------------------------- /douban/libs/douban_client/api/base.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from pyoauth2 import AccessToken 4 | 5 | from .error import DoubanAPIError, DoubanOAuthError 6 | 7 | DEFAULT_START = 0 8 | DEFAULT_COUNT = 20 9 | 10 | 11 | def check_execption(func): 12 | def _check(*arg, **kws): 13 | resp = func(*arg, **kws) 14 | if resp.status >= 400: 15 | raise DoubanAPIError(resp) 16 | body = resp.body 17 | if body: 18 | return resp.parsed 19 | return body 20 | return _check 21 | 22 | 23 | class DoubanAPIBase(object): 24 | 25 | def __init__(self, access_token): 26 | self.access_token = access_token 27 | if not isinstance(self.access_token, AccessToken): 28 | raise DoubanOAuthError(401, 'UNAUTHORIZED') 29 | 30 | def __repr__(self): 31 | return '' 32 | 33 | @check_execption 34 | def _get(self, url, **opts): 35 | return self.access_token.get(url, **opts) 36 | 37 | @check_execption 38 | def _post(self, url, **opts): 39 | return self.access_token.post(url, **opts) 40 | 41 | @check_execption 42 | def _put(self, url, **opts): 43 | return self.access_token.put(url, **opts) 44 | 45 | @check_execption 46 | def _patch(self, url, **opts): 47 | return self.access_token.patch(url, **opts) 48 | 49 | @check_execption 50 | def _delete(self, url, **opts): 51 | return self.access_token.delete(url, **opts) 52 | -------------------------------------------------------------------------------- /dlvideo/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import sys 5 | import unittest 6 | import dlvideo 7 | import dl_helper 8 | 9 | class TestParsers(unittest.TestCase): 10 | def test_urls(self): 11 | import parsers 12 | urls = [ 13 | 'http://tv.sohu.com/20120726/n349115692.shtml', 14 | # 'http://v.youku.com/v_show/id_XNzM3MTQwMDY4.html?f=22506977&ev=1', 15 | 'http://www.56.com/u52/v_MTE4NjA0MDY1.html', 16 | 'http://www.tudou.com/programs/view/ZAoQTPEqjAo/', 17 | # 'http://www.iqiyi.com/v_19rrhkqzgo.html' 18 | ] 19 | for url in urls: 20 | print parsers.getVidPageParser(url).info(url) 21 | 22 | def test_playlist(self): 23 | import parsers 24 | urls = [ 25 | 'http://tv.sohu.com/20120726/n349115692.shtml', 26 | 'http://v.youku.com/v_show/id_XNDIwNjkzMzky.html', 27 | 'http://v.youku.com/v_show/id_XNzIyOTE1NTUy.html?f=22331872', 28 | ] 29 | for url in urls: 30 | print parsers.getPlayListParser(url).info(url) 31 | 32 | class TestDl_helper(unittest.TestCase): 33 | def test_dlhelper(self): 34 | filename = """a\\b'c/d.test""" 35 | result = dl_helper.escape_file_path(filename) 36 | self.assertEqual(result, 'a_b_c_d.test') 37 | 38 | def suite(): 39 | suite = unittest.TestSuite() 40 | suite.addTest(TestDl_helper()) 41 | suite.addTest(TestParsers()) 42 | return suite 43 | 44 | if __name__ == "__main__": 45 | # unittest.main(defaultTest = 'suite') 46 | runner = unittest.TextTestRunner() 47 | runner.run(suite) 48 | -------------------------------------------------------------------------------- /douban/libs/douban_client/api/doumail.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .base import DoubanAPIBase, DEFAULT_START, DEFAULT_COUNT 4 | 5 | 6 | class Doumail(DoubanAPIBase): 7 | 8 | def __repr__(self): 9 | return '' 10 | 11 | def get(self, id): 12 | return self._get('/v2/doumail/%s' % id) 13 | 14 | def inbox(self, start=DEFAULT_START, count=DEFAULT_COUNT): 15 | return self._get('/v2/doumail/inbox', start=start, count=count) 16 | 17 | def outbox(self, start=DEFAULT_START, count=DEFAULT_COUNT): 18 | return self._get('/v2/doumail/outbox', start=start, count=count) 19 | 20 | def unread(self, start=DEFAULT_START, count=DEFAULT_COUNT): 21 | return self._get('/v2/doumail/inbox/unread', start=start, count=count) 22 | 23 | def read(self, id): 24 | return self._put('/v2/doumail/%s' % id, key='key') 25 | 26 | def reads(self, ids): 27 | if isinstance(ids, (list, tuple)): 28 | ids = ','.join(ids) 29 | return self._put('/v2/doumail/read', ids=ids) 30 | 31 | def delete(self, id): 32 | return self._delete('/v2/doumail/%s' % id) 33 | 34 | def deletes(self, ids): 35 | if isinstance(ids, (tuple, list)): 36 | ids = ','.join(ids) 37 | return self._post('/v2/doumail/delete', ids=ids) 38 | 39 | def new(self, title, content, receiver_id, captcha_token=None, captcha_string=None): 40 | return self._post('/v2/doumails', 41 | title=title, content=content, receiver_id=receiver_id, 42 | captcha_toke=captcha_token, captcha_string=captcha_string) 43 | -------------------------------------------------------------------------------- /douban/libs/pyoauth2/libs/response.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import urlparse 3 | import json 4 | 5 | def to_json(txt): 6 | try: 7 | return json.loads(txt) 8 | except ValueError: 9 | return txt 10 | 11 | def to_query(txt): 12 | qs = urlparse.parse_qsl(txt) 13 | ret = dict(qs) 14 | return _check_expires_in(ret) 15 | 16 | def to_text(txt): 17 | return txt 18 | 19 | def _check_expires_in(ret): 20 | expires_in = ret.get('expires_in') 21 | if expires_in and expires_in.isdigit(): 22 | ret['expires_in'] = int(expires_in) 23 | return ret 24 | 25 | PARSERS = { 26 | 'text': to_text, 27 | 'json': to_json, 28 | 'query': to_query, 29 | } 30 | 31 | 32 | CONTENT_TYPES = { 33 | 'text/plain': 'text', 34 | 'text/javascript': 'json', 35 | 'application/json': 'json', 36 | 'application/x-www-form-urlencoded': 'query', 37 | } 38 | 39 | class Response(object): 40 | 41 | def __init__(self, response, **opts): 42 | response, body = response 43 | self.body = body 44 | self.response = response 45 | self.reason = response.reason 46 | self.status = response.status 47 | self.content_type = response.get('content-type') 48 | 49 | options = { 'parse': 'text' } 50 | options.update(opts) 51 | 52 | self.options = options 53 | 54 | def __repr__(self): 55 | return '' 56 | 57 | @property 58 | def parsed(self): 59 | format = self.options['parse'] 60 | func = PARSERS.get(format, to_text) 61 | return func(self.body) 62 | -------------------------------------------------------------------------------- /douban/libs/pyoauth2/libs/multipart.py: -------------------------------------------------------------------------------- 1 | import codecs 2 | import mimetypes 3 | from uuid import uuid4 4 | from io import BytesIO 5 | 6 | CRLF = '\r\n' 7 | writer = codecs.lookup('utf-8')[3] 8 | 9 | def guess_type(filename): 10 | return mimetypes.guess_type(filename)[0] or 'application/sctet-stream' 11 | 12 | def iter_fields(fields): 13 | if isinstance(fields, dict): 14 | fields = fields.iteritems() 15 | return ((k, v) for k, v in fields) 16 | 17 | def build_multipart(fields, boundary=None): 18 | body = BytesIO() 19 | boundary = boundary or uuid4().hex 20 | 21 | for field_name, value in iter_fields(fields): 22 | body.write('--%s%s'%(boundary, CRLF)) 23 | 24 | if isinstance(value, tuple): 25 | file_name, data = value 26 | writer(body).write('Content-Disposition: form-data; name="%s"; ' 27 | 'filename="%s"%s'%(field_name, file_name, CRLF)) 28 | body.write('Content-Type: %s%s'%(guess_type(file_name), CRLF*2)) 29 | else: 30 | data = value 31 | writer(body).write('Content-Disposition: form-data; name="%s"%s' 32 | %(field_name, CRLF)) 33 | body.write('Content-Type: text/plain%s'%(CRLF*2)) 34 | 35 | if isinstance(data, int): 36 | data = str(data) 37 | 38 | if isinstance(data, unicode): 39 | writer(body).write(data) 40 | else: 41 | body.write(data) 42 | 43 | body.write(CRLF) 44 | 45 | body.write('--%s--%s'%(boundary, CRLF)) 46 | content_type = 'multipart/form-data; boundary=%s' % boundary 47 | return body.getvalue(), content_type 48 | -------------------------------------------------------------------------------- /bt/qll.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import os 5 | from vavava import util 6 | from vavava import httputil 7 | 8 | util.set_default_utf8() 9 | pjoin = os.path.join 10 | pdirname = os.path.dirname 11 | pabspath = os.path.abspath 12 | 13 | total = 0 14 | 15 | def geturls(): 16 | url = r"http://www.bjchs.org.cn/map/Org_infoList?key_area_code=%s" 17 | ids = [id for id in xrange(0, 20)] 18 | urls = [url%(10000 + id) for id in ids] 19 | return urls 20 | 21 | def getmatches(string): 22 | regstr = """机构名称:\s*([^\<]*)[^\<]*\

[^\>]+>机构地址:\s*([^\<]*)[^\<]*\

[^\>]+>区县:\s*([^\<]*)[^\<]*\

[^\>]+>机构电话:\s*([^\<]*)[^\<]*\

[^\>]+>基本医保点:\s*([^\<]*)[^\<]*\

[^\>]+>医保编码:\s*([^\<]*)[^\<]*\

[^\>]+>新农合定点:\s*([^\<]*)[^\<]*\

[^\>]+>邮政编码:\s*([^\<]*)[^\<]*\

[^\>]+>""" 23 | matches = util.reg_helper(string, regstr) 24 | return matches 25 | 26 | def save(matches, num): 27 | with open("%d.txt"%num, "w") as f: 28 | f.write("%s,%s,%s,%s,%s,%s,%s,%s,\n"%("机构名称", "机构地址", "区县", "机构电话", "基本医保点", "医保编码", "新农合定点", "邮政编码")) 29 | for match in matches: 30 | line = "%s,%s,%s,%s,%s,%s,%s,%s,\n"%match 31 | f.write(line) 32 | global total 33 | total += 1 34 | 35 | if __name__ == "__main__": 36 | log = util.get_logger() 37 | try: 38 | i = 0 39 | for url in geturls(): 40 | content = httputil.http_get(url) 41 | matches = getmatches(content) 42 | save(matches, i) 43 | i += 1 44 | print total 45 | except KeyboardInterrupt as e: 46 | print 'stop by user' 47 | exit(0) 48 | except Exception as e: 49 | log.exception(e) 50 | 51 | -------------------------------------------------------------------------------- /douban/libs/douban_client/api/album.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .base import DoubanAPIBase, DEFAULT_START, DEFAULT_COUNT 4 | 5 | 6 | class Album(DoubanAPIBase): 7 | 8 | def __repr__(self): 9 | return '' 10 | 11 | def get(self, id): 12 | return self._get('/v2/album/%s' % id) 13 | 14 | def new(self, title, desc='', order='desc', privacy='public'): 15 | return self._post('/v2/albums', 16 | title=title, desc=desc, 17 | order=order, privacy=privacy) 18 | 19 | def update(self, id, title='', desc='', order='desc', privacy='public'): 20 | return self._put('/v2/album/%s' % id, 21 | title=title, desc=desc, 22 | order=order, privacy=privacy) 23 | 24 | def delete(self, id): 25 | return self._delete('/v2/album/%s' % id) 26 | 27 | def list(self, user_id, start=DEFAULT_START, count=DEFAULT_COUNT): 28 | return self._get('/v2/album/user_created/%s' % user_id, 29 | start=start, count=count) 30 | 31 | def liked_list(self, user_id, start=DEFAULT_START, count=DEFAULT_COUNT): 32 | return self._get('/v2/album/user_liked/%s' % user_id, 33 | start=start, count=count) 34 | 35 | def photos(self, id, start=DEFAULT_START, count=DEFAULT_COUNT, order='', sortby='time'): 36 | return self._get('/v2/album/%s/photos' % id, 37 | start=start, count=count, order=order, sortby=sortby) 38 | 39 | def like(self, id): 40 | return self._post('/v2/album/%s/like' % id) 41 | 42 | def unlike(self, id): 43 | return self._delete('/v2/album/%s/like' % id) 44 | -------------------------------------------------------------------------------- /gaehelper/www/inc/visualize/css/visualize-light.css: -------------------------------------------------------------------------------- 1 | /* page styles */ 2 | body { font-size:62.5%; } 3 | 4 | /*demo styles*/ 5 | table {width: 500px; height: 200px; margin-left: 30px; } 6 | table.accessHide { position: absolute; left: -999999px; } 7 | td, th { font-size: 1.2em; padding: 2px; width: 13%; } 8 | th { background-color:#f4f4f4; } 9 | caption { font-size: 1.5em; } 10 | 11 | /*visualize extension styles*/ 12 | .visualize { margin: 60px 0 0 30px; padding: 70px 40px 90px; background: #ccc url(../images/chartbg-vanilla.png) top repeat-x; border: 1px solid #ddd; -moz-border-radius: 12px; -webkit-border-radius: 12px; border-radius: 12px; } 13 | .visualize canvas { border: 1px solid #aaa; margin: -1px; background: #fff; } 14 | .visualize-labels-x, .visualize-labels-y { top: 70px; left: 40px; z-index: 100; } 15 | .visualize-pie .visualize-labels { position: absolute; top: 70px; left: 40px; } 16 | .visualize-labels-x li span.label, .visualize-labels-y li span.label { color: #444; font-size: 1.3em; padding-right: 5px; } 17 | .visualize-labels-y li span.line { border-style: solid; opacity: .7; } 18 | .visualize .visualize-info { border: 0; position: static; opacity: 1; background: none; } 19 | .visualize .visualize-title { position: absolute; top: 20px; color: #333; margin-bottom: 0; left: 20px; font-size: 2.1em; font-weight: bold; } 20 | .visualize ul.visualize-key { position: absolute; bottom: 15px; background: #eee; z-index: 10; padding: 10px 0; color: #aaa; width: 100%; left: 0; } 21 | .visualize ul.visualize-key li { font-size: 1.2em; margin-left: 20px; padding-left: 18px; } 22 | .visualize ul.visualize-key .visualize-key-color { width: 10px; height: 10px; margin-top: -4px; } 23 | .visualize ul.visualize-key .visualize-key-label { color: #333; } -------------------------------------------------------------------------------- /gaehelper/www/inc/visualize/css/visualize-dark.css: -------------------------------------------------------------------------------- 1 | /* page styles */ 2 | body { font-size:62.5%; } 3 | 4 | /*demo styles*/ 5 | table {width: 500px; height: 200px; margin-left: 30px; } 6 | table.accessHide { position: absolute; left: -999999px; } 7 | td, th { font-size: 1.2em; padding: 2px; width: 13%; } 8 | th { background-color:#f4f4f4; } 9 | caption { font-size: 1.5em; } 10 | 11 | /*visualize extension styles*/ 12 | .visualize { margin: 60px 0 0 30px; padding: 70px 40px 90px; background: #222 url(../images/chartbg.png) top repeat-x; border: 1px solid #000; -moz-border-radius: 12px; -webkit-border-radius: 12px; border-radius: 12px; } 13 | .visualize canvas { border: 1px solid #888; margin: -1px; background: #222; } 14 | .visualize-labels-x, .visualize-labels-y { top: 70px; left: 40px; z-index: 100; } 15 | .visualize-pie .visualize-labels { position: absolute; top: 70px; left: 40px; } 16 | .visualize-labels-x li span.label, .visualize-labels-y li span.label { color: #aaa; font-size: 1.3em; padding-right: 5px; } 17 | .visualize-labels-y li span.line { border-style: dotted; opacity: .6; } 18 | .visualize .visualize-info { border: 0; position: static; opacity: 1; background: none; } 19 | .visualize .visualize-title { position: absolute; top: 20px; color: #fff; margin-bottom: 0; left: 20px; font-size: 2.1em; font-weight: bold; } 20 | .visualize ul.visualize-key { position: absolute; bottom: 15px; background: #444; z-index: 10; padding: 10px 0; color: #aaa; width: 100%; left: 0; } 21 | .visualize ul.visualize-key li { font-size: 1.2em; margin-left: 20px; padding-left: 18px; } 22 | .visualize ul.visualize-key .visualize-key-color { width: 10px; height: 10px; margin-top: -4px; } 23 | .visualize ul.visualize-key .visualize-key-label { color: #fff; } 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /backup/deploy.sh: -------------------------------------------------------------------------------- 1 | 2 | curl -o "wait4transfer.sh" "https://raw.githubusercontent.com/pkhopper/scripts/master/backup/wait4transfer.sh" 3 | 4 | if [ ! -d "$HOME/local" ]; then 5 | mkdir "$HOME/local" 6 | fi 7 | 8 | if [ ! -d "$HOME/local/share" ]; then 9 | mkdir "$HOME/local/share" 10 | fi 11 | 12 | if [ ! -f "$HOME/local/share/config.site" ]; then 13 | echo "CPPFLAGS=-I$HOME/local/include 14 | LDFLAGS=-L$HOME/local/lib" > "$HOME/local/share/config.site" 15 | fi 16 | 17 | echo "download Python-2.7.12.tgz" 18 | if [ ! -f "Python-2.7.12.tgz" ]; then 19 | curl "https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz" -o Python-2.7.12.tgz 20 | fi 21 | tar vxf "Python-2.7.12.tgz" 22 | cd Python-2.7.12 23 | ./configure --prefix="$HOME/local" 24 | make clean 25 | make 26 | make install 27 | cd .. 28 | 29 | 30 | PATH=$HOME/local/bin:$PATH 31 | EXPORT $PATH 32 | 33 | 34 | echo "download setuptools-26.0.0.tar.gz" 35 | if [ ! -f "setuptools-26.0.0.tar.gz" ]; then 36 | curl "https://pypi.python.org/packages/0d/13/ce6a0a22220f3da7483131bb8212d5791a03c8c3e86ff61b2c6a2de547cd/setuptools-26.0.0.tar.gz#md5=846e21fea62b9a70dfc845d70c400b7e" -o setuptools-26.0.0.tar.gz 37 | fi 38 | tar vxf "setuptools-26.0.0.tar.gz" 39 | cd "setuptools-26.0.0" 40 | python setup.py install 41 | cd .. 42 | 43 | 44 | echo "download django.1.9.4.tar.gz" 45 | if [ ! -f "django.1.9.4.tar.gz" ]; then 46 | curl "https://github.com/django/django/archive/1.9.4.tar.gz" -o django.1.9.4.tar.gz 47 | fi 48 | tar vxf "django.1.9.4.tar.gz" 49 | cd "django" 50 | python setup.py install 51 | cd .. 52 | 53 | 54 | echo "download supervisor" 55 | if [ ! -d "supervisor" ]; then 56 | git clone "https://github.com/Supervisor/supervisor.git" 57 | fi 58 | cd "supervisor" 59 | python setup.py install 60 | cd .. 61 | 62 | -------------------------------------------------------------------------------- /z7z8/convertfile2utf8.py: -------------------------------------------------------------------------------- 1 | #encoding=utf-8 2 | 3 | import os 4 | import codecs 5 | 6 | from vavava import util 7 | 8 | 9 | util.set_default_utf8() 10 | BUFFERSIZE = 1024*1024 11 | pjoin = os.path.join 12 | 13 | def filter(c): 14 | print 'source charset:', c 15 | if c.lower() == 'gb2312': 16 | return 'gbk' 17 | return c 18 | 19 | def convert_file(fin, fout, charset): 20 | print 'convert ', fin 21 | oldfile = codecs.open(fin, 'r', charset) 22 | tmpfile = codecs.open(fout, 'a', 'utf-8') 23 | while True: 24 | content = oldfile.read(BUFFERSIZE) 25 | if not content: 26 | return 27 | tmpfile.write(content) 28 | 29 | def convert2utf8(fin): 30 | try: 31 | tmp = fin + '.tmp' 32 | content = open(fin).read(1024) 33 | charset = filter(util.get_charset(content)) 34 | convert_file(fin, tmp, charset) 35 | os.rename(fin, fin+'.old') 36 | os.rename(tmp, fin) 37 | except Exception as e: 38 | os.rename(fin, fin+'.uncovered') 39 | print e 40 | 41 | def convert_dir(din): 42 | for top, dirs, files, dlns, flns, others in util.walk_dir(din): 43 | for f in files: 44 | convert2utf8(pjoin(din, f)) 45 | 46 | def convert(fileordir): 47 | fileordir = os.path.abspath(fileordir) 48 | if os.path.isfile(fileordir): 49 | print 'convert file:', fileordir 50 | convert2utf8(fileordir) 51 | elif os.path.isdir(fileordir): 52 | print 'convert dir:', fileordir 53 | convert_dir(fileordir) 54 | else: 55 | print 'input error:', fileordir 56 | 57 | if __name__ == '__main__': 58 | convert('/Users/pk/Downloads/tmp/swresult.txt') 59 | # convert(sys.argv[1]) 60 | 61 | -------------------------------------------------------------------------------- /dlvideo/parsers/flvcd.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from urllib import quote 4 | from vavava.httputil import HttpUtil 5 | from base_types import VidParserBase 6 | import vavava.util 7 | vavava.util.set_default_utf8() 8 | 9 | def host_filter(url): 10 | # http://video.sina.com.cn/p/ent/v/m/2014-08-14/102164094039.html 11 | if url.find('video.sina.com.cn') > 0: 12 | return 1, {'Referer': url, 'DNT': '1'} 13 | return 3, None 14 | 15 | class FLVCD(VidParserBase): 16 | def info(self, url, vidfmt): 17 | parse_url = 'http://www.flvcd.com/parse.php?' 18 | parse_url += 'kw='+ quote(url) 19 | parse_url += '&flag=one' 20 | format = ['', 'high', 'super', 'real'] 21 | if vidfmt > 0: 22 | parse_url += '&format=%s'%format[vidfmt] 23 | parse_url += "&Go=1&go=1" # 20150723 24 | http = HttpUtil() 25 | http.add_header('Referer', parse_url) 26 | print parse_url 27 | try: 28 | html = http.get(parse_url).decode('gb2312', 'ignore') 29 | from bs4 import BeautifulSoup 30 | soup = BeautifulSoup(html) 31 | m3u = soup.find('input', attrs={'name': 'inf'}).get('value') 32 | title = soup.find('input', attrs={'name': 'name'}).get('value') 33 | except Exception as e: 34 | # raise ValueError('not support') 35 | return [], '', None, 0, None 36 | urls = [u for u in m3u.split('|')] 37 | npf, headers = host_filter(url) 38 | return urls, title, None, npf, headers 39 | 40 | def test(): 41 | url = r'http://video.sina.com.cn/p/ent/v/m/2014-08-14/102164094039.html' 42 | flvcd = FLVCD() 43 | print flvcd.info(url, 0) 44 | 45 | 46 | if __name__ == '__main__': 47 | test() 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /douban/libs/pyoauth2/client.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from libs.auth_code import AuthCode 4 | from libs.password import Password 5 | from libs.access_token import AccessToken 6 | from libs.request import Request 7 | from libs.response import Response 8 | from libs.connection import Connection 9 | 10 | class Client(object): 11 | 12 | def __init__(self, client_id, client_secret, **opts): 13 | self.id = client_id 14 | self.secret = client_secret 15 | self.site = opts.pop('site', '') 16 | self.opts = { 'authorize_url': '/oauth/authorize', 17 | 'token_url': '/oauth/token', 18 | 'token_method': 'POST', 19 | 'connection_opts': {}, 20 | 'raise_errors': True, 21 | } 22 | self.opts.update(opts) 23 | 24 | def __repr__(self): 25 | return '' 26 | 27 | def authorize_url(self, params={}): 28 | return Connection.build_url(self.site, path=self.opts['authorize_url'], params=params) 29 | 30 | def token_url(self, params={}): 31 | return Connection.build_url(self.site, path=self.opts['token_url'], params=params) 32 | 33 | def request(self, method, uri, **opts): 34 | uri = Connection.build_url(self.site, path=uri) 35 | response = Request(method, uri, **opts).request() 36 | return response 37 | 38 | def get_token(self, **opts): 39 | response = self.request(self.opts['token_method'], self.token_url(), **opts) 40 | opts.update(response.parsed) 41 | return AccessToken.from_hash(self, **opts) 42 | 43 | @property 44 | def password(self): 45 | return Password(self) 46 | 47 | @property 48 | def auth_code(self): 49 | return AuthCode(self) 50 | -------------------------------------------------------------------------------- /douban/libs/douban_client/api/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .user import User 4 | from .doumail import Doumail 5 | from .discussion import Discussion 6 | from .note import Note 7 | from .album import Album 8 | from .photo import Photo 9 | from .online import Online 10 | from .event import Event 11 | from .guess import Guess 12 | from .miniblog import Miniblog 13 | from .book import Book 14 | from .movie import Movie 15 | from .music import Music 16 | 17 | 18 | class DoubanAPI(object): 19 | 20 | def __repr__(self): 21 | return '' 22 | 23 | @property 24 | def user(self): 25 | return User(self.access_token) 26 | 27 | @property 28 | def doumail(self): 29 | return Doumail(self.access_token) 30 | 31 | @property 32 | def discussion(self): 33 | return Discussion(self.access_token) 34 | 35 | @property 36 | def note(self): 37 | return Note(self.access_token) 38 | 39 | @property 40 | def album(self): 41 | return Album(self.access_token) 42 | 43 | @property 44 | def photo(self): 45 | return Photo(self.access_token) 46 | 47 | @property 48 | def online(self): 49 | return Online(self.access_token) 50 | 51 | @property 52 | def event(self): 53 | return Event(self.access_token) 54 | 55 | @property 56 | def guess(self): 57 | return Guess(self.access_token) 58 | 59 | @property 60 | def miniblog(self): 61 | return Miniblog(self.access_token) 62 | 63 | @property 64 | def book(self): 65 | return Book(self.access_token) 66 | 67 | @property 68 | def movie(self): 69 | return Movie(self.access_token) 70 | 71 | @property 72 | def music(self): 73 | return Music(self.access_token) 74 | -------------------------------------------------------------------------------- /dllive/config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | 5 | from vavava import scriptutils 6 | 7 | class DLLiveConfig(scriptutils.BaseConfig): 8 | 9 | def get_ini_attrs(self): 10 | return { 11 | 'default |outpath |s': None, 12 | 'default |channel |s': None, 13 | 'default |vfmt |i': None, 14 | 'default |liveurl |s': None, 15 | 'default |addrfile |s': None, 16 | 'default |npf |i': None, 17 | 'default |freq |i': None, 18 | 'network |tmin |i': None, 19 | 'network |tmax |i': None, 20 | # 'proxy |enable |b': None, 21 | # 'proxy |addr |s': None, 22 | 'favorites| |s': lambda cfg: cfg.items('favorites'), 23 | ' |log | ': scriptutils.get_log_from_config(), 24 | ' |proxyaddr| ': scriptutils.get_enabled_value_func('proxy', 'enable','addr'), 25 | } 26 | 27 | 28 | def get_args(self, argv): 29 | usage = """./dllive [-i|l][-c config][-o out_put_path][-f favorite][-d duration]""" 30 | import argparse 31 | parser=argparse.ArgumentParser(usage=usage, version='0.1.0') 32 | parser.add_argument('-c', '--config') 33 | parser.add_argument('-u', '--liveurl') 34 | parser.add_argument('-d', '--duration', type=float) 35 | parser.add_argument('-o', '--outpath',) 36 | parser.add_argument('-p', '--proxyaddr') 37 | parser.add_argument('-f', '--favorite') 38 | parser.add_argument('--vfmt') 39 | parser.add_argument('-i', '--interactive', action='store_true', default=False) 40 | parser.add_argument('-l', '--channellist', action='store_true', default=False) 41 | return parser.parse_args() 42 | -------------------------------------------------------------------------------- /douban/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import os 5 | import sys 6 | import getopt 7 | from douban_client import DoubanClient 8 | 9 | pjoin = os.path.join 10 | dirname = os.path.dirname 11 | abspath = os.path.abspath 12 | user_path = os.environ['HOME'] 13 | 14 | class Config: 15 | def __init__(self, config='config.ini'): 16 | dump_path = lambda path: path.replace(r"%(home)s", user_path) 17 | if os.path.islink(__file__): 18 | curr_dir = dirname(abspath(os.readlink(__file__))) 19 | else: 20 | curr_dir = dirname(abspath(__file__)) 21 | import ConfigParser 22 | cfg = ConfigParser.ConfigParser() 23 | cfg.read(pjoin(curr_dir, config)) 24 | self.key = cfg.get('login', 'key') 25 | self.code = cfg.get('login', 'code') 26 | self.secret = cfg.get('login', 'secret') 27 | self.callback = cfg.get('login', 'callback') 28 | self.scope = cfg.get('login', 'SCOPE') 29 | self.user = cfg.get('login', 'user') 30 | self.password = cfg.get('login', 'password') 31 | self.token = cfg.get('login', 'token') 32 | self.refresh_token = cfg.get('login', 'refresh_token') 33 | 34 | config = Config() 35 | 36 | KEY = config.key 37 | SECRET = config.secret 38 | CALLBACK = config.callback 39 | CODE = config.code 40 | SCOPE = config.scope 41 | user_email = config.user 42 | user_password = config.password 43 | TOKEN = config.token 44 | 45 | client = DoubanClient(KEY, SECRET, CALLBACK, SCOPE) 46 | 47 | def auth_with_code(): 48 | print client.authorize_url 49 | client.auth_with_code(CODE) 50 | 51 | def auth_with_password(): 52 | client.auth_with_password(user_email, user_password) 53 | 54 | def auth_with_token(): 55 | client.auth_with_token(TOKEN) 56 | 57 | 58 | if __name__ == "__main__": 59 | auth_with_token() 60 | print client.user.me 61 | -------------------------------------------------------------------------------- /gaehelper/www/inc/visualize/vanilla.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Charting 6 | 7 | 8 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 |
2009 Employee Sales by Department
foodautohouseholdfurniturekitchenbath
Mary190160401203070
Tom34030453549
Brad1018010852579
Kate4080902515119
78 | 79 | -------------------------------------------------------------------------------- /gaehelper/dnslib/test/sip2sip.info-ANY: -------------------------------------------------------------------------------- 1 | ;; Sending: 2 | ;; QUERY: 6c3e01000001000000000000077369703273697004696e666f0000ff0001 3 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27710 4 | ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 5 | ;; QUESTION SECTION: 6 | ;sip2sip.info. IN ANY 7 | 8 | ;; Got answer: 9 | ;; RESPONSE: 6c3e81800001000800000000077369703273697004696e666f0000ff0001c00c0023000100000df2002900050064017308534950532b44325400055f73697073045f746370077369703273697004696e666f00c00c000200010000010e0012036e73320b646e732d686f7374696e67c014c00c0023000100000df20027001e00640173075349502b44325500045f736970045f756470077369703273697004696e666f00c00c000200010000010e0006036e7331c063c00c0001000100000df200045117e48cc00c0023000100000df20027000a00640173075349502b44325400045f736970045f746370077369703273697004696e666f00c00c000600010000010e002dc0b007646f6d61696e73096a6f62736572766572036f72670077afd6a00000708000001c2000093a8000002a30c00c000200010000010e0006036e7333c063 10 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27710 11 | ;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 0 12 | ;; QUESTION SECTION: 13 | ;sip2sip.info. IN ANY 14 | ;; ANSWER SECTION: 15 | sip2sip.info. 3570 IN NAPTR 5 100 "s" "SIPS+D2T" "" _sips._tcp.sip2sip.info. 16 | sip2sip.info. 270 IN NS ns2.dns-hosting.info. 17 | sip2sip.info. 3570 IN NAPTR 30 100 "s" "SIP+D2U" "" _sip._udp.sip2sip.info. 18 | sip2sip.info. 270 IN NS ns1.dns-hosting.info. 19 | sip2sip.info. 3570 IN A 81.23.228.140 20 | sip2sip.info. 3570 IN NAPTR 10 100 "s" "SIP+D2T" "" _sip._tcp.sip2sip.info. 21 | sip2sip.info. 270 IN SOA ns1.dns-hosting.info. domains.jobserver.org. 2008012448 28800 7200 604800 10800 22 | sip2sip.info. 270 IN NS ns3.dns-hosting.info. 23 | 24 | -------------------------------------------------------------------------------- /gaehelper/www/inc/visualize/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Charting 6 | 7 | 8 | 23 | 24 | 25 |
26 |

Filament Group

27 |
28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 |
2009 Employee Sales by Department
foodautohouseholdfurniturekitchenbath
Mary190160401203070
Tom34030453549
Brad1018010852579
Kate4080902515119
81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /douban/libs/douban_client/client.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from pyoauth2 import Client, AccessToken 4 | from .api import DoubanAPI 5 | 6 | 7 | class DoubanClient(DoubanAPI): 8 | 9 | API_HOST = 'https://api.douban.com' 10 | AUTH_HOST = 'https://www.douban.com' 11 | TOKEN_URL = AUTH_HOST + '/service/auth2/token' 12 | AUTHORIZE_URL = AUTH_HOST + '/service/auth2/auth' 13 | 14 | def __init__(self, key, secret, redirect='', scope=''): 15 | self.redirect_uri = redirect 16 | self.scope = scope 17 | self.client = Client(key, secret, 18 | site=self.API_HOST, 19 | authorize_url=self.AUTHORIZE_URL, 20 | token_url=self.TOKEN_URL) 21 | self.access_token = None 22 | 23 | def __repr__(self): 24 | return '' 25 | 26 | @property 27 | def authorize_url(self): 28 | return self.client.auth_code.authorize_url(redirect_uri=self.redirect_uri, scope=self.scope) 29 | 30 | def auth_with_code(self, code): 31 | self.access_token = self.client.auth_code.get_token(code, redirect_uri=self.redirect_uri) 32 | 33 | def auth_with_token(self, token): 34 | self.access_token = AccessToken(self.client, token) 35 | 36 | def auth_with_password(self, username, password, **opt): 37 | self.access_token = self.client.password.get_token(username=username, password=password, 38 | redirect_uri=self.redirect_uri, **opt) 39 | 40 | @property 41 | def token_code(self): 42 | return self.access_token and self.access_token.token 43 | 44 | @property 45 | def refresh_token_code(self): 46 | return getattr(self.access_token, 'refresh_token', None) 47 | 48 | def refresh_token(self, refresh_token): 49 | access_token = AccessToken(self.client, token='', refresh_token=refresh_token) 50 | self.access_token = access_token.refresh() 51 | -------------------------------------------------------------------------------- /edict/online_dict.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # thx, cp from http://www.tuicool.com/articles/eaeUVz 4 | import sys 5 | import urllib2 6 | from HTMLParser import HTMLParser 7 | from vavava import util 8 | util.set_default_utf8() 9 | 10 | 11 | class MyHTMLParser(HTMLParser): 12 | def __init__(self): 13 | HTMLParser.__init__(self) 14 | self.t=False 15 | self.pronouce = [] 16 | self.trans=[] 17 | self.pr=False 18 | 19 | def handle_starttag(self, tag, attrs): 20 | if tag=='div': 21 | for attr in attrs: 22 | if attr==('class','hd_prUS') or \ 23 | attr==('class','hd_pr'): 24 | self.pr=True 25 | if tag=='span': 26 | for attr in attrs: 27 | if attr==('class','def'): 28 | self.t=True 29 | 30 | def handle_data(self, data): 31 | if self.t: 32 | self.trans.append(data) 33 | self.t=False 34 | if self.pr: 35 | self.pronouce.append(data) 36 | self.pr=False 37 | def getTrans(self): 38 | return self.trans 39 | 40 | 41 | class Trans: 42 | _URL='http://cn.bing.com/dict/search' 43 | def __init__(self): 44 | self.url=Trans._URL+"?q=%s&go=&qs=bs&form=CM&mkt=zh-CN&setlang=ZH" 45 | self.html=None 46 | 47 | def trans(self, w): 48 | self.getHtml(w) 49 | return self.parseHtml() 50 | 51 | def getHtml(self,word): 52 | self.url=self.url %word 53 | req = urllib2.Request(self.url) 54 | fd=urllib2.urlopen(req) 55 | self.html=fd.read() 56 | self.html=unicode(self.html,'utf-8') 57 | fd.close() 58 | 59 | def parseHtml(self): 60 | parser = MyHTMLParser() 61 | self.html=parser.unescape(self.html) 62 | parser.feed(self.html) 63 | string = '' 64 | for i, s in enumerate(parser.getTrans()): 65 | string += "%s. %s\n" % (i, s) 66 | return string 67 | 68 | if __name__=='__main__': 69 | print Trans().trans(sys.argv[1]) -------------------------------------------------------------------------------- /gaehelper/dnslib/test/google.com-A: -------------------------------------------------------------------------------- 1 | ;; Sending: 2 | ;; QUERY: e21b0100000100000000000006676f6f676c6503636f6d0000010001 3 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57883 4 | ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 5 | ;; QUESTION SECTION: 6 | ;google.com. IN A 7 | 8 | ;; Got answer: 9 | ;; RESPONSE: e21b8180000100100000000006676f6f676c6503636f6d0000010001c00c000100010000004e00043efca9b7c00c000100010000004e00043efca9a7c00c000100010000004e00043efca9b1c00c000100010000004e00043efca9b6c00c000100010000004e00043efca99dc00c000100010000004e00043efca9a2c00c000100010000004e00043efca9a8c00c000100010000004e00043efca9acc00c000100010000004e00043efca9adc00c000100010000004e00043efca999c00c000100010000004e00043efca99ec00c000100010000004e00043efca998c00c000100010000004e00043efca994c00c000100010000004e00043efca9bbc00c000100010000004e00043efca9a3c00c000100010000004e00043efca9b2 10 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57883 11 | ;; flags: qr rd ra; QUERY: 1, ANSWER: 16, AUTHORITY: 0, ADDITIONAL: 0 12 | ;; QUESTION SECTION: 13 | ;google.com. IN A 14 | ;; ANSWER SECTION: 15 | google.com. 78 IN A 62.252.169.183 16 | google.com. 78 IN A 62.252.169.167 17 | google.com. 78 IN A 62.252.169.177 18 | google.com. 78 IN A 62.252.169.182 19 | google.com. 78 IN A 62.252.169.157 20 | google.com. 78 IN A 62.252.169.162 21 | google.com. 78 IN A 62.252.169.168 22 | google.com. 78 IN A 62.252.169.172 23 | google.com. 78 IN A 62.252.169.173 24 | google.com. 78 IN A 62.252.169.153 25 | google.com. 78 IN A 62.252.169.158 26 | google.com. 78 IN A 62.252.169.152 27 | google.com. 78 IN A 62.252.169.148 28 | google.com. 78 IN A 62.252.169.187 29 | google.com. 78 IN A 62.252.169.163 30 | google.com. 78 IN A 62.252.169.178 31 | 32 | -------------------------------------------------------------------------------- /dlvideo/config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | 5 | import argparse 6 | from vavava import scriptutils 7 | 8 | class DLVideoConfig(scriptutils.BaseConfig): 9 | 10 | def get_ini_attrs(self): 11 | return { 12 | 'default|outpath |s': None, 13 | 'default|vidfmt |i': None, 14 | 'default|dlmethod |s': None, 15 | 'default|npf |i': None, 16 | 'default|tmin |i': None, 17 | 'default|tmax |i': None, 18 | 'u2b |u2b_cmd |s': None, 19 | 'u2b |u2b_proxy |s': None, 20 | 'u2b |u2b_cache |s': None, 21 | 'u2b |u2b_title_format| ': lambda cfg: cfg.get('u2b', 'u2b_title_format', raw=True), 22 | 'u2b |u2b_create_dir |s': None, 23 | ' |flv | ': self.__flvcd, 24 | ' |log | ': scriptutils.get_log_from_config() 25 | } 26 | 27 | 28 | def __flvcd(self, cfg): 29 | flvcd = {} 30 | for k,v in cfg.items('flvcd'): 31 | flvcd[k] = v.lower() == 'true' 32 | return flvcd 33 | 34 | 35 | def get_args(self, argv): 36 | usage = """./dlvideo [-m][-l][-c config][-o output][-f format] url ...""" 37 | parser=argparse.ArgumentParser(prog=argv, usage=usage, version='0.1') 38 | parser.add_argument('urls', nargs='*', help='urls') 39 | parser.add_argument('-c', '--config') 40 | parser.add_argument('-o', '--outpath') 41 | parser.add_argument('-m', '--dlmethod') 42 | parser.add_argument('-i', '--interact', action='store_true', default=False) 43 | parser.add_argument('-l', '--playlist', action='store_true', default=False) 44 | parser.add_argument('-f', '--vidfmt', type=int, help='[0,3]',choices=[0, 1, 2, 3]) 45 | result = parser.parse_args() 46 | return result 47 | 48 | if __name__ == "__main__": 49 | import sys 50 | sys.argv = ['cmd', '-f', '0', 'http://v.youku.com/v_show/id_XNzMyMzM1OTg4.html'] 51 | cfg = DLVideoConfig() 52 | cfg.read_cmdline_config('dlvideo.ini', script=__file__, argv=sys.argv) 53 | print cfg -------------------------------------------------------------------------------- /miniaxel/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import sys 5 | import unittest 6 | import os 7 | 8 | from vavava import util 9 | import miniaxel 10 | 11 | sys.path.insert(0, '.') 12 | 13 | 14 | __all__ = ['download',] 15 | 16 | util.set_default_utf8() 17 | 18 | 19 | class Test_miniaxel(unittest.TestCase): 20 | url = r'http://cdn.mysql.com/Downloads/Connector-J/mysql-connector-java-gpl-5.1.31.msi' 21 | orig_md5 = r'140c4a7c9735dd3006a877a9acca3c31' 22 | 23 | def test_miniaxel(self): 24 | print 'test_miniaxel' 25 | out_file = r'out_file' 26 | test_cases = [ 27 | ['mini', '-n', '5', '-r', Test_miniaxel.url], 28 | ['mini', '-n', '2', '-r', Test_miniaxel.url], 29 | ['mini', '-n', '1', '-r', Test_miniaxel.url], 30 | ['mini', '-n', '5', '-r', Test_miniaxel.url], 31 | ] 32 | for argv in test_cases: 33 | try: 34 | miniaxel.main(argv) 35 | with open(out_file, 'rb') as fp: 36 | md5 = util.md5_for_file(fp) 37 | self.assertTrue(Test_miniaxel.orig_md5 == md5) 38 | except Exception as e: 39 | print e 40 | finally: 41 | if os.path.exists(out_file): 42 | os.remove(out_file) 43 | 44 | 45 | def make_suites(): 46 | test_cases = { 47 | 'mini_axel': 'Test_miniaxel', 48 | } 49 | suite = unittest.TestSuite() 50 | if len(sys.argv) == 1: 51 | cases = [x for y, x in test_cases.items()] 52 | else: 53 | cases = [test_cases[x] for x in sys.argv[1:]] 54 | mod = sys.modules[__name__] 55 | for cls_name in cases: 56 | testcase = getattr(mod, cls_name) 57 | for attr, obj in testcase.__dict__.items(): 58 | if attr.startswith('test_'): 59 | suite.addTest(testcase(attr)) 60 | return suite 61 | 62 | 63 | if __name__ == "__main__": 64 | try: 65 | runner = unittest.TextTestRunner() 66 | runner.run(make_suites()) 67 | except KeyboardInterrupt as e: 68 | print 'stop by user' 69 | exit(0) 70 | except Exception as e: 71 | print e 72 | finally: 73 | pass -------------------------------------------------------------------------------- /douban/libs/douban_client/api/note.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .base import DoubanAPIBase, DEFAULT_START, DEFAULT_COUNT 4 | from .comment import Comment 5 | 6 | 7 | class Note(DoubanAPIBase): 8 | 9 | target = 'note' 10 | 11 | def __repr__(self): 12 | return '' 13 | 14 | def new(self, title, content, privacy='public', can_reply='true'): 15 | return self._post('/v2/notes', 16 | title=title, content=content, 17 | privacy=privacy, can_reply=can_reply) 18 | 19 | def get(self, id, format='text'): 20 | return self._get('/v2/note/%s' % id, format=format) 21 | 22 | def update(self, id, title, content, privacy='public', can_reply='true'): 23 | return self._put('/v2/note/%s' % id, 24 | title=title, content=content, 25 | privacy=privacy, can_reply=can_reply) 26 | 27 | def upload_photo(self, id, pid, image, content, layout=None, desc=None): 28 | kwargs = { 29 | 'pids': 'p_%s' % pid, 30 | 'content': content, 31 | 'layout_%s' % pid: layout, 32 | 'desc_%s' % pid: desc 33 | } 34 | files = { 35 | 'image_%s' % pid: image 36 | } 37 | return self._post('/v2/note/%s' % id, files=files, **kwargs) 38 | 39 | def delete(self, id): 40 | return self._delete('/v2/note/%s' % id) 41 | 42 | def like(self, id): 43 | return self._post('/v2/note/%s/like' % id) 44 | 45 | def unlike(self, id): 46 | return self._delete('/v2/note/%s/like' % id) 47 | 48 | def list(self, user_id, start=DEFAULT_START, count=DEFAULT_COUNT): 49 | return self._get('/v2/note/user_created/%s' % user_id, 50 | start=start, count=count) 51 | 52 | def liked_list(self, user_id, start=DEFAULT_START, count=DEFAULT_COUNT): 53 | return self._get('/v2/note/user_liked/%s' % user_id, 54 | start=start, count=count) 55 | 56 | def comments(self, id, start=DEFAULT_START, count=DEFAULT_COUNT): 57 | return Comment(self.access_token, self.target).list(id, start=start, count=count) 58 | 59 | @property 60 | def comment(self): 61 | return Comment(self.access_token, self.target) 62 | -------------------------------------------------------------------------------- /douban/mydouban.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import os 5 | import sys 6 | import getopt 7 | from douban_client import DoubanClient 8 | 9 | pjoin = os.path.join 10 | dirname = os.path.dirname 11 | abspath = os.path.abspath 12 | user_path = os.environ['HOME'] 13 | 14 | class Config: 15 | def __init__(self, config='config.ini'): 16 | dump_path = lambda path: path.replace(r"%(home)s", user_path) 17 | if os.path.islink(__file__): 18 | curr_dir = dirname(abspath(os.readlink(__file__))) 19 | else: 20 | curr_dir = dirname(abspath(__file__)) 21 | import ConfigParser 22 | cfg = ConfigParser.ConfigParser() 23 | cfg.read(pjoin(curr_dir, config)) 24 | self.key = cfg.get('login', 'key') 25 | self.code = cfg.get('login', 'code') 26 | self.secret = cfg.get('login', 'secret') 27 | self.callback = cfg.get('login', 'callback') 28 | self.scope = cfg.get('login', 'SCOPE') 29 | self.user = cfg.get('login', 'user') 30 | self.password = cfg.get('login', 'password') 31 | self.token = cfg.get('login', 'token') 32 | self.refresh_token = cfg.get('login', 'refresh_token') 33 | config = Config() 34 | 35 | KEY = config.key 36 | SECRET = config.secret 37 | CALLBACK = config.callback 38 | CODE = config.code 39 | SCOPE = config.scope 40 | user_email = config.user 41 | user_password = config.password 42 | TOKEN = config.token 43 | 44 | class MyDouban: 45 | def __init__(self): 46 | self.clent = DoubanClient(KEY, SECRET, CALLBACK, SCOPE) 47 | self.clent.auth_with_token(TOKEN) 48 | 49 | def search_movie(self, keyword): 50 | q = '' 51 | for kw in keyword: 52 | q += kw + '' 53 | return self.clent.movie.search(q) 54 | 55 | def usage(): 56 | print \ 57 | """ 58 | usage: 59 | cmd [-h] [c configfile] 60 | """ 61 | 62 | 63 | if __name__ == "__main__": 64 | config = '' 65 | opts, args = getopt.getopt(sys.argv[1:], "c:h", ["--long-one"]) 66 | for k, v in opts: 67 | if k in ("-h"): 68 | usage() 69 | exit(0) 70 | elif k in ("-c"): 71 | config = v 72 | 73 | douban = MyDouban() 74 | print douban.clent.user.me 75 | print douban.search_movie(args) 76 | -------------------------------------------------------------------------------- /dlvideo/parsers/yytingting.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from urllib import quote 4 | from vavava.httputil import HttpUtil 5 | from base_types import VidParserBase 6 | import util as _util 7 | import vavava.util 8 | vavava.util.set_default_utf8() 9 | # http://www.yytingting.com/#/bookstore/bookDetail.jsp?bookId=126 10 | import json 11 | 12 | class Yytingting(VidParserBase): 13 | def info(self, url, vidfmt): 14 | try: 15 | return self.__info(url, vidfmt) 16 | except Exception as e: 17 | raise e 18 | 19 | def __info(self, url, vidfmt): 20 | parse_url = 'http://www.yytingting.com/bookstore/playAndDownload.action?' \ 21 | 'id=%s&pageNo=%d&pageSize=%d' 22 | id = _util.r1('bookId=(\d+)', url) 23 | http = HttpUtil() 24 | http.add_header('Referer', url) 25 | tmp = parse_url % (id, 1, 20) 26 | info = http.get(tmp) 27 | js = json.loads(info) 28 | data = js['data']['data'] 29 | pageNo = js['data']['pageNo'] 30 | pageSize = js['data']['pageSize'] 31 | total = js['data']['total'] 32 | 33 | urls1 = [] 34 | for i in range(total/pageSize): 35 | url = parse_url % (id, i+1, pageSize) 36 | html = http.get(url) 37 | js = json.loads(html) 38 | fmt = 'http://www.yytingting.com/resource/getPlayUrl.action?id=%d&type=6' 39 | urls1 = urls1 + [(data['resName'], fmt % data['resId']) for data in js['data']['data']] 40 | 41 | urls = [] 42 | for name, url in urls1: 43 | html = http.get(url) 44 | js = json.loads(html) 45 | urls.append((name, js['data']['url'])) 46 | return urls 47 | 48 | 49 | def test(): 50 | url = r'http://www.iqiyi.com/dianshiju/20120730/9682f22c54d70f29.html' 51 | url = r'http://www.tudou.com/programs/view/hVT9-loKZ_M/' 52 | url = r'http://v.youku.com/v_show/id_XNzQzNTc0Nzgw.html' 53 | url = r'http://www.yytingting.com/#/bookstore/bookDetail.jsp?bookId=126' 54 | yytingting = Yytingting() 55 | urls = yytingting.info(url, 0) 56 | urls = ['%s.mp3,%s\n' %(data[0], data[1]) for data in urls] 57 | with open('urls.txt', 'w') as fp: 58 | fp.writelines(urls) 59 | 60 | 61 | if __name__ == '__main__': 62 | test() 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /douban/libs/douban_client/api/event.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .base import DoubanAPIBase, DEFAULT_START, DEFAULT_COUNT 4 | 5 | 6 | class Event(DoubanAPIBase): 7 | 8 | def __repr__(self): 9 | return '' 10 | 11 | def get(self, id): 12 | return self._get('/v2/event/%s' % id) 13 | 14 | def list(self, loc, day_type=None, type=None, start=DEFAULT_START, count=DEFAULT_COUNT): 15 | return self._get('/v2/event/list', 16 | loc=loc, day_type=day_type, type=type, start=start, count=count) 17 | 18 | def search(self, q, loc, start=DEFAULT_START, count=DEFAULT_COUNT): 19 | return self._get('/v2/event/search', q=q, loc=loc) 20 | 21 | def join(self, id, participate_date=''): 22 | data = dict(participate_date=participate_date) if participate_date else {} 23 | return self._post('/v2/event/%s/participants' % id, **data) 24 | 25 | def quit(self, id, participate_date=''): 26 | data = dict(participate_date=participate_date) if participate_date else {} 27 | return self._delete('/v2/event/%s/participants' % id, **data) 28 | 29 | def wish(self, id): 30 | return self._post('/v2/event/%s/wishers' % id) 31 | 32 | def unwish(self, id): 33 | return self._delete('/v2/event/%s/wishers' % id) 34 | 35 | def participants(self, id, start=DEFAULT_START, count=DEFAULT_COUNT): 36 | return self._get('/v2/event/%s/participants' % id, 37 | start=start, count=count) 38 | 39 | def wishers(self, id, start=DEFAULT_START, count=DEFAULT_COUNT): 40 | return self._get('/v2/event/%s/wishers' % id, 41 | start=start, count=count) 42 | 43 | def owned(self, user_id, start=DEFAULT_START, count=DEFAULT_COUNT): 44 | return self._get('/v2/event/user_created/%s' % user_id, 45 | start=start, count=count) 46 | 47 | def participated(self, user_id, start=DEFAULT_START, count=DEFAULT_COUNT): 48 | return self._get('/v2/event/user_participated/%s' % user_id, 49 | start=start, count=count) 50 | 51 | def wished(self, user_id, start=DEFAULT_START, count=DEFAULT_COUNT): 52 | return self._get('/v2/event/user_wished/%s' % user_id, 53 | start=start, count=count) 54 | -------------------------------------------------------------------------------- /gaehelper/www/inc/visualize/editable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Charting 6 | 7 | 8 | 23 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 |
2009 Employee Sales by Department
foodautohouseholdfurniturekitchenbath
Mary190160401203070
Tom34030453549
Brad1018010852579
Kate4080902515119
84 | 85 | 86 | -------------------------------------------------------------------------------- /gaehelper/dnslib/test/dig/google.com-ANY.dig: -------------------------------------------------------------------------------- 1 | 2 | ; <<>> DiG 9.8.5-P1 <<>> +qr google.com ANY @8.8.8.8 3 | ;; global options: +cmd 4 | ;; Sending: 5 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64619 6 | ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 7 | 8 | ;; QUESTION SECTION: 9 | ;google.com. IN ANY 10 | 11 | ;; Truncated, retrying in TCP mode. 12 | ;; Sending: 13 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 42748 14 | ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 15 | 16 | ;; QUESTION SECTION: 17 | ;google.com. IN ANY 18 | 19 | ;; Got answer: 20 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 42748 21 | ;; flags: qr rd ra; QUERY: 1, ANSWER: 28, AUTHORITY: 0, ADDITIONAL: 0 22 | 23 | ;; QUESTION SECTION: 24 | ;google.com. IN ANY 25 | 26 | ;; ANSWER SECTION: 27 | google.com. 299 IN A 62.252.169.183 28 | google.com. 299 IN A 62.252.169.152 29 | google.com. 299 IN A 62.252.169.172 30 | google.com. 299 IN A 62.252.169.177 31 | google.com. 299 IN A 62.252.169.157 32 | google.com. 299 IN A 62.252.169.153 33 | google.com. 299 IN A 62.252.169.182 34 | google.com. 299 IN A 62.252.169.168 35 | google.com. 299 IN A 62.252.169.178 36 | google.com. 299 IN A 62.252.169.162 37 | google.com. 299 IN A 62.252.169.187 38 | google.com. 299 IN A 62.252.169.167 39 | google.com. 299 IN A 62.252.169.148 40 | google.com. 299 IN A 62.252.169.173 41 | google.com. 299 IN A 62.252.169.158 42 | google.com. 299 IN A 62.252.169.163 43 | google.com. 21599 IN NS ns4.google.com. 44 | google.com. 599 IN MX 50 alt4.aspmx.l.google.com. 45 | google.com. 21599 IN NS ns2.google.com. 46 | google.com. 599 IN MX 10 aspmx.l.google.com. 47 | google.com. 21599 IN NS ns3.google.com. 48 | google.com. 21599 IN SOA ns1.google.com. dns-admin.google.com. 2014021800 7200 1800 1209600 300 49 | google.com. 599 IN MX 40 alt3.aspmx.l.google.com. 50 | google.com. 599 IN MX 20 alt1.aspmx.l.google.com. 51 | google.com. 21599 IN TYPE257 \# 19 0005697373756573796D616E7465632E636F6D 52 | google.com. 3599 IN TXT "v=spf1 include:_spf.google.com ip4:216.73.93.70/31 ip4:216.73.93.72/31 ~all" 53 | google.com. 599 IN MX 30 alt2.aspmx.l.google.com. 54 | google.com. 21599 IN NS ns1.google.com. 55 | 56 | ;; Query time: 36 msec 57 | ;; SERVER: 8.8.8.8#53(8.8.8.8) 58 | ;; WHEN: Mon May 05 12:12:07 BST 2014 59 | ;; MSG SIZE rcvd: 629 60 | 61 | -------------------------------------------------------------------------------- /gaehelper/www/inc/common.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | function update_tabledata(url, tb, tp, callback){ 4 | if (tb[0] != '#'){ 5 | tb = '#' + tb; 6 | } 7 | $.getJSON(url,function(result){ 8 | if (tp == null){ 9 | for (i in result["data"]) { 10 | x = result["data"][i]; 11 | x[0] = ''+x[0]+''; 12 | x[1] = ''+x[1]+''; 13 | } 14 | } 15 | col = []; 16 | for (i in result["columns"]){ 17 | col.push({"sTitle": result["columns"][i]}); 18 | } 19 | data = { 20 | // retrieve: true, 21 | "aaData": result["data"], 22 | "aoColumns": col, 23 | // "scrollY": 340 24 | }; 25 | if (tp == 0) { 26 | data['ordering'] = false; 27 | } 28 | if (callback) { 29 | callback(tb, data); 30 | } else { 31 | $(tb).DataTable(data); 32 | } 33 | // console.log(data); 34 | }); 35 | } 36 | 37 | 38 | /** 39 | * Function : dump() 40 | * Arguments: The data - array,hash(associative array),object 41 | * The level - OPTIONAL 42 | * Returns : The textual representation of the array. 43 | * This function was inspired by the print_r function of PHP. 44 | * This will accept some data as the argument and return a 45 | * text that will be a more readable version of the 46 | * array/hash/object that is given. 47 | * Docs: http://www.openjs.com/scripts/others/dump_function_php_print_r.php 48 | */ 49 | function dump(arr,level) { 50 | var dumped_text = ""; 51 | if(!level) level = 0; 52 | 53 | //The padding given at the beginning of the line. 54 | var level_padding = ""; 55 | for(var j=0;j \"" + value + "\"\n"; 66 | } 67 | } 68 | } else { //Stings/Chars/Numbers etc. 69 | dumped_text = "===>"+arr+"<===("+typeof(arr)+")"; 70 | } 71 | return dumped_text; 72 | } -------------------------------------------------------------------------------- /gaehelper/www/inc/visualize/css/visualize.css: -------------------------------------------------------------------------------- 1 | /*plugin styles*/ 2 | .visualize { border: 1px solid #888; position: relative; background: #fafafa; } 3 | .visualize canvas { position: absolute; } 4 | .visualize ul,.visualize li { margin: 0; padding: 0;} 5 | 6 | /*table title, key elements*/ 7 | .visualize .visualize-info { padding: 3px 5px; background: #fafafa; border: 1px solid #888; position: absolute; top: -20px; right: 10px; opacity: .8; } 8 | .visualize .visualize-title { display: block; color: #333; margin-bottom: 3px; font-size: 1.1em; } 9 | .visualize ul.visualize-key { list-style: none; } 10 | .visualize ul.visualize-key li { list-style: none; float: left; margin-right: 10px; padding-left: 10px; position: relative;} 11 | .visualize ul.visualize-key .visualize-key-color { width: 6px; height: 6px; left: 0; position: absolute; top: 50%; margin-top: -3px; } 12 | .visualize ul.visualize-key .visualize-key-label { color: #000; } 13 | 14 | /*pie labels*/ 15 | .visualize-pie .visualize-labels { list-style: none; } 16 | .visualize-pie .visualize-label-pos, .visualize-pie .visualize-label { position: absolute; margin: 0; padding:0; } 17 | .visualize-pie .visualize-label { display: block; color: #fff; font-weight: bold; font-size: 1em; } 18 | .visualize-pie-outside .visualize-label { color: #000; font-weight: normal; } 19 | 20 | /*line,bar, area labels*/ 21 | .visualize-labels-x,.visualize-labels-y { position: absolute; left: 0; top: 0; list-style: none; } 22 | .visualize-labels-x li, .visualize-labels-y li { position: absolute; bottom: 0; } 23 | .visualize-labels-x li span.label, .visualize-labels-y li span.label { position: absolute; color: #555; } 24 | .visualize-labels-x li span.line, .visualize-labels-y li span.line { position: absolute; border: 0 solid #ccc; } 25 | .visualize-labels-x li { height: 100%; } 26 | .visualize-labels-x li span.label { top: 100%; margin-top: 5px; } 27 | .visualize-labels-x li span.line { border-left-width: 1px; height: 100%; display: block; } 28 | .visualize-labels-x li span.line { border: 0;} /*hide vertical lines on area, line, bar*/ 29 | .visualize-labels-y li { width: 100%; } 30 | .visualize-labels-y li span.label { right: 100%; margin-right: 5px; display: block; width: 100px; text-align: right; } 31 | .visualize-labels-y li span.line { border-top-width: 1px; width: 100%; } 32 | .visualize-bar .visualize-labels-x li span.label { width: 100%; text-align: center; } -------------------------------------------------------------------------------- /gaehelper/pac/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import os 5 | import sys 6 | 7 | pjoin = os.path.join 8 | pdirname = os.path.dirname 9 | pabspath = os.path.abspath 10 | 11 | 12 | class Config: 13 | def __init__(self, config=None): 14 | if os.path.islink(__file__): 15 | script_dir = pdirname(pabspath(os.readlink(__file__))) 16 | else: 17 | script_dir = pdirname(pabspath(__file__)) 18 | config_file = config 19 | if config_file: 20 | config_file = pabspath(config_file) 21 | else: 22 | config_file = pjoin(script_dir, 'config.ini') 23 | import ConfigParser 24 | 25 | cfg = ConfigParser.ConfigParser() 26 | cfg.read(config_file) 27 | self.out_dir = cfg.get('default', 'out_dir') 28 | self.log = cfg.get('default', 'log') 29 | self.log_level = cfg.get('default', 'log_level') 30 | lvlconvert = { 31 | 'critical': 50, 32 | 'fatal': 50, 33 | 'error': 40, 34 | 'warning': 30, 35 | 'warn': 30, 36 | 'info': 20, 37 | 'debug': 10, 38 | 'notset': 0 39 | } 40 | if self.log_level: 41 | self.log_level = lvlconvert[self.log_level.strip().lower()] 42 | 43 | 44 | config = None 45 | log = None 46 | 47 | # 48 | 49 | def parse_args(): 50 | usage = """./cmd [-c config][-o out_put_path]""" 51 | import argparse 52 | 53 | parser = argparse.ArgumentParser(usage=usage, description='', version='0.1') 54 | parser.add_argument('-c', '--config', default='config.ini') 55 | parser.add_argument('-o', '--out-path', dest='out_dir', default=config.out_dir) 56 | args = parser.parse_args() 57 | return args 58 | 59 | 60 | def init_args_config(): 61 | config = Config() 62 | args = parse_args() 63 | if args.config != 'config.ini': 64 | config = Config(config=args.config) 65 | args = parse_args() 66 | log = util.get_logger(logfile=config.log, level=config.log_level) 67 | return args, config, log 68 | 69 | 70 | def main(): 71 | global log 72 | global config 73 | args, config, log = init_args_config() 74 | pass 75 | 76 | 77 | if __name__ == "__main__": 78 | try: 79 | main() 80 | except KeyboardInterrupt as e: 81 | print 'stop by user' 82 | exit(0) 83 | -------------------------------------------------------------------------------- /miniaxel/config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import os 5 | from vavava import scriptutils 6 | 7 | pjoin = os.path.join 8 | pdirname = os.path.dirname 9 | pabspath = os.path.abspath 10 | 11 | 12 | class MiniAxelConfig(scriptutils.BaseConfig): 13 | 14 | def get_ini_attrs(self): 15 | return { 16 | 'default|outpath |s': None, 17 | 'default|retrans |b': None, 18 | 'default|tmin |i': None, 19 | 'default|tmax |i': None, 20 | 'default|npf |i': None, 21 | 'proxy |enable |b': None, 22 | 'proxy |addr |s': None, 23 | ' |log | ': scriptutils.get_log_from_config() 24 | } 25 | 26 | def get_args(self, argv): 27 | usage = """./mini """ 28 | import argparse 29 | parser=argparse.ArgumentParser(prog=argv, usage=usage, description='mini axel', version='0.1') 30 | parser.add_argument('urls', nargs='*') 31 | parser.add_argument('-c', '--config') 32 | parser.add_argument('-r', '--retrans', action='store_true') 33 | parser.add_argument('-o', '--out_dir') 34 | parser.add_argument('-p', '--proxy', dest='proxy', action='store_true') 35 | parser.add_argument('-n', '--nthread') 36 | args = parser.parse_args() 37 | return args 38 | 39 | def miniaxel_test(self): 40 | from vavava import util 41 | url = r'http://cdn.mysql.com/Downloads/Connector-J/mysql-connector-java-gpl-5.1.31.msi' 42 | orig_md5 = r'140c4a7c9735dd3006a877a9acca3c31' 43 | out_file = r'out_file' 44 | test_cases = [ 45 | ['mini', '-n', '5', '-r', url], 46 | ['mini', '-n', '2', '-r', url], 47 | ['mini', '-n', '1', '-r', url], 48 | ['mini', '-n', '5', '-r', url], 49 | ] 50 | for argv in test_cases: 51 | try: 52 | from miniaxel import main as _main 53 | _main(argv) 54 | with open(out_file, 'rb') as fp: 55 | md5 = util.md5_for_file(fp) 56 | self.assertTrue(orig_md5 == md5) 57 | except Exception as e: 58 | print e 59 | finally: 60 | if os.path.exists(out_file): 61 | os.remove(out_file) 62 | 63 | if __name__ == '__main__': 64 | import sys 65 | cfg = MiniAxelConfig() 66 | cfg.read_cmdline_config('miniaxel.ini', sys.argv) 67 | print cfg -------------------------------------------------------------------------------- /bt/6.txt: -------------------------------------------------------------------------------- 1 | 机构名称,机构地址,区县,机构电话,基本医保点,医保编码,新农合定点,邮政编码, 2 | 大峪街道高层社区卫生服务站,北京市门头沟区大峪街道南路二区35-1-6,门头沟区,69842525,是,09162010,否,102300, 3 | 大峪街道永新社区卫生服务站,永新小区4号楼前,门头沟区,69835104,是,09162013,是,102300, 4 | 永定镇永兴社区卫生服务站,门头沟区永兴小区10号楼旁,门头沟区,60804502,否,09162020,是,102308, 5 | 妙峰山镇社区卫生服务中心(妙峰山镇卫生院),北京市门头沟区妙峰山镇陇驾庄村,门头沟区,61881686,是,09120004,是,102300, 6 | 大台街道灰地社区卫生服务站,北京市门头沟区大台街道灰地村,门头沟区,61871180,是,09132006,是,102303, 7 | 大峪街道绮霞苑社区卫生服务站,承泽苑1号楼底商,门头沟区,61865756,是,09162014,是,102300, 8 | 雁翅镇田庄社区卫生服务站,北京市门头沟区雁翅镇田庄村,门头沟区,61837097,是,09120008,是,102305, 9 | 王平地区王平矿社区卫生服务站,北京市门头沟区王平镇王平矿口,门头沟区,61859181,是,09162001,是,102300, 10 | 雁翅镇付家台社区卫生服务站,北京市门头沟区雁翅镇付家台村,门头沟区,61839958,是,09120008,是,102305, 11 | 军庄镇新村社区卫生服务站,军庄镇新村117号,门头沟区,60813184,否,,是,102300, 12 | 三家店社区卫生服务站,三家店东街56号,门头沟区,69842682,是,09162017,是,102300, 13 | 城子街道华新建社区卫生服务站,三家店新建路甲7号,门头沟区,61819636,是,09110010,是,102300, 14 | 大峪街道葡东社区卫生服务站,倚山嘉园底商,门头沟区,69805321,是,09162012,是,102300, 15 | 东辛房社区卫生服务中心(京煤总医院门矿医院),北京市门头沟区门头沟路47号,门头沟区,61815049,是,09110006,是,102300, 16 | 永定镇北岭社区卫生服务站,门头沟区永定镇益群山庄敬老院院内,门头沟区,60804694,是,09162019,是,102308, 17 | 清水镇社区卫生服务中心(清水中心卫生院),北京市门头沟区清水镇上清水村、清水镇黄塔村、清水镇齐家庄村,门头沟区,60855119,是,09120001,是,102311, 18 | 清水镇黄塔社区卫生服务站,北京市门头沟区清水镇黄塔村,门头沟区,61826047,否,,是,102311, 19 | 潭柘寺镇社区卫生服务中心,北京市门头沟区潭柘寺镇鲁家滩大街64号,门头沟区,60861550,是,09120011,是,102308, 20 | 斋堂镇沿河城社区卫生服务站,北京市门头沟区斋堂镇沿河城村,门头沟区,61821910,否,,是,102309, 21 | 大峪街道德露苑社区卫生服务站,德露苑小区3号楼-2,门头沟区,61864524,是,09162011,是,102300, 22 | 清水镇齐家庄社区卫生服务站,北京市门头沟区清水镇齐家庄村,门头沟区,61827847,否,,是,102311, 23 | 王平镇社区卫生服务中心(色树坟中心卫生院),北京市门头沟区王平镇色树坟大街10号,门头沟区,61859443,是,09120002,是,102301, 24 | 斋堂镇军响社区卫生服务站,北京市门头沟区斋堂镇军响村,门头沟区,61817945,否,,是,102309, 25 | 军庄镇社区卫生服务中心,军庄镇政府东侧(军庄镇卫生院),门头沟区,60811931,是,09120006,是,102300, 26 | 永定镇社区卫生服务中心(永定镇卫生院),石门营B1-7号楼,门头沟区,69804370,是,09120003,是,102308, 27 | 军庄镇军庄社区卫生服务站,军庄镇军庄村,门头沟区,60812387,否,,是,102300, 28 | 东辛房街道东辛房社区卫生服务站,北京市门头沟区龙门新区一区5号楼3单元102室,门头沟区,69859556,是,09162007,是,102300, 29 | 东辛房街道西山社区卫生服务站,门头沟区圈门大街45号,门头沟区,61825960,是,09162004,是,102300, 30 | 大台社区卫生服务中心(京煤总医院大台医院),北京市门头沟区大台北大地9号,门头沟区,61870100,是,09110007,是,102303, 31 | 大峪街道向东社区卫生服务站,门头沟区新桥大街新桥家园2号楼旁,门头沟区,69867246,是,09162009,是,102300, 32 | 妙峰山镇上苇甸社区卫生服务站,北京市门头沟区妙峰山镇上苇甸村,门头沟区,61884764,否,,是,102300, 33 | 斋堂镇社区卫生服务中心(斋堂医院),北京市门头沟区斋堂镇东斋堂村33号,门头沟区,15611523043,是,09110008,是,102309, 34 | 门城地区社区卫生服务中心,北京市门头沟区峪园小区甲六号,门头沟区,69842268,是,09151002,是,102300, 35 | 雁翅镇大村社区卫生服务站,北京市门头沟区雁翅镇大村村,门头沟区,61836045,是,09120008,是,102305, 36 | 雁翅镇社区卫生服务中心(雁翅中心卫生院),北京市门头沟区雁翅镇雁翅村,门头沟区,61830208,是,09120008,是,102305, 37 | 石门营新区社区卫生服务站,,门头沟区,,否,,否,, 38 | -------------------------------------------------------------------------------- /gaehelper/dnslib/bimap.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Bimap - bidirectional mapping between code/value 5 | """ 6 | 7 | class BimapError(Exception): 8 | pass 9 | 10 | class Bimap(object): 11 | 12 | """ 13 | Bi-directional mapping between code/value. 14 | 15 | Initialised using: 16 | 17 | name: Used for exceptions 18 | dict: Dict mapping from value (numeric) to code (text) 19 | error: Error type to raise if key not found 20 | 21 | The class provides: 22 | 23 | * A 'forward' map (code->text) which is accessed through 24 | __getitem__ (bimap[code]) 25 | * A 'reverse' map (code>value) which is accessed through 26 | __getattr__ (bimap.text) 27 | * A 'get' method which does a forward lookup (code->text) 28 | and returns a textual version of code if there is no 29 | explicit mapping (or default provided) 30 | 31 | >>> class TestError(Exception): 32 | ... pass 33 | 34 | >>> TEST = Bimap('TEST',{1:'A', 2:'B', 3:'C'},TestError) 35 | >>> TEST[1] 36 | 'A' 37 | >>> TEST.A 38 | 1 39 | >>> TEST.X 40 | Traceback (most recent call last): 41 | ... 42 | TestError: TEST: Invalid reverse lookup: [X] 43 | >>> TEST[99] 44 | Traceback (most recent call last): 45 | ... 46 | TestError: TEST: Invalid forward lookup: [99] 47 | >>> TEST.get(99) 48 | '99' 49 | 50 | """ 51 | 52 | def __init__(self,name,forward,error=KeyError): 53 | self.name = name 54 | self.error = error 55 | self.forward = forward.copy() 56 | self.reverse = dict([(v,k) for (k,v) in list(forward.items())]) 57 | 58 | def get(self,k,default=None): 59 | try: 60 | return self.forward[k] 61 | except KeyError as e: 62 | return default or str(k) 63 | 64 | def __getitem__(self,k): 65 | try: 66 | return self.forward[k] 67 | except KeyError as e: 68 | raise self.error("%s: Invalid forward lookup: [%s]" % (self.name,k)) 69 | 70 | def __getattr__(self,k): 71 | try: 72 | return self.reverse[k] 73 | except KeyError as e: 74 | raise self.error("%s: Invalid reverse lookup: [%s]" % (self.name,k)) 75 | 76 | if __name__ == '__main__': 77 | import doctest 78 | doctest.testmod() 79 | -------------------------------------------------------------------------------- /edict/edict.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import os 5 | import re 6 | from vavava import util 7 | from vavava import scriptutils 8 | from online_dict import Trans 9 | 10 | class EdictConfig(scriptutils.BaseConfig): 11 | 12 | def get_ini_attrs(self): 13 | return { 14 | 'default |outpath |s': None, 15 | } 16 | 17 | 18 | def get_args(self, argv): 19 | usage = """./edict word""" 20 | import argparse 21 | parser=argparse.ArgumentParser(usage=usage, version='0.1') 22 | parser.add_argument('-c', '--config') 23 | parser.add_argument('-o', '--outpath',) 24 | parser.add_argument('-l', '--list',) 25 | parser.add_argument('words', nargs='*') 26 | return parser.parse_args() 27 | 28 | def wexists(word, dict_string): 29 | reg = re.compile('^###\s+%s\s+' % (word), re.M|re.I) 30 | return reg.search(dict_string) 31 | 32 | def info(w, dict_string): 33 | r = re.search("^### (%s(.|\s)+?)^###" % (w), dict_string, re.M|re.I) 34 | if r: 35 | return r.group(1) 36 | 37 | def main(cfg): 38 | if cfg.outpath is None or len(cfg.outpath) is 0: 39 | cfg.outpath = "./" 40 | outfile = os.path.join(cfg.outpath, "edict.md") 41 | if not os.path.exists(outfile): 42 | with open(outfile, 'w') as fp: 43 | dict_string = '' 44 | else: 45 | with open(outfile, 'r') as fp: 46 | dict_string = fp.read() 47 | with open(outfile, 'a+') as fp: 48 | for w in cfg.words: 49 | if wexists(w.strip(), dict_string): 50 | #os.system('say exists') 51 | print info(w, dict_string) 52 | continue 53 | else: 54 | content = '\n### %s\n%s' % (w, Trans().trans(w)) 55 | print content 56 | #os.system('say %s' % w) 57 | fp.write(content) 58 | 59 | if __name__ == "__main__": 60 | # from config import EdictConfig 61 | from sys import argv 62 | cfg = EdictConfig().read_cmdline_config('edict.ini', __file__, argv) 63 | cfg.log = util.get_logger() 64 | try: 65 | if cfg.words is None or len(cfg.words) is 0: 66 | while True: 67 | print ">>" 68 | cfg.words = raw_input().split(" ") 69 | main(cfg) 70 | else: 71 | main(cfg) 72 | except KeyboardInterrupt: 73 | print 'stop by user' 74 | exit(0) 75 | except Exception as e: 76 | cfg.log.exception(e) -------------------------------------------------------------------------------- /bt/btparser.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import os 5 | import sys 6 | from bencode import bencode 7 | import hashlib 8 | from vavava import util 9 | 10 | util.set_default_utf8() 11 | pjoin = os.path.join 12 | pdirname = os.path.dirname 13 | pabspath = os.path.abspath 14 | 15 | 16 | def decode(btfile): 17 | with open(btfile, 'rb') as fp: 18 | data = fp.read() 19 | torrent = bencode.bdecode(data) 20 | return torrent 21 | 22 | def encode(data): 23 | return bencode.bencode(data) 24 | 25 | def decode_file(btfile, infofile='out.txt'): 26 | with open(infofile, 'w') as fp: 27 | data = decode(btfile) 28 | fp.write(str(data)) 29 | return data 30 | 31 | def encode_file(infofile='out.txt', btfile=''): 32 | with open(infofile, 'r') as fp: 33 | data = eval(fp.read()) 34 | name = data["info"]["name"] + btfile + '.torrent' 35 | with open(name, 'w') as fp: 36 | torrent = encode(data) 37 | fp.write(torrent) 38 | 39 | def edit(btfile, data_map): 40 | data = decode(btfile) 41 | for k, v in data_map.items(): 42 | data['info'][k] = v 43 | with open(btfile, 'w') as fp: 44 | torrent = encode(data) 45 | fp.write(torrent) 46 | return data 47 | 48 | def usage(): 49 | print 'cmd: decode/encode/edit' 50 | print '\tbt.py decode btfile [infofile]' 51 | print '\tbt.py encode infofile [btfile]' 52 | print '\tbt.py edit btfile info_map' 53 | 54 | if __name__ == "__main__": 55 | log = util.get_logger() 56 | try: 57 | cmd = sys.argv[1] 58 | f1 = sys.argv[2] 59 | infofile = 'out.json' 60 | if cmd in ('decode'): 61 | btfile = f1 62 | if len(sys.argv) > 3: 63 | infofile = sys.argv[3] 64 | data = decode_file(btfile, infofile) 65 | print data['info'] 66 | elif cmd in ('encode'): 67 | btfile = '' 68 | infofile = f1 69 | if len(sys.argv) > 3: 70 | btfile = sys.argv[3] 71 | encode_file(infofile=infofile, btfile=btfile) 72 | elif cmd in ('edit'): 73 | btfile = f1 74 | info_map = eval(sys.argv[3]) 75 | print edit(btfile, info_map)['info'] 76 | elif cmd in ('info'): 77 | btfile = f1 78 | print decode(btfile) 79 | else: 80 | usage() 81 | except KeyboardInterrupt as e: 82 | print 'stop by user' 83 | exit(0) 84 | except Exception as e: 85 | log.exception(e) 86 | 87 | -------------------------------------------------------------------------------- /douban/libs/douban_client/api/miniblog.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .base import DoubanAPIBase, DEFAULT_COUNT 4 | 5 | 6 | class Miniblog(DoubanAPIBase): 7 | 8 | def __repr__(self): 9 | return '' 10 | 11 | def get(self, id): 12 | return self._get('/shuo/v2/statuses/%s' % id) 13 | 14 | def new(self, text, image=None): 15 | files = dict(image=image) if image else dict() 16 | return self._post('/shuo/v2/statuses/', text=text, files=files) 17 | 18 | def rec(self, title='', url='', desc='', image=''): 19 | return self._post('/shuo/v2/statuses/', 20 | rec_title=title, rec_url=url, 21 | rec_desc=desc, rec_image=image) 22 | 23 | def delete(self, id): 24 | return self._delete('/shuo/v2/statuses/%s' % id) 25 | 26 | def home_timeline(self, count=DEFAULT_COUNT, since_id=None, until_id=None, category=None): 27 | return self._get('/shuo/v2/statuses/home_timeline', 28 | count=count, since_id=since_id, 29 | until_id=until_id, category=category) 30 | 31 | def user_timeline(self, user_id, since_id=None, until_id=None): 32 | return self._get('/shuo/v2/statuses/user_timeline/%s' % user_id, 33 | since_id=since_id, until_id=until_id) 34 | 35 | def like(self, id): 36 | return self._post('/shuo/v2/statuses/%s/like' % id) 37 | 38 | def unlike(self, id): 39 | return self._delete('/shuo/v2/statuses/%s/like' % id) 40 | 41 | def likers(self, id): 42 | return self._get('/shuo/v2/statuses/%s/like' % id) 43 | 44 | def reshare(self, id): 45 | return self._post('/shuo/v2/statuses/%s/reshare' % id) 46 | 47 | def unreshare(self, id): 48 | return self._delete('/shuo/v2/statuses/%s/reshare' % id) 49 | 50 | def reshareders(self, id): 51 | return self._get('/shuo/v2/statuses/%s/reshare' % id) 52 | 53 | def comments(self, id): 54 | return self._get('/shuo/v2/statuses/%s/comments' % id) 55 | 56 | @property 57 | def comment(self): 58 | return MiniblogComment(self.access_token) 59 | 60 | 61 | class MiniblogComment(DoubanAPIBase): 62 | 63 | def new(self, miniblog_id, text): 64 | return self._post('/shuo/v2/statuses/%s/comments' % miniblog_id, text=text) 65 | 66 | def get(self, id): 67 | return self._get('/shuo/v2/statuses/comment/%s' % id) 68 | 69 | def delete(self, id): 70 | return self._delete('/shuo/v2/statuses/comment/%s' % id) 71 | -------------------------------------------------------------------------------- /backup/zipTodayFiles.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import os 5 | import zipfile 6 | from sys import argv 7 | from time import localtime, strftime 8 | import datetime 9 | import time 10 | import urllib2 11 | 12 | 13 | join, abspath, basename = os.path.join, os.path.abspath, os.path.basename 14 | 15 | 16 | def get_online_time(): 17 | resp = urllib2.urlopen(urllib2.Request("http://www.baidu.com")) 18 | if resp.code == 200: 19 | t = resp.headers['Date'] 20 | t = time.strptime(t, "%a, %d %b %Y %H:%M:%S %Z") 21 | t = datetime.datetime(*t[:6]) + datetime.timedelta(hours=8) 22 | t = time.mktime(t.timetuple()) 23 | return time.localtime(t) 24 | 25 | 26 | 27 | def get_files(root, files): 28 | for parent, dirnames, filenames in os.walk(root): 29 | for filename in filenames: 30 | files.append(abspath(join(parent, filename))) 31 | 32 | 33 | 34 | def zip_files(root, files, zipName): 35 | tmp_zip = zipName + "!!!" 36 | try: 37 | zf = zipfile.ZipFile(tmp_zip, "w", zipfile.zlib.DEFLATED) 38 | for f in files: 39 | print f 40 | zf.write(f, f[len(root):]) 41 | zf.close() 42 | os.rename(tmp_zip, zipName) 43 | return files 44 | except Exception as e: 45 | os.remove(tmp_zip) 46 | raise e 47 | finally: 48 | pass 49 | 50 | 51 | def unzip_file(zipfilename, unziptodir): 52 | if not os.path.exists(unziptodir): 53 | os.mkdir(unziptodir, 0777) 54 | zfobj = zipfile.ZipFile(zipfilename) 55 | for name in zfobj.namelist(): 56 | name = name.replace('\\', '/') 57 | 58 | if name.endswith('/'): 59 | os.mkdir(os.path.join(unziptodir, name)) 60 | else: 61 | ext_filename = os.path.join(unziptodir, name) 62 | ext_dir = os.path.dirname(ext_filename) 63 | if not os.path.exists(ext_dir): os.mkdir(ext_dir, 0777) 64 | outfile = open(ext_filename, 'wb') 65 | outfile.write(zfobj.read(name)) 66 | outfile.close() 67 | 68 | 69 | 70 | def main(): 71 | rootDir = "./" 72 | if len(argv) > 1: 73 | rootDir = argv[1] 74 | files = [] 75 | rootDir = abspath(rootDir) 76 | get_files(rootDir, files) 77 | files = [f for f in files if datetime.date.fromtimestamp(os.path.getctime(f)) == datetime.date.today()] 78 | out = strftime("%Y%m%d.%H.%M.%S", get_online_time()) 79 | out = join(rootDir, out + "_" + strftime("%Y%m%d%H%M%S", localtime()) + ".zip") 80 | zip_files(rootDir, files, out) 81 | 82 | if __name__ == "__main__": 83 | main() -------------------------------------------------------------------------------- /gaehelper/www/inc/visualize/filtering.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Charting subsets of table data - Visualize 6 | 7 | 8 | 23 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 |
2009 Employee Sales by Department
foodautohouseholdfurniturekitchenbathTotal
Mary190160401203070610
Tom34030453549202
Brad1018010852579389
Kate4080902515119369
Total2434601702751053171570
99 | 100 | 101 | -------------------------------------------------------------------------------- /dlvideo/parsers/sohu.py: -------------------------------------------------------------------------------- 1 | 2 | #!/usr/bin/env python 3 | # coding=utf-8 4 | 5 | from util import * 6 | from base_types import VidParserBase, PlayListFilterBase 7 | from vavava.httputil import HttpUtil 8 | 9 | def real_url(host, prot, file, new): 10 | url = 'http://%s/?prot=%s&file=%s&new=%s' % (host, prot, file, new) 11 | html = HttpUtil().get(url) 12 | start, _, host, key, _, _, _, _, _ = html.split('|') 13 | return '%s%s?key=%s' % (start[:-1], new, key) 14 | 15 | class Sohu(VidParserBase): 16 | def info(slef, url, merge=True, vidfmt=0): 17 | """ format_op = ["norVid", "highVid", "superVid", "oriVid"] """ 18 | assert vidfmt in (0, 1, 2, 3) 19 | http = HttpUtil() 20 | vid_page = http.get(url) 21 | vid = r1('vid="(\d+)"', vid_page) 22 | if not vid: 23 | vid = r1('vid:\s*\'(\d+)\'', vid_page) 24 | assert vid 25 | import json 26 | html = http.get('http://hot.vrs.sohu.com/vrs_flash.action?vid=%s' % vid) 27 | data = json.loads(html.decode(http.parse_charset())) 28 | if vidfmt > 0: 29 | format_op = ["norVid", "highVid", "superVid", "oriVid"] 30 | vid = data['data'][format_op[vidfmt]] 31 | html = http.get('http://hot.vrs.sohu.com/vrs_flash.action?vid=%s' % vid) 32 | data = json.loads(html.decode(http.parse_charset())) 33 | host = data['allot'] 34 | prot = data['prot'] 35 | urls = [] 36 | data = data['data'] 37 | title = data['tvName'] 38 | size = sum(data['clipsBytes']) 39 | assert len(data['clipsURL']) == len(data['clipsBytes']) == len(data['su']) 40 | for file, new in zip(data['clipsURL'], data['su']): 41 | urls.append(real_url(host, prot, file, new)) 42 | assert data['clipsURL'][0].endswith('.mp4') 43 | return urls, title, 'mp4', 5, None 44 | 45 | class SohuPlaylist(PlayListFilterBase): 46 | def info(self, url): 47 | if url.find('sohu.com') < 0: 48 | raise ValueError('not a sohu.com video url') 49 | import json 50 | import re 51 | html = HttpUtil().get(url) 52 | playlistid = re.findall(r'var playlistId="(?P[^"]*?)";', html)[0] 53 | url = r'http://pl.hd.sohu.com/videolist?playlistid=%s'%playlistid 54 | data = json.loads(HttpUtil().get(url), encoding='gbk') 55 | title = data['albumName'] 56 | items = [video['pageUrl'] for video in data['videos']] 57 | return title, items 58 | 59 | if __name__ == "__main__": 60 | url = "http://my.tv.sohu.com/us/42891366/72351551.shtml" 61 | info = Sohu().info(url, vidfmt=0) 62 | print info -------------------------------------------------------------------------------- /bt/13.txt: -------------------------------------------------------------------------------- 1 | 机构名称,机构地址,区县,机构电话,基本医保点,医保编码,新农合定点,邮政编码, 2 | 穆家峪镇社区卫生服务中心,密云县穆家峪镇南穆家峪村,密云县,61053836,是,28120014,是,101500, 3 | 西田各庄镇服务中心西庄户村社区卫生服务站,密云县西田各庄镇西庄户村,密云县,010-61003241,否,,是,101509, 4 | 密云镇社区卫生服务中心,北京市密云县密云镇李各庄村委会南,密云县,010-69080456,是,28110028,是,101500, 5 | 不老屯镇社区卫生服务中心,北京市密云县不老屯镇不老屯村,密云县,81091893,是,28120016,是,101516, 6 | 十里堡镇社区卫生服务中心,密云区十里堡镇河槽村西200米,密云县,01089023297,是,28120015,是,101500, 7 | 高岭镇社区卫生服务中心,北京市密云区高岭镇高岭村政府路9号,密云县,81081157,是,28120004,是,101507, 8 | 果园服务中心果园小区社区卫生服务站,密云县密云镇果园小区,密云县,69059033,是,28110005,是,101500, 9 | 鼓楼社区卫生服务中心滨阳北里社区卫生服务站,密云县密云镇滨阳北里小区,密云县,69055004,是,28162025,是,101500, 10 | 古北口镇服务中心北甸子村社区卫生服务站,密云县古北口镇北甸子村,密云县,81052007,否,,是,101508, 11 | 古北口镇社区卫生服务中心,密云县古北口镇河东村,密云县,81051007,是,88424184,是,101508, 12 | 西田各庄镇服务中心西智村社区卫生服务站,密云县西田各庄镇西智村,密云县,010-89031078,否,,是,101509, 13 | 巨各庄镇社区卫生服务中心,密云县巨各庄镇水峪村,密云县,61033001,是,28120001,是,101501, 14 | 大城子镇服务中心墙子路村社区卫生服务站,大城子镇墙子路村,密云县,61070596,否,,是,101502, 15 | 穆家峪镇服务中心后栗园社区卫生服务站,密云县穆家峪镇后栗园村,密云县,89015495,否,,是,101500, 16 | 石城镇服务中心四合堂村社区卫生服务站,北京市密云县石城镇四合堂村,密云县,69015267,否,,是,101514, 17 | 北庄镇社区卫生服务中心,密云县北庄镇北庄村,密云县,81002006,是,28120013,是,101503, 18 | 穆家峪镇服务中心碱厂村社区卫生服务站,密云县穆家峪镇碱厂村,密云县,61051129,否,,是,101500, 19 | 穆家峪镇服务中心前栗园村社区卫生服务站,密云县穆家峪镇前栗园村,密云县,89013340,否,,是,101500, 20 | 太师屯镇社区卫生服务中心,密云县太师屯镇,密云县,69032541,是,28110002,是,101504, 21 | 溪翁庄镇社区卫生服务中心,密云县溪翁庄镇溪翁庄村,密云县,69012577,是,28120012,是,101512, 22 | 高岭镇服务中心上甸子村社区卫生服务站,密云县高岭镇上甸子村,密云县,81082117,是,11128120004,是,101507, 23 | 溪翁庄镇服务中心石马峪村社区卫生服务站,溪翁庄石马峪村,密云县,18519002551,否,,是,101512, 24 | 溪翁庄镇服务中心金叵罗村社区卫生服务站,溪翁庄金叵罗村,密云县,18519002550,否,,是,101512, 25 | 果园服务中心康居社区卫生服务站,密云县果园街道康居南区,密云县,69029385,是,28110005,是,101500, 26 | 西田各庄镇社区卫生服务中心,密云县西田各庄镇西田各庄村,密云县,61015254,是,28120009,是,101509, 27 | 冯家峪镇服务中心番字牌村社区卫生服务站,北京市密云县冯家峪镇番字牌村,密云县,69015949,否,,是,101515, 28 | 溪翁庄镇北白岩村社区卫生服务站,溪翁庄北白岩村,密云县,18519002561,否,,是,101512, 29 | 东邵渠镇社区卫生服务中心,密云县东邵渠镇高各庄村,密云县,61061321,是,28120007,是,101501, 30 | 鼓楼社区卫生服务中心长安社区服务站,密云县长安小区25号楼2单元101,密云县,69072160,是,28162026,是,101500, 31 | 果园社区卫生服务中心,密云县果园街道西门外,密云县,69044606,是,28110005,是,101500, 32 | 石城镇社区卫生服务中心,北京市密云县石城镇南石城村,密云县,61025192,是,28120002,是,101513, 33 | 河南寨镇社区卫生服务中心,北京市密云区河南寨镇芦古庄村北,密云县,61087288,是,28120006,是,101500, 34 | 大城子镇社区卫生服务中心,大城子镇大城子村,密云县,61071761,是,28120008,是,101502, 35 | 新城子镇社区卫生服务中心,北京市密云县新城子镇新城子村,密云县,81023799,是,28120005,是,101506, 36 | 新城子镇服务中心曹家路村社区卫生服务站,密云县新城子镇曹家路社区社区卫生服务站,密云县,81021403,否,,是,101506, 37 | 冯家峪镇社区卫生服务中心,密云县冯家峪镇冯家峪村99号,密云县,81069963,是,28120010,是,101515, 38 | 鼓楼社区卫生服务中心宾阳社区卫生服务站,密云县密云镇宾阳西里24号楼2单元,密云县,69020414,是,28110024,是,101500, 39 | 东菜园社区卫生服务站,密云县东菜园小区,密云县,69067740,是,28162002,是,101500, 40 | 巨各庄镇服务中心蔡家洼村社区卫生服务站,密云县巨各庄镇蔡家洼村,密云县,89092968,否,,是,101501, 41 | 鼓楼社区卫生服务中心,密云区鼓楼东大街6号,密云县,69044334,是,28110003,是,101500, 42 | 东邵渠镇服务中心西邵渠村社区卫生服务站,东邵渠镇西邵渠村,密云县,61063884,否,,是,101501, 43 | 鼓楼社区卫生服务中心行宫社区卫生服务站,密云县行宫小区28号楼3单元102-202,密云县,69058355,是,28162001,是,101500, 44 | -------------------------------------------------------------------------------- /gaehelper/dnslib/test/sipgate.co.uk-ANY: -------------------------------------------------------------------------------- 1 | ;; Sending: 2 | ;; QUERY: a85701000001000000000000077369706761746502636f02756b0000ff0001 3 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43095 4 | ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 5 | ;; QUESTION SECTION: 6 | ;sipgate.co.uk. IN ANY 7 | 8 | ;; Got answer: 9 | ;; RESPONSE: a85781800001000c00000000077369706761746502636f02756b0000ff0001c00c00060001000053950033036e73310b6e65747a717561647261740264650008646e7361646d696ec02f780bd92200002a3000000e1000093a8000012a70c00c00020001000053950002c02bc00c00020001000053950006036e7332c02fc00c001000010000377500cecd763d737066312061206d7820613a6d61696c2d696e2e6e65747a717561647261742e646520613a6d7830312e736970676174652e6e657420613a6d7830322e736970676174652e6e657420613a72362d312e6e65747a717561647261742e6e657420613a72362d332e6e65747a717561647261742e6e657420613a72362d342e6e65747a717561647261742e6e657420696e636c7564653a6173706d782e676f6f676c656d61696c2e636f6d20696e636c7564653a737570706f72742e7a656e6465736b2e636f6d207e616c6cc00c000f00010000539500160001054153504d58014c06474f4f474c4503434f4d00c00c000f0001000053950009000504414c5431c166c00c000f0001000053950009000504414c5432c166c00c000f0001000053950016000a064153504d58320a474f4f474c454d41494cc175c00c000f000100005395000b000a064153504d5833c1b9c00c000f000100005395000b000a064153504d5834c1b9c00c000f000100005395000b000a064153504d5835c1b9c00c0001000100000d450004d90a4f17 10 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43095 11 | ;; flags: qr rd ra; QUERY: 1, ANSWER: 12, AUTHORITY: 0, ADDITIONAL: 0 12 | ;; QUESTION SECTION: 13 | ;sipgate.co.uk. IN ANY 14 | ;; ANSWER SECTION: 15 | sipgate.co.uk. 21397 IN SOA ns1.netzquadrat.de. dnsadmin.netzquadrat.de. 2014042402 10800 3600 604800 76400 16 | sipgate.co.uk. 21397 IN NS ns1.netzquadrat.de. 17 | sipgate.co.uk. 21397 IN NS ns2.netzquadrat.de. 18 | sipgate.co.uk. 14197 IN TXT "v=spf1 a mx a:mail-in.netzquadrat.de a:mx01.sipgate.net a:mx02.sipgate.net a:r6-1.netzquadrat.net a:r6-3.netzquadrat.net a:r6-4.netzquadrat.net include:aspmx.googlemail.com include:support.zendesk.com ~all" 19 | sipgate.co.uk. 21397 IN MX 1 ASPMX.L.GOOGLE.COM. 20 | sipgate.co.uk. 21397 IN MX 5 ALT1.ASPMX.L.GOOGLE.COM. 21 | sipgate.co.uk. 21397 IN MX 5 ALT2.ASPMX.L.GOOGLE.COM. 22 | sipgate.co.uk. 21397 IN MX 10 ASPMX2.GOOGLEMAIL.COM. 23 | sipgate.co.uk. 21397 IN MX 10 ASPMX3.GOOGLEMAIL.COM. 24 | sipgate.co.uk. 21397 IN MX 10 ASPMX4.GOOGLEMAIL.COM. 25 | sipgate.co.uk. 21397 IN MX 10 ASPMX5.GOOGLEMAIL.COM. 26 | sipgate.co.uk. 3397 IN A 217.10.79.23 27 | 28 | -------------------------------------------------------------------------------- /gaehelper/dnslib/ranges.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Wrapper around property builtin to restrict attribute to defined 5 | integer value range (throws ValueError). 6 | 7 | Intended to ensure that values packed with struct are in the 8 | correct range 9 | 10 | >>> class T(object): 11 | ... a = range_property('a',-100,100) 12 | ... b = B('b') 13 | ... c = H('c') 14 | ... d = I('d') 15 | >>> t = T() 16 | >>> for i in [0,100,-100]: 17 | ... t.a = i 18 | ... assert t.a == i 19 | >>> t.a = 101 20 | Traceback (most recent call last): 21 | ... 22 | ValueError: Attribute 'a' must be between -100-100 [101] 23 | >>> t.a = -101 24 | Traceback (most recent call last): 25 | ... 26 | ValueError: Attribute 'a' must be between -100-100 [-101] 27 | >>> t.a = 'blah' 28 | Traceback (most recent call last): 29 | ... 30 | ValueError: Attribute 'a' must be between -100-100 [blah] 31 | 32 | """ 33 | 34 | import sys 35 | if sys.version < '3': 36 | int_types = (int, long,) 37 | else: 38 | int_types = (int,) 39 | 40 | def range_property(attr,min,max): 41 | def getter(obj): 42 | return getattr(obj,"_%s" % attr) 43 | def setter(obj,val): 44 | if isinstance(val,int_types) and min <= val <= max: 45 | setattr(obj,"_%s" % attr,val) 46 | else: 47 | raise ValueError("Attribute '%s' must be between %d-%d [%s]" % 48 | (attr,min,max,val)) 49 | return property(getter,setter) 50 | 51 | def B(attr): 52 | """ 53 | Unsigned Byte 54 | """ 55 | return range_property(attr,0,255) 56 | 57 | def H(attr): 58 | """ 59 | Unsigned Short 60 | """ 61 | return range_property(attr,0,65535) 62 | 63 | def I(attr): 64 | """ 65 | Unsigned Long 66 | """ 67 | return range_property(attr,0,4294967295) 68 | 69 | def ntuple_range(attr,n,min,max): 70 | f = lambda x : isinstance(x,int_types) and min <= x <= max 71 | def getter(obj): 72 | return getattr(obj,"_%s" % attr) 73 | def setter(obj,val): 74 | if len(val) != n: 75 | raise ValueError("Attribute '%s' must be tuple with %d elements [%s]" % 76 | (attr,n,val)) 77 | if all(map(f,val)): 78 | setattr(obj,"_%s" % attr,val) 79 | else: 80 | raise ValueError("Attribute '%s' elements must be between %d-%d [%s]" % 81 | (attr,min,max,val)) 82 | return property(getter,setter) 83 | 84 | def IP4(attr): 85 | return ntuple_range(attr,4,0,255) 86 | 87 | def IP6(attr): 88 | return ntuple_range(attr,16,0,255) 89 | 90 | if __name__ == '__main__': 91 | import doctest 92 | doctest.testmod() 93 | 94 | -------------------------------------------------------------------------------- /dlmusic/songsdb.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from vavava import sqliteutil 5 | 6 | SQL_CREATE_TABLES = """ 7 | -- Table: songs 8 | CREATE TABLE IF NOT EXISTS songs ( 9 | id INTEGER PRIMARY KEY, 10 | code TEXT UNIQUE, 11 | title TEXT, 12 | offline INTEGER 13 | ); 14 | 15 | -- Index: idx_songs_code 16 | -- CREATE INDEX idx_songs_code ON songs ( 17 | -- code COLLATE NOCASE DESC 18 | -- ); 19 | """ 20 | 21 | class Songs: 22 | def __init__(self, db_file): 23 | self.db_file = db_file 24 | self.db = sqliteutil.Sqlite3Helper(db_file) 25 | self.db.get_connection() 26 | self.db.conn.executescript(SQL_CREATE_TABLES) 27 | 28 | def exists(self, code): 29 | sql = r'select count(id) from song where code=%s'%code 30 | return self.db.fetch_one(sql)[0] > 0 31 | 32 | def insert(self, code, title): 33 | sql = r'insert into songs(code, title, offline) values("%s", "%s", 0)' % (code, title) 34 | self.db.conn.execute(sql) 35 | 36 | def set_offline(self, code, offline): 37 | sql = r'update songs set offline=%s where code=%s' % (offline, code) 38 | self.db.conn.execute(sql) 39 | 40 | def get_need_offline_list(self): 41 | """return [(id,code,title,offline)]""" 42 | sql = r'select * from songs where offline=0' 43 | return self.db.fetch_all(sql) 44 | 45 | 46 | def getinfo_by_code(self, code): 47 | """return (id,code,title,offline)""" 48 | sql = r'select * from songs where code="%s"' % (code) 49 | return self.db.fetch_one(sql) 50 | 51 | 52 | ###### for test ##### 53 | 54 | def test_set_offline(songs): 55 | code = '158465' 56 | print r'===> %d,%s,%s,%d' % songs.getinfo_by_code(code) 57 | songs.set_offline(code, 1) 58 | print r'===> %d,%s,%s,%d' % songs.getinfo_by_code(code) 59 | songs.set_offline(code, 0) 60 | print r'===> %d,%s,%s,%d' % songs.getinfo_by_code(code) 61 | 62 | def test_syn_song_list_to_db(songs): 63 | for song in open('song_list.txt', 'r').readlines(): 64 | try: 65 | info = song.split("#") 66 | code, title = info[0], info[1] 67 | songs.insert(code, title) 68 | print '===> insert:', code, "#", title 69 | except Exception as e: 70 | print e.message 71 | 72 | def test_get_need_offline_list(songs): 73 | for info in songs.get_need_offline_list(): 74 | print r'%d,%s,%s,%d'%info 75 | 76 | def test_set_all(songs): 77 | for code in [x[1] for x in songs.get_need_offline_list()]: 78 | songs.set_offline(code, 1) 79 | 80 | if __name__ == "__main__": 81 | songs = Songs('songs.db3') 82 | # test_syn_song_list_to_db(songs) 83 | # test_set_offline(songs) 84 | test_get_need_offline_list(songs) 85 | # test_set_all(songs) 86 | -------------------------------------------------------------------------------- /gaehelper/dnslib/bit.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Some basic bit mainpulation utilities 5 | """ 6 | from __future__ import print_function 7 | 8 | FILTER = bytearray([ (i < 32 or i > 127) and 46 or i for i in range(256) ]) 9 | 10 | def hexdump(src, length=16, prefix=''): 11 | """ 12 | Print hexdump of string 13 | 14 | >>> print(hexdump(b"abcd" * 4)) 15 | 0000 61 62 63 64 61 62 63 64 61 62 63 64 61 62 63 64 abcdabcd abcdabcd 16 | 17 | >>> print(hexdump(bytearray(range(48)))) 18 | 0000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ........ ........ 19 | 0010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f ........ ........ 20 | 0020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f !"#$%&' ()*+,-./ 21 | 22 | """ 23 | n = 0 24 | left = length // 2 25 | right = length - left 26 | result= [] 27 | src = bytearray(src) 28 | while src: 29 | s,src = src[:length],src[length:] 30 | l,r = s[:left],s[left:] 31 | hexa = "%-*s" % (left*3,' '.join(["%02x"%x for x in l])) 32 | hexb = "%-*s" % (right*3,' '.join(["%02x"%x for x in r])) 33 | lf = l.translate(FILTER) 34 | rf = r.translate(FILTER) 35 | result.append("%s%04x %s %s %s %s" % (prefix, n, hexa, hexb, 36 | lf.decode(), rf.decode())) 37 | n += length 38 | return "\n".join(result) 39 | 40 | def get_bits(data,offset,bits=1): 41 | """ 42 | Get specified bits from integer 43 | 44 | >>> bin(get_bits(0b0011100,2)) 45 | '0b1' 46 | >>> bin(get_bits(0b0011100,0,4)) 47 | '0b1100' 48 | 49 | """ 50 | mask = ((1 << bits) - 1) << offset 51 | return (data & mask) >> offset 52 | 53 | def set_bits(data,value,offset,bits=1): 54 | """ 55 | Set specified bits in integer 56 | 57 | >>> bin(set_bits(0,0b1010,0,4)) 58 | '0b1010' 59 | >>> bin(set_bits(0,0b1010,3,4)) 60 | '0b1010000' 61 | """ 62 | mask = ((1 << bits) - 1) << offset 63 | clear = 0xffff ^ mask 64 | data = (data & clear) | ((value << offset) & mask) 65 | return data 66 | 67 | def binary(n,count=16,reverse=False): 68 | """ 69 | Display n in binary (only difference from built-in `bin` is 70 | that this function returns a fixed width string and can 71 | optionally be reversed 72 | 73 | >>> binary(6789) 74 | '0001101010000101' 75 | >>> binary(6789,8) 76 | '10000101' 77 | >>> binary(6789,reverse=True) 78 | '1010000101011000' 79 | 80 | """ 81 | bits = [str((n >> y) & 1) for y in range(count-1, -1, -1)] 82 | if reverse: 83 | bits.reverse() 84 | return "".join(bits) 85 | 86 | if __name__ == '__main__': 87 | import doctest 88 | doctest.testmod() 89 | 90 | -------------------------------------------------------------------------------- /gaehelper/www/ip_info.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | 63 | 64 | 65 | 66 |
67 | 68 |
69 |
70 | 71 | 72 | -------------------------------------------------------------------------------- /gaehelper/dnslib/test/microsoft.com-ANY: -------------------------------------------------------------------------------- 1 | ;; Sending: 2 | ;; QUERY: b8f001000001000000000000096d6963726f736f667403636f6d0000ff0001 3 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47344 4 | ;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 5 | ;; QUESTION SECTION: 6 | ;microsoft.com. IN ANY 7 | 8 | ;; Got answer: 9 | ;; RESPONSE: b8f081800001000b00000000096d6963726f736f667403636f6d0000ff0001c00c0001000100000227000486aab92ec00c0001000100000227000486aabcddc00c0002000100004877000e036e7332046d736674036e657400c00c00020001000048770006036e7333c04fc00c00020001000048770006036e7334c04fc00c00020001000048770006036e7335c04fc00c00020001000048770006036e7331c04fc00c0006000100000227001fc09b066d736e687374c00c780c762a0000012c000002580024ea0000000e10c00c000f000100000227002a000a0d6d6963726f736f66742d636f6d046d61696c0a70726f74656374696f6e076f75746c6f6f6bc016c00c0010000100000227005958466255463644626b452b4177312f77693978674469384b567249495a75733576384c36746249515a6b4772512f7256514b4a6938436a5162427457744536346579344e4a4a776a354a36355049676756594e616264513d3dc00c001000010000022700f9f8763d7370663120696e636c7564653a5f7370662d612e6d6963726f736f66742e636f6d20696e636c7564653a5f7370662d622e6d6963726f736f66742e636f6d20696e636c7564653a5f7370662d632e6d6963726f736f66742e636f6d20696e636c7564653a5f7370662d7373672d612e6d6963726f736f66742e636f6d20696e636c7564653a7370662d612e686f746d61696c2e636f6d206970343a3134372e3234332e3132382e3234206970343a3134372e3234332e3132382e3236206970343a3134372e3234332e3132382e3235206970343a3134372e3234332e312e3437206970343a3134372e3234332e312e3438202d616c6c 10 | ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47344 11 | ;; flags: qr rd ra; QUERY: 1, ANSWER: 11, AUTHORITY: 0, ADDITIONAL: 0 12 | ;; QUESTION SECTION: 13 | ;microsoft.com. IN ANY 14 | ;; ANSWER SECTION: 15 | microsoft.com. 551 IN A 134.170.185.46 16 | microsoft.com. 551 IN A 134.170.188.221 17 | microsoft.com. 18551 IN NS ns2.msft.net. 18 | microsoft.com. 18551 IN NS ns3.msft.net. 19 | microsoft.com. 18551 IN NS ns4.msft.net. 20 | microsoft.com. 18551 IN NS ns5.msft.net. 21 | microsoft.com. 18551 IN NS ns1.msft.net. 22 | microsoft.com. 551 IN SOA ns1.msft.net. msnhst.microsoft.com. 2014082602 300 600 2419200 3600 23 | microsoft.com. 551 IN MX 10 microsoft-com.mail.protection.outlook.com. 24 | microsoft.com. 551 IN TXT "FbUF6DbkE+Aw1/wi9xgDi8KVrIIZus5v8L6tbIQZkGrQ/rVQKJi8CjQbBtWtE64ey4NJJwj5J65PIggVYNabdQ==" 25 | microsoft.com. 551 IN TXT "v=spf1 include:_spf-a.microsoft.com include:_spf-b.microsoft.com include:_spf-c.microsoft.com include:_spf-ssg-a.microsoft.com include:spf-a.hotmail.com ip4:147.243.128.24 ip4:147.243.128.26 ip4:147.243.128.25 ip4:147.243.1.47 ip4:147.243.1.48 -all" 26 | 27 | -------------------------------------------------------------------------------- /backup/renamefiles.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys 4 | import os 5 | import getopt 6 | from shutil import copyfile 7 | 8 | 9 | try: 10 | reload(sys).setdefaultencoding("utf8") 11 | except: 12 | pass 13 | 14 | pjoin, pabspath, pbasename = os.path.join, os.path.abspath, os.path.basename 15 | 16 | 17 | 18 | class OptionParser(): 19 | def __init__(self, *args): 20 | self.OPTS = args 21 | self.PARAM = {} 22 | for cmd in self.OPTS: 23 | if cmd.endswith ('='): 24 | self.PARAM[cmd.replace ('=', '')] = None 25 | else: 26 | self.PARAM[cmd] = False 27 | 28 | try: 29 | opts, sys.args = getopt.getopt (sys.argv[1:], "hic:", self.OPTS) 30 | except getopt.GetoptError as e: 31 | print("options:", self.OPTS) 32 | return 33 | if len (opts) == 0: 34 | print("options:", self.OPTS) 35 | return 36 | for opt, arg in opts: 37 | if arg is not "": 38 | self.PARAM[opt.replace ('-', '')] = arg 39 | else: 40 | self.PARAM[opt.replace ('-', '')] = True 41 | 42 | def check(self, opt): 43 | return opt in self.PARAM and self.PARAM[opt] 44 | 45 | def __getattr__(self, attr_name): 46 | if attr_name in self.PARAM: 47 | return self.PARAM[attr_name] 48 | else: 49 | raise(AttributeError, attr_name) 50 | 51 | 52 | 53 | def main(): 54 | args = OptionParser("path=", "force", "out=", "undo", "sufix=") 55 | if not args.path: 56 | print("python rename.py --path=./123 --force --sufix=xls") 57 | print("python rename.py --path=./123 --force --undo") 58 | exit(0) 59 | root = pabspath(args.path if args.path else "./") 60 | for parent, dirs, files in os.walk(root): 61 | path_name = os.path.split(parent) 62 | path_name = path_name[len(path_name)-1] 63 | for f in files: 64 | if args.undo: 65 | if f.find(path_name) == 0: 66 | src = pjoin(parent, f) 67 | dst = pjoin(parent, f[len(path_name)+1:]) 68 | if args.force: 69 | os.rename(src, dst) 70 | else: 71 | print(src, dst) 72 | continue 73 | if args.sufix: 74 | if f.split('.')[1:][0] != args.sufix: 75 | continue 76 | src = pjoin(parent, f) 77 | dst = pjoin(parent, "%s_%s" % (path_name, f)) 78 | if not args.force: 79 | print(src, dst) 80 | elif args.out: 81 | copyfile(src, dst) 82 | else: 83 | os.rename(src, dst) 84 | 85 | 86 | if __name__ == "__main__": 87 | try: 88 | main () 89 | except KeyboardInterrupt as e: 90 | print("stop by user") 91 | exit (0) -------------------------------------------------------------------------------- /bt/3.txt: -------------------------------------------------------------------------------- 1 | 机构名称,机构地址,区县,机构电话,基本医保点,医保编码,新农合定点,邮政编码, 2 | 八角北里社区卫生服务站,北京市石景山区八角北里物业楼一层,石景山区,68863275,是,07162004,否,100043, 3 | 五里坨社区卫生服务中心,石景山区石门路322号,石景山区,51510589,是,07110031,是,100042, 4 | 衙门口社区卫生服务站,北京市石景山区衙门口南,石景山区,68604109,是,07162040,否,100043, 5 | 水泥厂社区卫生服务站,北京市石景山区京原路68号,石景山区,88806839,是,07162010,否,100041, 6 | 老古城社区卫生服务站,北京市石景山区老古城北后道8号,石景山区,68820341,是,07162025,否,100043, 7 | 永乐二社区卫生服务站,永乐东区23-4-1、2、3,石景山区,68637183,是,07162007,否,100040, 8 | 杨庄社区卫生服务站,石景山杨庄路西口,石景山区,57100114,是,07110008,否,100043, 9 | 重兴园社区卫生服务站,石景山区八宝山南路重兴嘉园1号楼一层,石景山区,85858188,是,07162042,否,100040, 10 | 雍景四季社区卫生服务站,北京市石景山区苹果园街道西黄新村西里12号楼601室,石景山区,68898184,是,07162044,否,100144, 11 | 模式口西里社区卫生服务站,北京市石景山区模式口西里小区,石景山区,88293254,是,07162011,否,100041, 12 | 刘娘府社区卫生服务站,北京市石景山区苹果园街道刘娘府大队1号,石景山区,88734456,是,07162039,否,100041, 13 | 体育馆路社区卫生服务站,石景山路32号,石景山区,88707949,是,07162024,否,100043, 14 | 依翠园社区卫生服务站,石景山区依翠园5号院,石景山区,68629157,是,07162027,否,100040, 15 | 金世界社区卫生服务站,石景山杨北21楼,石景山区,88929572,是,07162017,否,100043, 16 | 北辛安社区卫生服务站,石景山区古城街道北辛安南岔149号,石景山区,68871640,是,07110028,否,100041, 17 | 老山社区卫生服务中心,北京市石景山区老山西里,石景山区,88296529,是,07161005,否,100049, 18 | 广宁社区卫生服务中心,北京市石景山区广宁街道原广宁中学院内,石景山区,88990400,是,07110043,否,100041, 19 | 西山社区卫生服务站,北京市石景山区黑石头路炮厂小区,石景山区,88952242,是,07130002,否,100042, 20 | 永乐社区卫生服务站,北京市石景山区鲁谷街道永乐西小区23号楼底商,石景山区,68663281,是,07162023,否,100040, 21 | 鲁谷社区卫生服务中心,石景山鲁谷小区六合园,石景山区,010-51718219,是,07161007,否,100040, 22 | 远洋山水社区卫生服务站,北京市石景山区玉泉西里二区29号楼,石景山区,68652494,是,07162002,否,100040, 23 | 古城南里社区卫生服务站,北京市石景山区古城南里5号楼2门43号,石景山区,68844325,是,07162001,否,100043, 24 | 南宫社区卫生服务站,石景山石门路368号,石景山区,51511215,是,07162046,否,100042, 25 | 海特花园社区卫生服务站,北京市石景山区海特花园45号楼101-102,石景山区,88794771,是,07162026,否,100041, 26 | 八角中里社区卫生服务站,石景山八角中里居委会,石景山区,88928021,是,07162015,否,100043, 27 | 璟都馨园社区卫生服务站,石景山区时代花园南路28号院2号楼底商,石景山区,88980010,是,07162045,否,100043, 28 | 麻峪社区卫生服务站,广宁街道麻峪南沟甲5号,石景山区,51946123,是,07162003,否,100041, 29 | 八角南路社区卫生服务站,北京市石景山区八角南路21栋旁,石景山区,68816992,是,07162005,否,100043, 30 | 金四区社区卫生服务站,北京市石景山区金顶街四区,石景山区,88757497,是,07162033,否,100041, 31 | 西山枫林社区卫生服务站,北京市石景山区香山南路166号院56号,石景山区,88994615,是,07162037,否,100144, 32 | 赵山社区卫生服务站,北京市石景山区金顶街街道赵山宿舍院内平房,石景山区,88749656,是,07162019,否,100041, 33 | 西黄村社区卫生服务站,北京市石景山区西黄村后街24号,石景山区,88701091,是,07162020,否,100144, 34 | 八宝山社区卫生服务中心,石景山鲁谷东街38号,石景山区,010-88655151,是,07161002,否,100040, 35 | 寿山福海社区卫生服务站,北京市石景山区双峪路23号,石景山区,88991616,是,07162041,否,100041, 36 | 北方工大社区卫生服务中心,石景山区晋元庄路5号,石景山区,88803257,是,07111003,否,100144, 37 | 古城社区卫生服务中心,北京市石景山区古城小街,石景山区,88296532,是,07161003,否,100043, 38 | 融景城社区卫生服务站,,石景山区,,否,,否,, 39 | 北京市石景山区消防支队社区卫生服务 40 | 站,,石景山区,,否,,否,, 41 | 燕保京原家园社区卫生服务站,,石景山区,,否,,否,, 42 | 金汉丽苑社区卫生服务站,,石景山区,,否,,否,, 43 | 隆恩家园社区卫生服务站,,石景山区,,否,,否,, 44 | 金顶街模东社区卫生服务站,,石景山区,,否,,否,, 45 | 十万平社区卫生服务站,,石景山区,,否,,否,, 46 | 远洋沁山水社区卫生服务站,,石景山区,,否,,否,, 47 | 滨和园东社区卫生服务站,,石景山区,,否,,否,, 48 | 八角北路社区卫生服务站,石景山区八角北路小区17幢 49 | ,石景山区,68884381 50 | ,是,07162018,否,100043 51 | , 52 | 金顶街社区卫生服务中心,北京市石景山区金顶北路22号院1号楼,石景山区,88778785,是,07161004,否,100041, 53 | 中础社区卫生服务站,北京市石景山区石景山路23号,石景山区,68885504,是,07131002,否,100049, 54 | 苹果园社区卫生服务中心,石景山区苹果园大街86号,石景山区,88707858,是,07161006,否,100041, 55 | 八角社区卫生服务中心,北京市石景山区八角北路,石景山区,68862920,是,07110030,否,100043, 56 | -------------------------------------------------------------------------------- /dlmusic/.gitignore: -------------------------------------------------------------------------------- 1 | *.ini 2 | *.txt 3 | *.db3 4 | 5 | ################# 6 | ## Eclipse 7 | ################# 8 | 9 | *.pydevproject 10 | .project 11 | .metadata 12 | bin/ 13 | tmp/ 14 | *.tmp 15 | *.bak 16 | *.swp 17 | *~.nib 18 | local.properties 19 | .classpath 20 | .settings/ 21 | .loadpath 22 | 23 | # External tool builders 24 | .externalToolBuilders/ 25 | 26 | # Locally stored "Eclipse launch configurations" 27 | *.launch 28 | 29 | # CDT-specific 30 | .cproject 31 | 32 | # PDT-specific 33 | .buildpath 34 | 35 | 36 | ################# 37 | ## Visual Studio 38 | ################# 39 | 40 | ## Ignore Visual Studio temporary files, build results, and 41 | ## files generated by popular Visual Studio add-ons. 42 | 43 | # User-specific files 44 | *.suo 45 | *.user 46 | *.sln.docstates 47 | 48 | # Build results 49 | [Dd]ebug/ 50 | [Rr]elease/ 51 | *_i.c 52 | *_p.c 53 | *.ilk 54 | *.meta 55 | *.obj 56 | *.pch 57 | *.pdb 58 | *.pgc 59 | *.pgd 60 | *.rsp 61 | *.sbr 62 | *.tlb 63 | *.tli 64 | *.tlh 65 | *.tmp 66 | *.vspscc 67 | .builds 68 | *.dotCover 69 | 70 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 71 | #packages/ 72 | 73 | # Visual C++ cache files 74 | ipch/ 75 | *.aps 76 | *.ncb 77 | *.opensdf 78 | *.sdf 79 | 80 | # Visual Studio profiler 81 | *.psess 82 | *.vsp 83 | 84 | # ReSharper is a .NET coding add-in 85 | _ReSharper* 86 | 87 | # Installshield output folder 88 | [Ee]xpress 89 | 90 | # DocProject is a documentation generator add-in 91 | DocProject/buildhelp/ 92 | DocProject/Help/*.HxT 93 | DocProject/Help/*.HxC 94 | DocProject/Help/*.hhc 95 | DocProject/Help/*.hhk 96 | DocProject/Help/*.hhp 97 | DocProject/Help/Html2 98 | DocProject/Help/html 99 | 100 | # Click-Once directory 101 | publish 102 | 103 | # Others 104 | [Bb]in 105 | [Oo]bj 106 | sql 107 | TestResults 108 | *.Cache 109 | ClientBin 110 | stylecop.* 111 | ~$* 112 | *.dbmdl 113 | Generated_Code #added for RIA/Silverlight projects 114 | 115 | # Backup & report files from converting an old project file to a newer 116 | # Visual Studio version. Backup files are not needed, because we have git ;-) 117 | _UpgradeReport_Files/ 118 | Backup*/ 119 | UpgradeLog*.XML 120 | 121 | 122 | 123 | ############ 124 | ## Windows 125 | ############ 126 | 127 | # Windows image file caches 128 | Thumbs.db 129 | 130 | # Folder config file 131 | Desktop.ini 132 | 133 | 134 | ############# 135 | ## Python 136 | ############# 137 | 138 | *.py[co] 139 | 140 | # Packages 141 | *.egg 142 | *.egg-info 143 | dist 144 | build 145 | eggs 146 | parts 147 | bin 148 | var 149 | sdist 150 | develop-eggs 151 | .installed.cfg 152 | 153 | # Installer logs 154 | pip-log.txt 155 | 156 | # Unit test / coverage reports 157 | .coverage 158 | .tox 159 | 160 | #Translations 161 | *.mo 162 | 163 | #Mr Developer 164 | .mr.developer.cfg 165 | 166 | # Mac crap 167 | .DS_Store 168 | 169 | *.mp3 170 | *.lrc 171 | *.jpg 172 | 173 | # Third-party component 174 | /mutagen* 175 | -------------------------------------------------------------------------------- /dlvideo/utils.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import os 5 | import sys 6 | from vavava import util 7 | from vavava import httputil 8 | 9 | default_encoding = sys.getfilesystemencoding() 10 | if default_encoding.lower() == 'ascii': 11 | default_encoding = 'utf-8' 12 | 13 | pjoin = os.path.join 14 | dirname = os.path.dirname 15 | abspath = os.path.abspath 16 | exists = os.path.exists 17 | 18 | 19 | def to_native_string(s): 20 | if type(s) == unicode: 21 | return s.encode(default_encoding) 22 | else: 23 | return s 24 | 25 | 26 | def escape_file_path(path): 27 | path = path.replace('/', '_') 28 | path = path.replace('\\', '_') 29 | path = path.replace('*', '_') 30 | path = path.replace('?', '_') 31 | path = path.replace('\'', '_') 32 | return path 33 | 34 | 35 | def guess_ext(urls, title): 36 | for url in urls: 37 | if url.find('mp4') >= 0: 38 | return 'mp4' 39 | if title.find('mp4') >= 0: 40 | return 'mp4' 41 | return 'flv' 42 | 43 | 44 | class Wget: 45 | 46 | def __init__(self): 47 | self.useragent = r'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) ' \ 48 | r'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/' \ 49 | r'33.0.1750.149 Safari/537.36' 50 | 51 | def get(self, url, out=None, headers=None, proxy=None): 52 | cmd = "wget -c --user-agent='%s'" % (self.useragent) 53 | if headers: 54 | for k, v in headers.items(): 55 | if k in ('referer'): 56 | cmd += " --referer='%s'" % (v) 57 | else: 58 | cmd += " --header='%s:%s'" % (k, v) 59 | if out: 60 | cmd += " --output-document='%s'" % (out) 61 | if not proxy: 62 | cmd += " --no-proxy" 63 | cmd += " '%s'" % (url) 64 | self.__exec(cmd) 65 | 66 | def __exec(self, cmd): 67 | print cmd 68 | self.result = os.system(cmd) 69 | if self.result != 0: 70 | raise StandardError("result=%d %s" % (self.result, cmd)) 71 | 72 | 73 | class Axel: 74 | def __init__(self): 75 | self.useragent = r'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) ' \ 76 | r'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.149 ' \ 77 | r'Safari/537.36' 78 | 79 | def get(self, url, out=None, n=None, headers=None): 80 | cmd = "axel -v -a -U '%s'" % (self.useragent) 81 | if headers: 82 | for k, v in headers.items(): 83 | cmd += " -H '%s:%s'" % (k, v) 84 | if n: 85 | cmd += " -n %d" % (n) 86 | if out: 87 | cmd += " -o '%s'" % (out) 88 | cmd += " '%s'" % (url) 89 | self.__exec(cmd) 90 | 91 | def __exec(self, cmd): 92 | print cmd 93 | self.result = os.system(cmd) 94 | if self.result != 0: 95 | raise StandardError("result=%d %s" % (self.result, cmd)) 96 | -------------------------------------------------------------------------------- /weibo/.gitignore: -------------------------------------------------------------------------------- 1 | *.ini 2 | *.json 3 | *.txt 4 | *.db3 5 | 6 | ################# 7 | ## Eclipse 8 | ################# 9 | 10 | *.pydevproject 11 | .project 12 | .metadata 13 | bin/ 14 | tmp/ 15 | *.tmp 16 | *.bak 17 | *.swp 18 | *~.nib 19 | local.properties 20 | .classpath 21 | .settings/ 22 | .loadpath 23 | 24 | # External tool builders 25 | .externalToolBuilders/ 26 | 27 | # Locally stored "Eclipse launch configurations" 28 | *.launch 29 | 30 | # CDT-specific 31 | .cproject 32 | 33 | # PDT-specific 34 | .buildpath 35 | 36 | 37 | ################# 38 | ## Visual Studio 39 | ################# 40 | 41 | ## Ignore Visual Studio temporary files, build results, and 42 | ## files generated by popular Visual Studio add-ons. 43 | 44 | # User-specific files 45 | *.suo 46 | *.user 47 | *.sln.docstates 48 | 49 | # Build results 50 | [Dd]ebug/ 51 | [Rr]elease/ 52 | *_i.c 53 | *_p.c 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.vspscc 68 | .builds 69 | *.dotCover 70 | 71 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 72 | #packages/ 73 | 74 | # Visual C++ cache files 75 | ipch/ 76 | *.aps 77 | *.ncb 78 | *.opensdf 79 | *.sdf 80 | 81 | # Visual Studio profiler 82 | *.psess 83 | *.vsp 84 | 85 | # ReSharper is a .NET coding add-in 86 | _ReSharper* 87 | 88 | # Installshield output folder 89 | [Ee]xpress 90 | 91 | # DocProject is a documentation generator add-in 92 | DocProject/buildhelp/ 93 | DocProject/Help/*.HxT 94 | DocProject/Help/*.HxC 95 | DocProject/Help/*.hhc 96 | DocProject/Help/*.hhk 97 | DocProject/Help/*.hhp 98 | DocProject/Help/Html2 99 | DocProject/Help/html 100 | 101 | # Click-Once directory 102 | publish 103 | 104 | # Others 105 | [Bb]in 106 | [Oo]bj 107 | sql 108 | TestResults 109 | *.Cache 110 | ClientBin 111 | stylecop.* 112 | ~$* 113 | *.dbmdl 114 | Generated_Code #added for RIA/Silverlight projects 115 | 116 | # Backup & report files from converting an old project file to a newer 117 | # Visual Studio version. Backup files are not needed, because we have git ;-) 118 | _UpgradeReport_Files/ 119 | Backup*/ 120 | UpgradeLog*.XML 121 | 122 | 123 | 124 | ############ 125 | ## Windows 126 | ############ 127 | 128 | # Windows image file caches 129 | Thumbs.db 130 | 131 | # Folder config file 132 | Desktop.ini 133 | 134 | 135 | ############# 136 | ## Python 137 | ############# 138 | 139 | *.py[co] 140 | 141 | # Packages 142 | *.egg 143 | *.egg-info 144 | dist 145 | build 146 | eggs 147 | parts 148 | bin 149 | var 150 | sdist 151 | develop-eggs 152 | .installed.cfg 153 | 154 | # Installer logs 155 | pip-log.txt 156 | 157 | # Unit test / coverage reports 158 | .coverage 159 | .tox 160 | 161 | #Translations 162 | *.mo 163 | 164 | #Mr Developer 165 | .mr.developer.cfg 166 | 167 | # Mac crap 168 | .DS_Store 169 | 170 | *.mp3 171 | *.lrc 172 | *.jpg 173 | 174 | # Third-party component 175 | /mutagen* 176 | -------------------------------------------------------------------------------- /backup/.gitignore: -------------------------------------------------------------------------------- 1 | *.ini 2 | *.json 3 | *.txt 4 | *.db3 5 | 6 | ################# 7 | ## Eclipse 8 | ################# 9 | 10 | *.pydevproject 11 | .project 12 | .metadata 13 | bin/ 14 | tmp/ 15 | *.tmp 16 | *.bak 17 | *.swp 18 | *~.nib 19 | local.properties 20 | .classpath 21 | .settings/ 22 | .loadpath 23 | 24 | # External tool builders 25 | .externalToolBuilders/ 26 | 27 | # Locally stored "Eclipse launch configurations" 28 | *.launch 29 | 30 | # CDT-specific 31 | .cproject 32 | 33 | # PDT-specific 34 | .buildpath 35 | 36 | 37 | ################# 38 | ## Visual Studio 39 | ################# 40 | 41 | ## Ignore Visual Studio temporary files, build results, and 42 | ## files generated by popular Visual Studio add-ons. 43 | 44 | # User-specific files 45 | *.suo 46 | *.user 47 | *.sln.docstates 48 | 49 | # Build results 50 | [Dd]ebug/ 51 | [Rr]elease/ 52 | *_i.c 53 | *_p.c 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.vspscc 68 | .builds 69 | *.dotCover 70 | 71 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 72 | #packages/ 73 | 74 | # Visual C++ cache files 75 | ipch/ 76 | *.aps 77 | *.ncb 78 | *.opensdf 79 | *.sdf 80 | 81 | # Visual Studio profiler 82 | *.psess 83 | *.vsp 84 | 85 | # ReSharper is a .NET coding add-in 86 | _ReSharper* 87 | 88 | # Installshield output folder 89 | [Ee]xpress 90 | 91 | # DocProject is a documentation generator add-in 92 | DocProject/buildhelp/ 93 | DocProject/Help/*.HxT 94 | DocProject/Help/*.HxC 95 | DocProject/Help/*.hhc 96 | DocProject/Help/*.hhk 97 | DocProject/Help/*.hhp 98 | DocProject/Help/Html2 99 | DocProject/Help/html 100 | 101 | # Click-Once directory 102 | publish 103 | 104 | # Others 105 | [Bb]in 106 | [Oo]bj 107 | sql 108 | TestResults 109 | *.Cache 110 | ClientBin 111 | stylecop.* 112 | ~$* 113 | *.dbmdl 114 | Generated_Code #added for RIA/Silverlight projects 115 | 116 | # Backup & report files from converting an old project file to a newer 117 | # Visual Studio version. Backup files are not needed, because we have git ;-) 118 | _UpgradeReport_Files/ 119 | Backup*/ 120 | UpgradeLog*.XML 121 | 122 | 123 | 124 | ############ 125 | ## Windows 126 | ############ 127 | 128 | # Windows image file caches 129 | Thumbs.db 130 | 131 | # Folder config file 132 | Desktop.ini 133 | 134 | 135 | ############# 136 | ## Python 137 | ############# 138 | 139 | *.py[co] 140 | 141 | # Packages 142 | *.egg 143 | *.egg-info 144 | dist 145 | build 146 | eggs 147 | parts 148 | bin 149 | var 150 | sdist 151 | develop-eggs 152 | .installed.cfg 153 | 154 | # Installer logs 155 | pip-log.txt 156 | 157 | # Unit test / coverage reports 158 | .coverage 159 | .tox 160 | 161 | #Translations 162 | *.mo 163 | 164 | #Mr Developer 165 | .mr.developer.cfg 166 | 167 | # Mac crap 168 | .DS_Store 169 | 170 | *.mp3 171 | *.lrc 172 | *.jpg 173 | 174 | # Third-party component 175 | /mutagen* 176 | -------------------------------------------------------------------------------- /dllive/.gitignore: -------------------------------------------------------------------------------- 1 | *.ini 2 | *.json 3 | *.txt 4 | *.db3 5 | 6 | ################# 7 | ## Eclipse 8 | ################# 9 | 10 | *.pydevproject 11 | .project 12 | .metadata 13 | bin/ 14 | tmp/ 15 | *.tmp 16 | *.bak 17 | *.swp 18 | *~.nib 19 | local.properties 20 | .classpath 21 | .settings/ 22 | .loadpath 23 | 24 | # External tool builders 25 | .externalToolBuilders/ 26 | 27 | # Locally stored "Eclipse launch configurations" 28 | *.launch 29 | 30 | # CDT-specific 31 | .cproject 32 | 33 | # PDT-specific 34 | .buildpath 35 | 36 | 37 | ################# 38 | ## Visual Studio 39 | ################# 40 | 41 | ## Ignore Visual Studio temporary files, build results, and 42 | ## files generated by popular Visual Studio add-ons. 43 | 44 | # User-specific files 45 | *.suo 46 | *.user 47 | *.sln.docstates 48 | 49 | # Build results 50 | [Dd]ebug/ 51 | [Rr]elease/ 52 | *_i.c 53 | *_p.c 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.vspscc 68 | .builds 69 | *.dotCover 70 | 71 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 72 | #packages/ 73 | 74 | # Visual C++ cache files 75 | ipch/ 76 | *.aps 77 | *.ncb 78 | *.opensdf 79 | *.sdf 80 | 81 | # Visual Studio profiler 82 | *.psess 83 | *.vsp 84 | 85 | # ReSharper is a .NET coding add-in 86 | _ReSharper* 87 | 88 | # Installshield output folder 89 | [Ee]xpress 90 | 91 | # DocProject is a documentation generator add-in 92 | DocProject/buildhelp/ 93 | DocProject/Help/*.HxT 94 | DocProject/Help/*.HxC 95 | DocProject/Help/*.hhc 96 | DocProject/Help/*.hhk 97 | DocProject/Help/*.hhp 98 | DocProject/Help/Html2 99 | DocProject/Help/html 100 | 101 | # Click-Once directory 102 | publish 103 | 104 | # Others 105 | [Bb]in 106 | [Oo]bj 107 | sql 108 | TestResults 109 | *.Cache 110 | ClientBin 111 | stylecop.* 112 | ~$* 113 | *.dbmdl 114 | Generated_Code #added for RIA/Silverlight projects 115 | 116 | # Backup & report files from converting an old project file to a newer 117 | # Visual Studio version. Backup files are not needed, because we have git ;-) 118 | _UpgradeReport_Files/ 119 | Backup*/ 120 | UpgradeLog*.XML 121 | 122 | 123 | 124 | ############ 125 | ## Windows 126 | ############ 127 | 128 | # Windows image file caches 129 | Thumbs.db 130 | 131 | # Folder config file 132 | Desktop.ini 133 | 134 | 135 | ############# 136 | ## Python 137 | ############# 138 | 139 | *.py[co] 140 | 141 | # Packages 142 | *.egg 143 | *.egg-info 144 | dist 145 | build 146 | eggs 147 | parts 148 | bin 149 | var 150 | sdist 151 | develop-eggs 152 | .installed.cfg 153 | 154 | # Installer logs 155 | pip-log.txt 156 | 157 | # Unit test / coverage reports 158 | .coverage 159 | .tox 160 | 161 | #Translations 162 | *.mo 163 | 164 | #Mr Developer 165 | .mr.developer.cfg 166 | 167 | # Mac crap 168 | .DS_Store 169 | 170 | *.mp3 171 | *.lrc 172 | *.jpg 173 | 174 | # Third-party component 175 | /mutagen* 176 | -------------------------------------------------------------------------------- /dlvideo/.gitignore: -------------------------------------------------------------------------------- 1 | *.ini 2 | *.json 3 | *.txt 4 | *.db3 5 | 6 | ################# 7 | ## Eclipse 8 | ################# 9 | 10 | *.pydevproject 11 | .project 12 | .metadata 13 | bin/ 14 | tmp/ 15 | *.tmp 16 | *.bak 17 | *.swp 18 | *~.nib 19 | local.properties 20 | .classpath 21 | .settings/ 22 | .loadpath 23 | 24 | # External tool builders 25 | .externalToolBuilders/ 26 | 27 | # Locally stored "Eclipse launch configurations" 28 | *.launch 29 | 30 | # CDT-specific 31 | .cproject 32 | 33 | # PDT-specific 34 | .buildpath 35 | 36 | 37 | ################# 38 | ## Visual Studio 39 | ################# 40 | 41 | ## Ignore Visual Studio temporary files, build results, and 42 | ## files generated by popular Visual Studio add-ons. 43 | 44 | # User-specific files 45 | *.suo 46 | *.user 47 | *.sln.docstates 48 | 49 | # Build results 50 | [Dd]ebug/ 51 | [Rr]elease/ 52 | *_i.c 53 | *_p.c 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.vspscc 68 | .builds 69 | *.dotCover 70 | 71 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 72 | #packages/ 73 | 74 | # Visual C++ cache files 75 | ipch/ 76 | *.aps 77 | *.ncb 78 | *.opensdf 79 | *.sdf 80 | 81 | # Visual Studio profiler 82 | *.psess 83 | *.vsp 84 | 85 | # ReSharper is a .NET coding add-in 86 | _ReSharper* 87 | 88 | # Installshield output folder 89 | [Ee]xpress 90 | 91 | # DocProject is a documentation generator add-in 92 | DocProject/buildhelp/ 93 | DocProject/Help/*.HxT 94 | DocProject/Help/*.HxC 95 | DocProject/Help/*.hhc 96 | DocProject/Help/*.hhk 97 | DocProject/Help/*.hhp 98 | DocProject/Help/Html2 99 | DocProject/Help/html 100 | 101 | # Click-Once directory 102 | publish 103 | 104 | # Others 105 | [Bb]in 106 | [Oo]bj 107 | sql 108 | TestResults 109 | *.Cache 110 | ClientBin 111 | stylecop.* 112 | ~$* 113 | *.dbmdl 114 | Generated_Code #added for RIA/Silverlight projects 115 | 116 | # Backup & report files from converting an old project file to a newer 117 | # Visual Studio version. Backup files are not needed, because we have git ;-) 118 | _UpgradeReport_Files/ 119 | Backup*/ 120 | UpgradeLog*.XML 121 | 122 | 123 | 124 | ############ 125 | ## Windows 126 | ############ 127 | 128 | # Windows image file caches 129 | Thumbs.db 130 | 131 | # Folder config file 132 | Desktop.ini 133 | 134 | 135 | ############# 136 | ## Python 137 | ############# 138 | 139 | *.py[co] 140 | 141 | # Packages 142 | *.egg 143 | *.egg-info 144 | dist 145 | build 146 | eggs 147 | parts 148 | bin 149 | var 150 | sdist 151 | develop-eggs 152 | .installed.cfg 153 | 154 | # Installer logs 155 | pip-log.txt 156 | 157 | # Unit test / coverage reports 158 | .coverage 159 | .tox 160 | 161 | #Translations 162 | *.mo 163 | 164 | #Mr Developer 165 | .mr.developer.cfg 166 | 167 | # Mac crap 168 | .DS_Store 169 | 170 | *.mp3 171 | *.lrc 172 | *.jpg 173 | 174 | # Third-party component 175 | /mutagen* 176 | -------------------------------------------------------------------------------- /douban/.gitignore: -------------------------------------------------------------------------------- 1 | *.ini 2 | *.json 3 | *.txt 4 | *.db3 5 | 6 | ################# 7 | ## Eclipse 8 | ################# 9 | 10 | *.pydevproject 11 | .project 12 | .metadata 13 | bin/ 14 | tmp/ 15 | *.tmp 16 | *.bak 17 | *.swp 18 | *~.nib 19 | local.properties 20 | .classpath 21 | .settings/ 22 | .loadpath 23 | 24 | # External tool builders 25 | .externalToolBuilders/ 26 | 27 | # Locally stored "Eclipse launch configurations" 28 | *.launch 29 | 30 | # CDT-specific 31 | .cproject 32 | 33 | # PDT-specific 34 | .buildpath 35 | 36 | 37 | ################# 38 | ## Visual Studio 39 | ################# 40 | 41 | ## Ignore Visual Studio temporary files, build results, and 42 | ## files generated by popular Visual Studio add-ons. 43 | 44 | # User-specific files 45 | *.suo 46 | *.user 47 | *.sln.docstates 48 | 49 | # Build results 50 | [Dd]ebug/ 51 | [Rr]elease/ 52 | *_i.c 53 | *_p.c 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.vspscc 68 | .builds 69 | *.dotCover 70 | 71 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 72 | #packages/ 73 | 74 | # Visual C++ cache files 75 | ipch/ 76 | *.aps 77 | *.ncb 78 | *.opensdf 79 | *.sdf 80 | 81 | # Visual Studio profiler 82 | *.psess 83 | *.vsp 84 | 85 | # ReSharper is a .NET coding add-in 86 | _ReSharper* 87 | 88 | # Installshield output folder 89 | [Ee]xpress 90 | 91 | # DocProject is a documentation generator add-in 92 | DocProject/buildhelp/ 93 | DocProject/Help/*.HxT 94 | DocProject/Help/*.HxC 95 | DocProject/Help/*.hhc 96 | DocProject/Help/*.hhk 97 | DocProject/Help/*.hhp 98 | DocProject/Help/Html2 99 | DocProject/Help/html 100 | 101 | # Click-Once directory 102 | publish 103 | 104 | # Others 105 | [Bb]in 106 | [Oo]bj 107 | sql 108 | TestResults 109 | *.Cache 110 | ClientBin 111 | stylecop.* 112 | ~$* 113 | *.dbmdl 114 | Generated_Code #added for RIA/Silverlight projects 115 | 116 | # Backup & report files from converting an old project file to a newer 117 | # Visual Studio version. Backup files are not needed, because we have git ;-) 118 | _UpgradeReport_Files/ 119 | Backup*/ 120 | UpgradeLog*.XML 121 | 122 | 123 | 124 | ############ 125 | ## Windows 126 | ############ 127 | 128 | # Windows image file caches 129 | Thumbs.db 130 | 131 | # Folder config file 132 | Desktop.ini 133 | 134 | 135 | ############# 136 | ## Python 137 | ############# 138 | 139 | *.py[co] 140 | 141 | # Packages 142 | *.egg 143 | *.egg-info 144 | dist 145 | build 146 | eggs 147 | parts 148 | bin 149 | var 150 | sdist 151 | develop-eggs 152 | .installed.cfg 153 | 154 | # Installer logs 155 | pip-log.txt 156 | 157 | # Unit test / coverage reports 158 | .coverage 159 | .tox 160 | 161 | #Translations 162 | *.mo 163 | 164 | #Mr Developer 165 | .mr.developer.cfg 166 | 167 | # Mac crap 168 | .DS_Store 169 | 170 | *.mp3 171 | *.lrc 172 | *.jpg 173 | 174 | # Third-party component 175 | /mutagen* 176 | -------------------------------------------------------------------------------- /miniaxel/.gitignore: -------------------------------------------------------------------------------- 1 | *.ini 2 | *.json 3 | *.txt 4 | *.db3 5 | 6 | ################# 7 | ## Eclipse 8 | ################# 9 | 10 | *.pydevproject 11 | .project 12 | .metadata 13 | bin/ 14 | tmp/ 15 | *.tmp 16 | *.bak 17 | *.swp 18 | *~.nib 19 | local.properties 20 | .classpath 21 | .settings/ 22 | .loadpath 23 | 24 | # External tool builders 25 | .externalToolBuilders/ 26 | 27 | # Locally stored "Eclipse launch configurations" 28 | *.launch 29 | 30 | # CDT-specific 31 | .cproject 32 | 33 | # PDT-specific 34 | .buildpath 35 | 36 | 37 | ################# 38 | ## Visual Studio 39 | ################# 40 | 41 | ## Ignore Visual Studio temporary files, build results, and 42 | ## files generated by popular Visual Studio add-ons. 43 | 44 | # User-specific files 45 | *.suo 46 | *.user 47 | *.sln.docstates 48 | 49 | # Build results 50 | [Dd]ebug/ 51 | [Rr]elease/ 52 | *_i.c 53 | *_p.c 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.vspscc 68 | .builds 69 | *.dotCover 70 | 71 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 72 | #packages/ 73 | 74 | # Visual C++ cache files 75 | ipch/ 76 | *.aps 77 | *.ncb 78 | *.opensdf 79 | *.sdf 80 | 81 | # Visual Studio profiler 82 | *.psess 83 | *.vsp 84 | 85 | # ReSharper is a .NET coding add-in 86 | _ReSharper* 87 | 88 | # Installshield output folder 89 | [Ee]xpress 90 | 91 | # DocProject is a documentation generator add-in 92 | DocProject/buildhelp/ 93 | DocProject/Help/*.HxT 94 | DocProject/Help/*.HxC 95 | DocProject/Help/*.hhc 96 | DocProject/Help/*.hhk 97 | DocProject/Help/*.hhp 98 | DocProject/Help/Html2 99 | DocProject/Help/html 100 | 101 | # Click-Once directory 102 | publish 103 | 104 | # Others 105 | [Bb]in 106 | [Oo]bj 107 | sql 108 | TestResults 109 | *.Cache 110 | ClientBin 111 | stylecop.* 112 | ~$* 113 | *.dbmdl 114 | Generated_Code #added for RIA/Silverlight projects 115 | 116 | # Backup & report files from converting an old project file to a newer 117 | # Visual Studio version. Backup files are not needed, because we have git ;-) 118 | _UpgradeReport_Files/ 119 | Backup*/ 120 | UpgradeLog*.XML 121 | 122 | 123 | 124 | ############ 125 | ## Windows 126 | ############ 127 | 128 | # Windows image file caches 129 | Thumbs.db 130 | 131 | # Folder config file 132 | Desktop.ini 133 | 134 | 135 | ############# 136 | ## Python 137 | ############# 138 | 139 | *.py[co] 140 | 141 | # Packages 142 | *.egg 143 | *.egg-info 144 | dist 145 | build 146 | eggs 147 | parts 148 | bin 149 | var 150 | sdist 151 | develop-eggs 152 | .installed.cfg 153 | 154 | # Installer logs 155 | pip-log.txt 156 | 157 | # Unit test / coverage reports 158 | .coverage 159 | .tox 160 | 161 | #Translations 162 | *.mo 163 | 164 | #Mr Developer 165 | .mr.developer.cfg 166 | 167 | # Mac crap 168 | .DS_Store 169 | 170 | *.mp3 171 | *.lrc 172 | *.jpg 173 | 174 | # Third-party component 175 | /mutagen* 176 | -------------------------------------------------------------------------------- /douban/douban_movie_search.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import sys 5 | import getopt 6 | import json 7 | import urllib 8 | import urllib2 9 | 10 | from lxml import etree 11 | 12 | from vavava import util 13 | from vavava import httputil 14 | 15 | 16 | search_url = r'http://movie.douban.com/j/subject_suggest?q=%s' 17 | search_page_url = r'http://movie.douban.com/subject_search?search_text=%s&cat=1002' 18 | 19 | util.set_default_utf8() 20 | 21 | class Search: 22 | def __init__(self): 23 | self.http = httputil.HttpUtil() 24 | def search(self, keyword): 25 | str = search_url%urllib2.quote(keyword) 26 | data = self.http.get(str) 27 | j = json.loads(data) 28 | for movie in j: 29 | if movie['type'] == 'movie': 30 | print '==============================================================' 31 | print 'Title: ', movie['title'] 32 | print 'SubTitle: ', movie['sub_title'] 33 | print 'year: ', movie['year'] 34 | print 'url: ', movie['url'] 35 | print 'img: ', movie['img'] 36 | 37 | 38 | class SearchPage: 39 | def __init__(self): 40 | self.http = httputil.HttpUtil() 41 | def search(self, keyword): 42 | str = search_page_url%urllib.quote(keyword) 43 | data = self.http.get(str).decode('utf-8') 44 | tree = etree.HTML(data) 45 | movies = tree.xpath(r'//*[@id="content"]/div/div[1]/div[2]/table//div[@class="pl2"]') 46 | for movie in movies: 47 | try: 48 | children = movie.getchildren() 49 | a = children[0] # title 50 | url = a.get('href') # addr 51 | span = a.find('span') # alias 52 | p = movie.find(r'p[@class="pl"]') # score 53 | span_rating_nums = movie.find(r'div/span[@class="rating_nums"]') 54 | title = a.text 55 | if span is not None: 56 | title = a.text + span.text 57 | print '========================================================' 58 | print title.replace(' ', '').replace('\n', '') 59 | print p.text 60 | if span_rating_nums is not None: 61 | score = span_rating_nums.text 62 | print score 63 | print url 64 | except: 65 | print '????????????' 66 | 67 | def usage(): 68 | print \ 69 | """ 70 | usage: 71 | cmd [-h] [c configfile] 72 | """ 73 | 74 | if __name__ == "__main__": 75 | config = '' 76 | opts, args = getopt.getopt(sys.argv[1:], "c:h", ["--long-one"]) 77 | for k, v in opts: 78 | if k in ("-h"): 79 | usage() 80 | exit(0) 81 | elif k in ("-c"): 82 | config = v 83 | if len(args) > 0: 84 | keywords = '' 85 | for x in args: 86 | keywords += x + ' ' 87 | SearchPage().search(keywords) 88 | else: 89 | print 'keyword needed.' 90 | exit(0) 91 | -------------------------------------------------------------------------------- /dlvideo/dlvideo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import os 5 | import sys 6 | from time import sleep as _sleep 7 | from vavava import util 8 | from config import DLVideoConfig 9 | from vavava.threadutil import WorkShop 10 | from miniaxel.miniaxel import ProgressBar 11 | from vaxel import VUrlTask 12 | 13 | util.set_default_utf8() 14 | import parsers 15 | 16 | pjoin = os.path.join 17 | pdirname = os.path.dirname 18 | pabspath = os.path.abspath 19 | pexists = os.path.exists 20 | try: 21 | user_path = os.environ['HOME'] 22 | except: 23 | user_path = "./" 24 | print("""os.environ['HOME'] not exists, use user_path = "./" """) 25 | 26 | 27 | default_encoding = sys.getfilesystemencoding() 28 | if default_encoding.lower() == 'ascii': 29 | default_encoding = 'utf-8' 30 | 31 | def dl_u2b(cfg): 32 | if not cfg.urls[0].find("youtube.com/"): 33 | return False 34 | if not util.check_cmd(cfg.u2b_cmd): 35 | raise Exception( 'command not found:%s' %cfg.u2b_cmd) 36 | cmd = cfg.u2b_cmd 37 | cmd += r' --proxy "%s"' % cfg.u2b_proxy 38 | cmd += r' --o "%s"' % cfg.u2b_tiele_format 39 | cmd += r' --cache-dir "%s"' % cfg.u2b_cache 40 | cmd += r' %s' % cfg.urls[0] 41 | print('==> %s', cmd) 42 | os.system(cmd) 43 | 44 | def main(cfg, log): 45 | if cfg.playlist: 46 | for url in cfg.urls: 47 | outpath, cfg.urls = parsers.getPlayListParser(url).info(url) 48 | cfg.outpath = pjoin(cfg.outpath, outpath) 49 | util.assure_path(cfg.outpath) 50 | with open(pjoin(cfg.outpath, 'url.txt'), 'w') as fp: 51 | fp.writelines([url + "\n\n"]) 52 | for i, clip in enumerate(cfg.urls): 53 | fp.writelines(["[%03d] %s\n"%(i, clip)]) 54 | 55 | bar = ProgressBar() 56 | ws = WorkShop(tmin=cfg.tmin, tmax=cfg.tmax, log=log) 57 | dlvs = [] 58 | for i, url in enumerate(cfg.urls): 59 | dlvideo = VUrlTask(url, vidfmt=cfg.vidfmt, npf=cfg.npf, 60 | outpath=cfg.outpath, bar=bar, log=log) 61 | dlvs.append(dlvideo) 62 | try: 63 | ws.serve() 64 | ws.addTasks(dlvs) 65 | while len(dlvs) > 0: 66 | for i, dlv in enumerate(dlvs): 67 | if dlv.isArchived() or dlv.isError(): 68 | del dlvs[i] 69 | _sleep(1) 70 | except Exception as e: 71 | log.exception(e) 72 | finally: 73 | ws.setToStop() 74 | ws.join() 75 | 76 | 77 | if __name__ == "__main__": 78 | cfg = DLVideoConfig().read_cmdline_config('dlvideo.ini', __file__, sys.argv) 79 | log = cfg.log 80 | try: 81 | print sys.argv 82 | if not dl_u2b(cfg): 83 | main(cfg, log) 84 | if util.check_cmd('say'): 85 | os.system(r'say "download finished!!"') 86 | except KeyboardInterrupt as e: 87 | print 'stop by user' 88 | exit(0) 89 | except Exception as e: 90 | log.exception(e) 91 | if util.check_cmd('say'): 92 | os.system(r'say "download failed!!"') 93 | raise 94 | 95 | 96 | -------------------------------------------------------------------------------- /gaehelper/httpServer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import sys 5 | import json 6 | import StringIO 7 | import BaseHTTPServer 8 | from time import sleep as _sleep 9 | from SimpleHTTPServer import SimpleHTTPRequestHandler 10 | from ipscanner import IPScanner 11 | from vavava import util 12 | 13 | ServerClass = BaseHTTPServer.HTTPServer 14 | Protocol = "HTTP/1.0" 15 | log = util.get_logger() 16 | gIpScanner = IPScanner(log=util.get_logger()) 17 | 18 | class MyRequestHandler(SimpleHTTPRequestHandler): 19 | 20 | def send_head(self): 21 | content_type = 'text/html; charset=utf-8' 22 | param = '' 23 | req_path = self.path 24 | if req_path.find('?') > 0: 25 | req_path, param = req_path.split('?') 26 | if req_path in ('/'): 27 | self.path = '/www/index.html' 28 | return SimpleHTTPRequestHandler.send_head(self) 29 | elif req_path in ('/curr'): 30 | iplist = [[ip.duration, ip.ip, ip.country, ip.timeString] for ip in gIpScanner.currBuff] 31 | html = json.dumps({'name': 'curr', 'data': iplist, 'columns': ['duration', 'ip', 'country', 'time']}) 32 | elif req_path in ('/average'): 33 | history = [[ip.duration, ip.ip, ip.country, ip.timeString] for ip in gIpScanner.avgBuff] 34 | html = json.dumps({'name': 'history', 'data': history, 'columns': ['average', 'ip', 'country', 'time']}) 35 | elif req_path in ('/ip_history'): 36 | param = param.strip() 37 | data = [ 38 | [ip.duration, ip.ip, ip.country, ip.timeString] 39 | for ip in gIpScanner.historyBuff 40 | if not param or ip.ip == param 41 | ] 42 | html = json.dumps({'name': 'ip_history', 'data': data, 'columns': ['t', 'ip', 'country', 'time']}) 43 | elif req_path in ('/ss'): 44 | html = json.dumps({'status': gIpScanner.status}) 45 | else: 46 | return SimpleHTTPRequestHandler.send_head(self) 47 | f = StringIO.StringIO(html) 48 | self.send_response(200) 49 | self.send_header("Content-type", content_type) 50 | self.send_header("Content-Length", str(f.len)) 51 | self.send_header("Last-Modified", self.date_time_string()) 52 | self.end_headers() 53 | return f 54 | 55 | HandlerClass = MyRequestHandler 56 | 57 | def httpserver_serve(log): 58 | if sys.argv[1:]: 59 | port = int(sys.argv[1]) 60 | else: 61 | port = 8000 62 | 63 | HandlerClass.protocol_version = Protocol 64 | httpd = ServerClass(('0.0.0.0', port), HandlerClass) 65 | 66 | sa = httpd.socket.getsockname() 67 | log.info("Serving HTTP on {} port={}".format(sa[0], sa[1])) 68 | httpd.serve_forever() 69 | 70 | if __name__ == "__main__": 71 | try: 72 | gIpScanner.start() 73 | while not gIpScanner.isAvailable(): 74 | _sleep(1) 75 | httpserver_serve(log) 76 | except KeyboardInterrupt as e: 77 | print 'stop by user' 78 | finally: 79 | if gIpScanner.isAlive(): 80 | gIpScanner.setToStop() 81 | gIpScanner.join() 82 | -------------------------------------------------------------------------------- /dlvideo/parsers/iqiyi.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import json 4 | 5 | from util import r1 6 | from vavava import httputil 7 | 8 | 9 | class Iqiyi(): 10 | def __init__(self): 11 | self.http = httputil.HttpUtil() 12 | 13 | def real_url(self, url): 14 | import time 15 | return json.loads(self.http.get(url[:-3]+'hml?v='+str(int(time.time()) + 1921658928)))['l'] # XXX: what is 1921658928? 16 | 17 | def info(self, url, vidfmt): 18 | headers = { 19 | 'Referer': 'http://www.iqiyi.com/player/20140626170254/Player.swf', 20 | 'User-Agent': r'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:30.0) Gecko/20100101 Firefox/30.0', 21 | 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' 22 | } 23 | html = self.http.get(url, headers=headers) 24 | videoId = r1(r'''data-player-videoid\s*[:=]\s*["']([^"']*)["']''', html) 25 | info_url = r'http://cache.video.qiyi.com/vms?key=fvip&src=p&vid={}'.format(videoId) 26 | html = self.http.get(info_url, headers=headers) 27 | js = json.loads(html) 28 | vstream = js['data']['vp'] 29 | # du = 'http://data.video.qiyi.com' 30 | # nvid = e2847b3b9b81469cbf7247ee8a1da61f 31 | du, dts, nvid = vstream['du'], vstream['dts'], vstream['nvid'] 32 | for vs in vstream['tkl'][0]['vs']: 33 | for fs in vs['fs']: 34 | b, d, l, msz = fs['b'], fs['d'], fs['l'], fs['msz'] 35 | real_url = 'http://data.video.qiyi.com/{}/videos{}'.format(nvid, l) 36 | addr = html = self.http.get(real_url, headers=headers) 37 | print addr 38 | # info_url = 'http://cache.video.qiyi.com/v/%s/%s/%s/' % (videoId, pid, ptype) 39 | # return info_url 40 | # 41 | # def iqiyi_download(url, merge=True): 42 | # # html = get_html(url) 43 | # # #title = r1(r'title\s*:\s*"([^"]+)"', html) 44 | # # #title = unescape_html(title).decode('utf-8') 45 | # # #videoId = r1(r'videoId\s*:\s*"([^"]+)"', html) 46 | # # #pid = r1(r'pid\s*:\s*"([^"]+)"', html) 47 | # # #ptype = r1(r'ptype\s*:\s*"([^"]+)"', html) 48 | # # #info_url = 'http://cache.video.qiyi.com/v/%s/%s/%s/' % (videoId, pid, ptype) 49 | # # videoId = r1(r'''data-player-videoid\s*[:=]\s*["']([^"']*)["']''', html, flag=re.I) 50 | # # assert videoId 51 | # # info_url = 'http://cache.video.qiyi.com/v/%s' % videoId 52 | # 53 | # info_url = Iqiyi().get_info_url(url) 54 | # info_xml = get_html(info_url) 55 | # 56 | # from xml.dom.minidom import parseString 57 | # doc = parseString(info_xml) 58 | # title = doc.getElementsByTagName('title')[0].firstChild.nodeValue 59 | # size = int(doc.getElementsByTagName('totalBytes')[0].firstChild.nodeValue) 60 | # urls = [n.firstChild.nodeValue for n in doc.getElementsByTagName('file')] 61 | # assert urls[0].endswith('.f4v'), urls[0] 62 | # urls = map(real_url, urls) 63 | # download_urls(urls, title, 'flv', total_size=size, merge=merge) 64 | 65 | def test(): 66 | url = r'http://www.iqiyi.com/dianshiju/20120730/9682f22c54d70f29.html' 67 | url = r'http://www.iqiyi.com/dianshiju/20120730/9682f22c54d70f29.html' 68 | qiyi = Iqiyi() 69 | qiyi.info(url, 0) 70 | 71 | 72 | if __name__ == '__main__': 73 | test() 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /douban/libs/pyoauth2/libs/access_token.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import time 3 | import urlparse 4 | 5 | class AccessToken(object): 6 | 7 | def __init__(self, client, token, **opts): 8 | self.client = client 9 | self.token = token 10 | 11 | [setattr(self, attr, opts.pop(attr)) for attr in ['refresh_token', 'expires_in', 'expires_at'] if opts.has_key(attr)] 12 | 13 | if hasattr(self, 'expires_in') and str(self.expires_in).isdigit(): 14 | self.expires_at = int(time.time()) + int(self.expires_in) 15 | 16 | self.opts = { 'mode': opts.pop('mode', 'header'), 17 | 'header_format': opts.pop('header_format', 'Bearer %s'), 18 | 'param_name': opts.pop('param_name', 'bearer_token'), 19 | } 20 | self.params = opts 21 | 22 | def __repr__(self): 23 | return '' 24 | 25 | @classmethod 26 | def from_hash(cls, client, **opts): 27 | return cls(client, opts.pop('access_token', ''), **opts) 28 | 29 | @classmethod 30 | def from_kvform(cls, client, kvform): 31 | opts = dict(urlparse.parse_qsl(kvform)) 32 | return cls(client, opts.pop('access_token', ''), **opts) 33 | 34 | def refresh(self, **opts): 35 | if not getattr(self, 'refresh_token', None): 36 | raise 'A refresh_token is not available' 37 | 38 | opts = { 'client_id': self.client.id, 39 | 'client_secret': self.client.secret, 40 | 'refresh_token': self.refresh_token, 41 | 'grant_type': 'refresh_token', 42 | } 43 | new_token = self.client.get_token(**opts) 44 | return new_token 45 | 46 | def request(self, method, uri, **opts): 47 | opts = self.__set_token(**opts) 48 | return self.client.request(method, uri, **opts) 49 | 50 | def get(self, uri, **opts): 51 | return self.request('GET', uri, **opts) 52 | 53 | def post(self, uri, **opts): 54 | return self.request('POST', uri, **opts) 55 | 56 | def put(self, uri, **opts): 57 | return self.request('PUT', uri, **opts) 58 | 59 | def patch(self, uri, **opts): 60 | return self.request('PATCH', uri, **opts) 61 | 62 | def delete(self, uri, **opts): 63 | return self.request('DELETE', uri, **opts) 64 | 65 | @property 66 | def headers(self): 67 | return {'Authorization': self.opts['header_format'] % self.token} 68 | 69 | def __set_token(self, **opts): 70 | mode = self.opts['mode'] 71 | if mode == 'header': 72 | headers = opts.get('headers', {}) 73 | headers.update(self.headers) 74 | opts['headers'] = headers 75 | elif mode == 'query': 76 | params = opts.get('params', {}) 77 | params[self.opts['param_name']] = self.token 78 | opts['params'] = params 79 | elif mode == 'body': 80 | body = opts.get('body', {}) 81 | if isinstance(body, dict): 82 | opts['body'][self.opts['param_name']] = self.token 83 | else: 84 | opts['body'] += "&%s=%s"%(self.opts['param_name'], self.token) 85 | else: 86 | raise "invalid :mode option of %s"%(self.opts['param_name']) 87 | 88 | return opts 89 | -------------------------------------------------------------------------------- /douban/libs/douban_client/api/online.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .base import DoubanAPIBase, DEFAULT_START, DEFAULT_COUNT 4 | 5 | 6 | class Online(DoubanAPIBase): 7 | 8 | def __repr__(self): 9 | return '' 10 | 11 | def get(self, id): 12 | return self._get('/v2/online/%s' % id) 13 | 14 | def new(self, title, desc, begin_time, end_time, 15 | related_url='', cascade_invite='false', tags=''): 16 | return self._post('/v2/onlines', 17 | title=title, desc=desc, tags=tags, 18 | begin_time=begin_time, end_time=end_time, 19 | related_url=related_url, cascade_invite=cascade_invite) 20 | 21 | def update(self, id, title, desc, begin_time, end_time, 22 | related_url='', cascade_invite='false', tags=''): 23 | return self._put('/v2/online/%s' % id, 24 | title=title, desc=desc, tags=tags, 25 | begin_time=begin_time, end_time=end_time, 26 | related_url=related_url, cascade_invite=cascade_invite) 27 | 28 | def delete(self, id): 29 | return self._delete('/v2/online/%s' % id) 30 | 31 | def join(self, id): 32 | return self._post('/v2/online/%s/participants' % id) 33 | 34 | def quit(self, id): 35 | return self._delete('/v2/online/%s/participants' % id) 36 | 37 | def photos(self, id, start=DEFAULT_START, count=DEFAULT_COUNT, order='', sortby='time'): 38 | return self._get('/v2/online/%s/photos' % id, 39 | start=start, count=count, order=order, sortby=sortby) 40 | 41 | def upload(self, id, image, desc=''): 42 | return self._post('/v2/online/%s/photos' % id, 43 | desc=desc, files={'image': image}) 44 | 45 | def like(self, id): 46 | return self._post('/v2/online/%s/like' % id) 47 | 48 | def unlike(self, id): 49 | return self._delete('/v2/online/%s/like' % id) 50 | 51 | def participants(self, id, start=DEFAULT_START, count=DEFAULT_COUNT): 52 | return self._get('/v2/online/%s/participants' % id, 53 | start=start, count=count) 54 | 55 | def discussions(self, id, start=DEFAULT_START, count=DEFAULT_COUNT): 56 | return self._get('/v2/online/%s/discussions' % id, 57 | start=start, count=count) 58 | 59 | @property 60 | def discussion(self): 61 | return OnlineDiscussion(self.access_token) 62 | 63 | def list(self, cate='day', start=DEFAULT_START, count=DEFAULT_COUNT): 64 | # cate: day, week, latest 65 | return self._get('/v2/onlines', cate=cate, start=start, count=count) 66 | 67 | def created(self, user_id, start=DEFAULT_START, count=DEFAULT_COUNT): 68 | return self._get('/v2/online/user_created/%s' % user_id, 69 | start=start, count=count) 70 | 71 | def joined(self, user_id, start=DEFAULT_START, count=DEFAULT_COUNT): 72 | return self._get('/v2/online/user_participated/%s' % user_id, 73 | start=start, count=count) 74 | 75 | 76 | class OnlineDiscussion(DoubanAPIBase): 77 | 78 | def new(self, target_id, title, content): 79 | return self._post('/v2/online/%s/discussions' % target_id, 80 | title=title, content=content) 81 | -------------------------------------------------------------------------------- /gaehelper/dnslib/buffer.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Buffer - simple data buffer 5 | """ 6 | 7 | import binascii,struct 8 | 9 | class BufferError(Exception): 10 | pass 11 | 12 | class Buffer(object): 13 | 14 | """ 15 | A simple data buffer - supports packing/unpacking in struct format 16 | 17 | # Needed for Python 2/3 doctest compatibility 18 | >>> def p(s): 19 | ... if not isinstance(s,str): 20 | ... return s.decode() 21 | ... return s 22 | 23 | >>> b = Buffer() 24 | >>> b.pack("!BHI",1,2,3) 25 | >>> b.offset 26 | 7 27 | >>> b.append(b"0123456789") 28 | >>> b.offset 29 | 17 30 | >>> p(b.hex()) 31 | '0100020000000330313233343536373839' 32 | >>> b.offset = 0 33 | >>> b.unpack("!BHI") 34 | (1, 2, 3) 35 | >>> bytearray(b.get(5)) 36 | bytearray(b'01234') 37 | >>> bytearray(b.get(5)) 38 | bytearray(b'56789') 39 | >>> b.update(7,"2s",b"xx") 40 | >>> b.offset = 7 41 | >>> bytearray(b.get(5)) 42 | bytearray(b'xx234') 43 | """ 44 | 45 | def __init__(self,data=b''): 46 | """ 47 | Initialise Buffer from data 48 | """ 49 | self.data = bytearray(data) 50 | self.offset = 0 51 | 52 | def remaining(self): 53 | """ 54 | Return bytes remaining 55 | """ 56 | return len(self.data) - self.offset 57 | 58 | def get(self,length): 59 | """ 60 | Gen len bytes at current offset (& increment offset) 61 | """ 62 | if length > self.remaining(): 63 | raise BufferError("Not enough bytes [offset=%d,remaining=%d,requested=%d]" % 64 | (self.offset,self.remaining(),length)) 65 | start = self.offset 66 | end = self.offset + length 67 | self.offset += length 68 | return bytes(self.data[start:end]) 69 | 70 | def hex(self): 71 | """ 72 | Return data as hex string 73 | """ 74 | return binascii.hexlify(self.data) 75 | 76 | def pack(self,fmt,*args): 77 | """ 78 | Pack data at end of data according to fmt (from struct) & increment 79 | offset 80 | """ 81 | self.offset += struct.calcsize(fmt) 82 | self.data += struct.pack(fmt,*args) 83 | 84 | def append(self,s): 85 | """ 86 | Append s to end of data & increment offset 87 | """ 88 | self.offset += len(s) 89 | self.data += s 90 | 91 | def update(self,ptr,fmt,*args): 92 | """ 93 | Modify data at offset `ptr` 94 | """ 95 | s = struct.pack(fmt,*args) 96 | self.data[ptr:ptr+len(s)] = s 97 | 98 | def unpack(self,fmt): 99 | """ 100 | Unpack data at current offset according to fmt (from struct) 101 | """ 102 | try: 103 | data = self.get(struct.calcsize(fmt)) 104 | return struct.unpack(fmt,data) 105 | except struct.error as e: 106 | raise BufferError("Error unpacking struct '%s' <%s>" % 107 | (fmt,binascii.hexlify(data).decode())) 108 | 109 | def __len__(self): 110 | return len(self.data) 111 | 112 | if __name__ == '__main__': 113 | import doctest 114 | doctest.testmod() 115 | -------------------------------------------------------------------------------- /js/common.js: -------------------------------------------------------------------------------- 1 | 2 | function init_modal_alert() { 3 | var ss = ""; 12 | document.body.insertAdjacentHTML( 'beforeend', ss ); 13 | } 14 | 15 | function modal_alert() { 16 | var s = ""; 17 | for (i=0; i < arguments.length; ++i) { 18 | s += arguments[i]; 19 | } 20 | $("#modal_alert_text").text(s); 21 | $("#modal_alert").modal("toggle"); 22 | } 23 | 24 | function modal_alert_json() { 25 | var s = ""; 26 | for (i=1; i < arguments.length; ++i) { 27 | s += arguments[i]; 28 | } 29 | $("#modal_alert_text").JSONView(arguments[0], { collapsed: true }); 30 | $("#modal_alert").modal("toggle"); 31 | } 32 | 33 | function modal_alert_and_reload() { 34 | $("#modal_alert").on('hidden.bs.modal', function () { 35 | location.reload(); 36 | }) 37 | modal_alert.apply(this, arguments); 38 | } 39 | 40 | function modal_alert_json_and_reload() { 41 | $("#modal_alert").on('hidden.bs.modal', function () { 42 | location.reload(); 43 | }) 44 | modal_alert_json.apply(this, arguments); 45 | } 46 | 47 | // post 方法请求一个 ajax 数据 48 | function server_post(url, data, call) { 49 | var req = $.post(url, data, 50 | function(ret) { 51 | if (ret['rst'] == 'ok') { 52 | if (call != undefined) { 53 | call(ret['data']); 54 | } 55 | } else { 56 | alert('操作不成功, ' + ret['rst']); 57 | } 58 | }); 59 | req.error(function(err) { 60 | alert('有错误发生[' + err['rst'] + ']'); 61 | }); 62 | } 63 | 64 | // get 方法请求一个 ajax 数据 65 | function server_get(url, data, call) { 66 | var req = $.post(url, data, 67 | function(ret) { 68 | if (ret['rst'] == 'ok') { 69 | if (call != undefined) { 70 | call(ret['data']); 71 | } 72 | } else { 73 | alert('操作不成功, ' + ret['rst']); 74 | } 75 | }); 76 | req.error(function(err) { 77 | alert('有错误发生[' + err['rst'] + ']'); 78 | }); 79 | } 80 | 81 | function syntaxHighlight(json) { 82 | if (typeof json != 'string') { 83 | json = JSON.stringify(json, undefined, 2); 84 | } 85 | json = json.replace(/&/g, '&').replace(//g, '>'); 86 | return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) { 87 | var cls = 'number'; 88 | if (/^"/.test(match)) { 89 | if (/:$/.test(match)) { 90 | cls = 'key'; 91 | } else { 92 | cls = 'string'; 93 | } 94 | } else if (/true|false/.test(match)) { 95 | cls = 'boolean'; 96 | } else if (/null/.test(match)) { 97 | cls = 'null'; 98 | } 99 | return '' + match + ''; 100 | }); 101 | } 102 | -------------------------------------------------------------------------------- /dllive/dllive.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | import os 5 | import time 6 | from vavava import util as _util 7 | from vavava.httputil import HttpFetcher 8 | from vavava.threadutil import WorkShop 9 | from m3u8stream import M3u8Stream 10 | 11 | _util.set_default_utf8() 12 | CHARSET = "utf-8" 13 | pjoin = os.path.join 14 | pdirname = os.path.dirname 15 | pabspath = os.path.abspath 16 | 17 | 18 | def __is_url_file(url): 19 | import urllib2 20 | req = urllib2.Request(url) 21 | resp = urllib2.urlopen(req) 22 | info = resp.info() 23 | return info.type.find('url') > 0 24 | 25 | 26 | def recode(url, duration=None, vfmt=2, outpath='./', 27 | npf=3, freq=10, tmin=5, tmax=20, proxy=None, log=None): 28 | assert duration is None or duration > 0 29 | name = '%s.%s.ts' % (_util.get_time_string(), hash(url)) 30 | outfile = pjoin(outpath, name) 31 | log.info("|=> begin: %s", url) 32 | if duration: 33 | log.info("|=>duration: %d", duration) 34 | log.info("|=> output: %s", outfile) 35 | 36 | _util.assure_path(outpath) 37 | axel = WorkShop(tmin=tmin, tmax=tmax, log=log) 38 | m3u8 = M3u8Stream(axel=axel, proxy=proxy,log=log) 39 | fetcher = HttpFetcher() 40 | start_at = time.time() 41 | try: 42 | with open(outfile, 'wb') as fp: 43 | if url.find('m3u8') > 0 or __is_url_file(url): 44 | axel.serve() 45 | m3u8.recode(url=url, duration=duration, vfmt=vfmt, fp=fp, npf=npf, freq=cfg.freq) 46 | else: 47 | fetcher.fetch(url=url, fp=fp) 48 | log.info("|=> end: total=%.2fs, out=%s", time.time() - start_at, outfile) 49 | finally: 50 | if axel.isAlive(): 51 | axel.setToStop() 52 | axel.join() 53 | 54 | 55 | def interact(cfg): 56 | channel = raw_input('channel?') 57 | with open(cfg.address_file, 'r') as fp: 58 | address = fp.readlines() 59 | sub_addr = dict() 60 | for addr in address: 61 | kv = addr.split('#') 62 | if kv[0].lower().find(channel) > 0: 63 | sub_addr[kv[0]] = kv[1] 64 | index = 0 65 | channel_list = [] 66 | for k, v in sub_addr.items(): 67 | index += 1 68 | channel_list.append(k) 69 | print '[%2d] %s %s'%(index, k, v) 70 | channel_id = int(raw_input('id? ')) - 1 71 | return sub_addr[channel_list[channel_id]] 72 | 73 | 74 | def main(cfg): 75 | liveurl = cfg.liveurl 76 | if cfg.interactive: 77 | liveurl = interact(cfg) 78 | elif cfg.favorite: 79 | for f in cfg.favorites: 80 | if f[0] == cfg.favorite: 81 | liveurl = f[1] 82 | elif cfg.channellist: 83 | spath = _util.script_path(__file__) 84 | os.system('python %s/xbmc_5ivdo.py -t 直播 > %s'%(spath, cfg.address_file)) 85 | return 86 | recode(url=liveurl, duration=cfg.duration, vfmt=cfg.vfmt, outpath=cfg.outpath, npf=cfg.npf, 87 | freq=cfg.freq, tmin=cfg.tmin, tmax=cfg.tmax, proxy=cfg.proxyaddr, log=cfg.log) 88 | 89 | 90 | if __name__ == "__main__": 91 | from config import DLLiveConfig 92 | from sys import argv 93 | cfg = DLLiveConfig().read_cmdline_config('dllive.ini', __file__, argv) 94 | try: 95 | main(cfg) 96 | except KeyboardInterrupt: 97 | print 'stop by user' 98 | exit(0) 99 | except Exception as e: 100 | cfg.log.exception(e) -------------------------------------------------------------------------------- /gaehelper/dnslib/fixedresolver.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | FixedResolver - example resolver which responds with fixed response 5 | to all requests 6 | """ 7 | 8 | from __future__ import print_function 9 | 10 | import copy 11 | 12 | from dnslib import RR 13 | from dnslib.server import DNSServer,DNSHandler,BaseResolver,DNSLogger 14 | 15 | class FixedResolver(BaseResolver): 16 | """ 17 | Respond with fixed response to all requests 18 | """ 19 | def __init__(self,zone): 20 | # Parse RRs 21 | self.rrs = RR.fromZone(zone) 22 | 23 | def resolve(self,request,handler): 24 | reply = request.reply() 25 | qname = request.q.qname 26 | # Replace labels with request label 27 | for rr in self.rrs: 28 | a = copy.copy(rr) 29 | a.rname = qname 30 | reply.add_answer(a) 31 | return reply 32 | 33 | if __name__ == '__main__': 34 | 35 | import argparse,sys,time 36 | 37 | p = argparse.ArgumentParser(description="Fixed DNS Resolver") 38 | p.add_argument("--response","-r",default=". 60 IN A 127.0.0.1", 39 | metavar="", 40 | help="DNS response (zone format) (default: 127.0.0.1)") 41 | p.add_argument("--zonefile","-f", 42 | metavar="", 43 | help="DNS response (zone file, '-' for stdin)") 44 | p.add_argument("--port","-p",type=int,default=53, 45 | metavar="", 46 | help="Server port (default:53)") 47 | p.add_argument("--address","-a",default="", 48 | metavar="
", 49 | help="Listen address (default:all)") 50 | p.add_argument("--udplen","-u",type=int,default=0, 51 | metavar="", 52 | help="Max UDP packet length (default:0)") 53 | p.add_argument("--tcp",action='store_true',default=False, 54 | help="TCP server (default: UDP only)") 55 | p.add_argument("--log",default="request,reply,truncated,error", 56 | help="Log hooks to enable (default: +request,+reply,+truncated,+error,-recv,-send,-data)") 57 | p.add_argument("--log-prefix",action='store_true',default=False, 58 | help="Log prefix (timestamp/handler/resolver) (default: False)") 59 | args = p.parse_args() 60 | 61 | if args.zonefile: 62 | if args.zonefile == '-': 63 | args.response = sys.stdin 64 | else: 65 | args.response = open(args.zonefile) 66 | 67 | resolver = FixedResolver(args.response) 68 | logger = DNSLogger(args.log,args.log_prefix) 69 | 70 | print("Starting Fixed Resolver (%s:%d) [%s]" % ( 71 | args.address or "*", 72 | args.port, 73 | "UDP/TCP" if args.tcp else "UDP")) 74 | 75 | for rr in resolver.rrs: 76 | print(" | ",rr.toZone().strip(),sep="") 77 | print() 78 | 79 | if args.udplen: 80 | DNSHandler.udplen = args.udplen 81 | 82 | udp_server = DNSServer(resolver, 83 | port=args.port, 84 | address=args.address, 85 | logger=logger) 86 | udp_server.start_thread() 87 | 88 | if args.tcp: 89 | tcp_server = DNSServer(resolver, 90 | port=args.port, 91 | address=args.address, 92 | tcp=True, 93 | logger=logger) 94 | tcp_server.start_thread() 95 | 96 | while udp_server.isAlive(): 97 | time.sleep(1) 98 | 99 | --------------------------------------------------------------------------------