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
status
data but does not include the unformattedStatusSource
text needed to repost the status elsewhere, nor does it include media files. - Works back through the downloaded statuses (to download the
StatusSource
and media files for eachstatus
, and to identify any self-thread relationships that need to be preserved) and saves them as aPost
to aPostArchive
named according to thearchiveName
parameter (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
PostArchive
by loading the data for itsPost
objects from the set of XML files on the local filesystem. - Iterates through the archive, uploading any media attached to each
Post
to 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 repostedstatus
where 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
save
orpost
-username
-instance
-archiveName
-showdebug
-preserveHashtags
-bookmarkedOnly
-from
(only when usingpost
)-until
(only when usingpost
)-extraThrottle
-customPort
- Since:
- 0.01.00
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static boolean
Confirms whether the application's data directory exists at the location specified by theDATA_DIRECTORY
constant, and tries to create it if it does not.protected static String
Provides the location of the application's data directory, currently as specified by theDATA_DIRECTORY
constant.protected static String
Provides the prefix used when debug messages are printed to the console, as specified by theDEBUG_PREFIX
constant.protected static String
Provides the prefix used when error messages are printed to the console, as specified by theERROR_MESSAGE_PREFIX
constant.static void
Initializes application, accepting command-line parameters, callingparseParameters
to parse them into global variables and then calling the requested procedure accordingly.protected static boolean
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.
-
Constructor Details
-
Mover
public Mover()
-
-
Method Details
-
main
Initializes application, accepting command-line parameters, callingparseParameters
to parse them into global variables and then calling the requested procedure accordingly.- Parameters:
args
- space-delimited command line parameters as a primitive array ofString
objects- Since:
- 0.01.00
-
getDataDirectory
Provides the location of the application's data directory, currently as specified by theDATA_DIRECTORY
constant.- 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_DIRECTORY
constant, and tries to create it if it does not.- Returns:
true
if the directory exists or was successfully created, orfalse
otherwise- 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:
true
if debug messages should be printed to the console, orfalse
otherwise- Since:
- 0.01.00
-
getDebugPrefix
Provides the prefix used when debug messages are printed to the console, as specified by theDEBUG_PREFIX
constant.- 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_PREFIX
constant.
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
-