Git Product home page Git Product logo

ephemetoot's Introduction

πŸ₯³ ==> 🧼 ==> πŸ˜‡

ephemetoot is a Python command line tool for deleting old toots.

As Mastodon now has similar functionality built in, ephemetoot is now in maintenance mode - no new features will be added, only security updates.

Quickstart

You should have Python3 and pip installed, and an app access token on hand. More detail information is available in the docs

Install with pip:

pip install ephemetoot

Create a config file:

ephemetoot --init

Do a first run in --test mode:

ephemetoot --test

Find out about other options:

ephemetoot --help

Documentation

You can also read the docs at ephemetoot.hugh.run

Prior and related work

The initial ephemetoot script was based on this tweet-deleting script by @flesueur

ephemetoot relies heavily on the Mastodon.py package by @halcy

Looks like Gabriel Augendre had the same idea. You might prefer to use Gabriel's cleantoots instead.

Usage

You can use ephemetoot to delete Mastodon toots that are older than a certain number of days (default is 365). Toots can optionally be saved from deletion if:

  • they are pinned; or
  • they include certain hashtags; or
  • they have certain visibility; or
  • they are individually listed to be kept

Contributing

ephemetoot is tested using pytest.

For bugs or other contributions, please check the contributing guide.

License

This project and all contributions are licensed under the GPL 3.0 or future version

ephemetoot's People

Contributors

96radhikajadhav avatar dependabot[bot] avatar fobser avatar hughrun avatar jneplokh avatar jpmens avatar markeeaton avatar msafadieh avatar pacoesteban avatar rugk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ephemetoot's Issues

BUG - upgrade instructions in --version are wrong

Description
ephemetoot --version provides the following message:

To upgrade to the most recent version run pip3 install --update ephemetoot

This should be:

To upgrade to the most recent version run pip install --upgrade ephemetoot

Please only log one bug per issue.

Environment (please complete the following information):

  • OS: MacOS and Ubuntu Linux
  • Python version 3.8

To Reproduce
Run ephemetoot --version

Expected behavior
Correct upgrade instructions are shown.

Actual behavior
Incorrect upgrade instructions are shown.

Optionally include media attachments in archives

Does your proposal relate to...

  • documentation
  • what is displayed when running ephemetoot
  • a new config value
  • a new flag (option)
  • something else

Is your feature request related to a problem? Please describe.
The archive option stores the json representation of a toot on disk.
The media_attachments array contains a list of URIs that point to fediverse server.
Once a toot is deleted media_attachments are deleted as well and are then lost.

Describe the solution you'd like
I would like to fetch the media attachments and store them alongside the json of the toot.
It is probably best to replicate the directory structure the servers uses, for example I see
https://SERVER/media_attachments/files/000/718/385/original/IMAGE.png
The file IMAGE.png should be stored in the directory media_attachments/files/000/718/385/original below the archive path.
This would be configurable by a new archive_media [yes/no] option.

Would like to write the code yourself?

  • I would like to write the code myself and then log a pull request
  • I would like someone else to write the code
  • I would like someone to help me write the code

Ephemetoot may die when encountering utf8 encoded toots

Adding "PYTHONIOENCODING=utf-8" fixes the error. Error and post error with utf-8 setting below.

bills-grimoire:ephemetoot> python3 ephemetoot.py --test                          
This is a test run...
Fetching account details...
Checking 1314 toots...
Traceback (most recent call last):
  File "ephemetoot.py", line 80, in checkToots
    + toot.created_at.strftime("%d %b %Y")
UnicodeEncodeError: 'ascii' codec can't encode character '\u274c' in position 0: ordinal not in range(128)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "ephemetoot.py", line 139, in <module>
    checkToots(timeline)
  File "ephemetoot.py", line 121, in checkToots
    checkToots(next_batch, deleted_count)
  File "ephemetoot.py", line 121, in checkToots
    checkToots(next_batch, deleted_count)
  File "ephemetoot.py", line 121, in checkToots
    checkToots(next_batch, deleted_count)
  [Previous line repeated 4 more times]
  File "ephemetoot.py", line 111, in checkToots
    print("\U0001f6d1 Unknown ERROR deleting toot - " + str(toot.id))
UnicodeEncodeError: 'ascii' codec can't encode character '\U0001f6d1' in position 0: ordinal not in range(128)

bills-grimoire:ephemetoot> PYTHONIOENCODING=utf-8 python3 ephemetoot.py --test 
This is a test run...
Fetching account details...
Checking 1314 toots...
<snip>
Test run. This would have removed 1044 toots.

