Youtube for mIRC

By troll on Jun 25, 2010

How to use:
1) Add the code into your remotes (alt + r), then click OK
2) Right click anywhere on your mIRC screen and select "Youtube by Troll"

In order to watch video directly from mIRC, you will need to download a DLL. The script will tell you where to get the DLL and where to save it when you click on "Watch".

If it dosen't work try downloading the 'nHTMLn_2.92.dll' dll first.

menu * {
  Youtube by Troll: dialog $+(-,$iif($dialog(Youtube),ev,dm)) Youtube Youtube
}

dialog youtube {
  title "Youtube by Troll"
  size -1 -1 134 154
  option dbu
  box "Query", 5, 8 2 77 21
  edit "", 6, 11 10 70 10, autohs center
  box "", 7, 83 2 44 21
  button "Search", 8, 87 8 37 12
  tab "Videos", 9, 2 23 129 103
  list 11, 4 39 125 76, tab 9 size hsbar vsbar
  button "Add", 12, 105 116 23 8, tab 9
  link "5", 17, 72 116 3 8, hide tab 9
  link "4", 16, 68 116 3 8, hide tab 9
  link "3", 15, 64 116 3 8, hide tab 9
  link "2", 14, 60 116 3 8, hide tab 9
  text "Page:", 13, 43 116 15 8, hide tab 9
  text "Results:", 18, 5 116 37 8, hide tab 9
  check "Show video's link", 19, 72 25 52 10, tab 9
  tab "Favorites", 10
  list 1, 4 39 125 76, tab 10 size hsbar vsbar
  button "Delete", 2, 80 116 24 8, tab 10
  button "Clear", 3, 106 116 22 8, tab 10
  box "Link", 20, 2 129 128 22
  edit "", 21, 5 137 88 10, read autohs
  button "Copy", 22, 95 137 32 10
  button "Watch", 4, 80 116 23 8, tab 9
  button "Watch", 32, 5 116 23 8, tab 10
}

