0

Today I found that my site (WordPress-based) has some mistakes in YouTube urls, like "https://www.youtube.com/embed/VIDEO_ID&autoplay=1". The autoplay should be preceded by ?, so it's returning error.

How can I use mysql to correct it? I know that I can use something like:

UPDATE wp_posts SET post_content = 
replace(post_content, '/embed/VIDEO_ID&autoplay', '/embed/VIDEO_ID?autoplay' ) ;

But how to deal with the VIDEO_ID?

Daniel Lemes
  • 279
  • 4
  • 21
  • just replacing '&autoplay' with '?autoplay' ? – Rostol Mar 07 '17 at 01:46
  • No, there are other urls with different params, like ".../embed/ID?rel=0&autoplay" and in this case is ok. – Daniel Lemes Mar 07 '17 at 01:51
  • yes, i see. I think Regex are your only hope. in the most extreme case you could rebuild all the links, getting the id with this http://stackoverflow.com/questions/6903823/regex-for-youtube-id and then rebuild the rest of the url around it. – Rostol Mar 07 '17 at 05:11

0 Answers0