tumblr_backup icon indicating copy to clipboard operation
tumblr_backup copied to clipboard

No source link for pictures?

Open briatte opened this issue 11 years ago • 2 comments

It seems that the script does not include the source when saving posts that are made of a single picture. Any way this could be fixed? It's a tragic loss of information! Otherwise, great stuff :+1:

briatte avatar Jan 03 '13 17:01 briatte

Ah, I had always just assumed that the images provided would be self-hosted as part of the Tumblr account. Linking to an outside source would definitely be a common case though, and then you'd definitely want to include the source.

So this is a good idea. I'll add it in when I get the chance. Thanks!

bdoms avatar Jan 03 '13 18:01 bdoms

Great! I'm unfortunately too weak on Python and BeautifulSoup to help with that, but it seems to me that:

  • for an image with a click-through link, the source is always found in the href attribute of the first <a> tag placed immediately after the <div class="photo"> tag.
  • for an image with no click-through link, the source is usually in the <p>(via <a href="here">)</p> standard Tumblr source link paragraph.

Example of the first case:

<div class="photo">     
    <a href="source_link"><img alt="…" src="image_url"/></a>
    <p>(via <a href="source_link_again">source_link_title</a>)</p>
    <div class="info">
        <a href="post_url">post_date</a>
    </div>
</div>

Example of the second case:

<div class="photo">     
    <img alt="…" src="image_url"/>
    <p>(via <a href="source_link">source_link_title</a>)</p>
    <div class="info">
        <a href="post_url">post_date</a>
    </div>
</div>

Hope this helps!

briatte avatar Jan 03 '13 19:01 briatte