Example #1
0
func ExampleEpisodeRange_Split() {
	a := misc.ParseEpisodeRange("1.0-1.3")
	b := misc.ParseEpisode("1.2")
	fmt.Println(a.Split(b))

	b = misc.ParseEpisode("1")
	fmt.Println(a.Split(b))

	a = misc.ParseEpisodeRange("1.1-2")
	fmt.Println(a.Split(b))

	b = misc.ParseEpisode("2")
	fmt.Println(a.Split(b))

	a = misc.ParseEpisodeRange("1-10")
	fmt.Println(a.Split(b))

	b = misc.ParseEpisode("4")
	fmt.Println(a.Split(b))

	// Output:
	// [1.0-1.1 1.3]
	// [<nil> <nil>]
	// [<nil> 2]
	// [1.1 <nil>]
	// [1 03-10]
	// [1-3 05-10]
}
Example #2
0
func ExampleParseEpisode() {
	fmt.Printf("%#v\n", misc.ParseEpisode("1"))
	fmt.Printf("%#v\n", misc.ParseEpisode("S2"))
	fmt.Printf("%#v\n", misc.ParseEpisode("03"))
	fmt.Printf("%#v\n", misc.ParseEpisode("")) // invalid episode

	// Output:
	// &misc.Episode{Type:1, Number:1, Part:-1, Parts:0}
	// &misc.Episode{Type:2, Number:2, Part:-1, Parts:0}
	// &misc.Episode{Type:1, Number:3, Part:-1, Parts:0}
	// (*misc.Episode)(nil)
}
Example #3
0
func ExamplePartialEpisode() {
	eps := []*misc.Episode{
		misc.ParseEpisode("1.0"),
		misc.ParseEpisode("1.1"),
	}
	for _, ep := range eps {
		fmt.Printf("%#v %s\n", ep, ep)
	}
	for _, ep := range eps {
		ep.Parts = 2
		fmt.Printf("%s\n", ep)
	}

	// Output:
	// &misc.Episode{Type:1, Number:1, Part:0, Parts:0} 1.0
	// &misc.Episode{Type:1, Number:1, Part:1, Parts:0} 1.1
	// 1.00
	// 1.50
}
Example #4
0
func ExampleEpisodeList_Add() {
	a := misc.ParseEpisodeList("1-3")
	a.Add(misc.ParseEpisode("3.1"))
	fmt.Println(a)

	a.Add(misc.ParseEpisode("4.0"))
	fmt.Println(a)

	a.Add(misc.ParseEpisode("4"))
	fmt.Println(a)

	a.Add(misc.ParseEpisode("5.1"))
	fmt.Println(a)

	a.Add(misc.ParseEpisode("6"))
	fmt.Println(a)

	// Output:
	// 1-3
	// 1-4.0
	// 1-4
	// 1-4,5.1
	// 1-4,5.1,6
}
Example #5
0
// Convenience method that parses the string into an Episode
// before doing the Episode search.
func (a *Anime) EpisodeByString(name string) *Episode {
	return a.Episode(misc.ParseEpisode(name))
}