|
@@ -2,7 +2,6 @@ package movies
|
2
|
2
|
|
3
|
3
|
import (
|
4
|
4
|
"encoding/json"
|
5
|
|
- "fmt"
|
6
|
5
|
"strconv"
|
7
|
6
|
"strings"
|
8
|
7
|
)
|
|
@@ -86,19 +85,14 @@ func (m *Movie) FillFromOMDB() error {
|
86
|
85
|
}
|
87
|
86
|
|
88
|
87
|
if m.Rating == nil {
|
89
|
|
- note, err := strconv.ParseFloat(m.OMDB.IMDBRating, 64)
|
90
|
|
- if err != nil {
|
91
|
|
- return fmt.Errorf("cannot convert %q to float64: %w", m.OMDB.IMDBRating, err)
|
92
|
|
- }
|
|
88
|
+ m.Rating = &Rating{}
|
93
|
89
|
|
94
|
|
- votes, err := strconv.ParseInt(strings.ReplaceAll(m.OMDB.IMDBVotes, ",", ""), 10, 64)
|
95
|
|
- if err != nil {
|
96
|
|
- return fmt.Errorf("cannot convert %q to int: %w", m.OMDB.IMDBVotes, err)
|
|
90
|
+ if note, err := strconv.ParseFloat(m.OMDB.IMDBRating, 64); err == nil {
|
|
91
|
+ m.Rating.Note = note
|
97
|
92
|
}
|
98
|
93
|
|
99
|
|
- m.Rating = &Rating{
|
100
|
|
- Note: note,
|
101
|
|
- Votes: votes,
|
|
94
|
+ if votes, err := strconv.ParseInt(strings.ReplaceAll(m.OMDB.IMDBVotes, ",", ""), 10, 64); err == nil {
|
|
95
|
+ m.Rating.Votes = votes
|
102
|
96
|
}
|
103
|
97
|
}
|
104
|
98
|
|