Package io.github.mastodonContentMover
Class Mover
java.lang.Object
io.github.mastodonContentMover.Mover
Bootstraps application, parses command-line parameters, determines which function
was requested by the user, and then performs that function.
Currently two functions are available:
At a high level, saving to an archive does the following:
The main, required command-line options are as follows:
Currently two functions are available:
save, to download and save statuses
for a given user account on a specified Mastodon instance to an XML-based archive on
the local machine, and post, to repost them to a user account on a Mastodon
instance.
At a high level, saving to an archive does the following:
- Parses and validates command-line parameters
- Connects to the specified user account and Mastodon instance (obtaining client and user authorization where necessary, and saving the relevant credentials to file for future use)
- Downloads the Mastodon statuses from that user's own timeline in a series
of pages (backwards from the most recent), which obtains much
statusdata but does not include the unformattedStatusSourcetext needed to repost the status elsewhere, nor does it include media files. - Works back through the downloaded statuses (to download the
StatusSourceand media files for eachstatus, and to identify any self-thread relationships that need to be preserved) and saves them as aPostto aPostArchivenamed according to thearchiveNameparameter (which holds this data in memory and also persists it to a set of XML files, using JAXB, on the local filesystem within a directory named to match the name of the archive).
- Parses and validates command-line parameters
- Connects to the specified user account and Mastodon instance (obtaining client and user authorization where necessary and saving the relevant credentials to file for future use)
- Populates a
PostArchiveby loading the data for itsPostobjects from the set of XML files on the local filesystem. - Iterates through the archive, uploading any media attached to each
Postto the specified Mastodon instance, removing meaningful symbols such as the at-mark for mentions or hashtag that would trigger spurious notifications from the text, and then submitting it as a newstatus(and as a reply to a previously repostedstatuswhere it is part of a self-thread). - Re-bookmarks or re-pins reposted statuses that were bookmarked or pinned by the saving user when the archive was created, and where this is specified
The main, required command-line options are as follows:
- either
saveorpost -username-instance-archiveName
-showdebug-preserveHashtags-bookmarkedOnly-from(only when usingpost)-until(only when usingpost)-extraThrottle-customPort
- Since:
- 0.01.00
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static booleanConfirms whether the application's data directory exists at the location specified by theDATA_DIRECTORYconstant, and tries to create it if it does not.protected static StringProvides the location of the application's data directory, currently as specified by theDATA_DIRECTORYconstant.protected static StringProvides the prefix used when debug messages are printed to the console, as specified by theDEBUG_PREFIXconstant.protected static StringProvides the prefix used when error messages are printed to the console, as specified by theERROR_MESSAGE_PREFIXconstant.static voidInitializes application, accepting command-line parameters, callingparseParametersto parse them into global variables and then calling the requested procedure accordingly.protected static booleanIndicates whether debug messages should be printed to the console, according to whether that option was specified as a parameter when the application was run.
-
Constructor Details
-
Mover
public Mover()
-
-
Method Details
-
main
Initializes application, accepting command-line parameters, callingparseParametersto parse them into global variables and then calling the requested procedure accordingly.- Parameters:
args- space-delimited command line parameters as a primitive array ofStringobjects- Since:
- 0.01.00
-
getDataDirectory
Provides the location of the application's data directory, currently as specified by theDATA_DIRECTORYconstant.- Returns:
- the folder name within the working directory that is used to store all the
application's data
- Since:
- 0.01.00
-
checkDataDirectoryExists
protected static boolean checkDataDirectoryExists()Confirms whether the application's data directory exists at the location specified by theDATA_DIRECTORYconstant, and tries to create it if it does not.- Returns:
trueif the directory exists or was successfully created, orfalseotherwise- Since:
- 0.01.00
-
showDebug
protected static boolean showDebug()Indicates whether debug messages should be printed to the console, according to whether that option was specified as a parameter when the application was run.- Returns:
trueif debug messages should be printed to the console, orfalseotherwise- Since:
- 0.01.00
-
getDebugPrefix
Provides the prefix used when debug messages are printed to the console, as specified by theDEBUG_PREFIXconstant.- Returns:
- the prefix used when debug messages are printed to the console
- Since:
- 0.01.00
-
getErrorMessagePrefix
Provides the prefix used when error messages are printed to the console, as specified by theERROR_MESSAGE_PREFIXconstant.
Do not use this to prefix the messages attached to thrown exceptions, or the prefix will be displayed twice.- Returns:
- the prefix used when error messages are printed to the console
- Since:
- 0.01.00
-