on *:dialog:Youtube:*:*:{
  if ($devent == init) {
    did -c $dname 19
    if ($exists(YTfav.txt)) && ($lines(YTfav.txt) > 0) {
      var %x 1
      while ($read(YTfav.txt,%x)) {
        did -az $dname 1 $gettok($v1,2-,32)
        inc %x
      }
    }
  }
  elseif ($devent = sclick) {
    if ($did == 4) {
      if ($did(11).seltext) {
        if ($gettok($read(Youtube.txt,w,$+(*,$v1,*)),1,32)) {
          noop $Youtube.Watch($remove($v1,/watch?v=))
        }
      }
    }
    elseif ($did == 32) {
      if ($did(1).seltext) {
        if ($gettok($read(YTfav.txt,w,$+(*,$v1,*)),1,32)) {
          noop $Youtube.Watch($remove($v1,/watch?v=))
        }
      }
    }
    elseif ($did == 8) {
      if ($did(6)) {
        var %Sock YoutubeDialog. [ $+ [ $md5($right($ticks,4)) ] ]
        did -r $dname 11 | write -c Youtube.txt
        sockopen %Sock www.youtube.com 80
        sockmark %Sock $replace($did(6),$chr(32),$chr(43)) $+ &page=1
      }
      else noop $tip(Youtube,Youtube,Your query was not found. $+ $crlf Please make sure you have specified one into the appropriate box.)
    }
    elseif ($did == 19) {
      if ($did(19).state = 1) {
        dialog -s $dname -1 -1 267 307
      }
      else dialog -s $dname -1 -1 267 256
    }
    elseif ($did == 12) {
      if ($did(11).seltext) {
        did -a $dname 1 $v1
        write YTfav.txt $read(Youtube.txt,w,$+(*,$v1,*))
      }
      else noop $tip(Youtube,Youtube,Please select a video before trying to add one into your favorites.)
    }
    elseif ($did == 1) {
      if ($did($dname,19).state == 1) {
        if ($gettok($read(YTfav.txt,w,$+(*,$did($dname,1).seltext,*)),1,32)) {
          did -ra $dname 21 http://youtube.com $+ $v1
        }
        else noop $tip(Youtube,Youtube,An error has occured while trying to get $qt($did($dname,1).seltext) URL.)
      }
      else return
    }
    elseif ($did == 2) {
      if ($did(1).seltext) {
        write $+(-dl,$did(1).sel) YTfav.txt
        did -d $dname 1 $did(1).sel
        if ($lines(YTfav.txt) < 1) .remove YTfav.txt
      }
      else noop $tip(Youtube,Youtube,Please select a video before tying to delete one from your favorites.)
    }
    elseif ($did == 3) {
      if ($exists(YTfav.txt)) {
        .remove YTfav.txt | did -r $dname 1
      }
    }
    elseif ($did == 22) {
      if ($did(21)) {
        clipboard $v1
        if ($did($dname,11)) {
          noop $tip(Youtube,Youtube,Successfully copied $qt($v1).seltext) URL.)
        }
      }
    }
    elseif ($did isnum 14-17) {
      if ($did(6)) {
        var %Sock YoutubeDialog. [ $+ [ $md5($right($ticks,4)) ] ]
        did -bh $dname $did
        sockopen %Sock www.youtube.com 80
        sockmark %Sock $replace($did(6),$chr(32),$chr(43)) $+ &page= $+ $did($dname,$did).text
      }
      else noop $tip(Youtube,Youtube,Your query was not found. $+ $crlf Please make sure you have specified it into the appropriate box.)
    }
    elseif ($did == 11) {
      if ($did($dname,19).state == 1) {
        if ($gettok($read(Youtube.txt,w,$+(*,$did($dname,11).seltext,*)),1,32)) {
          did -ra $dname 21 http://youtube.com $+ $v1
        }
        else noop $tip(Youtube,Youtube,An error has occured while trying to get $qt($did($dname,11).seltext) URL.)
      }
      else return
    }
  }
  elseif ($devent == dclick) {
    if ($did == 11) {
      if ($did(11).seltext) {
        if ($gettok($read(Youtube.txt,w,$+(*,$v1,*)),1,32)) {
          var %url http://youtube.com $+ $v1
          url -an %url
          if ($did($dname,19).state == 1) did -ra $dname 21 %url
        }
        else noop $tip(Youtube,Youtube,An error has occured while trying to open $qt($did($dname,11).seltext))
      }
    }
    elseif ($did == 1) {
      if ($did(1).seltext) {
        if ($gettok($read(YTfav.txt,w,$+(*,$v1,*)),1,32)) {
          var %url http://youtube.com $+ $v1
          url -an %url
          if ($did($dname,19).state == 1) did -ra $dname 21 %url
        }
        else noop $tip(Youtube,Youtube,An error has occrured while trying to open $qt($did($dname,1).seltext) URL.)
      }
    }
  }
  elseif ($devent == close) {
    if ($exists(Youtube.txt)) .remove Youtube.txt
    if ($exists(YTfav.txt)) && ($lines(YTfav.txt) < 1) .remove YTfav.txt
  }
}
on *:sockopen:YoutubeDialog.*:{
  if ($sockerr) {
    noop $tip(Youtube,Youtube,An error has occurred. $+ $crlf $+ Error: $sock($sockname).wsmsg $+ $crlf $+ Please try again.) 
    sockclose $sockname | return
  }
  sockwrite -nt $sockname GET $+(/results?search_query=,$sock($sockname).mark) HTTP/1.0
  sockwrite -nt $sockname Host: www.youtube.com
  sockwrite -nt $sockname $crlf
}
on *:sockread:YoutubeDialog.*:{
  if ($sockerr) {
    noop $tip(Youtube,Youtube,An error has occurred. $+ $crlf $+ Error: $sock($sockname).wsmsg $+ $crlf $+ Please try again.)
    sockclose $sockname
  }
  else {
    var %Youtube | sockread %Youtube
    if (No videos found for isin %Youtube) {
      noop $tip(Youtube,Youtube,No results were found for your query)      
      sockclose $sockname
    }
    else {
      if (*<a id="video-long-title-* iswm %Youtube) {
        write Youtube.txt $gettok(%Youtube,4,34) $gettok(%Youtube,6,34)
        did -az Youtube 11 $nohtml($gettok(%Youtube,6,34)) | did -aev Youtube 18 Results: $did(Youtube,11).lines
      }
      elseif (<span class="yt-uix-button-content">1 isin %Youtube) {
        var %sn $gettok($sock($sockname).mark,2-,38)
        if ($gettok(%sn,2,61) == 1) {
          sockread %Youtube
          if (*data-page="2">* iswm %Youtube) { did -ev Youtube 13,14 | sockread %Youtube }
          if (*data-page="3">* iswm %Youtube) { did -ev Youtube 15 | sockread %Youtube }
          if (*data-page="4">* iswm %Youtube) { did -ev Youtube 16 | sockread %Youtube }
          if (*data-page="5">* iswm %Youtube) { did -ev Youtube 17 }
        }
      }
      elseif (<div id="copyright"> isin %Youtube) {
        sockclose $sockname
      }
    }
  }
}

