python parse Медиа RSS (MRSS) - PullRequest
       58

python parse Медиа RSS (MRSS)

0 голосов
/ 15 октября 2018

Я ищу пакет или функцию, которая может читать файл MRSS (медиа RSS) и добавлять в него новые записи.

Я пытался использовать xml.etree.ElementTree для чтения файла MRSS, но когдаон читает файл и сохраняет его, изменив элемент media:<...> на ns0:<...>

. Вот файл, который я пытаюсь прочитать:

<?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>

и вот он после этого:

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

выходные данные:

<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 ...

выглядят все медиа как измененные на ns0

Я использую Python 3.6 кто-нибудь знает, как это исправить?или посоветуете другой пакет?

...