bbolli / tumblr-utils

Utilities for dealing with Tumblr blogs, Tumblr backup
GNU General Public License v3.0
668 stars 124 forks source link

Tumblr theme #88

Open RomeSilvanus opened 7 years ago

RomeSilvanus commented 7 years ago

Are there any plans of actually saving and using the Layout/Theme (the html) as it appears on the Tumblr blog. Instead of using the standard html that comes with your application?

It would be a nice feature to have the backed up blog look exactly the same as the original.

bbolli commented 7 years ago

AFAIK, there's no API to get the HTML template code which would be needed for this. But if you find a different way, you're welcome to send a pull request!

andreacfromtheapp commented 6 years ago

@bbolli could this be helpful? https://github.com/pabluk/tumblr-theme-parser

wertercatt commented 5 years ago

@bbolli www.tumblr.com/customize_api/demo_content/{blog-identifier} is an internal API which seems to return the theme configuration in JSON format. This appears to work for any blog and only requires the cookies of any logged-in user.

Example for my blog teamawe5ome5inceweareawe5omene55.tumblr.com : https://www.tumblr.com/customize_api/demo_content/teamawe5ome5inceweareawe5omene55

www.tumblr.com/customize_api/theme/{blog-identifier} also exists, and might return the theme template code. However, it tells me my request was denied when I try to just request it without any special headers, so I'm not sure. I'll try and figure out how to access it.

wertercatt commented 5 years ago

https://www.tumblr.com/customize_api/blog/{blog-identifier} This internal api gets the theme config and the custom theme code! ...but it requires the cookies of a logged-in user and will deny requests for blogs the user isn't part of.

wertercatt commented 5 years ago

@Cebtenzzre could you make a patch to save stuff from my findings?

cebtenzzre commented 5 years ago

@wertercatt Well, there is some theme data in there. But I don't know how you would get a proper CSS stylesheet from it that could be used to change the look of the HTML archive tumblr-utils creates.

I've managed to find a consistent style.css in the HTML, but I haven't yet figured out how to get an XPath expression for xmlstarlet working in Python, and I don't know what I'd do with the stylesheet once it's been retrieved. I suppose it could be saved separately "for future/external usage" in the same way we save JSON payloads.

Do you really just want to save the HTTP responses from those URLs? Because if you want to do that, all you need is curl. Just pass it some cookies and headers and stuff via the command line. I don't see why tumblr-utils should download that, since as far as I understand it's not useful to have locally.

bbolli commented 5 years ago

So if you want a mirror of your blog pages, you can use any web site scraper that supports cookies. Even wget would work for this with the right options. tumblr_backup is not a scraper, in that it backs up your posts with metadata if you also save the JSON.