Resource icon

Post Content Find / Replace 1.0.0

No permission to download
Well... I was sort of successful. :)

Thanks to your collective help with the regex (I'm totally helpless with it), I've converted my old VB4 youtube tags to the following:

Code:
[media]http://www.youtube.com/watch?feature=player_embedded&v=q2Axn0xpufM[/media]

Which is exactly how it now appears in posts. As text. Tags included.

If I go into an individual post to edit it, change nothing and save, the forum successful converts the link to an embedded video. What it changes to is:

Code:
[media][media=youtube]q2Axn0xpufM[/media]

And that's fine except:

1. It places the text of
Code:
[media]
in front of the embedded video.
2. I can't exactly edit/save every single post in the forum to force the conversion.

So I think what I need is:

1. a way to strip everything in the link up to and including the "v=" as well as everything after that code. For instance, some links appear as
Code:
http://www.youtube.com/watch?v=hpxWTtq4wjk&feature=player_embedded
. So I need to eliminate everything up to an including "v=" and everything from "&" to the end of the link.

2. change
Code:
[media]
to
Code:
[media=youtube]
.

Once all that's done, do I need to rebuild the forum in some way to force the software to do the embedding?

Regardless, I throw myself at the mercy of you regex heroes. Thank you if you have a moment to help me!
 
Well if you already changed all of your tags and you just want to change ..

[media][media=youtube]q2Axn0xpufM[/media]
to
[media=youtube]q2Axn0xpufM[/media]

you can do this...

Code:
Quick Find:           [media][media=youtube]
Regular expression:   #\[media](\[media=youtube\])#siu
Replacement String:   \1

______________________________________________________________

Now if you want to change
[media]http://www.youtube.com/watch?feature=player_embedded&v=q2Axn0xpufM[/media]
to

[media=youtube]q2Axn0xpufM[/media]


Code:
Quick Find:           [media
Regular expression:   #(\[media])http:\/\/(www\.)?(youtube)\.com\/watch\?(feature=player_embedded\&)?v=([a-z0-9]+)(\[\/media])#siu
Replacement String:   [media=\3]\5\6




Once all that's done, do I need to rebuild the forum in some way to force the software to do the embedding?
If you are talking about the auto embedding no...xenforo does that automatically. See what happens is when you post a youtube link at post time (or upon editing and saving) xenforo parses that link and turns it into the media tags. All youtube links will just embed from now on when you click post reply


ok time to wake up...I need coffee let me know how that works out for you.
 
Last edited:
Thanks! That did the trick for many of the links. There were some that had trailing stuff, and those didn't carry over so well, but at this point... hey... 80% good is better than what I had! Really appreciate it.
 
Gimme some of the other examples, I would have included them in one expression had I known that the pattern was not unique.
 
Ah man, you're the best. Okay... here are the examples of some stuff as they currently appear (as text) in posts. As you can see, in each example, they deviated enough to evade capture and replacement.

Code:
[media]http://www.youtube.com/watch?feature=player_embedded&v=8GBVF8FzPI0#![/media]

Code:
[media]http://www.youtube.com/watch?v=Iuv__-nyO1M[/media]

Code:
[media]http://www.youtube.com/watch?v=hpxWTtq4wjk&feature=player_embedded[/media]

Really appreciate this.
 
Try this without saving...let me know if it get's you good results...I can't test it thoroughly without a good set of sample data like a full import so I am kind of playing it by ear or whatever saying fits here.

This one should catch everything including your original links which were already converted at this point. If you are doing this as a test...this is the expression to use in the final as it will (or is supposed to) catch everything
Code:
Quick Find:           [media=
Regular expression:   #(\[media])http:\/\/(www\.)?(youtube)\.com\/watch\?([^\-?=\&]+\=[^\-?=\&]+\&)*v\=([a-z0-9_-]+)(\&[^\-?=\&]+\=[^\-?=\[\&]+)*(\[\/media])#siu
Replacement String:   [media=\3]\5\7
 
Okay, this definitely converted a bunch more, but not all of them. For instance, this is still unconverted:

Code:
[media]http://www.youtube.com/watch?v=WNQ6_1GCVVA[/media]

I know you already know this, but you've gone way beyond the call of duty, so if you've had enough, I'm totally fine with that! I really appreciate all the attention.
 
I'm not very good with regex and I looked all over this thread for an exact example of how to remove some old AME tags but didn't see anything. Here's what I currently have and want to get rid of

[ame=[media=youtube]QrDTmOECeMw[/media] - Inner City - YouTube[/ame]


I'm wondering if i'll even be able to run this with 5 million posts or if I'll need to do some db queries :unsure:
 
Hi. Get this error when going to Tools -> Replace in Posts:
Code:
A controller for the route path post-replace/ was not found.
Is there any idea why it is happening?
 
Hi. Get this error when going to Tools -> Replace in Posts:
Code:
A controller for the route path post-replace/ was not found.
Is there any idea why it is happening?

If you go to your library folder at your site, is there a folder called PostReplace in it?
 
Thanks jake.

Another quick question...if I do a replacement for old @tagging, will that send everyone a new alert for all the old user tags?
I do not think it will, I tested it on my end and it did not but it is not a real environment and I am every user there. Assuming that what I saw in my tests repeats I would say no it won't resend all the alerts.

I have a feeling that is done at post time but you will have to wait for another answer to know for sure what's really good with that.

I'm not very good with regex and I looked all over this thread for an exact example of how to remove some old AME tags but didn't see anything. Here's what I currently have and want to get rid of

[ame=[media=youtube]QrDTmOECeMw[/media] - Inner City - YouTube[/ame]


to turn:
[ame=[media=youtube]QrDTmOECeMw[/media] - Inner City - YouTube[/ame]
into:
[media=youtube]QrDTmOECeMw[/media]
you should be able to use the following:


Code:
Quick Find:           [ame=[
Regular expression:   #\[ame=(\[media\=youtube\][^\[]+\[\/media\])[^\[]+\[\/ame\]#siu
Replacement String:   \1
 
Back
Top Bottom