| View previous topic :: View next topic |
| Author |
Message |
BigToe Halfop
Joined: 30 Dec 2010 Posts: 99
|
Posted: Sat Jun 09, 2012 2:48 pm Post subject: Embed Youtube Links to a HTML File |
|
|
Well my idea is this:
Lets say someone posts a youtube url, for example: http://www.youtube.com/watch?v=lKpMePk-fHg&feature=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-fHg&feature=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 |
|
| Back to top |
|
 |
doggo Halfop
Joined: 05 Jan 2010 Posts: 97
|
Posted: Sat Jun 16, 2012 9:26 am Post subject: |
|
|
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
| Code: |
# 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
}
}
|
_________________ NON geeky!! http://gotcode4u.com/ |
|
| Back to top |
|
 |
BigToe Halfop
Joined: 30 Dec 2010 Posts: 99
|
Posted: Sat Jun 16, 2012 11:15 am Post subject: |
|
|
Hey doggo,
Thanks for the script. great stuff!
Any chance for something similiar, embeding images like .jpg & .bmp please? |
|
| Back to top |
|
 |
doggo Halfop
Joined: 05 Jan 2010 Posts: 97
|
|
| Back to top |
|
 |
|