From f4c91466c0e3293f56be6810501d03b2eeaef497 Mon Sep 17 00:00:00 2001 From: Oliver Kahrmann Date: Sat, 11 Apr 2026 21:01:56 +0200 Subject: [PATCH] Change TVShow.id to string Some IDs are not integers, e.g. imdb IDs, and they may also be used in ``. Kodi's code writes `` as string: `XMLUtils::SetString(movie, "id", GetUniqueID());`. --- tvshow.go | 2 +- tvshow_test.go | 25 +++++++++++++++++++-- tvshow_ttid.nfo | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 tvshow_ttid.nfo diff --git a/tvshow.go b/tvshow.go index fdb3b52..64c3b7c 100644 --- a/tvshow.go +++ b/tvshow.go @@ -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"` diff --git a/tvshow_test.go b/tvshow_test.go index 02a9a1b..a0e6cb3 100644 --- a/tvshow_test.go +++ b/tvshow_test.go @@ -8,7 +8,8 @@ import ( ) const ( - tvshowNfoFile = "tvshow.nfo" + tvshowNfoFile = "tvshow.nfo" + tvshowNfoFileTTID = "tvshow_ttid.nfo" ) func TestTVShowMarshal(t *testing.T) { @@ -29,7 +30,7 @@ func TestTVShowMarshal(t *testing.T) { MPAA: "23", Playcount: 1, Lastplayed: "", - Id: 123, + Id: "123", Premiered: "", Year: "2021", Status: "", @@ -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 { diff --git a/tvshow_ttid.nfo b/tvshow_ttid.nfo new file mode 100644 index 0000000..a33a6b7 --- /dev/null +++ b/tvshow_ttid.nfo @@ -0,0 +1,60 @@ + + + Space Janitors + + tt2266399 + 264109 + tt2266399 + + + 7.5 + 54 + + + 0 + 0 + 24 + 3 + Two janitors, Mike Chet and Darby Richards, serve aboard an iconic space station buffing out blaster burns and mopping up hero guts. + + 2012-11-09 + + Ended + YouTube + 4 + + {"imdb":"tt2266399","tvdb":"264109"} + Comedy + Science Fiction + + Brendan Halloran + Darby Richards + 0 + + + Pat Thornton + Mike Chet + 1 + + + Scott Yamamura + Dennis 4862 + 3 + + + Tess Degenstein + LN6-K + 4 + + + Evany Rosen + Edith Kingpin + 5 + + + MediaElch + 2.10.6 + 20 + 2024-03-28T23:47:23Z + +