Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / PHP
Print

One Line of code to download youtube's flv file in php

5.00/5 (1 vote)
25 Mar 2011CPOL 20.7K  
One Line of code to download youtube's flv file in php
$video_id is the id of youtube video
$video_path is the saving path

<br />
exec('wget -t 2  --cookies=on --keep-session-cookies --save-cookies=/home/cookie.txt http://www.youtube.com/get_video_info?video_id='.$video_id.' -qO- | sed -n "/fmt_url_map/{s/[\\&]/\\n/g;p}" | sed -n \'/^fmt_url_map=/p\'  | sed -n "s/\\%7C/\\n/g;p"  | sed -n \'/itag%3D5/p\'|  sed \'s/%3A/:/g;s/%2F/\\//g;s/%3F/\\?/g;s/%3D/=/g;s/%26/\\&/g ;s/%25/%/g \' | wget  --cookies=on --load-cookies=/home/cookie.txt  -i - -O '.$video_path);

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)