46 lines
836 B
Go
46 lines
836 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"log"
|
|
|
|
"github.com/dstotijn/go-notion"
|
|
)
|
|
|
|
const (
|
|
collectionsDatabaseID = "32fc86afa91e4718b17cb79ab8794265"
|
|
)
|
|
|
|
func main() {
|
|
content, err := downloadURL(sourcesURL)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
log.Println(string(content))
|
|
|
|
var sources []source
|
|
if err := json.Unmarshal(content, &sources); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
ctx := context.Background()
|
|
dbSources := make(map[string]notion.Page)
|
|
|
|
client := notion.NewClient("secret_135hSjxx1xcFWcrjcS1eejjp120T86V8sIGzVeW21X4")
|
|
|
|
result, err := client.QueryDatabase(ctx, collectionsDatabaseID, ¬ion.DatabaseQuery{})
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
for _, s := range result.Results {
|
|
dbSources[s.Properties.(notion.DatabasePageProperties)["SourceID"].Value().(string)] = s
|
|
}
|
|
|
|
// for _, s := range sources {
|
|
|
|
// }
|
|
}
|