enclosure.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2017 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package model // import "miniflux.app/model"
  5. import "strings"
  6. // Enclosure represents an attachment.
  7. type Enclosure struct {
  8. ID int64 `json:"id"`
  9. UserID int64 `json:"user_id"`
  10. EntryID int64 `json:"entry_id"`
  11. URL string `json:"url"`
  12. MimeType string `json:"mime_type"`
  13. Size int64 `json:"size"`
  14. MediaProgression int64 `json:"media_progression"`
  15. }
  16. // Html5MimeType will modify the actual MimeType to allow direct playback from HTML5 player for some kind of MimeType
  17. func (e Enclosure) Html5MimeType() string {
  18. if strings.HasPrefix(e.MimeType, "video") {
  19. switch e.MimeType {
  20. // Solution from this stackoverflow discussion:
  21. // https://stackoverflow.com/questions/15277147/m4v-mimetype-video-mp4-or-video-m4v/66945470#66945470
  22. // tested at the time of this commit (06/2023) on latest Firefox & Vivaldi on this feed
  23. // https://www.florenceporcel.com/podcast/lfhdu.xml
  24. case "video/m4v":
  25. return "video/x-m4v"
  26. }
  27. }
  28. return e.MimeType
  29. }
  30. // EnclosureList represents a list of attachments.
  31. type EnclosureList []*Enclosure