Add flag to skip archival of excluded toots

Is your feature request related to a problem? Please describe.
When choosing to keep certain Toots (e.g, dms, pins, or specific ones), they are still archived even if not deleted.

Describe the solution you'd like
A flag which would skip the archival of excluded toots.

Do you have a Kofi/PayPal/Venmo?

Does your proposal relate to...

  • something else

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. e.g. I'm always frustrated when [...]

This script is incredible, evolving and has saved me countless hours already. Can the author be "tipped" via standard methods (Kofi, PayPal, Venmo)?

Describe the solution you'd like

A way to tip the author

Would like to write the code yourself?

That is exactly why I want to tip.

Describe alternatives you've considered

Not tipping.

Additional context

add boosts only option

Does your proposal relate to...

  • documentation
  • what is displayed when running ephemetoot
  • a new config value
  • a new flag (option)
  • something else

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. e.g. I'm always frustrated when [...]

I just want to be able to clear out my account from posts that I've boosted

Describe the solution you'd like
A clear and concise description of what you want to happen.

I can use ephemetoot to remove only boosted toots and nothing else

Would like to write the code yourself?

  • I would like to write the code myself and then log a pull request
  • I would like someone else to write the code
  • I would like someone to help me write the code

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

https://github.com/wgahnagl/ephemetoot/tree/add-boosts-only
I've got it working (and deleting toots on my mastodon account right now lol)
I'll write tests for it when I get back home tomorrow and open a PR! πŸ‘Œ

Requesting --version switch

Is your feature request related to a problem? Please describe.
I went to upgrade to the latest version (Wow, that was so fast! Thank you! Do you have a Kofi or Paypal or something?) and I realized I have no idea which version I'm running at any given point. It would be nice to be able to run --version and see which version it is.

Describe the solution you'd like
--version displays current version of application

Describe alternatives you've considered
grepping for the version in the source code.

Additional context
Fairly simple request.

Use virtualenv

You could use Pythons virtualenv for an easier setup and development.

Enable script to process more than one account

It would be useful to be able to process toots from multiple accounts using the one script - probably using a dict of account objects or something like that and then looping through them.

quiet mode

Is your feature request related to a problem? Please describe.
The default is to log every delete action - sometimes you just want to delete your toots though with no feedback necessary other than a total at the end.

Describe the solution you'd like
Add a --quiet flag to optionally silence all print() statements

Describe alternatives you've considered
Doing nothing.
We already have --ignore_skipped but --quiet will ignore everything.

Additional context
Add any other context or screenshots about the feature request here.

BUG - v2.6 still shows v2.5

Description

After upgrading, getting the older version displaying, and then doing a full uninstall/reinstall, getting v2.5 in header instead of v2.6:

============= EPHEMETOOT v2.5 ================

Environment (please complete the following information):
Current Raspian
Python 2.7

To Reproduce

./ephemetoot --datestamp --pace --retry-mins 5

Expected behavior
Header should show proper version (v2.6)

Actual behavior
Header displays "v2.5"

Screenshots

Additional context

pip uninstall ephemetoot
cd ..
rm -rf ephemetoot/
git clone https://github.com/hughrun/ephemetoot.git
cd ephemetoot
git checkout master

$ pip install .
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Processing /home/amarand/ephemetoot
Requirement already satisfied: Mastodon.py in /home/amarand/.local/lib/python2.7/site-packages (from ephemetoot==2.6) (1.5.1)
Requirement already satisfied: pyyaml in /home/amarand/.local/lib/python2.7/site-packages (from ephemetoot==2.6) (5.3.1)
Requirement already satisfied: requests in /usr/lib/python2.7/dist-packages (from ephemetoot==2.6) (2.21.0)
Requirement already satisfied: blurhash>=1.1.4 in /home/amarand/.local/lib/python2.7/site-packages (from Mastodon.py->ephemetoot==2.6) (1.1.4)
Requirement already satisfied: six in /usr/lib/python2.7/dist-packages (from Mastodon.py->ephemetoot==2.6) (1.12.0)
Requirement already satisfied: python-magic in /home/amarand/.local/lib/python2.7/site-packages (from Mastodon.py->ephemetoot==2.6) (0.4.18)
Requirement already satisfied: decorator>=4.0.0 in /home/amarand/.local/lib/python2.7/site-packages (from Mastodon.py->ephemetoot==2.6) (4.4.2)
Requirement already satisfied: python-dateutil in /home/amarand/.local/lib/python2.7/site-packages (from Mastodon.py->ephemetoot==2.6) (2.8.1)
Requirement already satisfied: pytz in /home/amarand/.local/lib/python2.7/site-packages (from Mastodon.py->ephemetoot==2.6) (2020.1)
Building wheels for collected packages: ephemetoot
Running setup.py bdist_wheel for ephemetoot ... done
Stored in directory: /tmp/pip-ephem-wheel-cache-tIelrK/wheels/a5/17/aa/24a4cb71e1e04e01c8c977ce1c50c043e2377f1ff1d6be57ba
Successfully built ephemetoot
Installing collected packages: ephemetoot
Successfully installed ephemetoot-2.6

