This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Embed Youtube Links to a HTML File

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
B
BigToe
Halfop
Posts: 99
Joined: Thu Dec 30, 2010 4:49 pm

Embed Youtube Links to a HTML File

Post by BigToe »

Well my idea is this:

Lets say someone posts a youtube url, for example: http://www.youtube.com/watch?v=lKpMePk- ... ure=g-vrec

The script will fetch the embed code for that link and write to a .html file

Let me show you what I mean, if you go to http://www.youtube.com/watch?v=lKpMePk- ... ure=g-vrec
and click on 'Share' you can click on a 'Embed' button that will write you the code I need to write to a html file so it will embed the link.

I want to embed youtube videos posted in the channel to a .html file
d
doggo
Halfop
Posts: 97
Joined: Tue Jan 05, 2010 7:53 am
Contact:

Post by doggo »

give this a go

result can be seen http://omgwtfnzbs.com/youtube.html
has a "dupe checker" so should only save the link to the video once :D

Code: Select all

# 16/06/2012 
# by doggo #omgwtfnzbs @ EFNET 
# youtube_html.tcl 
#########################################################


bind pubm -|- "% *http://*youtube*" youtube_html

#file must exist or you will get an error!
set fname "/var/www/youtube.html"

proc youtube_html {nick userhost handle channel args} {
global fname

#edit at own risk!
if {[regexp -nocase -- {http://.*youtube.com/watch\?(.*)v=([A-Za-z0-9_\-]+)} $args match fluff video_id]} {

       #check if its allready in the file
       set file [open $fname r] 
       set data [read $file] 
       close $file 
       foreach line [split $data \n] { 
           if { [string match -nocase "*$video_id*" "$line"] == 1 } { 
               catch {unset data} 
              #stops the video being added again
               putlog "youtube link exists.";return
           } 
       } 

	#not in the file? then we will add it
	set tformat "%a, %d %b %Y @ %r" 
	set date [clock format [clock seconds] -format $tformat]

	set fp [open $fname "a"]
	set line_to_add "<center><strong>$nick $channel $date</strong><br /><iframe class=\"youtube-player\" width=\"1000\" height=\"500\" src=\"http://www.youtube.com/v/$video_id\" frameborder=\"0\" allowfullscreen></iframe></center><br /><br />" 
	puts $fp $line_to_add 
	close $fp

   } 
}
B
BigToe
Halfop
Posts: 99
Joined: Thu Dec 30, 2010 4:49 pm

Post by BigToe »

Hey doggo,

Thanks for the script. great stuff!

Any chance for something similiar, embeding images like .jpg & .bmp please?
d
doggo
Halfop
Posts: 97
Joined: Tue Jan 05, 2010 7:53 am
Contact:

Post by doggo »

http://forum.egghelp.org/viewtopic.php?t=18765

quick forum search returned this.. sounds like what your after
Post Reply