My first time working with socket.........
Its been created when Im feel so tired to open the youtube pages and its source code and then find the video url there's.
So Ive decided to write a simple snippet in mirc to allow me just gave the page url where theres was a video that I want to downloading.
/*
> File Information
>-------------------
>Name: /getvid
>Author: zonIRC
>Testing with: mIRC 6.21
>Description: A simple snippet that get the url of youtube video based on url specify.
>How To Install
>----------------
>1) Open your mIRC editor by hit 'Alt+R'.
>2) Then hit 'Ctrl+L'.
>3) Select this file and click 'Open'.
>Syntax
>---------
>/getvid [-b] url
>[-b] to make snippet downloading the file by using your default browser.
> when 'File Download' dialog opened, click 'Save' and choose where to
> saved it(make sure you named it as .flv file since youtube used that
> file format).
>url the address of the file that you like to get.
> 'http://' and 'www.' are not essential.
>Example
>--------
>/getvid youtube.com/watch?v=wvMc84FZnI0
>this will opened @getvid and echoing the video URL, so if you want to get the file just
>double click on text after URL:. When you like to see the video on your browser, just
>double click on text after For:
>/getvid -b http://youtube.com/watch?v=wvMc84FZnI0
>this will automatically downloading the video file by using your default browser.
>Credits
>--------
>1) Sais - for giving me a link for socket code(http://tinyurl.com/3cwfcv)
>2) puzzling - for advice me to send 'User-Agent'
>3) Riamus2 - where its code(http://tinyurl.com/3cwfcv) at that forum have
> been used by me to learning a way to establish a connection.
*/
alias getvid {
;/getvid [-b] [url]
if (!$1) echo -ftsc info * /getvid: insufficient parameter
else {
set %openbrowser $iif($1 = -b,1)
if ($iif(%openbrowser,$2-,$1-)) {
set %getvid www. $+ $regsubex($v1,/^http://(www.)?/i,)
if ($sock(getvid)) sockclose getvid
sockopen getvid $gettok(%getvid,1,47) 80
}
else echo -ftsc info * /getvid: url not specified.
}
}
on *:sockopen:getvid:{
if (!$window(@getvid)) window @getvid
sockwrite -n $sockname GET / $+ $gettok(%getvid,2,47) HTTP/1.1
sockwrite -n $sockname Host: $gettok(%getvid,1,47)
sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6)
sockwrite -n $sockname $sockname Accept: */* $+ $crlf $+ $crlf
}
on *:sockread:getvid:{
var %temp
sockread %temp
if ($regsubex(%temp,/var fullscreenUrl = '\/watch_fullscreen/i,) != %temp) {
var %vidurl = $+($gettok(%getvid,1,47),/get_video,$remove($left($v1,-2),$chr(9)))
echo @getvid Video URL: %vidurl For: %getvid
if (%openbrowser) url %vidurl
sockclose getvid
}
}
thanx water_dragon
at least someone feel this one are useful :P
anyway this snippet will downloading a .flv file(which that was a youtube video file format) and that means you need a FLV player which like mountaindew suggesting you can try total video player or you can google for \'flv player\' or you can get a codec that supported the .flv player such as storm codec.
water_dragon you can renamed the file as any .xxx that you like, however you still need a FLV player to play it. Even if you rename it as .wmv(for example) and your player didnt support flv format then an error occured.
If you want to convert the downloaded file, once again u can follow what mountaindew said. Or you can try media converter(which im prefer :P), you can get it at http://www.mediaconverter.org/ (either you want used the online converter or download its free version)
For others, there was some major problem for the url this snippet echoing(at @getvid). Since any url that have a spaces are not being converted into url form so a clicking at it will not working(eventhough its work but its redirect the browser to a wrong url).... So its better used the \'-b\' switches for this moment(until Ive got a desire to recode this thing-got many video to download so cant have spare time to coding lol :P)