3

I need to download a specific part of a Youtube video using Curl. (Let's say I want to download the first 2MB) I'm using the -r switch in Curl to achieve this. It works for non-youtube links, but the range I specify with -r is ignored for Youtube links. Curl downloads the entire video file, instead of downloading the chunk I want. How can I do this?
Thanks in advance!

(A sample code I used:)

curl --cookie "VISITOR_INFO1_LIVE=EIBGUtRnRx4; demographics=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=S9zOUZzYLsi3ygHS9YD4BA&ved=CIgBEPklKAE; __utma=27069237.288981257.1372343761.1372343761.1372511855.2; __utmb=27069237.5.10.1372511855; __utmz=27069237.1372343761.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmc=27069237; YSC=TwN0bcR_vzM; recently_watched_video_id_list=cc05ffe7b8a53d9d2dbcb9695b1b5354WwEAAABzCwAAAEhTZUltcWJWMzBz; ACTIVITY=1372523413722; PREF=f1=50000000&fv=11.2.202&al=en;" -o ~/Downloads/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"

2
  • Please Naveen to talk us about the solution you used to bypass this limitation. Downloading the whole video in server is bad for performance. Thanks in advance.
    – Adib Aroui
    Aug 19, 2013 at 17:48
  • 1
    Sorry there is no way to bypass. Even if curl requests a specific range of bytes, some weak servers sends the whole file. Such servers do not offer download pause/resume support.
    – Naveen
    Sep 24, 2013 at 6:51

1 Answer 1

2

It seems that the YouTube servers don't support the range parameter or they ignore it. From the cURL docs:

4.11 Why does my HTTP range requests return the full document?

Because the range may not be supported by the server, or the server may choose to ignore it and return the full document anyway.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.