BUG - unhelpful error message when insufficient API scopes

Description
When I attempt to use ephemetoot for the first time using Python 3.8.5 I get a ModuleNotFound error.

Please only log one bug per issue.

Environment (please complete the following information):

  • OS Manjaro Linux
  • Python 3.8.5

To Reproduce
pip install ephemetoot in any way you'd like other than with sudo. Was able to replicate it with --user, virtualenv and pipenv.

Expected behavior
I get to use ephemetoot

Actual behavior
I don't get to use ephemetoot

Screenshots
Nah

Additional context

  File "/home/user/.local/share/virtualenvs/ephemetoot-7ki6mRLC/bin/ephemetoot", line 5, in <module>
    from ephemetoot.console import main
  File "/home/trev/.local/share/virtualenvs/ephemetoot-7ki6mRLC/lib/python3.8/site-packages/ephemetoot/console.py", line 36, in <module>
    from lib import ephemetoot
ModuleNotFoundError: No module named 'lib'

move test run completion message to after cleanup complete message

i.e. do this:

---------------------------------------
πŸ₯³ ==> 🧼 ==> πŸ˜‡ User cleanup complete!
---------------------------------------

Test run completed. This would have removed 6 toots.

Instead of this:


Test run completed. This would have removed 6 toots.

---------------------------------------
πŸ₯³ ==> 🧼 ==> πŸ˜‡ User cleanup complete!
---------------------------------------

Or maybe do this:

---------------------------------------
πŸ₯³ ==> πŸ§ͺ ==> πŸ“‹ Test run complete!
This would have removed 6 toots.
---------------------------------------

BUG -

Describe the bug
Pulled down the latest version, created a new directory, git, copied configuration file over, ran with --pace and -datestamp and noticed that neither datestamps were shown, and the pacing did not throttle back to 30 per minute to avoid rate limit.

To Reproduce
Steps to reproduce the behavior:
Running the following script from the freshly downloaded ephemetoot (with git):

python3 ephemetoot --pace --datestamp

This is in a fresh directory. Old directory renamed. Verified this is the correct version by running --help, which displays properly.

Expected behavior
Expect rate throttled back to one per minute, and date stamps to display (for each line?)

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: Raspian 4.19.95-v7+
  • Python version 3.7.3

Additional context
Add any other context about the problem here.

Add --hide_skipped flag

Listing every skipped toot is tedious if e.g. all direct or all public toots are excluded. This opt-in flag would enable users to make logging less verbose and only list unboost or delete actions.

"FileNotFoundError" when running script

Description
When running ephemetoot, after "fetching account details," the program fails with a FileNotFoundError in ~/toots_archive/TOOT.json, a DM, and I would like to exclude DMs.

Environment:

  • MacOS 10.15.5 Catalina
  • Python 3.8

To Reproduce
Run the installation instructions and configure the config.yaml as told.

Expected behavior
The script to fetch account details and go on to delete the toots.

Actual behavior
As stated, the script fails as it says that toot file cannot be found and fails. Full read and write access is given as well.

Output

Traceback (most recent call last):
  File "/usr/local/bin/ephemetoot", line 92, in <module>
    ephemetoot.checkToots(user, options)
  File "/usr/local/lib/python3.8/site-packages/lib/ephemetoot.py", line 366, in checkToots
    checkBatch(timeline)
  File "/usr/local/lib/python3.8/site-packages/lib/ephemetoot.py", line 112, in checkBatch
    with open(filename, "w") as f:
FileNotFoundError: [Errno 2] No such file or directory: '~/toots_archive/TOOT.json'

Additional Information
When I remove the archive option and run ephemetoot --test it works just fine, but I would really like to archive my toots, of course.

ERROR: unsupported operand type(s) for +=: 'NoneType' and 'int'

Does your proposal relate to...

  • a new flag (option)

