SlyMarbo / rss

A Go library for fetching, parsing, and updating RSS feeds.
Other
399 stars 85 forks source link

Possible to parse other XML fields? #60

Open ghost opened 6 years ago

ghost commented 6 years ago

I would like to get the value of the field <newznab:attr name="group" value="alt.binaries.teevee"/> so ending up with the value alt.binaries.teevee.

How do I do so?

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:newznab="http://www.newznab.com/DTD/2010/feeds/attributes/" encoding="utf-8">
 <channel>
  <atom:link href="https://REMOVED.com/api" rel="self" type="application/rss+xml"/>
  <title>REMOVED</title>
  <description>API Details</description>
  <link>https://REMOVED.com/</link>
  <language>en-gb</language>
  <webMaster>hello@REMOVED.com</webMaster>
  <category>Stuff</category>
  <generator>Me</generator>
  <ttl>10</ttl>
  <docs>https://removed.com/apihelp/</docs>
  <image url="https://removed.com/themes/shared/img/logo.png" title="REMOVED" link="https://removed.com/" description="Visit REMOVED"/>
  <newznab:response offset="0" total="125000"/>
  <item>
   <title>Fair.Go.2017.09.18.HDTV.x264-FiHTV </title>
   <guid isPermaLink="true">https://REMOVED.com/details/427d2b6c5fb3a0f73bd43be4bb8cff955700fd4d</guid>
   <link>https://REMOVED.com/getnzb/427d2b6c5fb3a0f73bd43be4bb8cff955700fd4d.nzb&amp;i=1&amp;r=3bc4e94ef14337e4e2b490a3897c48f6</link>
   <comments>https://REMOVED.com/details/427d2b6c5fb3a0f73bd43be4bb8cff955700fd4d#comments</comments>
   <pubDate>Tue, 19 Sep 2017 10:18:21 +0200</pubDate>
   <category>TV &gt; SD</category>
   <description>Fair.Go.2017.09.18.HDTV.x264-FiHTV </description>
   <enclosure url="https://REMOVED.com/getnzb/427d2b6c5fb3a0f73bd43be4bb8cff955700fd4d.nzb&amp;i=1&amp;r=3bc4e94ef14337e4e2b490a3897c48f6" length="168013625" type="application/x-nzb"/>
   <newznab:attr name="category" value="5030"/>
   <newznab:attr name="size" value="168013625"/>
   <newznab:attr name="files" value="17"/>
   <newznab:attr name="poster" value="provide@4u.net (yeahsure)"/>
   <newznab:attr name="prematch" value="1"/>
   <newznab:attr name="info" value="https://REMOVED.com/api?t=info&amp;id=427d2b6c5fb3a0f73bd43be4bb8cff955700fd4d&amp;r=3bc4e94ef14337e4e2b490a3897c48f6"/>
   <newznab:attr name="grabs" value="0"/>
   <newznab:attr name="comments" value="0"/>
   <newznab:attr name="password" value="0"/>
   <newznab:attr name="usenetdate" value="Tue, 19 Sep 2017 10:07:47 +0200"/>
   <newznab:attr name="group" value="alt.binaries.teevee"/>
  </item>
</channel>
</rss>
SlyMarbo commented 6 years ago

I'm afraid I can't think of anything other than forking the package or parsing the data twice; once with this package, once with package "encoding/XML".

ghost commented 6 years ago

Damn. Can I use something like this:

for _, value := range feed.Items {}

And then use value (which should contain the whole <item></item>?) to further parse with encoding/xml?

SlyMarbo commented 6 years ago

Possibly, but I don't have easy access to the docs at the moment. I'll check later 🙂