-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
51 lines (39 loc) · 1.38 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
MessagesModel "github.com/mrnegativetw/FacebookArchiveRenamer/models/messages"
Utils "github.com/mrnegativetw/FacebookArchiveRenamer/utils"
)
const baseFolderPath string = "target/"
const photosFolderPath string = "photos/"
const messageFileName string = "message_1.json"
func main() {
// Feature 1 ~ 4 need this section of code.
// ------------------------------------------------------------
jsonFile, err := os.Open(baseFolderPath + messageFileName)
if err != nil {
fmt.Println(err)
} else {
fmt.Printf("%s opened successfully! \n", messageFileName)
}
defer jsonFile.Close()
byteValue, _ := ioutil.ReadAll(jsonFile)
var messages MessagesModel.Messages
json.Unmarshal(byteValue, &messages)
// ------------------------------------------------------------
// Features:
// 1. Print all messages from single file.
// Utils.Viewer{}.PrintMessage(messages)
// 2. Print all messages from single file with timestamp and name.
// Utils.Viewer{}.PrintMessageDetails(messages)
// 3. Calc total messages.
totalMessageCount := Utils.Calculator{}.CalculateTotalMessage(baseFolderPath)
fmt.Printf("Total message count: %d\n", totalMessageCount)
// 4. Rename photos from single json file.
// renamePhotosFromSingleJsonFile(messages)
// 5. Rename all photos from all json files. (Recommend)
// renamePhotosFromAllJsonFile()
}