rss_converter_instagram.com.xsl: update to new json format
authorAntonio Ospite <ao2@ao2.it>
Fri, 12 Jun 2015 10:06:02 +0000 (12:06 +0200)
committerAntonio Ospite <ao2@ao2.it>
Fri, 12 Jun 2015 10:06:02 +0000 (12:06 +0200)
The new Instagram homepage provides json data in a format different than
before, update the xsl to support it.

Unfortunately the data in the new format does not provide the
descriptions of the items, so use some placeholder values (URL, comments
count, likes count) to present at least something.

rss_converter_instagram.com.xsl

index f42ca8b..d9dfcdd 100644 (file)
         <xsl:value-of disable-output-escaping="yes" select="php:function('Tweeper::generate_enclosure', string(./standard_resolution/url))"/>
     </xsl:template>
 
         <xsl:value-of disable-output-escaping="yes" select="php:function('Tweeper::generate_enclosure', string(./standard_resolution/url))"/>
     </xsl:template>
 
-    <xsl:variable name="screen-name" select="//UserProfile/XML_Serializer_Tag/user/full_name"/>
-    <xsl:variable name="user-name" select="//UserProfile/XML_Serializer_Tag/user/username"/>
+    <xsl:variable name="screen-name" select="//ProfilePage/XML_Serializer_Tag/user/full_name"/>
+    <xsl:variable name="user-name" select="//ProfilePage/XML_Serializer_Tag/user/username"/>
 
 
-    <xsl:template match="//userMedia/XML_Serializer_Tag">
-        <xsl:variable name="item-content-title" select="./caption/text"/>
-        <xsl:variable name="item-content-src" select="./images/standard_resolution/url"/>
-        <xsl:variable name="item-permalink" select="./link"/>
+    <xsl:template match="//media/nodes/XML_Serializer_Tag">
+        <xsl:variable name="item-content-src" select="./display_src"/>
+        <xsl:variable name="item-permalink" select="concat($BaseURL, '/p/', ./code, '/')"/>
+        <xsl:variable name="item-content-title" select="concat($user-name, ': ', $item-permalink, ', comments: ', ./comments/count, ', likes: ', ./likes/count)"/>
         <item>
             <title>
         <item>
             <title>
-                <xsl:value-of select="concat($user-name, ': ', $item-content-title)"/>
+                <xsl:value-of select="$item-content-title"/>
             </title>
             <link>
                 <xsl:value-of select="$item-permalink"/>
             </title>
             <link>
                 <xsl:value-of select="$item-permalink"/>
                 <xsl:value-of select="$item-permalink"/>
             </guid>
             <pubDate>
                 <xsl:value-of select="$item-permalink"/>
             </guid>
             <pubDate>
-                <xsl:variable name="timestamp" select="./created_time"/>
+                <xsl:variable name="timestamp" select="./date"/>
                 <xsl:value-of select="php:functionString('Tweeper::epoch_to_gmdate', number($timestamp))"/>
             </pubDate>
             <description>
                 <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
                 <p><xsl:value-of select="$item-content-title"/></p><br />
                 <xsl:value-of select="php:functionString('Tweeper::epoch_to_gmdate', number($timestamp))"/>
             </pubDate>
             <description>
                 <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
                 <p><xsl:value-of select="$item-content-title"/></p><br />
-                <img src="{$item-content-src}" title="{$item-content-title}" />
+                <a href="{$item-permalink}"><img src="{$item-content-src}" /></a>
                 <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
             </description>
             <xsl:if test="$generateEnclosure = 1">
                 <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
             </description>
             <xsl:if test="$generateEnclosure = 1">
@@ -71,7 +71,7 @@
 
     <xsl:template match="/">
         <xsl:variable name="channel-title" select="concat('Instagram / ', $screen-name)"/>
 
     <xsl:template match="/">
         <xsl:variable name="channel-title" select="concat('Instagram / ', $screen-name)"/>
-        <xsl:variable name="channel-link" select="concat($BaseURL, //user/__path)"/>
+        <xsl:variable name="channel-link" select="concat($BaseURL, //__path)"/>
 
         <rss version="2.0">
             <xsl:attribute name="xml:base"><xsl:value-of select="$BaseURL" /></xsl:attribute>
 
         <rss version="2.0">
             <xsl:attribute name="xml:base"><xsl:value-of select="$BaseURL" /></xsl:attribute>
@@ -84,7 +84,7 @@
                     <xsl:value-of select="$channel-link"/>
                 </link>
                 <description>
                     <xsl:value-of select="$channel-link"/>
                 </link>
                 <description>
-                    <xsl:value-of select="//user/bio"/>
+                    <xsl:value-of select="//user/biography"/>
                 </description>
                 <image>
                     <title>
                 </description>
                 <image>
                     <title>
                         <xsl:value-of select="$channel-link"/>
                     </link>
                     <url>
                         <xsl:value-of select="$channel-link"/>
                     </link>
                     <url>
-                        <xsl:value-of select="//user/profile_picture"/>
+                        <xsl:value-of select="//user/profile_pic_url"/>
                     </url>
                 </image>
                     </url>
                 </image>
-                <xsl:apply-templates select="//userMedia/XML_Serializer_Tag"/>
+                <xsl:apply-templates select="//media/nodes/XML_Serializer_Tag"/>
             </channel>
         </rss>
     </xsl:template>
             </channel>
         </rss>
     </xsl:template>