Author |
Topic  |
|
MarcelG
Retired Support Moderator
    
Netherlands
2625 Posts |
Posted - 07 May 2007 : 16:06:27
|
In the past year I've added a lot of forumcode to my site, for embedding different types of media, such as YouTube, Metacafe, GoogleVideo, DailyMotion and so on.
All these sites offer a simple copy/paste field to embed the media on another page. That code is plain HTML, which is not allowed on oxle (as on the majority of forums)
However, I was thinking: is there a way that when a user simply posts that HTML, the forum automatically converts it to 'legal' forumcode once posted?
So, for instance:
<div><object width="520" height="406"><param name="movie" value="http://www.dailymotion.com/swf/2ZXGrbXost8RBdrju"></param><param name="allowfullscreen" value="true"></param><embed src="http://www.dailymotion.com/swf/2ZXGrbXost8RBdrju" type="application/x-shockwave-flash" width="520" height="406" allowfullscreen="true"></embed></object><br /><b><a href="http://www.dailymotion.com/video/x1wnng_drunk-david-hasselhoff-eats-a-burge">Drunk David Hasselhoff eats a burger</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/ker1905">ker1905</a></i></div>
becomes
[dm]http://www.dailymotion.com/swf/2ZXGrbXost8RBdrju[/dm]
after posting.
In this case, the red parts are discarded, and replaced by [dm] and [/dm].
For YouTube this works similar, but the HTML is differently constructed. Is this doable with regular expressions or VBScript text manipulation functions, or am I trying something that's simply not going to work? |
portfolio - linkshrinker - oxle - twitter |
Edited by - MarcelG on 07 May 2007 16:08:06 |
|
ILLHILL
Junior Member
 
Netherlands
341 Posts |
Posted - 07 May 2007 : 16:51:23
|
Hmmmm.... very very hmmmm
Let's see. As a start you could use Islike to determine which media/source is used. I played around with something where the Islike would determine if something was an YouTube link and if so, load the object and settings then use the link used into these loaded settings, but that would mean visitors have to filter out the link out of the html code, which is exactly what you don't want.
Hmmm...you could theoretically use Islike to determine which type it is, then use a bunch of replace to possibly get it to what you want it to be. But, it might be better to see if there's a javascript way to do it.
Nice problem, cracks my brain a little. I'm working on a project that prevents me from really looking into this deeper, for this week, but if next week nobody has come with something I can look into it, although I must admit, if I get it to work, it will probably be in a way that is more difficult than it should be while there might be an easier alternative.
Greets, Dominic |
CLPPR.com - All The News Only Seconds Away |
 |
|
PPSSWeb
Junior Member
 
312 Posts |
Posted - 08 May 2007 : 10:29:09
|
This may be way to simplistic, but couldn't you just add to the chkString function in inc_common.asp using Instr to check for the source url before letting doCode convert it for you?
Something like:
if Instr("src="http://www.dailymotion.com/", fstring) then
fString = doCode(fString, "[dm]", "[/dm]", "all stuff before source url", "all stuff before source")
|
 |
|
Jezmeister
Senior Member
   
United Kingdom
1141 Posts |
Posted - 08 May 2007 : 12:12:26
|
"all stuff before source" and "all stuff after source" are variable - they'd have to be identical every time for that to work. if like illhill said you use islike to extract the type you may be in better stead... one way to do it would be to determine parts of each code that are always the same, for example you could trim off the first x characters from the start (assuming you can isolate the code) to give you the the url at the start, this is probably wishful thinking but if all the identifying strings are the same then the urls are all the same length so you can again trim to isolate the relevant code, leaving you with the job of removing the rest of the useless code of course... hmm
oo stroke of genius (inspired by whoever was asking about regexp in another topic... i've used strtextbox cos i've forgotten what the string for the message text really is ):
While that might get you the code outputted correctly - you've still got the issue of removing all the crap... hmm might be a start... |
 |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
Posted - 08 May 2007 : 12:26:42
|
This is definitely doable using regular expressions, both to identify the media type and to replace the HTML, but you do need to know how to identify each type. If the HTML is similar for each type, shouldn't be too difficult. |
Snitz 3.4 Readme | Like the support? Support Snitz too |
 |
|
Jezmeister
Senior Member
   
United Kingdom
1141 Posts |
Posted - 08 May 2007 : 13:24:35
|
hmm i suppose if you reinsert the result of strFCode afterwards you could use regexp to find and delete everything between the div tags? |
 |
|
MarcelG
Retired Support Moderator
    
Netherlands
2625 Posts |
|
Jezmeister
Senior Member
   
United Kingdom
1141 Posts |
Posted - 08 May 2007 : 14:18:37
|
Not me but I'll give it a whirl, then hopefully someone'll come and correct me lol
Now hopefully only the url + the forum code remains |
Edited by - Jezmeister on 08 May 2007 14:21:26 |
 |
|
MarcelG
Retired Support Moderator
    
Netherlands
2625 Posts |
Posted - 01 July 2007 : 15:53:20
|
FYI : I've managed to get it working. Well, not like I intended, but the funcionality is working as I want it to ; people can now post the embeddable player code, and only need to put the '[video][/video]' tag around it to have it interpreted as a Video player thing. Demo: http://oxle.com/topic.asp?tid=4760
Once finished I'll release it as a mod. |
portfolio - linkshrinker - oxle - twitter |
 |
|
AnonJr
Moderator
    
United States
5768 Posts |
Posted - 01 July 2007 : 16:23:45
|
Sweet. I've been meaning to get the other code for embedding all the multimedia formats added to a couple of my forums, but now that this is on its way, I may just wait a little longer.  |
 |
|
|
Topic  |
|