Video Cache Youtube ClearOS Debian

From MS Computech
Revision as of 23:19, 25 March 2010 by Snifer (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

วิธีติดตั้ง Cachevideos สำหรับ ClearOS 5.1 SP1 Contribute and test by [email protected] 25 March 2010 ( ทำงานในโหมด Transparent และโหมดปรกติ )

การลง Cachevideos จำเป็นต้องลง Webserver ด้วยในการติดตั้ง ClearOS

1. ClearOS 5.1 SP1

tar zxvf videocache-1.9.2.tar.gz
cd videocache-1.9.2
python setup.py install
chown -R squid.squid /var/log/videocache/
chown -R squid.squid /var/spool/videocache/
chmod -R 777 /var/spool/videocache/
service httpd restart

นำเครื่องหมาย#ออกที่ Squid.conf

acl our_networks src 192.168.1.0/24 192.168.2.0/24
http_access allow our_networks

นำ config ด้านล่างไปไว้ล่างสุดของ squid.conf

# --BEGIN-- videocache config for squid
url_rewrite_program /usr/bin/python /usr/share/videocache/videocache.py
url_rewrite_children 7
acl videocache_allow_url url_regex -i \.youtube\.com\/get_video\?
acl videocache_allow_url url_regex -i \.youtube\.com\/videoplayback \.youtube\.com\/videoplay \.youtube\.com\/get_video\?
acl videocache_allow_url url_regex -i \.youtube\.[a-z][a-z]\/videoplayback \.youtube\.[a-z][a-z]\/videoplay \.youtube\.[a-z][a-z]\/get_video\?
acl videocache_allow_url url_regex -i \.googlevideo\.com\/videoplayback \.googlevideo\.com\/videoplay \.googlevideo\.com\/get_video\?
acl videocache_allow_url url_regex -i \.google\.com\/videoplayback \.google\.com\/videoplay \.google\.com\/get_video\?
acl videocache_allow_url url_regex -i \.google\.[a-z][a-z]\/videoplayback \.google\.[a-z][a-z]\/videoplay \.google\.[a-z][a-z]\/get_video\?
acl videocache_allow_url url_regex -i (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$
acl videocache_allow_url url_regex -i (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$
acl videocache_allow_url url_regex -i (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$
acl videocache_allow_url url_regex -i proxy[a-z0-9\-][a-z0-9][a-z0-9][a-z0-9]?\.dailymotion\.com\/
acl videocache_allow_url url_regex -i vid\.akm\.dailymotion\.com\/
acl videocache_allow_url url_regex -i [a-z0-9][0-9a-z][0-9a-z]?[0-9a-z]?[0-9a-z]?\.xtube\.com\/(.*)flv
acl videocache_allow_url url_regex -i bitcast\.vimeo\.com\/vimeo\/videos\/
acl videocache_allow_url url_regex -i va\.wrzuta\.pl\/wa[0-9][0-9][0-9][0-9]?
acl videocache_allow_url url_regex -i \.files\.youporn\.com\/(.*)\/flv\/
acl videocache_allow_url url_regex -i \.msn\.com\.edgesuite\.net\/(.*)\.flv
acl videocache_allow_url url_regex -i media[a-z0-9]?[a-z0-9]?[a-z0-9]?\.tube8\.com\/ mobile[a-z0-9]?[a-z0-9]?[a-z0-9]?\.tube8\.com\/
acl videocache_allow_url url_regex -i \.mais\.uol\.com\.br\/(.*)\.flv
acl videocache_allow_url url_regex -i \.video[a-z0-9]?[a-z0-9]?\.blip\.tv\/(.*)\.(flv|avi|mov|mp3|m4v|mp4|wmv|rm|ram)
acl videocache_allow_url url_regex -i video\.break\.com\/(.*)\.(flv|mp4)
acl videocache_allow_dom dstdomain .mccont.com .metacafe.com .redtube.com .cdn.dailymotion.com
acl videocache_deny_url url_regex -i http:\/\/[a-z][a-z]\.youtube\.com http:\/\/www\.youtube\.com
url_rewrite_access deny videocache_deny_url
url_rewrite_access allow videocache_allow_url
url_rewrite_access allow videocache_allow_dom
redirector_bypass on
# --END-- videocache config for squid

สั่งรีสตาร์ท Proxy

service squid restart

ทดสอบว่าทำงานหรือไม่

[root@gw ~]# ps ax | grep video
21558 ?        Ss     0:00 (python) /usr/share/videocache/videocache.py
21559 ?        Ss     0:00 (python) /usr/share/videocache/videocache.py
21560 ?        Ss     0:00 (python) /usr/share/videocache/videocache.py
21561 ?        Ss     0:00 (python) /usr/share/videocache/videocache.py
21562 ?        Ssl    0:00 (python) /usr/share/videocache/videocache.py
21563 ?        Ss     0:00 (python) /usr/share/videocache/videocache.py
21564 ?        Ss     0:00 (python) /usr/share/videocache/videocache.py
22659 pts/0    S+     0:00 grep video
[root@gw videocache-1.9.2]# tail -f /var/log/videocache/videocache.log
2010-03-25 21:31:25,035 21558 192.168.2.88 - REQUEST - http://tc.v22.cache1.c.youtube.com/videoplayback?ip=125.0.0.0&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor&fexp=903914&algorithm=throttle-factor&itag=34&ipbits=8&burst=40&sver=3&expire=1269550800&key=yt1&signature=D1A8B5BDB4C146666075FACCBA6C97ADFDCD2FF6.D50FBF2204ABCF21C8086B717EBC39E809980B77&factor=1.25&id=a040e09a06d79be1&redirect_counter=1
2010-03-25 21:31:25,035 21558 192.168.2.88 a040e09a06d79be1 URL_HIT YOUTUBE http://tc.v22.cache1.c.youtube.com/videoplayback?ip=125.0.0.0&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor&fexp=903914&algorithm=throttle-factor&itag=34&ipbits=8&burst=40&sver=3&expire=1269550800&key=yt1&signature=D1A8B5BDB4C146666075FACCBA6C97ADFDCD2FF6.D50FBF2204ABCF21C8086B717EBC39E809980B77&factor=1.25&id=a040e09a06d79be1&redirect_counter=1
2010-03-25 21:31:25,035 21558 192.168.2.88 a040e09a06d79be1 CACHE_MISS YOUTUBE Requested video was not found in cache.
2010-03-25 21:31:25,038 21558 192.168.2.88 a040e09a06d79be1 NEW_URL YOUTUBE http://tc.v22.cache1.c.youtube.com/videoplayback?ip=125.0.0.0&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor&fexp=903914&algorithm=throttle-factor&itag=34&ipbits=8&burst=40&sver=3&expire=1269550800&key=yt1&signature=D1A8B5BDB4C146666075FACCBA6C97ADFDCD2FF6.D50FBF2204ABCF21C8086B717EBC39E809980B77&factor=1.25&id=a040e09a06d79be1&redirect_counter=1
2010-03-25 21:31:28,372 21562 192.168.2.88 a040e09a06d79be1 SCHEDULED YOUTUBE Video scheduled for download.
2010-03-25 21:31:28,386 21558 127.0.0.1 - REQUEST - http://v22.lscache1.c.youtube.com/videoplayback?ip=125.0.0.0&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor&fexp=903914&algorithm=throttle-factor&itag=34&ipbits=8&burst=40&sver=3&expire=1269550800&key=yt1&signature=D1A8B5BDB4C146666075FACCBA6C97ADFDCD2FF6.D50FBF2204ABCF21C8086B717EBC39E809980B77&factor=1.25&id=a040e09a06d79be1
2010-03-25 21:31:28,386 21558 127.0.0.1 a040e09a06d79be1 URL_HIT YOUTUBE http://v22.lscache1.c.youtube.com/videoplayback?ip=125.0.0.0&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor&fexp=903914&algorithm=throttle-factor&itag=34&ipbits=8&burst=40&sver=3&expire=1269550800&key=yt1&signature=D1A8B5BDB4C146666075FACCBA6C97ADFDCD2FF6.D50FBF2204ABCF21C8086B717EBC39E809980B77&factor=1.25&id=a040e09a06d79be1
2010-03-25 21:31:28,386 21558 127.0.0.1 a040e09a06d79be1 CACHE_MISS YOUTUBE Requested video was not found in cache.
2010-03-25 21:31:28,389 21558 127.0.0.1 a040e09a06d79be1 NEW_URL YOUTUBE http://v22.lscache1.c.youtube.com/videoplayback?ip=125.0.0.0&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor&fexp=903914&algorithm=throttle-factor&itag=34&ipbits=8&burst=40&sver=3&expire=1269550800&key=yt1&signature=D1A8B5BDB4C146666075FACCBA6C97ADFDCD2FF6.D50FBF2204ABCF21C8086B717EBC39E809980B77&factor=1.25&id=a040e09a06d79be1
2010-03-25 21:33:04,020 21733 192.168.2.88 a040e09a06d79be1 DOWNLOAD YOUTUBE 13583631 Video was downloaded and cached.

Video Cache ที่ถูกเก็บจะสามารถตรวจสอบได้โดยเรียกผ่านเว็บ

http://yourproxyip/videocache/

2.Debian Lenny 5.0r4

Setup Log On Debian Lenny 5.0r4 @25 march 2010 ติดตั้ง Package ที่จำเป็น

apt-get update
apt-get install ssh openssh-server bridge-utils python python-urlgrabber squid apache2

ติดตั้ง python-iniparse_0.3.1-1_all.deb

dpkg -i python-iniparse_0.3.1-1_all.deb 
tar zxvf videocache-1.9.2.tar.gz 
cd videocache-1.9.2
python setup-deb.py install
cd /etc/squid/
ln -s /usr/share/squid/errors/English/ errors
ln -s /usr/share/squid/icons/ icons
chmod 755 *

Download Videocache + Squid config Here แตกออกมา Copy config squid ไปที่ /etc/squid/ และ chmod -R 755 /etc/squid/

useradd squid
chown -R squid:squid /var/spool/squid/
chown -R squid:squid /var/log/squid/
chown -R squid:squid /var/log/videocache/
chown -R squid:squid /var/spool/videocache/
chmod -R 777 /var/spool/videocache/

ทดสอบโดยใช้คำสั่งเดียวกับ ClearOS ด้านบน

จบ



Refference


Cachevideo Official Site