diff options
| author | Heinrich 'Henrik' Langos <gumbo2000@noreply@mills.io> | 2023-01-04 11:34:40 +0000 |
|---|---|---|
| committer | James Mills <james@mills.io> | 2023-01-04 11:34:40 +0000 |
| commit | c0138ec10e28efd2a31e88ba94e991a8fb8145ae (patch) | |
| tree | 71d193d54e4c87799a84602c7a7260188b49d77a /media/video.go | |
| parent | 0a793f7d3fed115cdd242371490009db340deb00 (diff) | |
feat: Prefer external thumbnail over embedded ones (#44)
This changes the handling of external thumbnails as mentioned in issue #41
If there is an external thumbnail file, it is going to be used, even if there is an embedded thumbnail in the mp4 file.
Reviewed-on: https://git.mills.io/prologic/tube/pulls/44
Co-authored-by: Heinrich 'Henrik' Langos <gumbo2000@noreply@mills.io>
Co-committed-by: Heinrich 'Henrik' Langos <gumbo2000@noreply@mills.io>
Diffstat (limited to 'media/video.go')
| -rw-r--r-- | media/video.go | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/media/video.go b/media/video.go index cc78973..fdd30f4 100644 --- a/media/video.go +++ b/media/video.go @@ -101,21 +101,22 @@ func ParseVideo(p *Path, name string) (*Video, error) { log.Println("Failed to read yml for", v.Path) } - // Add thumbnail (if exists) + // Add thumbnail from embedded tags (if exists) pic := m.Picture() if pic != nil { v.Thumb = pic.Data v.ThumbType = pic.MIMEType - } else { - thumbFn := fmt.Sprintf("%s.jpg", strings.TrimSuffix(pth, filepath.Ext(pth))) - if utils.FileExists(thumbFn) { - data, err := ioutil.ReadFile(fmt.Sprintf("%s.jpg", strings.TrimSuffix(pth, filepath.Ext(pth)))) - if err != nil { - return nil, err - } - v.Thumb = data - v.ThumbType = "image/jpeg" + } + + // Add thumbnail from external file (if exists) + if utils.FileExists(fmt.Sprintf("%s.jpg", strings.TrimSuffix(pth, filepath.Ext(pth)))) { + data, err := ioutil.ReadFile(fmt.Sprintf("%s.jpg", strings.TrimSuffix(pth, filepath.Ext(pth)))) + if err != nil { + log.Println("Failed to read thumbnail file for", v.Path) + return nil, err } + v.Thumb = data + v.ThumbType = "image/jpeg" } return v, nil |
