tumblr-upload
Upload your Tumblr theme via node or CLI
Until now the only way to upload your custom theme to Tumblr was through their website, manually, by copying and pasting it into a form.
tumblr-upload
lets you upload your theme via command line or in a node application (like gulp
) using your Tumblr cookies as credentials.
Table of Contents
Install
$ npm install --save tumblr-upload
Setup
tumblr-upload
simulates the press of the Save button in their backend, so it needs your own valid and current cookies. The cookie recovery process only takes a minute and it has to be done just once (per blog).
Getting your credentials
Cookies will be invalidated on logout, so it's suggested to do the following in an incognito window and to close it afterwards without logging out. Chrome was used for these steps:
- Go to edit your Tumblr theme
- Log into Tumblr
- Select your blog
- Open Customize
- Open Edit HTML >
- Save your theme with your developer tools open
- Type anything to enable the Update preview button
- Press the Update preview button
- Open your browser developer tools
- Open the Network tab and enable it if necessary
- Press the Save button on the site
- You should see a POST request in the Network tab, select it
- Scroll to the bottom and copy the values of
id
anduser_form_key
- Visit the Cookies tab
- Copy the values of the cookies
anon_id
,pfe
,pfp
,pfs
, andpfu
Using your credentials
You can specify these values in node, via command line, or in the tumblr-upload.ini
file in your project root.
tumblr-upload.ini
Sample [my-special-tumblr] user_form_key: cqDwBjBTmy2oQHmyCFI574NNJQk anon_id: HTWJBOYOABHOFGDSLQIXNISORNJCVXSZ pfe: 1433542234 pfp: ihx7GPOIpOm1YoVN1Np7awxBmbXdsz4rHDFPn6z4 pfs: SpfJuvtJ5jxoDqCQ7qF1wA5mVdw pfu: 5252888[my-other-tumblr] user_form_key: myCFI574NNJQkcqDwBjBTmy2oQH anon_id: DSLQIXNISORNJCVXSZHTWJBOYOABHOFG pfe: 4223414335 pfp: p7awxBmbXdsz4rHDFPn6z4ihx7GPOIpOm1YoVN1N pfs: xoDqCQ7qF1wA5mVdwSpfJuvtJ5j pfu: 8885252
Usage
tumblr-upload.ini
project file
With var tumblrUpload = ;var fs = ;var template = fs; ;
With credentials passed as an argument
var tumblrUpload = ;var fs = ;var template = fs; var production = tumblr_id: 'my-special-tumblr' user_form_key: 'cqDwBjBTmy2oQHmyCFI574NNJQk' anon_id: 'HTWJBOYOBBHOFGDSQQIXNISORNJCVXSZ' pfe: '1423532234' pfp: 'ihx7GPOIpOm1YoVN1Rq7awxBfbXdsz4rHDFPe6z4' pfs: 'SffJuvtJ5jxorRqCQ7qF1wT5mVdw' pfu: '5258845'; production;
API
tumblrUpload(htmlTemplate, tumblr_id, callback)
This will upload the template using the credentials in tumblr-upload.ini
in your project's root (or cwd).
Returns an http.ClientRequest object that can be .abort()
'ed if necessary.
htmlTemplate
- Tumblr template to upload (the actual theme text, not the filename)tumblr_id
- Your Tumblr ID (i.e.something
insomething.tumblr.com
)callback(err)
- Function to call after the upload.Err
will contain the error message, or it will be undefined if successful.
new tumblrUpload.Blog(credentials)
Type: constructor
credentials
- Object or array previously-saved credentials. If array, follow this order:tumblr_id
,user_form_key
,anon_id
,pfe
,pfp
,pfs
,pfu
Returns an object with:
upload(htmlTemplate, callback)
(function)htmlTemplate
- Tumblr template to upload (the actual theme text, not the filename)callback(err)
- Function to call after the upload.Err
will contain the error message, or it will be undefined if successful.
CLI
$ npm install --global tumblr-upload
CLI examples
# Basic usage, will use tumblr-upload.ini tumblr-upload my-special-tumblr index.tumblr.html # Provide credentials on the fly, without relying on separate files # Must be in the following order: tumblr_id,user_form_key,anon_id,pfe,pfp,pfs,pfu tumblr-upload my-special-tumblr index.tumblr.html --credentials cqDwBjBTmy2oQHmyCFI574NNJQk,HTWJBOYOBBHOFGDSQQIXNISORNJCVXSZ,1423532234,ihx7GPOIpOm1YoVN1Rq7awxBfbXdsz4rHDFPe6z4,SffJuvtJ5jxorRqCQ7qF1wT5mVdw,5258845
Options
--credentials
Specify comma-separed credentials, without spaces, in this order: tumblr_id,user_form_key,anon_id,pfe,pfp,pfs,pfu
--help
Show help screen
Legal
License: MIT © Federico Brigante
Tumblr trademarks belong to Tumblr, Inc
tumblr-upload is NOT affiliated with, endorsed, or sponsored by Tumblr.