Is your feature request related to a problem? Please describe.
I am able to redirect standard and error output using cron - which I still haven't gotten working yet, but I'm working on it. Was wondering if you might be able to create a --log flag which would take a specific directory/filename argument, which would make cron a lot easier. Of course, you could also have that same thing inside the configuration file, which would make the cron entry even cleaner.

Describe the solution you'd like
I'd like either (or both) a --log flag that takes a directory and/or full path with filename for all log output. I rotate my files every day with Linux, so that should be fine, regardless the size.

Would like to write the code yourself?

  • I would like someone else to write the code

Describe alternatives you've considered
I've used the standard and error redirect in cron, but it doesn't seem to update like it should?

Additional context
Please forgive me if I've missed something terribly obvious here!

Use ratelimit_reset timestamp in rate limit message

Per #22, when we hit the rate limit, include some time data using the ratelimit_reset value provided by Mastodon.py. Either the timestamp itself, or a calculation from 'now' regarding how long until the rate limit resets.

use format checking in config file creation

When creating a config file with --init it is possible to enter any string for the server domain and username

Using a regex or similar to identify when the string starts with http or @ respectively may prevent annoying setup problems.

clearer config information

Does your proposal relate to...

  • documentation
  • what is displayed when running ephemetoot
  • a new config value
  • a new flag (option)
  • something else

Is your feature request related to a problem? Please describe.

@ephemetoot
Thank you for this useful little tool!

Feedback: I've searched for the yaml.config file to modify the max posting age and it took a while to understand that it was created in the current shell's path.

  • Could you rename the file to ephemtoot_yaml.config or something similar?

  • Could you display the path of the yaml.config file at the end of the init process to make it easier?

Describe the solution you'd like
A clear and concise description of what you want to happen.

Would like to write the code yourself?

  • I would like to write the code myself and then log a pull request
  • I would like someone else to write the code
  • I would like someone to help me write the code

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
message received as toot

Include tests on pypi distribution

Does your proposal relate to...

  • documentation
  • what is displayed when running ephemetoot
  • a new config value
  • a new flag (option)
  • something else

Is your feature request related to a problem? Please describe.
Not really, it's a "nice to have".
I maintain the OpenBSD port of ephemetoot, and it would be nice to have the tests included on the pypi distribution.

Describe the solution you'd like
Just that, having the tests included on the pypi distribution. It makes it easier for us to asses that and update does not break the port.

Would like to write the code yourself?

  • I would like to write the code myself and then log a pull request
  • I would like someone else to write the code
  • I would like someone to help me write the code

Describe alternatives you've considered

Additional context

Mention cleantoots in the docs

Does your proposal relate to...

  • documentation

Proposal
Hello ! πŸ‘‹πŸ»

I’m the author of cleantoots, a similar CLI program to delete your old toots.

I just randomly came across this project and it looks like we both had the same idea except in different timelines 😊

Would you be open to linking to cleantoot’s project page in your readme? Perhaps in a β€œSimilar projects” or β€œSee also” section?

I just did so myself (I don’t expect anything in return of course, I just find your project cool 😊): https://git.augendre.info/gaugendre/cleantoots

Anyway, have fun!

fix typo in docs

In docs/install.md there is a typo: Number of days to keep toots e.g. 30. If not value is provided the default number is 365

Date/time stamp, Rate Limiting, Retry-After Display

All of these suggestions would likely be options that can be turned on and off either on the command line and/or in the configuration file: (Not everyone wants these things, I imagine.)

I'd love to see an option to include a date/time stamp at the beginning of each action in the log-file. I'm running this script for about 30 days straight, due to rate limiting, to delete around 45k toots, and I'd like to see when each thing happened. I would especially like to see a date/time stamp for each action ("deleted"/"unboosted") but also for any errors (like rate limiting) so I can easily see when things are happening.

Also, as the Mastodon Core seems to have its API rate limited to 30 deletes per 30 minute period (or something like that), it might be nice to have a "slow down" rate limiting option so you can delete continuously, without causing your social media connection to also get throttled.

Also, I believe API rate limiting has a feature called Retry-After, and I'm wondering if that could be (optionally) displayed along with the "Rate Limited" error message?

BUG - Typo in Config Documentation

Description
I was reading back through the docs to see how to update, and while skimming I noticed I typo in the Configuration file docs. When describing copying example-config.yaml it currently says

cp example-config.yam config.yaml

while it should say

cp example-config.yaml config.yaml, of course.

Nothing too major, but just in case someone does not notice the error should they copy & paste. This is extremely simple, so I can make a PR if you would like. Only a letter :P

Remove favorites

Does your proposal relate to...

  • documentation
  • what is displayed when running ephemetoot
  • a new config value
  • a new flag (option)
  • something else

Is your feature request related to a problem? Please describe.
The script works great for deleting toots, it could be interesting to add an option to delete favorites as well, older than x days

Describe the solution you'd like
Maybe an option in config.yaml like delete_favs: true or false ?

Would like to write the code yourself?

  • I would like to write the code myself and then log a pull request
  • I would like someone else to write the code
  • I would like someone to help me write the code

Handling/retry of 500 errors?

Does your proposal relate to...

  • [X ] something else

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. e.g. I'm always frustrated when [...]

My Mastodon service provider sometimes throws his server into a "maintenance mode" and it throws a 521 error. It's semi-common for him to do this. It looks like ephemetoot gives up (which might be required for the protocol for a 500/521 error?) but is there a way to either A) add a switch that allows you to keep retrying (after a certain safe wait period, maybe a few minutes?) after getting a 500 error or B) just build that in without a switch (possibly with a switch to override that behavior)?

Describe the solution you'd like
A clear and concise description of what you want to happen.

Ideally, this would be an opt-in switch, because I think 500 errors might not be retryable by convention. But the switch would, upon receipt of a 500 error, back off, wait a certain amount of time (5 minutes? 10? 15? Possibly set at the command line with a default?) and then retry.

Would like to write the code yourself?

  • I would like someone else to write the code

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

When I see that it throws this error, I just restart the script and it runs usually right away. If I don't get to it for a few hours, I miss a few hours worth of deletions.

Additional context
Add any other context or screenshots about the feature request here.

Thanks!

Quieter mode?

Does your proposal relate to...

  • documentation
  • what is displayed when running ephemetoot
  • a new config value
  • a new flag (option)
  • something else

Is your feature request related to a problem? Please describe.
I run ephemetoot in a crontab, which means I get an email each time one of my scripts has any output. It would be cool if there was an option to completely suppress output when zero toots are deleted (since nothing changed).

Describe the solution you'd like
The behavior of --quiet could be modified to:

  • not print Fetching account details for X
  • only print Removed X toots when X > 0

Alternative, we could have a "--silent" or "-qq" (as in double quiet) flag but that could be confusing.

Would like to write the code yourself?

  • I would like to write the code myself and then log a pull request
  • I would like someone else to write the code
  • I would like someone to help me write the code

Describe alternatives you've considered
I can just wrap ephemetoot in a shell script that parses the output and only prints it out if the number of deleted toots is greater than zero.

ephemetoot --quiet -c config.yaml | grep "Removed [1-9][0-9]* toots."

Public visibility filter broken

Here is my config:

access_token = 'SOMETHING ;P'
base_url = 'https://chaos.social'
days_to_keep = 20
keep_pinned = True
toots_to_keep = []
hashtags_to_keep = {'introduction', 'announcement'} # comma separated Set as strings, e.g. 'introduction'
visibility_to_keep = ['public'] # options are: 'public', 'unlisted', 'private', 'direct'

version: 76ace13

Here is part of a --test run:

πŸ‘€ skipping public toot - 103811713295126113
πŸ‘€ skipping public toot - 103811703398555702
❌ deleting toot 103811699802705022 tooted 12 Mar 2020
πŸ‘€ skipping public toot - 103811677870289903
πŸ‘€ skipping public toot - 103811616338855727

However, the toot 103811699802705022 is public

BUG - "Unknown ERROR 'toots_to_keep'"

Running into a rather unusual issue.

Checking 252 toots...
πŸ›‘ Unknown ERROR deleting toot - 104119721104732502
'toots_to_keep'
πŸ›‘ Unknown ERROR deleting toot - 104118409476636157
'toots_to_keep'
πŸ›‘ Unknown ERROR deleting toot - 104117448639448175
'toots_to_keep'
...
πŸ“Œ skipping pinned toot - 103499629853797922
πŸ“Œ skipping pinned toot - 102981316242187388
....
Removed 0 toots.


πŸ₯³ ==> 🧼 ==> πŸ˜‡ User cleanup complete!

At first I thought this was a config.yaml issue, but it continues to persist with changes to the config. It's clearly not a token issue, since this token worked with the old ephemetoot and can clearly still retrieve all of the toots.

Environment is FreeBSD 12.1 using a Python 3.7 virtualenv (to avoid issues with modules.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.