/dsb-go

This library lets you access content from DSBmobile in golang.

Primary LanguageGoMIT LicenseMIT

dsb-go

GoDoc Travis

This library lets you access content from DSBmobile in Go (golang).

Unfortunately the heinekingmedia GmbH does not provide any official APIs nor documentation for developers. That sucks! This is why I reverse-engineered their app + website and developed a php script back in 2016 when I was still in school. I later moved on to using Go and created this package.

Contributions are welcome! Please give this repository a star ⭐ if it helped you.

Disclaimer

This is currently not actively maintained since I do not use DSBmobile.

"DSBmobile" and "Digitales Schwarzes Brett" are part of the heinekingmedia GmbH. I am not affiliated with them in any way nor do I endorse their products.

Installation

go get -u github.com/irgendwr/dsb-go

Example

package main

import (
	"fmt"
	"os"

	"github.com/irgendwr/dsb-go"
)

func main() {
	// set credentials
	account := dsb.NewAccount("user", "password")
	// get content
	content, err := account.GetContent()

	if err != nil {
		// exit on error
		fmt.Printf("Error: %s", err)
		os.Exit(1)
	}

	// get timetables
	timetables := content.GetTimetables()
	if len(timetables) == 0 {
		fmt.Println("no timetables found")
		return
	}

	// print all url's
	for i, timetable := range timetables {
		fmt.Printf("URL #%d: %s", i, timetable.GetURL())
	}
}