egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Embed Youtube Links to a HTML File

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
BigToe
Halfop


Joined: 30 Dec 2010
Posts: 99

PostPosted: Sat Jun 09, 2012 2:48 pm    Post subject: Embed Youtube Links to a HTML File Reply with quote

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
View user's profile Send private message
doggo
Halfop


Joined: 05 Jan 2010
Posts: 97

PostPosted: Sat Jun 16, 2012 9:26 am    Post subject: Reply with quote

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 Very Happy

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
View user's profile Send private message Visit poster's website
BigToe
Halfop


Joined: 30 Dec 2010
Posts: 99

PostPosted: Sat Jun 16, 2012 11:15 am    Post subject: Reply with quote

Hey doggo,

Thanks for the script. great stuff!

Any chance for something similiar, embeding images like .jpg & .bmp please?
Back to top
View user's profile Send private message
doggo
Halfop


Joined: 05 Jan 2010
Posts: 97

PostPosted: Sat Jun 16, 2012 11:45 am    Post subject: Reply with quote

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

quick forum search returned this.. sounds like what your after
_________________
NON geeky!! http://gotcode4u.com/
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber