2013-06-29 44 views
3

我需要使用Curl下載Youtube視頻的特定部分。 (假設我想下載第一個2MB)我正在使用Curl中的-r開關來實現這一點。它適用於非YouTube鏈接,但我用-r指定的範圍在Youtube鏈接中被忽略。 Curl下載整個視頻文件,而不是下載我想要的塊。我怎樣才能做到這一點?
在此先感謝!Curl爲什麼忽略給定的範圍?

(A樣本代碼我用:)

捲曲--cookie 「VISITOR_INFO1_LIVE = EIBGUtRnRx4; 人口統計= d9e6a6b806922b989c443b57cc40cf59e3QDAAAAYWdlaRQAAAB0BgAAAGdlbmRlcnQBAAAAbTA =; s_tempdata-336183159 = EI = xBC_UeOJLs6hkgXB7oGwDw & VED = CDcQvxs; s_tempdata- 3430648675 = EI = xBC_UeOJLs6hkgXB7oGwDw & VED = CEwQvxs; s_tempdata-877158463 = EI = xBC_UeOJLs6hkgXB7oGwDw & VED = CF8Qvxs; s_tempdata-2333910030 = EI = xBC_UeOJLs6hkgXB7oGwDw & ved = CHsQvxs; s_tempdata-3498387738 = ei = xBC_UeOJLs6hkgXB7oGwDw & ved = CDIQvxs; s_tempdata-106278690 = ved = CFcQvxs & ei = Q9LCUfqrJMK0kgX3ioGgBw; s_tempdata-1014563062 = ved = CFoQvxs & ei = cxDEUf3OAsiekQXjiYCACA; d9ji4.resume = uFMMXRoSxnA:183; s_tempdata-1950472349 = ei = ywzMUcPiJqekmQXrtIC4Cw & ved = CCMQvxs; s_tempdata-350957551 = ei = UxDMUaWGJOTnmAWnmIHICg & ved = CDMQvxs; s_tempdata-3561588006 = ei = MD_MUZyPGeTnmAX3koHgBw & ved = CDIQvxs; s_tempdata-1460032003 = ei = 1VDOUbSyIYjOmgXtyYGAAQ & ved = CA0Qvxs; s_tempdata-2286494229 = ei = lFXOUfiMLerbmAXrgoG4Aw & ved = CIABEL8b; s_tempdata-1936772083 = ei = lFXOUfiMLerbmAXrgoG4Aw & ved = CH0Qvxs; s_tempdata-190970993 = feature = g-high-crv & ei = S9zOZzYLsi3ygHS9YD4BA & ved = CIgBEPklKAE; __utma = 27069237.288981257.1372343761.1372343761.1372511855.2; __utmb = 27069237.5.10.1372511855; __utmz = 27069237.1372343761.1.1.utmcsr =(直接)| utmccn =(直接)| utmcmd =(無); __utmc = 27069237; YSC = TwN0bcR_vzM; recently_watched_video_id_list = cc05ffe7b8a53d9d2dbcb9695b1b5354WwEAAABzCwAAAEhTZUltcWJWMzBz;活性= 1372523413722; PREF = F1 = 5000 & FV = 11.2.202 &人= EN;」 -o 〜/下載/ File.part -r 0-2000000 「http://r4---sn-nau-jhcl.c.youtube.com/videoplayback?id=1d27889aa6d5df4b&ipbits=8&factor=1.25&ms=au&mt=1372523374&fexp=925614%2C906370%2C912519%2C904825%2C900222%2C909546%2C906397%2C928201%2C929123%2C929915%2C929906%2C929907%2C929125%2C929127%2C925714%2C929917%2C929919%2C931202%2C912512%2C912515%2C912521%2C906838%2C906840%2C931913%2C904830%2C919373%2C933701%2C904122%2C900816%2C909421%2C912711%2C907228&mv=m&burst=40&algorithm=throttle-factor&expire=1372545822&sver=3&source=youtube&newshard=yes&cp=U0hWR1VPU19HTENONl9NSVdJOkNGQUpTdVJvVnY0&upn=a9WEy2DAZiY&ip=103.21.166.17&key=yt1&itag=34&sparams=algorithm%2Cburst%2Ccp%2Cfactor%2Cid%2Cip%2Cipbits%2Citag%2Csource%2Cupn%2Cexpire&signature=399599C4C262CCEAED9AB8AEA48A71DDFADFB7CF.08C556136636AFD52BE0318D3E4AECAC1ABFB7C5

+0

請Naveen談談您用於繞過此限制的解決方案。下載服務器中的整個視頻對性能不利。提前致謝。 –

+1

抱歉,沒有辦法繞過。即使curl請求特定範圍的字節,一些弱服務器也會發送整個文件。這些服務器不提供下載暫停/恢復支持。 – Naveen

+1

非常感謝 –

回答

2

看來,YouTube的服務器唐「T支持範圍參數或者忽略它從cURL docs

4.11爲什麼我的HTTP範圍請求返回完整的文檔

B'因爲服務器可能不支持該範圍,或者服務器可能會選擇忽略它並返回完整文檔。