mastodon-archive icon indicating copy to clipboard operation
mastodon-archive copied to clipboard

Delete media from mentions

Open lapineige opened this issue 5 years ago • 6 comments

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 ?

lapineige avatar Jun 26 '19 09:06 lapineige

Not with the tool itself, unfortunately.

kensanata avatar Jun 30 '19 18:06 kensanata

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.

kensanata avatar Jun 30 '19 18:06 kensanata

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

lapineige avatar Jun 30 '19 19:06 lapineige

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')

kensanata avatar Jun 30 '19 19:06 kensanata

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)

lapineige avatar Jun 30 '19 19:06 lapineige

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

kensanata avatar Jun 30 '19 20:06 kensanata