You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.3 KiB
Go

package main
import (
"fmt"
"os"
"git.nroo.de/norwin/mobilizon-event-importer/mobilizon"
"git.nroo.de/norwin/mobilizon-event-importer/scrapers"
_ "git.nroo.de/norwin/mobilizon-event-importer/scrapers/facebook.com" // register scrapers
)
const usage = "usage:\nMOBI_INSTANCE= MOBI_EMAIL= MOBI_PASS= %s <event feed url>\n"
func main() {
instance, _ := os.LookupEnv("MOBI_INSTANCE")
email, _ := os.LookupEnv("MOBI_EMAIL")
pass, _ := os.LookupEnv("MOBI_PASS")
if len(os.Args) < 2 || instance == "" || email == "" || pass == "" {
fmt.Printf(usage, os.Args[0])
return
}
feed := os.Args[1]
scraper, err := scrapers.Get(feed)
if err != nil {
fmt.Println(err)
return
}
var events []*mobilizon.Event
fmt.Println("fetching events from", feed)
events, err = scraper.ScrapeFeed(feed)
if err != nil {
fmt.Println("ScrapeEvent err:", err)
return
}
fmt.Println(events)
fmt.Println("creating mobi client")
c := mobilizon.NewMobilizonClient(instance)
fmt.Println("authorizing mobi user")
if _, err = c.Authorize(email, pass); err != nil {
fmt.Println("Authorize err:", err)
return
}
// TODO:
// select actor based on account & feed type
// fetch events of actor
// for each scraped event
// check if actor already holds corresponding event
// otherwise create event
}