<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/18769" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2011-12-31T09:19:56-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/18769</id>

		<entry>
		<author><name><![CDATA[Football]]></name></author>
		<updated>2011-12-31T09:19:56-04:00</updated>

		<published>2011-12-31T09:19:56-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=98442#p98442</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=98442#p98442"/>
		<title type="html"><![CDATA[Youtube embed to HTML]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=98442#p98442"><![CDATA[
Hey, looking for a script that will embed YouTube links posted in a channel and add them to a .html file, something similiar to the follow script, but instead of pics, youtube videos.<br><div class="codebox"><p>Code: </p><pre><code>set piccheck(version) "0.1"set filePath /home/xabriel/eggdrop/images-epl.htmlbind pub - !plast urlshowproc urlshow {nick ushost hand chan text} {global filePath    set file [open $filePath r]    set data [read $file]    close $file    putlog [llength [split $data \n]]    set plast [string map {&lt;br&gt; "" &lt;b&gt; "\002" &lt;/b&gt; "\002" "&lt;img src=\"" "\00312\037" "\"&gt;" "\037"} [lindex [split $data \n] [expr [llength [split $data \n]]-2]]]    putserv "PRIVMSG $chan :Last picture: $plast"}bind pubm - * urlchecksetudef flag piccheckproc urlcheck { nick uhost hand chan str } {global piccheckset urlcheck(ext) {       jpg       jpe       jpeg       gif       pngbmp}if {![regexp {((?:http://|www\.)+[^ ]+)} $str str]} { return 0 }set extension ""       set wlink $str       regsub -all -- {(http://)+} $str "" str       regexp {(www.)?[A-z|0-9|\-|\.|\_]*\.[A-z]{2,3}} $str host       regexp {[/]+(.)*} $str url       regexp {[A-z]{3,4}$} $str extension       set ispic 0       foreach i $urlcheck(ext) {               if {[string match -nocase $extension $i]} {                       set ispic 1               }       }       if {$ispic != 1} { return 0 }       set linecheck "[getdata $host $url $chan]"       putlog "-- $linecheck"       set ispic 0       if {[string match -nocase *error* $linecheck]} { putserv "PRIVMSG $chan :\002Error:\002 $linecheck. \002Not a picture.\002"; set ispic 1 }       if {[string match -nocase "*&lt;html&gt;*" $linecheck]} { putserv "PRIVMSG $chan :\002Error:\002 $linecheck. \002Not a picture.\002"; set ispic 1 }       #putlog $linecheck       global filePath       set file [open $filePath r]       set data [read $file]       close $file       set already 0;       foreach line [split $data \n] {           if { [string match -nocase "*$wlink*" "$line"] == 1 } {               catch {unset data}               set already 1               putserv "PRIVMSG $chan :\002$nick\002, your link already exists."           }       }       if { $ispic == 0 &amp;&amp; $already == 0 } {              if {[catch {set file [open $filePath "a"]} err]} {putserv "PRIVMSG $chan :Error opening file: $err"}set systemTime [clock seconds]              if {[catch {puts $file "&lt;br&gt;&lt;b&gt;Added by $nick at [clock format $systemTime -format {%A, the %d of %B, %Y}]&lt;b&gt;&lt;br&gt; \&lt;img src=\"$wlink\"\&gt;&lt;br&gt;"} err]} {                        putserv "PRIVMSG $chan :Error appending file: $err"                }              close $file       }}proc getdata { host url chan } {global sock               if {[string match "*error*" [open_socket $host $url $chan]]} { return "error"}               gets $sock line               if {[string match -nocase "*HTTP/1.? 301 Moved*" $line]} {                       while {![eof $sock]} {                               gets $sock line                               if {[string match -nocase "*Location*" $line]} {                                       set url [lindex [split $line] 1]                                       regsub -all -- {(http://)+} $url "" url                                       regexp {[/]+(.)*} $url url                                       close $sock                                       open_socket $host $url $chan                                       gets $sock line                                       break                               }                       }               }               if {![string match "HTTP/1.? 200 OK" $line]} { close $sock;return "error($line)" }               set msg ""               while {(![eof $sock]) &amp;&amp; ([string length $line] != 0)} {                       gets $sock line                       if {[string match -nocase *server* $line]} {regsub -all -- "Server" $line "\002Server\002" line; append msg $line }                       if {[string match -nocase *date* $line]} {regsub -all -- "Date" $line "\002Date\002" line; append msg ", " $line }                       if {[string match -nocase *content*type* $line]} {                           if {![string match -nocase "*image/*" "$line"]} {                           close $sock                           return error                           }                       regsub -all -- "Content-Type" $line "\002Content-Type\002" line; append msg ", " $line                       }                       if {[string match -nocase *content*length* $line]} {regsub -all -- "Content-Length" $line "\002Content-Length\002" line; append msg ", " $line }                       if {[string match -nocase *connection* $line]} {regsub -all -- "Connection" $line "\002Connection\002" line; append msg ", " $line }                       if {[string match -nocase *keep*alive* $line]} {regsub -all -- "Keep-Alive" $line "\002Keep-Alive\002" line; append msg ", " $line }                       if {[string match -nocase *expires* $line]} {regsub -all -- "Expires" $line "\002Expires\002" line; append msg ", " $line }                       if {[string match -nocase *cache*control* $line]} {regsub -all -- "Cache-Control" $line "\002Cache-Control\002" line; append msg ", " $line }                       if {[string match -nocase *accept*ranges* $line]} {regsub -all -- "Accept-Ranges" $line "\002Accept-Ranges\002" line; append msg ", " $line }               }               gets $sock line               close $sock#putserv "PRIVMSG $chan :[string trim [join [append msg "."]] ", "]"return $line}proc open_socket { host url chan } {global sock#putlog "Host: $host - url : $url"       if {[catch {set sock [socket [string map -nocase {www. ""} $host] 80] } sockerror]} {               putserv "PRIVMSG $chan: \002Error:\002 $sockerror"               return "error: $sockerror"       } else {               puts $sock "GET $url HTTP/1.1"               puts $sock "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"               puts $sock "Accept :*/*"               puts $sock "Host: $host"               puts $sock ""               flush $sock       }}putlog "Drilly's Picture-URL-Saver $piccheck(version) loaded..."</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10393">Football</a> — Sat Dec 31, 2011 9:19 am</p><hr />
]]></content>
	</entry>
	</feed>
