rss_converter_twitter.com.xsl: restrict tweet matching
authorAntonio Ospite <ao2@ao2.it>
Tue, 5 May 2015 07:25:20 +0000 (09:25 +0200)
committerAntonio Ospite <ao2@ao2.it>
Tue, 5 May 2015 07:25:20 +0000 (09:25 +0200)
With new style retweets the quoted text is also matched by
[@data-item-type='tweet'] but then the content is not handled, resulting
in empty items in the RSS feed.

Checking also for @role='listitem' allows to pick up only top-level
tweets.

rss_converter_twitter.com.xsl

index 665b71d..9efc769 100644 (file)
@@ -38,7 +38,7 @@
 
     <xsl:variable name="screen-name" select="//div[@class='user-actions btn-group not-following ']/@data-screen-name"/>
 
-    <xsl:template match="//*[@data-item-type='tweet']">
+    <xsl:template match="//*[@data-item-type='tweet' and @role='listitem']">
         <xsl:variable name="user-name" select=".//div[contains(@class, 'js-stream-tweet')]/@data-screen-name"/>
         <xsl:variable name="item-content" select=".//p[contains(@class, 'js-tweet-text')]"/>
         <xsl:variable name="item-permalink" select="concat($BaseURL, .//a[contains(@class, 'js-permalink')]/@href)"/>
@@ -96,7 +96,7 @@
                         <xsl:value-of select="//a[contains(@class, 'profile-picture media-thumbnail')]/@href"/>
                     </url>
                 </image>
-                <xsl:apply-templates select="//*[@data-item-type='tweet']"/>
+                <xsl:apply-templates select="//*[@data-item-type='tweet' and @role='listitem']"/>
             </channel>
         </rss>
     </xsl:template>