enclosure.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  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 strings.HasPrefix(e.MimeType, "video") {
  18. switch e.MimeType {
  19. // Solution from this stackoverflow discussion:
  20. // https://stackoverflow.com/questions/15277147/m4v-mimetype-video-mp4-or-video-m4v/66945470#66945470
  21. // tested at the time of this commit (06/2023) on latest Firefox & Vivaldi on this feed
  22. // https://www.florenceporcel.com/podcast/lfhdu.xml
  23. case "video/m4v":
  24. return "video/x-m4v"
  25. }
  26. }
  27. return e.MimeType
  28. }
  29. // EnclosureList represents a list of attachments.
  30. type EnclosureList []*Enclosure