I'm trying to do a simple task of altering thousands of music video embed codes with a common with/height.
For example, I have the following code:
<object width="480px" height="407px" >
<param name="allowFullScreen" value="true"/>
<param name="wmode" value="transparent"/>
<param name="movie" value="http://mediaservices.myspace.com/services/media/embed.aspx/m=1311720,t=1,mt=video"/>
<embed src="http://mediaservices.myspace.com/services/media/embed.aspx/m=1311720,t=1,mt=video"
width="480" height="407" allowFullScreen="true"
type="application/x-shockwave-flash"
wmode="transparent">
</embed>
</object>
Line breaks added only for legibility
I need to edit the width/height parameters in both the <object>
and <embed>
tags, one having a 'px' suffix, and the other not having one at all (which is totally random, some codes have it in all cases, others do not).
Firstly, I'm trying to find out the width/height of the existing video.... finding the aspect ratio... and then replacing the existing values with the new values (width = "640" and height="xxx" which is based on the aspect ratio of the video).