rss_converter_twitter.com.xsl: support the new Twitter profile page
authorAntonio Ospite <ao2@ao2.it>
Thu, 24 Apr 2014 09:58:51 +0000 (11:58 +0200)
committerAntonio Ospite <ao2@ao2.it>
Thu, 24 Apr 2014 10:11:45 +0000 (12:11 +0200)
Adjust the XPath expressions to support both the classic and the new
profile pages.

rss_converter_twitter.com.xsl

index 3184044..db78963 100644 (file)
         <xsl:value-of disable-output-escaping="yes" select="php:function('Tweeper::generate_enclosure', string(./@data-expanded-url))"/>
     </xsl:template>
 
-    <xsl:variable name="screen-name" select="//div[@class='profile-card-inner']/@data-screen-name"/>
+    <xsl:variable name="screen-name" select="//div[@class='user-actions btn-group not-following ']/@data-screen-name"/>
 
-    <xsl:template match="//div[@id='timeline']//ol[@id='stream-items-id']//li[@data-item-type='tweet']">
-        <xsl:variable name="user-name" select=".//span[@class='username js-action-profile-name']/b"/>
-        <xsl:variable name="tweet-text" select=".//p[@class='js-tweet-text tweet-text']"/>
+    <xsl:template match="//*[@data-item-type='tweet']">
+        <xsl:variable name="user-name" select=".//div[contains(@class, 'js-stream-tweet')]/@data-screen-name"/>
+        <xsl:variable name="tweet-text" select=".//p[contains(@class, 'js-tweet-text')]"/>
         <item>
             <title>
                 <xsl:value-of select="concat($user-name, ': ', $tweet-text)"/>
             </title>
             <link>
-                <xsl:value-of select="concat($twitterBaseURL, .//a[@class='details with-icn js-details']/@href)"/>
+                <xsl:value-of select="concat($twitterBaseURL, .//a[contains(@class, 'js-permalink')]/@href)"/>
             </link>
             <pubDate>
-                <xsl:value-of select="php:functionString('Tweeper::epoch_to_gmdate', .//small[@class='time']//span/@data-time)"/>
+                <xsl:variable name="timestamp" select=".//span[contains(@class, 'js-short-timestamp')]/@data-time"/>
+                <xsl:value-of select="php:functionString('Tweeper::epoch_to_gmdate', number($timestamp))"/>
             </pubDate>
             <description>
                 <xsl:value-of select="concat($user-name, ': ')"/>
@@ -82,7 +83,7 @@
                         <xsl:value-of select="//a[@class='profile-picture media-thumbnail']/@href"/>
                     </url>
                 </image>
-                <xsl:apply-templates select="//div[@id='timeline']//ol[@id='stream-items-id']//li[@data-item-type='tweet']"/>
+                <xsl:apply-templates select="//*[@data-item-type='tweet']"/>
             </channel>
         </rss>
     </xsl:template>