python parse Media RSS (MRSS)

438 views Asked by At

I'm looking for a package or a function that can read MRSS (media RSS) file and add new entries to it.

I tried using xml.etree.ElementTree in order to read the MRSS file but when it read the file and save it the change the media:<...> element to be ns0:<...>

here is the file im trying to read:

<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
   <channel>
      <title>ReelSEO Video News</title>
      <link>https://tubularinsights.com/examples/mrss/</link>
      <description>The ReelSEO Video News Archive</description>
      <item>
         <title>MRRS Example Video</title>
         <link>https://tubularinsights.com/examples/mrss/example.html</link>
         <description>The example landing page for this MRSS item</description>
         <guid isPermaLink="false">https://tubularinsights.com/examples/mrss/example.html</guid>
         <media:content url="https://tubularinsights.com/examples/mrss /example.avi" fileSize="405321" type="video/x-msvideo" height="240" width="320" duration="120" medium="video" isDefault="true">
            <media:title>The ReelSEO MRSS example video</media:title>
            <media:description>Check out the 120 seconds of fast-paced MRSS fun with ReelSEO.</media:description>
            <media:thumbnail url="https://tubularinsights.com/examples/mrss/example.png" height="120" width="160" />
         </media:content>
      </item>
   </channel>
</rss>

and here it is after doing this:

tree = ET.parse('rss.xml')
root = tree.getroot()
tree.write("rss3.xml")

the output:

<rss xmlns:ns0="http://search.yahoo.com/mrss/" version="2.0">
   <channel>
      <title>ReelSEO Video News</title>
      <link>https://tubularinsights.com/examples/mrss/</link>
      <description>The ReelSEO Video News Archive</description>
      <item>
         <title>MRRS Example Video</title>
         <link>https://tubularinsights.com/examples/mrss/example.html</link>
         <description>The example landing page for this MRSS item</description>
         <guid isPermaLink="false">https://tubularinsights.com/examples/mrss/example.html</guid>
         <ns0:content duration="120" fileSize="405321" height="240" isDefault="true" medium="video" type="video/x-msvideo" url="https://tubularinsights.com/examples/mrss /example.avi" width="320">
            <ns0:title>The ReelSEO MRSS example video</ns0:title>
            <ns0:description>Check out the 120 seconds of fast-paced MRSS fun with ReelSEO.</ns0:description>
            <ns0:thumbnail height="120" url="https://tubularinsights.com/examples/mrss/example.png" width="160" />
         </ns0:content>
      </item>
   <item><guid isPermaLink="false">9030c790cf3911e893a29cb6d0d6506a</guid><title>Student Invents Phone Charger Powered by Spinning</title><description>Mikhail Vaga, a 19-year-old student from Minsk, invented the gyroscope powerbank which transforms human kinetic energy into electricity which can charge gadgets. Vaga set up a crowdfunding campaign on Kickstarter to receive backing for his innovative idea, and his project raised over $50,000 in two weeks. Top backers already received the powerbanks from the first production run for $79 apiece, and Vaga is now preparing for mass-production.</description><pubDate>Mon Oct 15 15:11:03 2018</pubDate><category /><enclosure ...

look all the media as changed to ns0

Im using Python 3.6 anyone knows how to fix it? or recommend on a different package?

0

There are 0 answers