Skip to content

Commit

Permalink
fix bug on video dimensions parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
AmarnathCJD committed Aug 5, 2024
1 parent b304fc2 commit 455d8fa
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions telegram/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,13 +596,17 @@ func gatherVideoMetadata(path string, attrs []DocumentAttribute) ([]DocumentAttr
}

lines := strings.Split(strings.TrimSpace(string(out)), "\n")
for i, line := range lines {
if i == 0 {
width, _ = strconv.ParseInt(strings.TrimSpace(line), 10, 32)
} else if i == 1 {
height, _ = strconv.ParseInt(strings.TrimSpace(line), 10, 32)
} else if i == len(lines)-1 {
dur, _ = strconv.ParseFloat(strings.TrimSpace(line), 64)
dur, _ = strconv.ParseFloat(strings.TrimSpace(lines[len(lines)-1]), 64)

for _, line := range lines {
line = strings.TrimSpace(line)
if w, err := strconv.ParseInt(line, 10, 32); err == nil {
if width == 0 {
width = w
} else if height == 0 {
height = w
break
}
}
}

Expand Down

0 comments on commit 455d8fa

Please sign in to comment.