mirror of
https://github.com/by-jp/www.byjp.me.git
synced 2025-08-09 18:06:07 +01:00
I kinda screwed with everything else to homogenise all the functions - the FB stuff works, but I've definitely broken some of the other importers. I can work on fixing them in the future if I need them; otherwise others can look at previous commits!
44 lines
911 B
Go
44 lines
911 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path"
|
|
"regexp"
|
|
|
|
"github.com/by-jp/www.byjp.me/tools/shared"
|
|
)
|
|
|
|
type Config struct {
|
|
Root string `default:"."`
|
|
}
|
|
|
|
var postsFileRE = regexp.MustCompile(
|
|
`(facebook-\w+-\d{4}-\d{2}-\d{2}-\w{8})/your_facebook_activity/posts/your_posts__check_ins__photos_and_videos_\d+.json`,
|
|
)
|
|
|
|
func main() {
|
|
var c Config
|
|
shared.Check(shared.LoadConfig("facebook", &c), "Unable to load config")
|
|
|
|
if len(os.Args) < 2 {
|
|
shared.ExitMessage(
|
|
"Usage: %s facebook-yourname-YYYY-MM-DD-xxxxxx-YYYYMMDDTHHMMSS-001.zip",
|
|
path.Base(os.Args[0]),
|
|
)
|
|
}
|
|
archives, err := findArchives(os.Args[1])
|
|
shared.Check(err, "Couldn't find facebook archive zipfile")
|
|
|
|
shared.Check(
|
|
shared.ExtractPostsFromArchives(
|
|
archives,
|
|
postsFileRE,
|
|
c.Root,
|
|
postize,
|
|
),
|
|
"Unable to extract posts from archive files",
|
|
)
|
|
|
|
fmt.Println("Your Facebook export has been imported into your blog.")
|
|
}
|