Well the solution is to take breaks! The so called "willpower" that other people talked about declines as you study more and more. You might be able to refrain yourself from getting distracted for the first hour of using the computer, but you'll gradually get more inclined to procrastinate etc. Hence the breaks
(if that makes sense?)
Just from personal experience - I can only tolerate 1.5 hours of continual study before I need to take a break or I'll be on youtube procrastinating, lol.
If your problem is that you end up on youtube after 5 minutes of studying then... you may need to reconsider the reasons why you're studying and hopefully find that spark of motivation that keeps you going. Blocking the sites works I guess, temporarily - until you inevitably find a way around it lol.