OsrParser

package module
v0.0.0-...-454ae0f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2019 License: MIT Imports: 12 Imported by: 0

README

OsrParser

Version 1.0.0

Osu! Replay parser build with GO version 1.11

Refrence

Usage

First of all install lzma package from Itchio's Repo

go get github.com/itchio/lzma

and then install this package

go get github.com/fauzanardh/OsrParser

(optional) add your osu!api apikey to get the beatmap data, edit the APIKEY from $GOPATH/src/github.com/fauzanardh/OsrParser/constants.go

How to use

package main

import (
	"io/ioutil"

	"github.com/fauzanardh/OsrParser"
)

func main() {
	buffer, _ := ioutil.ReadFile("rep.osr")
	replay, _ := OsrParser.ParseReplay(buffer, false)
	replay.PrintReplay()
	replay.PrintAllBeatmap()
}

Screenshot

result_exmaple

Author

@Fauzanardh

Documentation

Index

Constants

View Source
const (
	OSU   = 0
	TAIKO = 1
	CTB   = 2
	MANIA = 3
)

ALL OSU PLAYMODES

View Source
const (
	LEFTCLICK  = 2 << 0
	RIGHTCLICK = 2 << 1
	KEY1       = 2 << 2
	KEY2       = 2 << 3
	SMOKE      = 2 << 4
)

CLICKSTATE

View Source
const (
	APIKEY = "" // Enter your osu apikey, optional if you want to parse the beatmap
)

Keys

Variables

This section is empty.

Functions

func ParseMods

func ParseMods(mods uint32) (r []string, err error)

ParseMods parses a uint32 for mods and returns an array of strings

Types

type BeatmapData

type BeatmapData []struct {
	BeatmapsetID     string `json:"beatmapset_id"`
	BeatmapID        string `json:"beatmap_id"`
	Approved         string `json:"approved"`
	TotalLength      string `json:"total_length"`
	HitLength        string `json:"hit_length"`
	Version          string `json:"version"`
	FileMd5          string `json:"file_md5"`
	DiffSize         string `json:"diff_size"`
	DiffOverall      string `json:"diff_overall"`
	DiffApproach     string `json:"diff_approach"`
	DiffDrain        string `json:"diff_drain"`
	Mode             string `json:"mode"`
	ApprovedDate     string `json:"approved_date"`
	LastUpdate       string `json:"last_update"`
	Artist           string `json:"artist"`
	Title            string `json:"title"`
	Creator          string `json:"creator"`
	CreatorID        string `json:"creator_id"`
	Bpm              string `json:"bpm"`
	Source           string `json:"source"`
	Tags             string `json:"tags"`
	GenreID          string `json:"genre_id"`
	LanguageID       string `json:"language_id"`
	FavouriteCount   string `json:"favourite_count"`
	Playcount        string `json:"playcount"`
	Passcount        string `json:"passcount"`
	MaxCombo         string `json:"max_combo"`
	Difficultyrating string `json:"difficultyrating"`
}

BeatmapData from osu api

func NewBeatmap

func NewBeatmap() *BeatmapData

NewBeatmap returns a new pointer to BeatmapData

func ParseBeatmap

func ParseBeatmap(beatmapMD5 string) (r *BeatmapData, err error)

ParseBeatmap returns parsed BeatmapData

type KeyPressed

type KeyPressed struct {
	LeftClick  bool
	RightClick bool
	Key1       bool
	Key2       bool
	Smoke      bool
}

KeyPressed is the Parsed Compressed KeyPressed.

type LifeBarGraph

type LifeBarGraph struct {
	Time int32
	HP   float32
}

LifeBarGraph is the Bar under the Score stuff.

type Replay

type Replay struct {
	PlayMode      int8
	OsuVersion    int32
	BeatmapMD5    string
	BeatmapParsed bool
	Beatmap       *BeatmapData
	Username      string
	ReplayMD5     string
	Count300      uint16
	Count100      uint16
	Count50       uint16
	CountGeki     uint16
	CountKatu     uint16
	CountMiss     uint16
	Score         int32
	MaxCombo      uint16
	Fullcombo     bool
	Mods          []string
	LifebarGraph  []LifeBarGraph
	Timestamp     time.Time
	ReplayData    []*ReplayData
	OnlineScoreID int64
}

Replay is the Parsed replay.

func NewReplay

func NewReplay() *Replay

NewReplay returns an Empty Replay

func ParseReplay

func ParseReplay(file []byte, parseBeatmap bool) (r *Replay, err error)

ParseReplay parses a Replay and returns a *Replay

func (*Replay) PrintAllBeatmap

func (rep *Replay) PrintAllBeatmap()

PrintAllBeatmap prints informations about the replay's beatmaps

func (*Replay) PrintBeatmap

func (rep *Replay) PrintBeatmap(index int) (err error)

PrintBeatmap prints informations about the replay's beatmap at index

func (*Replay) PrintReplay

func (rep *Replay) PrintReplay()

PrintReplay informations about the replays

type ReplayData

type ReplayData struct {
	Time       int64
	MosueX     float32
	MouseY     float32
	KeyPressed *KeyPressed
}

ReplayData is the Parsed Compressed Replay data.

func ParseCompressed

func ParseCompressed(file []byte) (d []*ReplayData, err error)

ParseCompressed parses a compressed replay, (ReplayData)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL