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>
This commit is contained in:
parent
0a793f7d3f
commit
c0138ec10e
1 changed files with 11 additions and 10 deletions
|
@ -101,22 +101,23 @@ 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) {
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue