1 min read

Privoxy 去除 iOS 爱奇艺客户端广告

此前有人写邮件问我,Privoxy 如何去掉 iOS 上爱奇艺客户端的视频广告。当时我没时间,只大致给了几个建议,然后不了了之,没了下文。但心里记挂,想着什么时候有时间,要认真看看。所以就有了这一篇。

分析

涉及的设备及软件等如下:

  • iPhone 4s, 7.1.2 版本
  • ThinkPad,装有 openSUSE 13.2 32 位操作系统
  • Charles Proxy,收费的,Windows 系统下可以使用免费的 Fiddler2

预备工具

  1. 将 iPhone 与 ThinkPad 连入同一个 WIFI 环境
  2. 打开 iPhone 的 WIFI 连接设置,设置 HTTP Proxy(代理)为 ThinkPad 上 Charles Proxy 的 ip:port,比如我的:192.168.1.102:8888,手机上如有开启 VPN 之类的,请暂先关闭

现在查看 charles 的话,应该已经能看见 iPhone 上的 HTTP 请求/响应进出了。

打开爱奇艺客户端

现在打开爱奇艺客户端,点开一个视频,就能看到类似如下的请求:

http://iface2.iqiyi.com/php/xyz/entry/nebula.php?key=8e48946f144759d86a50075555fd5862&app_key=8e48946f144759d86a50075555fd5862&did=b1f4b27f4627d038&type=json&id=&deviceid=&version=5.7.1&os=7.1.2&ua=iPhone4,1&network=1&screen_status=1&udid=aeb89eb1a451f9e6082246e79e077bc543e327ae&ss=1&ppid=&uid=&uniqid=0f607264fc6318a92b9e13c65db7cd3c&openudid=aeb89eb1a451f9e6082246e79e077bc543e327ae&idfv=5D1578BE-ECE1-406E-A99F-42AB99A71130&idfa=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&qyid=aeb89eb1a451f9e6082246e79e077bc543e327ae&mac_md5=e3f5536a141811db40efd6400f1d0a4e&cc=%257B%250A%2520%2520%2520%2520cc%2520%253D%2520%2522%255CU6d77%255CU5916%255CU8fd0%255CU8425%255CU5546%2522%253B%250A%2520%2520%2520%2520city%2520%253D%2520%2522%255CU6d77%255CU5916%2522%253B%250A%2520%2520%2520%2520province%2520%253D%2520%2522%255CU6d77%255CU5916%2522%253B%250A%2520%2520%2520%2520respcode%2520%253D%25200%253B%250A%2520%2520%2520%2520timeout%2520%253D%25200%253B%250A%257D&agenttype=20&screen_res=640960&resolution=640960&cookie=0&ppid=(null)&user_res=4&js=0&a=0&b=0&x=0&y=5&z=0&r=0&v_m=2.5_002&vs=0&vt=0.000000&other=1&block=0&ad=2&ad_str=1&w=0&compat=1&v5=1&core=0&sn=1420974668080402944&api=2.4&cts=1420974668&platform=iPhone&pps=0&support_db=&many_id=331794000_331794000_0

广告就隐藏在这条请求的响应中:

HTTP/1.1 200 OK

Server: nginx

Date: Sun, 11 Jan 2015 11:11:09 GMT

Content-Type: text/json

Connection: close

X-Powered-By: PHP/5.3.6

Vary: Accept-Encoding

Expires: 0

Cache-Control: no-cache

{“_as”:””,”_blk”:0,”_cid”:4,”_ct”:”2014-12-05 16:35:45″,”_da”:””,”_dl”:1,”_dn”:”219″,”_id”:”331794000″,”_img”:”http:\/\/pic8.qiyipic.com\/image\/20141205\/4e\/7f\/v_108765570_m_601_120_160.jpg”,”_ip”:0,”_ma”:””,”_pc”:0,”_pid”:0,”_reseftv”:175,”_t”:”\u3010\u521d\u97f3miku\u3011\u30a2\u30ea\u30a2\u30c9\u30cd\u3010\u9ed2\u3046\u3055P\u3011″,”_tvct”:5,”_tvs”:1,”_vt”:12,”a_av”:1,”a_pro”:””,”bpt”:”0″,”clm”:””,”cn_year”:”0″,”co_album_id”:”0″,”ctype”:0,”desc”:”\u65e0″,”down”:3,”down2″:”3″,”drm”:0,”fst_time”:”2014-12-05″,”h1_img”:”http:\/\/pic8.qiyipic.com\/image\/20141205\/4e\/7f\/v_108765570_m_601_180_236.jpg”,”h2_img”:”http:\/\/pic8.qiyipic.com\/image\/20141205\/4e\/7f\/v_108765570_m_601_195_260.jpg”,”is_h”:0,”is_n”:0,”is_zb”:0,”k_word”:””,”language”:0,”live_center”:0,”live_start_time”:0,”live_stop_time”:0,”logo”:1,”m_av”:1,”mts”:0,”p_av”:1,”p_s”:1,”p_s_1″:1,”p_s_4″:1,”p_s_8″:1,”qct”:25,”qiyi_pro”:0,”qiyi_year”:”0″,”qt_id”:”0″,”s_TT”:”sm25051115″,”songname”:””,”t_pc”:0,”tag”:”\u65e5\u672c \u540c\u4eba ACG \u7279\u522b\u7248″,”tv_eftv”:1,”tv_pha”:”0″,”tv_pro”:””,”tv_ss”:”0″,”tvfcs”:”\u7231\u5947\u827a\u7231\u52a8\u6f2b”,”up”:9,”up2″:”9″,”upcl”:””,”v2_img”:”http:\/\/pic8.qiyipic.com\/image\/20141205\/4e\/7f\/v_108765570_m_601_284_160.jpg”,”v3_img”:”http:\/\/pic8.qiyipic.com\/image\/20141205\/4e\/7f\/v_108765570_m_601_480_270.jpg”,”vv”:”5403″,”year”:”2014″,”tv_id”:331794000,”vv_p”:61,”vv_f”:2,”vv_m”:39,”_sc”:7.5,”r_vv”:5403,”cpt_l”:0,”cpt_r”:0,”load_img”:”st”,”fst_time2″:””,”disable”:0,”weburl”:”http:\/\/m.iqiyi.com\/v_19rrn82058.html”,”auth”:1,”auth_error”:0,”tv”:{“block”:[],”block_now”:”0″,”count”:1,”other”:[“331794000~331794000~\u3010\u521d\u97f3miku\u3011\u30a2\u30ea\u30a2\u30c9\u30cd\u3010\u9ed2\u3046\u3055P\u3011~1~2014~http:\/\/pic8.qiyipic.com\/image\/20141205\/4e\/7f\/v_108765570_m_601_160_90.jpg~~~~~~sm25051115~0~1~5403~http:\/\/pic8.qiyipic.com\/image\/20141205\/4e\/7f\/v_108765570_m_601_284_160.jpg~2014~2014-12-05~~~\u65e5\u672c \u540c\u4eba ACG \u7279\u522b\u7248~219~0~1~1~0~0~\u7231\u5947\u827a\u7231\u52a8\u6f2b~~~0~http:\/\/m.iqiyi.com\/v_19rrn82058.html~0~0~0~0~0″],”0”:{“_id”:”331794000″,”_n”:”\u3010\u521d\u97f3miku\u3011\u30a2\u30ea\u30a2\u30c9\u30cd\u3010\u9ed2\u3046\u3055P\u3011″,”desc”:””,”_od”:1,”_dn”:219,”s_t”:-1,”e_t”:-1,”res”:[{“s”:1,”t”:”TS2″,”_v”:”e9898ca6870778b9a6f6a909fc763646″,”r_t”:”8″,”url”:””,”len”:24230959,”vid”:”http:\/\/cache.m.iqiyi.com\/dc\/dt\/mobile\/20141205\/dd\/6d\/c495ecbe9e6cace8c70d627f97113b69.m3u8?qypid=331794000_32&qd_src=5be6a2fdfe4f4a1a8c7b08ee46a18887&qd_tm=1420974669000&qd_ip=104.200.18.10&qd_sc=41c33c35701ea3789da74f6233714380″,”fid”:”OEVB5H6VUDZNWECGMJKPU3KRH7XLIO6B”,”pps”:”0″,”pps_url”:””,”uniq_id”:”100080001″,”_tsurl”:””,”type”:1,”f4v_url”:”http:\/\/cache.video.qiyi.com\/vp\/331794000\/e9898ca6870778b9a6f6a909fc763646\/”},{“s”:2,”t”:”TS1″,”_v”:”bb620e84cffc480d53f85d8842697cee”,”r_t”:”4″,”url”:””,”len”:11113689,”vid”:”http:\/\/cache.m.iqiyi.com\/dc\/dt\/mobile\/20141205\/95\/52\/cf82ab38c9949b20b2bf82ccab67777e.m3u8?qypid=331794000_32&qd_src=5be6a2fdfe4f4a1a8c7b08ee46a18887&qd_tm=1420974669000&qd_ip=104.200.18.10&qd_sc=c920c9a8c06403a72e0e149661aa683e”,”fid”:”34DSQJCHX6YW46NDC4KU7CVWZXCT5MVU”,”pps”:”0″,”pps_url”:””,”uniq_id”:”100040001″,”_tsurl”:””,”type”:1,”f4v_url”:”http:\/\/cache.video.qiyi.com\/vp\/331794000\/bb620e84cffc480d53f85d8842697cee\/”},{“s”:3,”t”:”TS4″,”_v”:”bd5ea43cdb556e035fa5ee99d2157e12″,”r_t”:”128″,”url”:””,”len”:4673682,”vid”:”http:\/\/cache.m.iqiyi.com\/dc\/dt\/mobile\/20141205\/2a\/74\/4f64780f9f4524311fa367414d8e5666.m3u8?qypid=331794000_32&qd_src=5be6a2fdfe4f4a1a8c7b08ee46a18887&qd_tm=1420974669000&qd_ip=104.200.18.10&qd_sc=4fbf13db970809a4e16ac3270f17f688″,”fid”:”CXFDFGWWNA6NVMBD7RHLEY2X7DQK7QTE”,”pps”:”0″,”pps_url”:””,”uniq_id”:”101280001″,”_tsurl”:””,”type”:1,”f4v_url”:”http:\/\/cache.video.qiyi.com\/vp\/331794000\/bd5ea43cdb556e035fa5ee99d2157e12\/”}],”len”:11113689,”vid”:”http:\/\/cache.m.iqiyi.com\/dc\/dt\/mobile\/20141205\/95\/52\/cf82ab38c9949b20b2bf82ccab67777e.m3u8?qypid=331794000_32&qd_src=5be6a2fdfe4f4a1a8c7b08ee46a18887&qd_tm=1420974669000&qd_ip=104.200.18.10&qd_sc=c920c9a8c06403a72e0e149661aa683e”,”url”:””,”_img”:”http:\/\/pic8.qiyipic.com\/image\/20141205\/4e\/7f\/v_108765570_m_601_160_90.jpg”,”web_url”:”http:\/\/m.iqiyi.com\/v_19rrn82058.html”,”albumid”:”331794000″,”subtitle”:”sm25051115″,”comment_on”:1,”_dv”:”e9898ca6870778b9a6f6a909fc763646″,”vote_id”:””,”_durl”:”http:\/\/data.video.qiyi.com\/videos\/v0\/20141205\/3d\/e7\/5d6c11ae9b1d465afd506c5fefbe4559.mp4?qypid=331794000_32&v=827122190&qd_src=app&qd_tm=1420974669000&qd_ip=104.200.18.10&qd_sc=92f4366fcb5a64db3c00a706388d7fe2″,”_dlen”:11971286,”pps”:”0″,”fid”:”34DSQJCHX6YW46NDC4KU7CVWZXCT5MVU”,”_res”:”4″,”_v”:”bb620e84cffc480d53f85d8842697cee”,”pps_url”:””,”f4v_url”:”http:\/\/cache.video.qiyi.com\/vp\/331794000\/bb620e84cffc480d53f85d8842697cee\/”,”ad_str”:”{\”ip\”:\”10.11.49.120\”,\”cupidExtras\”:{\”enableMiaozhenSDK\”:1,\”enableAdMasterSDK\”:1,\”enableAlimama\”:0,\”enableMmaMiaozhen\”:1,\”enableMmaCtr\”:1,\”alimamaId\”:71000017,\”enableMmaNielsen\”:1,\”enableMmaAdMaster\”:1},\”futureSlots\”:[{\”startTime\”:300,\”type\”:4}],\”reqUrl\”:\”\\\/mixer?a=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&b=331794000&c=bb620e84cffc480d53f85d8842697cee&d=qc_100001_100070&e=5.7.1&f=4&g=104.200.18.10&h=331794000&i=iPhone&k=4&l=8e48946f144759d86a50075555fd5862&m=iPhone4%2C1&n=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&o=0b05078afb5a24f5f97fadac83632383&vn=0&vd=0&r=2.5_002&rn=0&bd=219&p=-1&x=0&tp=0&nw=1&vs=0&pi=&pc=0&cts=1420974668<s=&y=103,1,2&fa=4&ut=0\”,\”version\”:\”2.0.8526\”,\”adSlots\”:[{\”startTime\”:0,\”duration\”:30,\”type\”:1,\”slotExtras\”:{},\”adZoneId\”:\”1000000000381\”,\”ads\”:[{\”adExtras\”:{},\”clickTracking\”:{\”adxTracking\”:[\”http:\\\/\\\/api.cupid.qiyi.com\\\/etx?i=qc_100001_100070&f=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&q=5000000678217&v=CAASEGseMM8pVUkpiJFs6m_FE1YaIDlhZTlmN2FkN2I4MzFiMDEyZjkwZjIxMzkyNTlhZmNj&c=1a9d6aa5607c24198908e4ecb7f36971&k=331794000&j=4&d=81000009&z=1000000000381&ds=71000001&du=15&n=331794000&g=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&o=1&e=104.200.18.10&l=8e48946f144759d86a50075555fd5862&r=0b05078afb5a24f5f97fadac83632383&a=1&b=1420974669\”],\”cupidTracking\”:[\”http:\\\/\\\/api.cupid.qiyi.com\\\/track2?a=1&b=1420974669&c=1a9d6aa5607c24198908e4ecb7f36971&d=5000000675829&e=104.200.18.10&f=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&g=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&h=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&i=qc_100001_100070&j=4&k=331794000&kp=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&l=8e48946f144759d86a50075555fd5862&m=iPhone4,1&n=331794000&o=1&p=1000000000381&q=5000000678217&r=0b05078afb5a24f5f97fadac83632383&s=dafea75e967cef6a25e0060b5aefbeb4&t=iPhone&u=1&w=2&up=&v=5000000675829\”]},\”impressionId\”:\”1a9d6aa5607c24198908e4ecb7f36971\”,\”vid\”:\”327d76cda8d3e7c29a41a52f1cb41ff8\”,\”priority\”:88,\”dspId\”:71000001,\”order\”:1,\”duration\”:15,\”clickThroughUrl\”:\”http:\\\/\\\/wt.game.pps.tv\\\/index.php?m=adsmd&c=tiepian&a=index&id=7421\”,\”impressionTracking\”:{\”adxTracking\”:[\”http:\\\/\\\/api.cupid.qiyi.com\\\/etx?i=qc_100001_100070&f=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&q=5000000678217&v=CAASEGseMM8pVUkpiJFs6m_FE1YaIDlhZTlmN2FkN2I4MzFiMDEyZjkwZjIxMzkyNTlhZmNj&c=1a9d6aa5607c24198908e4ecb7f36971&k=331794000&j=4&d=81000009&z=1000000000381&ds=71000001&du=15&n=331794000&g=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&o=1&e=104.200.18.10&l=8e48946f144759d86a50075555fd5862&r=0b05078afb5a24f5f97fadac83632383&a=0&b=1420974669\”],\”cupidTracking\”:[\”http:\\\/\\\/api.cupid.qiyi.com\\\/track2?a=0&b=1420974669&c=1a9d6aa5607c24198908e4ecb7f36971&d=5000000675829&e=104.200.18.10&f=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&g=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&h=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&i=qc_100001_100070&j=4&k=331794000&kp=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&l=8e48946f144759d86a50075555fd5862&m=iPhone4,1&n=331794000&o=1&p=1000000000381&q=5000000678217&r=0b05078afb5a24f5f97fadac83632383&s=dafea75e967cef6a25e0060b5aefbeb4&t=iPhone&u=1&w=2&up=&v=5000000675829\”]},\”creativeType\”:\”video_m3u8\”,\”clickThroughType\”:\”0\”,\”orderItemId\”:\”5000000675829\”,\”timePosition\”:\”2\”,\”adId\”:\”5000000677723\”,\”creativeObject\”:{},\”creativeUrl\”:\”\”,\”creativeId\”:\”5000000678217\”},{\”adExtras\”:{},\”clickTracking\”:{\”adxTracking\”:[\”http:\\\/\\\/api.cupid.qiyi.com\\\/etx?i=qc_100001_100070&f=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&q=5000000591849&v=CAASEGseMM8pVUkpiJFs6m_FE1YaIDlhZTlmN2FkN2I4MzFiMDEyZjkwZjIxMzkyNTlhZmNj&c=84e5330e3497a4c52b4ecfcd84e98f05&k=331794000&j=4&d=81000009&z=1000000000381&ds=71000001&du=15&n=331794000&g=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&o=1&e=104.200.18.10&l=8e48946f144759d86a50075555fd5862&r=0b05078afb5a24f5f97fadac83632383&a=1&b=1420974669\”],\”cupidTracking\”:[\”http:\\\/\\\/api.cupid.qiyi.com\\\/track2?a=1&b=1420974669&c=84e5330e3497a4c52b4ecfcd84e98f05&d=5000000589321&e=104.200.18.10&f=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&g=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&h=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&i=qc_100001_100070&j=4&k=331794000&kp=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&l=8e48946f144759d86a50075555fd5862&m=iPhone4,1&n=331794000&o=1&p=1000000000381&q=5000000591849&r=0b05078afb5a24f5f97fadac83632383&s=ddfc1cc2443276e5f8a2ea298a7774a8&t=iPhone&u=1&w=3&up=&v=5000000589321\”]},\”impressionId\”:\”84e5330e3497a4c52b4ecfcd84e98f05\”,\”vid\”:\”7d1bf186a55a5ae0bb2ad051666adb89\”,\”priority\”:88,\”dspId\”:71000001,\”order\”:2,\”duration\”:15,\”clickThroughUrl\”:\”http:\\\/\\\/serv.vip.iqiyi.com\\\/order\\\/preview.action?pid=a0226bd958843452&platform=bb35a104d95490f6&fc=a3dbfe9e7b9dba94#type=0\”,\”impressionTracking\”:{\”adxTracking\”:[\”http:\\\/\\\/api.cupid.qiyi.com\\\/etx?i=qc_100001_100070&f=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&q=5000000591849&v=CAASEGseMM8pVUkpiJFs6m_FE1YaIDlhZTlmN2FkN2I4MzFiMDEyZjkwZjIxMzkyNTlhZmNj&c=84e5330e3497a4c52b4ecfcd84e98f05&k=331794000&j=4&d=81000009&z=1000000000381&ds=71000001&du=15&n=331794000&g=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&o=1&e=104.200.18.10&l=8e48946f144759d86a50075555fd5862&r=0b05078afb5a24f5f97fadac83632383&a=0&b=1420974669\”],\”cupidTracking\”:[\”http:\\\/\\\/api.cupid.qiyi.com\\\/track2?a=0&b=1420974669&c=84e5330e3497a4c52b4ecfcd84e98f05&d=5000000589321&e=104.200.18.10&f=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&g=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&h=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&i=qc_100001_100070&j=4&k=331794000&kp=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&l=8e48946f144759d86a50075555fd5862&m=iPhone4,1&n=331794000&o=1&p=1000000000381&q=5000000591849&r=0b05078afb5a24f5f97fadac83632383&s=ddfc1cc2443276e5f8a2ea298a7774a8&t=iPhone&u=1&w=3&up=&v=5000000589321\”]},\”creativeType\”:\”video_m3u8\”,\”clickThroughType\”:\”3\”,\”orderItemId\”:\”5000000589321\”,\”timePosition\”:\”3\”,\”adId\”:\”5000000591634\”,\”creativeObject\”:{},\”creativeUrl\”:\”\”,\”creativeId\”:\”5000000591849\”}]}],\”videoEventId\”:\”0b05078afb5a24f5f97fadac83632383\”,\”finalUrl\”:\”http:\\\/\\\/cache.m.iqiyi.com\\\/dc\\\/amdt\\\/ae7578x3cd43d3f\\\/327d76cda8d3e7c29a41a52f1cb41ff8-7d1bf186a55a5ae0bb2ad051666adb89\\\/331794000\\\/bb620e84cffc480d53f85d8842697cee.m3u8?qd_asc=ae4f1fc1098e13132ea08c9490e419ee&qd_asrc=8c40568b52a2483ea7e88a948c7ed664&qd_at=1420974669569&qypid=331794000_32\”}”}},”sn”:”1420974668080402944″,”_tab”:[{“id”:2,”name”:”\u8be6\u60c5\u8bc4\u8bba”,”default”:0},{“id”:3,”name”:”\u731c\u4f60\u559c\u6b22″,”default”:1}],”cupid_app_on”:1,”cupid_app_tab”:3,”_av”:1,”album_barrage”:1,”album_barrage_lines”:3,”cupid_ut”:0,”cupid_nw”:1,”cupid_expire”:3}

以上是请求的原始响应报文,可以借用 charles 提供的 JSON 方式查看:

[resp_image id=’14942′ caption=” ]

由于对 iOS 上视频播放的机制并不熟悉,所以我只能一个一个测试过去,然后大致了解返回的数据是什么意思:

  • tv 键名下有个 res,里面有三个对象,包含的是三个清晰度的视频版本,其中有视频路径,格式为 m3u8,比如 http://cache.m.iqiyi.com/dc/dt/mobile/20141205/dd/6d/c495ecbe9e6cace8c70d627f97113b69.m3u8?qypid=331794000_32&qd_src=5be6a2fdfe4f4a1a8c7b08ee46a18887&qd_tm=1420974669000&qd_ip=104.200.18.10&qd_sc=41c33c35701ea3789da74f6233714380,在浏览器中打开这个路径,就可以下载 m3u8 文件,然后用 mplayer 等工具即可播放,借助 ffmpeg 工具也可以将它下载到本地。
  • tab 键名下有两个对象,包含是的”详情评论“和”猜你喜欢“,这是视频下的两个标签页。

经过排查,大致锁定一个叫 ad_str 的键名,其值如下:

{“ip”:”10.11.49.120″,”cupidExtras”:{“enableMiaozhenSDK”:1,”enableAdMasterSDK”:1,”enableAlimama”:0,”enableMmaMiaozhen”:1,”enableMmaCtr”:1,”alimamaId”:71000017,”enableMmaNielsen”:1,”enableMmaAdMaster”:1},”futureSlots”:[{“startTime”:300,”type”:4}],”reqUrl”:”\/mixer?a=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&b=331794000&c=bb620e84cffc480d53f85d8842697cee&d=qc_100001_100070&e=5.7.1&f=4&g=104.200.18.10&h=331794000&i=iPhone&k=4&l=8e48946f144759d86a50075555fd5862&m=iPhone4%2C1&n=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&o=0b05078afb5a24f5f97fadac83632383&vn=0&vd=0&r=2.5_002&rn=0&bd=219&p=-1&x=0&tp=0&nw=1&vs=0&pi=&pc=0&cts=1420974668<s=&y=103,1,2&fa=4&ut=0″,”version”:”2.0.8526″,”adSlots”:[{“startTime”:0,”duration”:30,”type”:1,”slotExtras”:{},”adZoneId”:”1000000000381″,”ads”:[{“adExtras”:{},”clickTracking”:{“adxTracking”:[“http:\/\/api.cupid.qiyi.com\/etx?i=qc_100001_100070&f=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&q=5000000678217&v=CAASEGseMM8pVUkpiJFs6m_FE1YaIDlhZTlmN2FkN2I4MzFiMDEyZjkwZjIxMzkyNTlhZmNj&c=1a9d6aa5607c24198908e4ecb7f36971&k=331794000&j=4&d=81000009&z=1000000000381&ds=71000001&du=15&n=331794000&g=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&o=1&e=104.200.18.10&l=8e48946f144759d86a50075555fd5862&r=0b05078afb5a24f5f97fadac83632383&a=1&b=1420974669″],”cupidTracking”:[“http:\/\/api.cupid.qiyi.com\/track2?a=1&b=1420974669&c=1a9d6aa5607c24198908e4ecb7f36971&d=5000000675829&e=104.200.18.10&f=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&g=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&h=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&i=qc_100001_100070&j=4&k=331794000&kp=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&l=8e48946f144759d86a50075555fd5862&m=iPhone4,1&n=331794000&o=1&p=1000000000381&q=5000000678217&r=0b05078afb5a24f5f97fadac83632383&s=dafea75e967cef6a25e0060b5aefbeb4&t=iPhone&u=1&w=2&up=&v=5000000675829″]},”impressionId”:”1a9d6aa5607c24198908e4ecb7f36971″,”vid”:”327d76cda8d3e7c29a41a52f1cb41ff8″,”priority”:88,”dspId”:71000001,”order”:1,”duration”:15,”clickThroughUrl”:”http:\/\/wt.game.pps.tv\/index.php?m=adsmd&c=tiepian&a=index&id=7421″,”impressionTracking”:{“adxTracking”:[“http:\/\/api.cupid.qiyi.com\/etx?i=qc_100001_100070&f=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&q=5000000678217&v=CAASEGseMM8pVUkpiJFs6m_FE1YaIDlhZTlmN2FkN2I4MzFiMDEyZjkwZjIxMzkyNTlhZmNj&c=1a9d6aa5607c24198908e4ecb7f36971&k=331794000&j=4&d=81000009&z=1000000000381&ds=71000001&du=15&n=331794000&g=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&o=1&e=104.200.18.10&l=8e48946f144759d86a50075555fd5862&r=0b05078afb5a24f5f97fadac83632383&a=0&b=1420974669″],”cupidTracking”:[“http:\/\/api.cupid.qiyi.com\/track2?a=0&b=1420974669&c=1a9d6aa5607c24198908e4ecb7f36971&d=5000000675829&e=104.200.18.10&f=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&g=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&h=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&i=qc_100001_100070&j=4&k=331794000&kp=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&l=8e48946f144759d86a50075555fd5862&m=iPhone4,1&n=331794000&o=1&p=1000000000381&q=5000000678217&r=0b05078afb5a24f5f97fadac83632383&s=dafea75e967cef6a25e0060b5aefbeb4&t=iPhone&u=1&w=2&up=&v=5000000675829″]},”creativeType”:”video_m3u8″,”clickThroughType”:”0″,”orderItemId”:”5000000675829″,”timePosition”:”2″,”adId”:”5000000677723″,”creativeObject”:{},”creativeUrl”:””,”creativeId”:”5000000678217″},{“adExtras”:{},”clickTracking”:{“adxTracking”:[“http:\/\/api.cupid.qiyi.com\/etx?i=qc_100001_100070&f=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&q=5000000591849&v=CAASEGseMM8pVUkpiJFs6m_FE1YaIDlhZTlmN2FkN2I4MzFiMDEyZjkwZjIxMzkyNTlhZmNj&c=84e5330e3497a4c52b4ecfcd84e98f05&k=331794000&j=4&d=81000009&z=1000000000381&ds=71000001&du=15&n=331794000&g=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&o=1&e=104.200.18.10&l=8e48946f144759d86a50075555fd5862&r=0b05078afb5a24f5f97fadac83632383&a=1&b=1420974669″],”cupidTracking”:[“http:\/\/api.cupid.qiyi.com\/track2?a=1&b=1420974669&c=84e5330e3497a4c52b4ecfcd84e98f05&d=5000000589321&e=104.200.18.10&f=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&g=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&h=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&i=qc_100001_100070&j=4&k=331794000&kp=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&l=8e48946f144759d86a50075555fd5862&m=iPhone4,1&n=331794000&o=1&p=1000000000381&q=5000000591849&r=0b05078afb5a24f5f97fadac83632383&s=ddfc1cc2443276e5f8a2ea298a7774a8&t=iPhone&u=1&w=3&up=&v=5000000589321″]},”impressionId”:”84e5330e3497a4c52b4ecfcd84e98f05″,”vid”:”7d1bf186a55a5ae0bb2ad051666adb89″,”priority”:88,”dspId”:71000001,”order”:2,”duration”:15,”clickThroughUrl”:”http:\/\/serv.vip.iqiyi.com\/order\/preview.action?pid=a0226bd958843452&platform=bb35a104d95490f6&fc=a3dbfe9e7b9dba94#type=0″,”impressionTracking”:{“adxTracking”:[“http:\/\/api.cupid.qiyi.com\/etx?i=qc_100001_100070&f=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&q=5000000591849&v=CAASEGseMM8pVUkpiJFs6m_FE1YaIDlhZTlmN2FkN2I4MzFiMDEyZjkwZjIxMzkyNTlhZmNj&c=84e5330e3497a4c52b4ecfcd84e98f05&k=331794000&j=4&d=81000009&z=1000000000381&ds=71000001&du=15&n=331794000&g=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&o=1&e=104.200.18.10&l=8e48946f144759d86a50075555fd5862&r=0b05078afb5a24f5f97fadac83632383&a=0&b=1420974669″],”cupidTracking”:[“http:\/\/api.cupid.qiyi.com\/track2?a=0&b=1420974669&c=84e5330e3497a4c52b4ecfcd84e98f05&d=5000000589321&e=104.200.18.10&f=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&g=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&h=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&i=qc_100001_100070&j=4&k=331794000&kp=EAA3CC99-FAB0-46CC-B1A0-67B9BA89BB7F&l=8e48946f144759d86a50075555fd5862&m=iPhone4,1&n=331794000&o=1&p=1000000000381&q=5000000591849&r=0b05078afb5a24f5f97fadac83632383&s=ddfc1cc2443276e5f8a2ea298a7774a8&t=iPhone&u=1&w=3&up=&v=5000000589321″]},”creativeType”:”video_m3u8″,”clickThroughType”:”3″,”orderItemId”:”5000000589321″,”timePosition”:”3″,”adId”:”5000000591634″,”creativeObject”:{},”creativeUrl”:””,”creativeId”:”5000000591849″}]}],”videoEventId”:”0b05078afb5a24f5f97fadac83632383″,”finalUrl”:”http:\/\/cache.m.iqiyi.com\/dc\/amdt\/ae7578x3cd43d3f\/327d76cda8d3e7c29a41a52f1cb41ff8-7d1bf186a55a5ae0bb2ad051666adb89\/331794000\/bb620e84cffc480d53f85d8842697cee.m3u8?qd_asc=ae4f1fc1098e13132ea08c9490e419ee&qd_asrc=8c40568b52a2483ea7e88a948c7ed664&qd_at=1420974669569&qypid=331794000_32″}

又一段非常长的文本,我想你我都懒得看内容了 – 不过拜语义化带来的好处,我们一眼就能从 ad_str 里判断它可能是广告入口。且在 Privoxy 里换掉它试试。

设定 Privoxy 规则

因为是过滤文本,所以要涉及 Privoxy 的两个文件:

  • user.filter
  • user.action
  1. 首先在 user.filter 文件中添加如下规则:

    FILTER: blockQiyiAd 去除爱奇艺 iOS 版本视频广告
    s|"ad_str"|"fuck_ad_str"|g
    

    这里,我创建了一条规则,把 ad_str 键名替换掉。

  2. 然后在 user.action 文件中启用过滤规则:

    {+filter{blockQiyiAd}}
    iface2.iqiyi.com
    

    再开启爱奇艺的客户端,视频广告已经不见。感谢语义,蒙对了。目前来看,也没有其他引发异常的副作用。

修改 Privoxy 监听地址

上面说明的是开启 charles 的情况,一旦 charles 关闭,我们就要把 iPhone 上的 HTTP PROXY 改为电脑上的 Privoxy 端口,比如 192.168.1.102:8118

但 Privoxy 默认监听的地址是 127.0.0.1:8118,如果不做修改,会导致 iPhone 设置的 HTTP 代理无法访问。所以我新增一个 Privoxy 的监听地址。

打开 config 文件,查找 listen-address 127.0.0.1:8118,在它下一行新增如下内容:

listen-address  192.168.1.102:8118

其中 192.168.1.102 是我笔记本电脑的 IP。

最后,重启 Privoxy。

更多规则,请看我维护的 Privoxy 配置文件库

更新

2015.2.8 爱奇艺把 ‘ad_str’ 换成 ‘ad_info’ 了,配置文件已更新。

报告问题 修订

如果你有自建 https 代理的需求,欢迎尝试 Phantom,一键搭建,方便快捷。查看 demo