寄居蟹Hcrab介紹 寄居蟹Hcrab,是一個離線下載youtube視頻的web服務。 Demo site: http://d.jaylab.org 安裝ubuntu系統 - sudo apt-get install nginx python-pip git
- 下載代碼: git clone https://[email protected]/xiaojay/jaylab-download.it
- 假設你下載到 /home/jay/websites/jaylab-download, cd /home/jay/websites/jaylab-download.
- sudo pip install -r requirements.pip
- 生成數據庫: mkdir jaylab/db; ./manage.py syncdb -all(會出現要求你輸入後台管理的用戶名和密碼);./manage.py migrate --fake
- 更改配置文件: vim jaylab/app_settings.py; 更改其中的HOST 和SERVER_VIDEO_DIR(這個是你存放下載的video的目錄)選項。
6 s& b/ p8 }- f/ }/ F# b+ v, f: w 測試- 將代碼目錄添加到python sys.path: 修改config/jay.pth 的中的目錄為你的代碼的目錄; sudo cp config/jay.pth /usr/lib/python2.7/dist-packages/
- ./manage.py runserver 0.0.0.0:8000; 用瀏覽器打開http://your-host:8000(主界面), 添加一個youtube鏈接.
- 測試下載 , python jaylab/hcrab/download.py' X' k( R* ?! |& i& T
實際生產環境下網站- ./manage.py collectstatic
- 修改nginx設置文件. vim config/hcrab (主要修改/home/jay/websites/download.jaylab.org/為你的目錄)
- sudo cp config/hcrab /etc/nginx/site-avaiable;ln -s /etc/nginx/site-avaiable/hcrab /etc/nginx/site-enabled/;sudo service nginx reload
- 用gunicorn做wsgi server: gunicorn_django -D -b 127.0.0.1:8000 jaylab/settings.py
- 把download.py 放到crontab,一分鐘執行一次。8 X4 W; B! q1 A" z
( n; h; c3 N$ [' F& s, h& A+ e O源碼地址:https://bitbucket.org/xiaojay/jaylab-download) p- ~5 X" t0 d. P
0 o. B: e$ V' P' U) k1 P# R5 r/ h
; h$ X. u0 h3 N- ~) A
7 W. @( q( K8 e0 s: t
4 k0 _& S# o) g1 B% ` |