番組登録を追加(登録時の過去回の選択、一時停止・再開・解除、既知の回の記録)
This commit is contained in:
@@ -22,6 +22,7 @@ var platformTokenPattern = regexp.MustCompile(`(?i)(platform_token=)[^&\s]+`)
|
||||
|
||||
type NewerFetcher interface {
|
||||
FetchNewer(context.Context, string) ([]tver.Episode, error)
|
||||
FetchSeriesEpisodes(context.Context, string) ([]tver.Episode, error)
|
||||
}
|
||||
|
||||
type cacheEntry struct {
|
||||
@@ -36,6 +37,8 @@ type newerOptions struct {
|
||||
|
||||
type episodeView struct {
|
||||
ID string
|
||||
SeriesID string
|
||||
SubscriptionAction subscriptionActionView
|
||||
Genre string
|
||||
Status string
|
||||
StatusText string
|
||||
@@ -150,10 +153,27 @@ func (s *server) newerView(ctx context.Context, options newerOptions) newerView
|
||||
view.ErrorText = "状態を取得できませんでした"
|
||||
return view
|
||||
}
|
||||
seriesIDs := make([]string, 0, len(visible))
|
||||
seenSeries := make(map[string]bool)
|
||||
for _, episode := range visible {
|
||||
if episode.SeriesID != "" && !seenSeries[episode.SeriesID] {
|
||||
seriesIDs = append(seriesIDs, episode.SeriesID)
|
||||
seenSeries[episode.SeriesID] = true
|
||||
}
|
||||
}
|
||||
subscribed, err := s.jobs.SubscribedSeries(ctx, seriesIDs)
|
||||
if err != nil {
|
||||
s.logger.Printf("登録番組の状態取得に失敗: %v", err)
|
||||
view.Failed = true
|
||||
view.ErrorText = "登録番組の状態を取得できませんでした"
|
||||
return view
|
||||
}
|
||||
for _, episode := range visible {
|
||||
endAt := time.Unix(episode.EndAt, 0).In(s.zone)
|
||||
view.Episodes = append(view.Episodes, episodeView{
|
||||
ID: episode.ID,
|
||||
SeriesID: episode.SeriesID,
|
||||
SubscriptionAction: subscriptionActionView{ID: episode.ID, Genre: options.genre, Subscribed: subscribed[episode.SeriesID]},
|
||||
Genre: options.genre,
|
||||
Status: statuses[episode.ID],
|
||||
StatusText: statusText(statuses[episode.ID]),
|
||||
|
||||
Reference in New Issue
Block a user