kensanata / mastodon-archive

Archive your statuses, favorites and media using the Mastodon API (i.e. login required)
https://alexschroeder.ch/software/Mastodon_Archive
GNU General Public License v3.0
358 stars 33 forks source link

Delete media from mentions #44

Open lapineige opened 5 years ago

lapineige commented 5 years ago

I downloaded my archive with my toots + mentions. Then I downloaded the media. The issue is that the media archive contains the media from the mentions. I would like to get rid of them.

Is it possible to add an option to download/remove the media from the mentions ?

kensanata commented 5 years ago

Not with the tool itself, unfortunately.

kensanata commented 5 years ago

I'd say such a feature would have to be added to the file media.py, in other words, some option for the media command.

lapineige commented 5 years ago

Ok, so as well as #40 that's something I should try to add, I guess ? :)

kensanata commented 5 years ago

Maybe? 😄

Actually, if you're comfortable with the command line, you could get the URLs of the url and the preview_url attributes of all the media in mentions (I think! Lightly tested…) by using this jq command:

jq '.mentions[].media_attachments[]|.url,.preview_url' octodon.social.user.kensanata.json

With a little sed you can extract all the path's you need:

jq '.mentions[].media_attachments[]|.url,.preview_url' octodon.social.user.kensanata.json \
| sed -n -e 's/[^\/]*\/\/[^\/]*\/\([^"]*\)"$/\1/p'

So perhaps this is enough to wrap around a loop to rm? Something like the following, untested?

rm $(jq '.mentions[].media_attachments[]|.url,.preview_url' octodon.social.user.kensanata.json \
| sed -n -e 's/[^\/]*\/\/[^\/]*\/\([^"]*\)"$/\1/p')
lapineige commented 5 years ago

Well, it's not that I don't want to do it, but I don't have the time right know but those media files takes some storage space :sweat_smile:

So thanks a lot for your command, I'll investigate. And maybe add some PR :)

(the best would be not to download them, with an option)

kensanata commented 5 years ago

Yeah, to be honest I never download media...