Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tvshow.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type TVShow struct {
MPAA string `xml:"mpaa,omitempty"`
Playcount int64 `xml:"playcount,omitempty"`
Lastplayed string `xml:"lastplayed,omitempty"`
Id int64 `xml:"id,omitempty"`
Id string `xml:"id,omitempty"`
Uniqueid []UniqueId `xml:"uniqueid,omitempty"`
Genre []string `xml:"genre,omitempty"`
Premiered string `xml:"premiered,omitempty"`
Expand Down
25 changes: 23 additions & 2 deletions tvshow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
)

const (
tvshowNfoFile = "tvshow.nfo"
tvshowNfoFile = "tvshow.nfo"
tvshowNfoFileTTID = "tvshow_ttid.nfo"
)

func TestTVShowMarshal(t *testing.T) {
Expand All @@ -29,7 +30,7 @@ func TestTVShowMarshal(t *testing.T) {
MPAA: "23",
Playcount: 1,
Lastplayed: "",
Id: 123,
Id: "123",
Premiered: "",
Year: "2021",
Status: "",
Expand Down Expand Up @@ -124,6 +125,26 @@ func TestTVShowUnmarshal(t *testing.T) {
t.Logf("Title: %s\n", m.Title)
}

// Some IDs are not numbers
func TestTVShowUnmarshalTextID(t *testing.T) {
b, err := ioutil.ReadFile(tvshowNfoFileTTID)
if err != nil {
t.Fatalf("Could not read file '%s': %v\n", tvshowNfoFile, err)
}

m := TVShow{}
err = xml.Unmarshal(b, &m)
if err != nil {
t.Logf("Error unmarshalling tvshow: %v\n", err)
t.Fail()
}
t.Logf("Title: %s\n", m.Title)

if m.Id != "tt2266399" {
t.Errorf("expected 'tt2266399' got '%s'", m.Id)
}
}

func TestTVShowNfoReader(t *testing.T) {
f, err := os.Open(tvshowNfoFile)
if err != nil {
Expand Down
60 changes: 60 additions & 0 deletions tvshow_ttid.nfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<tvshow>
<title>Space Janitors</title>
<showtitle></showtitle>
<uniqueid default="true" type="imdb">tt2266399</uniqueid>
<uniqueid type="tvdb">264109</uniqueid>
<id>tt2266399</id>
<ratings>
<rating name="tvdb" default="true" max="10">
<value>7.5</value>
<votes>54</votes>
</rating>
</ratings>
<userrating>0</userrating>
<top250>0</top250>
<episode>24</episode>
<season>3</season>
<plot>Two janitors, Mike Chet and Darby Richards, serve aboard an iconic space station buffing out blaster burns and mopping up hero guts.</plot>
<mpaa></mpaa>
<premiered>2012-11-09</premiered>
<dateadded></dateadded>
<status>Ended</status>
<studio>YouTube</studio>
<runtime>4</runtime>
<trailer></trailer>
<episodeguide>{&quot;imdb&quot;:&quot;tt2266399&quot;,&quot;tvdb&quot;:&quot;264109&quot;}</episodeguide>
<genre>Comedy</genre>
<genre>Science Fiction</genre>
<actor>
<name>Brendan Halloran</name>
<role>Darby Richards</role>
<order>0</order>
</actor>
<actor>
<name>Pat Thornton</name>
<role>Mike Chet</role>
<order>1</order>
</actor>
<actor>
<name>Scott Yamamura</name>
<role>Dennis 4862</role>
<order>3</order>
</actor>
<actor>
<name>Tess Degenstein</name>
<role>LN6-K</role>
<order>4</order>
</actor>
<actor>
<name>Evany Rosen</name>
<role>Edith Kingpin</role>
<order>5</order>
</actor>
<generator>
<appname>MediaElch</appname>
<appversion>2.10.6</appversion>
<kodiversion>20</kodiversion>
<datetime>2024-03-28T23:47:23Z</datetime>
</generator>
</tvshow>
Loading