From 449e618ee834bf69f52e35df495708cd04435dab Mon Sep 17 00:00:00 2001 From: aunefyren Date: Tue, 12 Dec 2023 16:24:58 +0100 Subject: [PATCH] Tautulli data parsing --- models/tautulli.go | 26 +++++++++++++------------- modules/statistics.go | 31 ++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/models/tautulli.go b/models/tautulli.go index dfd61ef..1a8cad2 100644 --- a/models/tautulli.go +++ b/models/tautulli.go @@ -37,19 +37,19 @@ type TautulliHistoryItem struct { Secure interface{} `json:"secure"` Relayed interface{} `json:"relayed"` MediaType string `json:"media_type"` - RatingKey int `json:"rating_key"` - ParentRatingKey int `json:"parent_rating_key"` - GrandparentRatingKey int `json:"grandparent_rating_key"` - FullTitle string `json:"full_title"` - Title string `json:"title"` - ParentTitle string `json:"parent_title"` - GrandparentTitle string `json:"grandparent_title"` - OriginalTitle string `json:"original_title"` - Year int `json:"year"` - MediaIndex string `json:"media_index"` - ParentMediaIndex string `json:"parent_media_index"` - Thumb string `json:"thumb"` - OriginallyAvailableAt string `json:"originally_available_at"` + RatingKey *int `json:"rating_key,omitempty"` + ParentRatingKey *int `json:"parent_rating_key,omitempty"` + GrandparentRatingKey *int `json:"grandparent_rating_key,omitempty"` + FullTitle *string `json:"full_title,omitempty"` + Title *string `json:"title,omitempty"` + ParentTitle *string `json:"parent_title,omitempty"` + GrandparentTitle *string `json:"grandparent_title,omitempty"` + OriginalTitle *string `json:"original_title,omitempty"` + Year int `json:"year,omitempty"` + MediaIndex *string `json:"media_index,omitempty"` + ParentMediaIndex *string `json:"parent_media_index,omitempty"` + Thumb *string `json:"thumb,omitempty"` + OriginallyAvailableAt *string `json:"originally_available_at,omitempty"` GUID string `json:"guid"` TranscodeDecision string `json:"transcode_decision"` PercentComplete int `json:"percent_complete"` diff --git a/modules/statistics.go b/modules/statistics.go index c76383f..b837a4d 100644 --- a/modules/statistics.go +++ b/modules/statistics.go @@ -235,27 +235,40 @@ func WrapperrDownloadDays(ID int, wrapperr_data []models.WrapperrDay, loop_inter continue } + if tautulli_data[j].FullTitle == nil || + tautulli_data[j].GrandparentRatingKey == nil || + tautulli_data[j].GrandparentTitle == nil || + tautulli_data[j].OriginalTitle == nil || + tautulli_data[j].ParentRatingKey == nil || + tautulli_data[j].ParentTitle == nil || + tautulli_data[j].RatingKey == nil || + tautulli_data[j].Title == nil || + tautulli_data[j].OriginallyAvailableAt == nil { + log.Println("Tautulli item has missing data point(s). Unable to process statistics. Skipping data.") + continue + } + // Translate data to own struct tautulli_entry := models.TautulliEntry{ Date: tautulli_data[j].Date, RowID: tautulli_data[j].RowID, Duration: tautulli_data[j].Duration, FriendlyName: tautulli_data[j].FriendlyName, - FullTitle: tautulli_data[j].FullTitle, - GrandparentRatingKey: tautulli_data[j].GrandparentRatingKey, - GrandparentTitle: tautulli_data[j].GrandparentTitle, - OriginalTitle: tautulli_data[j].OriginalTitle, + FullTitle: *tautulli_data[j].FullTitle, + GrandparentRatingKey: *tautulli_data[j].GrandparentRatingKey, + GrandparentTitle: *tautulli_data[j].GrandparentTitle, + OriginalTitle: *tautulli_data[j].OriginalTitle, MediaType: tautulli_data[j].MediaType, - ParentRatingKey: tautulli_data[j].ParentRatingKey, - ParentTitle: tautulli_data[j].ParentTitle, + ParentRatingKey: *tautulli_data[j].ParentRatingKey, + ParentTitle: *tautulli_data[j].ParentTitle, PausedCounter: tautulli_data[j].PausedCounter, PercentComplete: tautulli_data[j].PercentComplete, - RatingKey: tautulli_data[j].RatingKey, - Title: tautulli_data[j].Title, + RatingKey: *tautulli_data[j].RatingKey, + Title: *tautulli_data[j].Title, User: tautulli_data[j].User, UserID: tautulli_data[j].UserID, Year: tautulli_data[j].Year, - OriginallyAvailableAt: tautulli_data[j].OriginallyAvailableAt, + OriginallyAvailableAt: *tautulli_data[j].OriginallyAvailableAt, } // Append to day data