1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Removing vBulletin bbcodes after importing database

Discussion in 'Installation, Upgrade, and Import Support' started by asterix23, May 28, 2013.

  1. asterix23

    asterix23 Member

    Hi

    Just switch from vBulletin, I have now a lot of tags like this
    [youtube=425,350]string[/youtube]
    [YOUTUBE=string]string[/youtube]

    How to replace this with
    HTML:
    [media=youtube]\1[/media]
    ?

    I did a try with Post Content Find / Replace, but did not work for me.
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Use Kier's addon:

    http://xenforo.com/community/threads/post-content-find-replace.6548/

    Quick Find: [youtube

    Regular Expression: #\[youtube=([^\]]+)\]([^\[]+)\[/youtube\]#siU

    Replacement String: [media=youtube]\2[/media]

    I assume the middle string is the video id, but I can't be sure about this replacement unless you give me an actual code example.
     
  3. asterix23

    asterix23 Member

    I get this error
    Please enter a message with no more than 5 pieces of media
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You will need to increase this and try again:

    Admin CP -> Home -> Options -> Messages -> Maximum Media Embeds per Message
     
    asterix23 likes this.
  5. asterix23

    asterix23 Member

    thanks work great
     
  6. StonePilot

    StonePilot Member

    I've got a different set of code to change, I don't understand how it works, anyone help>?

    Code:
    [video=youtube;vPW6k3GWeUs]http://www.youtube.com/watch?v=vPW6k3GWeUs[/video]
     
  7. StonePilot

    StonePilot Member

    Anyone?
     
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  9. Superfluous

    Superfluous Member

    Anyone have any idea what I'm doing wrong? I'm getting a "Please enter a valid message." error when trying to replace Youtube videos as advised in the description. I'm assuming it's trying to insert a blank message somewhere, but I don't know why I'd be replacing the video with a blank message.

    [​IMG]

    [​IMG]
     
    Last edited: Dec 27, 2014
  10. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    That error usually indicates an empty post, but that shouldn't happen with your replacement.

    Try submitting that replacement without "Save Changes" to preview what the result is.
     
  11. Superfluous

    Superfluous Member

    Yeah it works fine without save changes - gives me 19,000+ results - and I've painfully waded down them to see if there were any empty ones, and there's none that I can see. I tried staggering the calls with your script modification with no luck as well.
     
  12. Superfluous

    Superfluous Member

    Sorry to be a torture Jake, but do you have to hand the 'direct to database' SQL queries/regular expressions to do the same thing? (I'll do a trial run on a test site - at least it will return specific errors) I'm sure I seen you post them somewhere here before but I can't find them now. I've got a newly converted 7 million post forum with 20k of unparsed Youtube videos, and since the natives didn't want 'change' in the first place I need to placate them with fixes :whistle:
     
  13. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    MySQL has no regex replace to my knowledge. It requires a user defined function.

    That replacement tool doesn't handle large numbers of posts very well. This might help:

    https://xenforo.com/community/threads/import-from-ipb-3-2-posts-not-parsed-at-all.39577/#post-435226

    Otherwise I wrote a custom script to do replacements on extremely large forums. But using it safely and effectively requires working with the code. I can use this script on your forum but I would insist on running it myself. If you want me to do this then send me a PM with FTP access and links to posts that need fixing.
     
    Superfluous likes this.
  14. balkanminion

    balkanminion Member

  15. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Can you post the raw unparsed code in the post? Use the [plain][/plain] tag here on this forum to post unparsed BB code.
     
    balkanminion likes this.
  16. balkanminion

    balkanminion Member

    [media]http://youtu.be/MOWDb2TBYDg[/media]
     
  17. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Use Kier's addon:

    https://xenforo.com/community/resources/post-content-find-replace.1549/

    Quick Find: [media]

    Regular Expression: #\[media\]http://youtu\.be/([A-Za-z0-9_\-]+)\[/media\]#siU

    Replacement String: [media=youtube]\1[/media]

    This works on my test forum.

    Youtube URLs come in a few varieties so if you find different URL formats you will need to adjust the Regular Expression accordingly.
     
  18. balkanminion

    balkanminion Member

  19. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Yep, that one is slightly different:

    Quick Find: [media]

    Regular Expression: #\[media\]https://www\.youtube\.com/watch\?v=([A-Za-z0-9_\-]+)\[/media\]#siU

    Replacement String: [media=youtube]\1[/media]
     
    balkanminion likes this.
  20. balkanminion

    balkanminion Member

    Thanks it works, but i am getting an PHP Timeout Error.
     

Share This Page