Youtube Download Link Generator

By FordLawnmower on Jan 25, 2010

This script will generate a Download link for a valid Youtube video url.

This script is made to be loaded into your bot and triggered by a second client but it can also be loaded into your main client and used with an alias.

Alias:
/YTDL ValidYoutubeVideoLinkHere
Will echo the results to the active screen.

Bot Triggers:
!YTDL ValidYoutubeVideoLinkHere
Will notice the user the results.

@YTDL ValidYoutubeVideoLinkHere
Will message the channel if the user has half ops or higher. Otherwise it will notice the user.

To use the bot triggers, right click the channel or status, select Youtube Download Link Trigger and click ON

Example Output:
21:40:00 @ytdl http://www.youtube.com/watch?v=RMnH5nhUUZI&feature=channel
21:40:01 <+Lunch|Box Searching Youtube........
21:40:02 <+Lunch|Box Low Download http://tinyurl.com/ykqvb9v
21:40:02 <+Lunch|Box High Download http://tinyurl.com/yghfrz3

;Youtube download link generator by Ford_Lawnmower irc.mindforge.org #USA-Chat
menu Channel,Status {
  .$iif($group(#YTDL) == On,$style(1)) Youtube Download Link Trigger
  ..$iif($group(#YTDL) == On,$style(2)) On: .enable #YTDL
  ..$iif($group(#YTDL) == Off,$style(2)) Off: .disable #YTDL
}
#YTDL OFF
On $*:Text:/^(!|@)YTDL.*/Si:#: {
  if (!$timer($+(YTDL,$network,$nick))) {
    .timer $+ $+(YTDL,$network,$nick) 1 6 noop
    var %method $iif($regml(1) == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%)/),.msg $chan,.notice $nick))
    YTGetLink %method $2-
  }
}
#YTDL END
alias YTDL { YTGetLink echo -a $1- }
alias -l YTGetLink {
  if (!$3) { $1-2 Syntax youtube linktovideohere }
  elseif (!$regex($3,/.*youtube\.com\/watch\?v=[\S]{11}/Si)) { $1-2 Invalid Link! Recheck it and try again! }
  else {
    $1-2 Searching Youtube........
    var %sockname $+(YTDL,$network,$2,$ticks) 
    sockopen %sockname www.youtube.com 80
    sockmark %sockname $1-2 $left($gettok($3,2,61),11)
  }
}
On *:sockopen:YTDL*: {
  if (!$sockerr) {
    sockwrite -nt $sockname GET $+(/watch?v=,$gettok($sock($sockname).mark,3,32)) HTTP/1.1
    sockwrite -n $sockname Host: www.youtube.com
    sockwrite -n $sockname $crlf
  }
  else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
}
on *:sockread:YTDL*: {
  sockread %ytube
  if ($regex(%ytube,"t":\s"(.*)"\x2C\s"(?:instream|fexp|rv\.6\.id)":)) {
    var %key $left($regml(1),46)
    ShrinkYT $gettok($sock($sockname).mark,1-2,32) 05High Download $+(http://www.youtube.com/get_video?,video_id=,$gettok($sock($sockname).mark,3,32),&t=,%key,&fmt=18)
    ShrinkYT $gettok($sock($sockname).mark,1-2,32) 11Low Download $+(http://www.youtube.com/get_video?,video_id=,$gettok($sock($sockname).mark,3,32),&t=,%key)
    sockclose $sockname
  }
}
alias -l ShrinkYT {
  if ($regex($1,/^[\.]?(echo|msg|notice)/Si)) && ($3) {
    if ($wildtok($strip($3-),http://*.*,0,32) == $wildtok($strip($3-),*http://tinyurl.com*,0,32)) { 
      $1-
      return
    }
    var %count $wildtok($strip($3-),http://*.*,0,32), %text $strip($3-)
    while %count {
      if ($left($wildtok(%text,http://*.*,%count,32),18) != http://tinyurl.com) {
        tinyyt $1-2 $wildtok(%text,http://*.*,%count,32) $3-
        %count = 0
        return 
      }
      dec %count
    }
  }
  else { echo -st ShrinkLinks error -- must start with msg #chan - msg nickname - notice nickname or echo -a }
}
alias -l TinyYT {
  var %sockname $+(YTTiny,$network,$ticks,$r(1,$ticks))
  sockopen %sockname tinyurl.com 80
  sockmark %sockname $1-2 $+(/create.php?url=,$3) $3 $4-
}
On *:sockopen:YTTiny*: {
  if (!$sockerr) {
    sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
    sockwrite -n $sockname Host: tinyurl.com
    sockwrite -n $sockname $crlf
  }
  else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
}
On *:sockread:YTTiny*: {
  if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  else {
    var %Tiny | sockread %Tiny
    if ($regex(%Tiny,/<blockquote><b>(.*)<\/b><br><small>/i)) {
      tokenize 32 $sock($sockname).mark
      ShrinkYT $1-2 $replace($5-,$4,$regml(1))
      sockclose $sockname
      return
    }
  }
}

Comments

Sign in to comment.
FordLawnmower   -  Jun 26, 2012

@RIcko For now you can use this script if you want something simple to download youtube videos:
http://www.hawkee.com/snippet/9281/

 Respond  
FordLawnmower   -  Jun 26, 2012

This script is outdated and public links are no longer supported. I may update it at some point but I have several other scripts that provide the same function.

 Respond  
RIcko   -  Jun 26, 2012

It says Searching.... with no results :/

update is needed

 Respond  
sunslayer   -  Mar 31, 2010

/YTDL ValidYoutubeVideoLinkHere

 Respond  
Joeyy   -  Mar 31, 2010

Is there ANY way to make this into an input script that notices yourself?

 Respond  
Roger   -  Jan 29, 2010

Ahh Ive not attempted to use a flv file with the DCX video control yet but mp4 certainly works well. Thanks sunslayer.

 Respond  
sunslayer   -  Jan 29, 2010

the high quality is .mp4 and low is .flv

 Respond  
Roger   -  Jan 28, 2010

What format does this download in? Ive been looking for something like this to implement into a DCX video control but it has limited video formats.

 Respond  
FordLawnmower   -  Jan 28, 2010

@GuitarMasterx7 I'll consider adding the Name and File size when I get some time.
If you want more information added, this one even has a picture -->> http://code.google.com/p/fordlawnmower/wiki/YoutubeVideoDownloader

 Respond  
sunslayer   -  Jan 28, 2010

that was just an example, im sure there are others out there

 Respond  
GuitarMasterx7   -  Jan 28, 2010

hm...kinda broken there >.>

 Respond  
FordLawnmower   -  Jan 27, 2010

Just glancing at the regex on that script, I'm sure it's broken. I don't think there is anything like that on the watch page anymore.

 Respond  
FordLawnmower   -  Jan 26, 2010

It's something to consider GuitarMasterx7 but I think I will just leave it for now.
I made this on the assumption that someone has already found a video that they like and they just want a link so they can download it.
Thanks for the comment/suggestions GuitarMasterx7 :)

 Respond  
GuitarMasterx7   -  Jan 26, 2010

ohh thas awesome.
=o
if you add anything you can put the uhhh
youtube direct link to the video to watch before dling wif the
length/views/votes/user who posted/how longs its been there[bit pointless an prob spams like crazy]
besides the suggestion
dat
is
awesome =D lol


alias -l ShrinkYT 

das a cute alias name lolz

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.