alias -l Youtube.Watch {
  if ($isfile(nHTMLn_2.92.dll)) {
    if ($1) {
      var %x <object width="580" height="360"><param  name="movie" value="http://www.youtube.com/v/ $+ $1 $+ &hl=en_GB $+  $&
         &fs=1&color1=0x234900&color2=0x4e9e00&border=1"></param><param  name="allowFullScreen" value="true"> $+ $&
        </param><param name="allowscriptaccess"  value="always"></param><embed src="http://www.youtube.com/v/  $+ $1 $+ &hl=en_GB& $+ $&
        fs=1&color1=0x234900&color2=0x4e9e00&border=1"  type="application/x-shockwave-flash" allowscriptaccess="always"  allowfullscreen="true" $+ $&
        width="580" height="360"></embed></object>

      write -c Youtube.html <html><body bgcolor="black"> $+  %x $+ </body></html>

      if (!$window(@Youtube)) window -aCdk0 @Youtube -1 -1 629 431
      else { noop $dll(nHTMLn_2.92.dll,detach,$window(@Youtube).hwnd) |  clear @Youtube }
      if ($dll(nHTMLn_2.92.dll,attach,$window(@Youtube).hwnd) == S_OK) {
        var %return $dll(nHTMLn_2.92.dll,navigate,$mircdirYoutube.html)
        if (%return != S_OK) noop $tip(Youtube,Youtube,Couldn't open the  video $+ $crlf $+ %return)
      }
    }
  }
  else {
    noop $tip(Youtube,Youtube,Could not find nHTMLn_2.92.dll $+ $crlf  Place it into: $mircdir)
    url -an http://www.mircscripts.org/comments.php?cid=1439
  }
}

Comments

Sign in to comment.
unforgiving   -  Sep 08, 2011

the addons need of the nHTMLn_2.92.dll, anyone scripter knows that dll, if you need it, you can download from mircscripts [dot] org [slash] /comments.php?cid=2463 , but I think that addon doesn't work anymore.

 Respond  
Stewie1k94   -  Sep 08, 2011

found it,but why does security essentials or whatever detect it as a virus?

 Respond  
Stewie1k94   -  Sep 08, 2011

how do i gett the dll?

 Respond  
Jethro   -  Mar 06, 2011

I never fancied a snippet or script that asks you to use a dll.

 Respond  
unforgiving   -  Mar 05, 2011

It is not work anymore, when click on search, nothing happens... I'm using the mirc 7.17 .

 Respond  
unforgiving   -  Jul 06, 2010

works fine! but the video window was transparent... is possible use a non transparent video window?

 Respond  
RagBot   -  Jun 28, 2010

Whenever I search something, I get a lot of blank spaces. I get the link, but I can't add a vid to favourites, or watch the video.

 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.