enclosure.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
  2. // SPDX-License-Identifier: Apache-2.0
  3. package model // import "miniflux.app/v2/internal/model"
  4. import "strings"
  5. // Enclosure represents an attachment.
  6. type Enclosure struct {
  7. ID int64 `json:"id"`
  8. UserID int64 `json:"user_id"`
  9. EntryID int64 `json:"entry_id"`
  10. URL string `json:"url"`
  11. MimeType string `json:"mime_type"`
  12. Size int64 `json:"size"`
  13. MediaProgression int64 `json:"media_progression"`
  14. }
  15. // Html5MimeType will modify the actual MimeType to allow direct playback from HTML5 player for some kind of MimeType
  16. func (e Enclosure) Html5MimeType() string {
  17. if e.MimeType == "video/m4v" {
  18. return "video/x-m4v"
  19. }
  20. return e.MimeType
  21. }
  22. // EnclosureList represents a list of attachments.
  23. type EnclosureList []*Enclosure
  24. func (el EnclosureList) ContainsAudioOrVideo() bool {
  25. for _, enclosure := range el {
  26. if strings.Contains(enclosure.MimeType, "audio/") || strings.Contains(enclosure.MimeType, "video/") {
  27. return true
  28. }
  29. }
  30. return false
  31. }