mirror of
https://github.com/adulau/mastodon-markdown-archive.git
synced 2024-11-24 10:57:08 +00:00
Support min and max id
This commit is contained in:
parent
308d257926
commit
621d5eee8f
3 changed files with 23 additions and 5 deletions
10
README.md
10
README.md
|
@ -1,6 +1,6 @@
|
||||||
# Mastodon PESOS
|
# Mastodon PESOS
|
||||||
|
|
||||||
Fetch a Mastodon account's posts and save them as Markdown files. Posts are transformed to Markdown, images are inlined, and replies are threaded.
|
Fetch a Mastodon account's posts and save them as Markdown files. Posts are transformed to Markdown, images are inlined, and replies are threaded. Implements most of the parameters in Mastodon's [API to get account's statuses](https://docs.joinmastodon.org/methods/accounts/#statuses).
|
||||||
|
|
||||||
For the time being this formats the files with [Hugo](https://gohugo.io) front-matter.
|
For the time being this formats the files with [Hugo](https://gohugo.io) front-matter.
|
||||||
|
|
||||||
|
@ -10,17 +10,21 @@ I use this small tool to create an archive of my Mastodon posts, which I then [s
|
||||||
```
|
```
|
||||||
Usage of ./mastodon-pesos:
|
Usage of ./mastodon-pesos:
|
||||||
-dist string
|
-dist string
|
||||||
Path to directory where files will be written
|
Path to directory where files will be written (default "./posts")
|
||||||
-exclude-reblogs
|
-exclude-reblogs
|
||||||
Whether or not to exclude reblogs
|
Whether or not to exclude reblogs
|
||||||
-exclude-replies
|
-exclude-replies
|
||||||
Whether or not exclude replies to other users
|
Whether or not exclude replies to other users
|
||||||
-limit int
|
-limit int
|
||||||
Maximum number of posts to fetch (default 40)
|
Maximum number of posts to fetch (default 40)
|
||||||
|
-max-id string
|
||||||
|
Fetch posts lesser than this id
|
||||||
|
-min-id string
|
||||||
|
Fetch posts immediately newer than this id
|
||||||
-persist
|
-persist
|
||||||
Persist most recent post id to /tmp/mastodon-pesos-fid
|
Persist most recent post id to /tmp/mastodon-pesos-fid
|
||||||
-since-id string
|
-since-id string
|
||||||
Fetch only posts made since passed post id
|
Fetch posts greater than this id
|
||||||
-user string
|
-user string
|
||||||
URL of User's Mastodon account whose toots will be fetched
|
URL of User's Mastodon account whose toots will be fetched
|
||||||
```
|
```
|
||||||
|
|
|
@ -42,6 +42,8 @@ type PostsFilter struct {
|
||||||
ExcludeReblogs bool
|
ExcludeReblogs bool
|
||||||
Limit int
|
Limit int
|
||||||
SinceId string
|
SinceId string
|
||||||
|
MinId string
|
||||||
|
MaxId string
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(userURL string) (Client, error) {
|
func New(userURL string) (Client, error) {
|
||||||
|
@ -84,6 +86,14 @@ func (c Client) GetPosts(filter PostsFilter) ([]Post, error) {
|
||||||
queryValues.Add("since_id", filter.SinceId)
|
queryValues.Add("since_id", filter.SinceId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if filter.MaxId != "" {
|
||||||
|
queryValues.Add("max_id", filter.MaxId)
|
||||||
|
}
|
||||||
|
|
||||||
|
if filter.MinId != "" {
|
||||||
|
queryValues.Add("min_id", filter.MinId)
|
||||||
|
}
|
||||||
|
|
||||||
queryValues.Add("limit", strconv.Itoa(filter.Limit))
|
queryValues.Add("limit", strconv.Itoa(filter.Limit))
|
||||||
|
|
||||||
query := fmt.Sprintf("?%s", queryValues.Encode())
|
query := fmt.Sprintf("?%s", queryValues.Encode())
|
||||||
|
|
8
main.go
8
main.go
|
@ -10,12 +10,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
dist := flag.String("dist", "", "Path to directory where files will be written")
|
dist := flag.String("dist", "./posts", "Path to directory where files will be written")
|
||||||
user := flag.String("user", "", "URL of User's Mastodon account whose toots will be fetched")
|
user := flag.String("user", "", "URL of User's Mastodon account whose toots will be fetched")
|
||||||
excludeReplies := flag.Bool("exclude-replies", false, "Whether or not exclude replies to other users")
|
excludeReplies := flag.Bool("exclude-replies", false, "Whether or not exclude replies to other users")
|
||||||
excludeReblogs := flag.Bool("exclude-reblogs", false, "Whether or not to exclude reblogs")
|
excludeReblogs := flag.Bool("exclude-reblogs", false, "Whether or not to exclude reblogs")
|
||||||
limit := flag.Int("limit", 40, "Maximum number of posts to fetch")
|
limit := flag.Int("limit", 40, "Maximum number of posts to fetch")
|
||||||
sinceId := flag.String("since-id", "", "Fetch only posts made since passed post id")
|
sinceId := flag.String("since-id", "", "Fetch posts greater than this id")
|
||||||
|
maxId := flag.String("max-id", "", "Fetch posts lesser than this id")
|
||||||
|
minId := flag.String("min-id", "", "Fetch posts immediately newer than this id")
|
||||||
persist := flag.Bool("persist", false, "Persist most recent post id to /tmp/mastodon-pesos-fid")
|
persist := flag.Bool("persist", false, "Persist most recent post id to /tmp/mastodon-pesos-fid")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
@ -31,6 +33,8 @@ func main() {
|
||||||
ExcludeReblogs: *excludeReblogs,
|
ExcludeReblogs: *excludeReblogs,
|
||||||
Limit: *limit,
|
Limit: *limit,
|
||||||
SinceId: *sinceId,
|
SinceId: *sinceId,
|
||||||
|
MaxId: *maxId,
|
||||||
|
MinId: *minId,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue