Last active
February 5, 2019 12:45
-
-
Save bryanrasmussen/19fd79e3e86f3601193b23c6794b7373 to your computer and use it in GitHub Desktop.
An XSLT to output command line calls for curl to download photos from your tumblr blogs. because I tried a few libraries to do the same thing that failed abysmally.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<!-- how to output depends on your processor, I used saxon Transform.exe tumblrimages.xml -xsl tumblr2curl.xsl -o output2.txt | |
then I copied pasted output2.txt into the my shell. Could have written something to parse the format etc. and download at the same time | |
but seemed overkill considering I would probably never use again. | |
--> | |
<xsl:output method="text"/> | |
<xsl:template match="post"> | |
<xsl:apply-templates select="photoset"/> | |
</xsl:template> | |
<xsl:template match="photoset"> | |
<xsl:apply-templates select="photo" /> | |
</xsl:template> | |
<xsl:template match="photo"> | |
<!--this part of course only outputs the biggest image--> | |
<xsl:variable name="photo" select="photo-url[1]"/> | |
<xsl:text>./curl.exe --output </xsl:text><xsl:value-of select="ancestor::post/@slug"/>_<xsl:value-of select="@offset"/><xsl:value-of select="substring($photo, string-length($photo) - 3, 4)" /><xsl:text> </xsl:text><xsl:value-of select="$photo"/><xsl:text>
</xsl:text> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment