Skip to content

Commit 65f910e

Browse files
committed
fix(video): Align data model with Pixabay's new API, add 'thumbnail' field, remove 'picture_id' (fixed #122)
Adjusted the video module's data model to match Pixabay's updated API response. Removed the outdated 'picture_id' field and added 'thumbnail' fields to prevent errors and ensure smooth operation.
1 parent ef68906 commit 65f910e

File tree

7 files changed

+176
-118
lines changed

7 files changed

+176
-118
lines changed

core/data/src/main/java/com/wei/picquest/core/data/model/VideoDetail.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ fun NetworkVideoDetail.asExternalModel() = VideoDetail(
1313
type = this.type,
1414
tags = this.tags,
1515
duration = this.duration,
16-
pictureId = this.pictureId,
1716
videos = this.videos.asExternalModel(),
1817
views = this.views,
1918
downloads = this.downloads,
@@ -36,4 +35,5 @@ fun NetworkVideoDetailSize.asExternalModel() = VideoDetailSize(
3635
width = this.width,
3736
height = this.height,
3837
size = this.size,
38+
thumbnail = this.thumbnail,
3939
)

core/model/src/main/java/com/wei/picquest/core/model/data/VideoDetail.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ data class VideoDetail(
66
val type: String,
77
val tags: String,
88
val duration: Int,
9-
val pictureId: String,
109
val videos: VideoStreams,
1110
val views: Int,
1211
val downloads: Int,
@@ -29,4 +28,5 @@ data class VideoDetailSize(
2928
val width: Int,
3029
val height: Int,
3130
val size: Long,
31+
val thumbnail: String,
3232
)
Lines changed: 158 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,182 @@
11
{
2-
"total": 3,
3-
"totalHits": 3,
4-
"hits": [
2+
"total":4,
3+
"totalHits":4,
4+
"hits":[
55
{
6-
"id": 26451,
7-
"pageURL": "https://pixabay.com/videos/id-26451/",
8-
"type": "film",
9-
"tags": "cat, happy, animal",
10-
"duration": 13,
11-
"picture_id": "812497041-23341c0640e56f02b0026e5b218ed3d904c28c2659fc45b01f955081ae5bcf59-d",
12-
"videos": {
13-
"large": {
14-
"url": "https://cdn.pixabay.com/vimeo/358778852/cat-26451.mp4?width=1920&hash=c8cdad290d1a1f4769d27507dd118d5fa516c4d8",
15-
"width": 1920,
16-
"height": 1080,
17-
"size": 4880942
6+
"id":11543,
7+
"pageURL":"https://pixabay.com/videos/id-11543/",
8+
"type":"film",
9+
"tags":"music box, carousel, music",
10+
"duration":64,
11+
"videos":{
12+
"large":{
13+
"url":"https://cdn.pixabay.com/video/2017/08/23/11543-231232163_large.mp4",
14+
"width":1920,
15+
"height":1080,
16+
"size":25726331,
17+
"thumbnail":"https://cdn.pixabay.com/video/2017/08/23/11543-231232163_large.jpg"
1818
},
19-
"medium": {
20-
"url": "https://cdn.pixabay.com/vimeo/358778852/cat-26451.mp4?width=1280&hash=3881821c4ebfbcff7ad26565e0e7d4799d89489a",
21-
"width": 1280,
22-
"height": 720,
23-
"size": 2400471
19+
"medium":{
20+
"url":"https://cdn.pixabay.com/video/2017/08/23/11543-231232163_medium.mp4",
21+
"width":1280,
22+
"height":720,
23+
"size":11295563,
24+
"thumbnail":"https://cdn.pixabay.com/video/2017/08/23/11543-231232163_medium.jpg"
2425
},
25-
"small": {
26-
"url": "https://cdn.pixabay.com/vimeo/358778852/cat-26451.mp4?width=960&hash=7c54108fa571d78b323b9354b13b0e2bb22f265a",
27-
"width": 960,
28-
"height": 540,
29-
"size": 1606121
26+
"small":{
27+
"url":"https://cdn.pixabay.com/video/2017/08/23/11543-231232163_small.mp4",
28+
"width":960,
29+
"height":540,
30+
"size":7681183,
31+
"thumbnail":"https://cdn.pixabay.com/video/2017/08/23/11543-231232163_small.jpg"
3032
},
31-
"tiny": {
32-
"url": "https://cdn.pixabay.com/vimeo/358778852/cat-26451.mp4?width=640&hash=e31e3b41a6c9e838e934bfa9bcfc6c8d4686cf34",
33-
"width": 640,
34-
"height": 360,
35-
"size": 671151
33+
"tiny":{
34+
"url":"https://cdn.pixabay.com/video/2017/08/23/11543-231232163_tiny.mp4",
35+
"width":640,
36+
"height":360,
37+
"size":3389174,
38+
"thumbnail":"https://cdn.pixabay.com/video/2017/08/23/11543-231232163_tiny.jpg"
3639
}
3740
},
38-
"views": 24055,
39-
"downloads": 9349,
40-
"likes": 92,
41-
"comments": 20,
42-
"user_id": 13034296,
43-
"user": "talipozer",
44-
"userImageURL": ""
41+
"views":189557,
42+
"downloads":81491,
43+
"likes":750,
44+
"comments":202,
45+
"user_id":2336747,
46+
"user":"isakarakus",
47+
"userImageURL":"https://cdn.pixabay.com/user/2016/09/21/21-33-28-7_250x250.jpg"
4548
},
4649
{
47-
"id": 2911,
48-
"pageURL": "https://pixabay.com/videos/id-2911/",
49-
"type": "film",
50-
"tags": "cat, cats, lazy",
51-
"duration": 20,
52-
"picture_id": "568296387-20dc5252018653569acaab9576e70bc7c7e407eb9497db84db1f0a221c39e32d-d",
53-
"videos": {
54-
"large": {
55-
"url": "https://cdn.pixabay.com/vimeo/164639743/cat-2911.mp4?width=1920&hash=ea47340c69dce271c915bf2bc6bb5efef3da797c",
56-
"width": 1920,
57-
"height": 1080,
58-
"size": 11063802
50+
"id":5317,
51+
"pageURL":"https://pixabay.com/videos/id-5317/",
52+
"type":"film",
53+
"tags":"music box, carousel, toy",
54+
"duration":78,
55+
"videos":{
56+
"large":{
57+
"url":"",
58+
"width":0,
59+
"height":0,
60+
"size":0,
61+
"thumbnail":""
5962
},
60-
"medium": {
61-
"url": "https://cdn.pixabay.com/vimeo/164639743/cat-2911.mp4?width=1280&hash=438c8c8033af16e66a03c9236957e0ab82ccebea",
62-
"width": 1280,
63-
"height": 720,
64-
"size": 6160427
63+
"medium":{
64+
"url":"https://cdn.pixabay.com/video/2016/09/18/5317-183300227_medium.mp4",
65+
"width":1280,
66+
"height":720,
67+
"size":20090630,
68+
"thumbnail":"https://cdn.pixabay.com/video/2016/09/18/5317-183300227_medium.jpg"
6569
},
66-
"small": {
67-
"url": "https://cdn.pixabay.com/vimeo/164639743/cat-2911.mp4?width=960&hash=75923149aa3c2e036435aa17abc45912a26cfa94",
68-
"width": 960,
69-
"height": 540,
70-
"size": 3572267
70+
"small":{
71+
"url":"https://cdn.pixabay.com/video/2016/09/18/5317-183300227_small.mp4",
72+
"width":960,
73+
"height":540,
74+
"size":11907779,
75+
"thumbnail":"https://cdn.pixabay.com/video/2016/09/18/5317-183300227_small.jpg"
7176
},
72-
"tiny": {
73-
"url": "https://cdn.pixabay.com/vimeo/164639743/cat-2911.mp4?width=640&hash=e0685c1462618d5573e047d85022acbba86d8aa1",
74-
"width": 640,
75-
"height": 360,
76-
"size": 1219438
77+
"tiny":{
78+
"url":"https://cdn.pixabay.com/video/2016/09/18/5317-183300227_tiny.mp4",
79+
"width":640,
80+
"height":360,
81+
"size":5705698,
82+
"thumbnail":"https://cdn.pixabay.com/video/2016/09/18/5317-183300227_tiny.jpg"
7783
}
7884
},
79-
"views": 18617,
80-
"downloads": 10409,
81-
"likes": 104,
82-
"comments": 26,
83-
"user_id": 1,
84-
"user": "Pixabay",
85-
"userImageURL": "https://cdn.pixabay.com/user/2014/10/13/11-29-23-818_250x250.png"
85+
"views":109748,
86+
"downloads":43833,
87+
"likes":380,
88+
"comments":98,
89+
"user_id":2114853,
90+
"user":"Luiz-Jorge-Artista",
91+
"userImageURL":"https://cdn.pixabay.com/user/2017/06/27/01-52-28-5_250x250.jpg"
8692
},
8793
{
88-
"id": 143654,
89-
"pageURL": "https://pixabay.com/videos/id-143654/",
90-
"type": "film",
91-
"tags": "cat, kitten, stray cat",
92-
"duration": 77,
93-
"picture_id": "1574564044-6813360a2af587b3a9fbb58ec9497fd15f06a189129c18e044f52715eacf6ef0-d",
94-
"videos": {
95-
"large": {
96-
"url": "https://cdn.pixabay.com/vimeo/784129635/cat-143654.mp4?width=1920&hash=b4f0f888802678d03b66ae5c7d0ed846314b88ab",
97-
"width": 1920,
98-
"height": 1080,
99-
"size": 54308977
94+
"id":46695,
95+
"pageURL":"https://pixabay.com/videos/id-46695/",
96+
"type":"film",
97+
"tags":"toy poodle, cute, animals",
98+
"duration":27,
99+
"videos":{
100+
"large":{
101+
"url":"https://cdn.pixabay.com/video/2020/08/08/46695-448489495_large.mp4",
102+
"width":1920,
103+
"height":1080,
104+
"size":18859416,
105+
"thumbnail":"https://cdn.pixabay.com/video/2020/08/08/46695-448489495_large.jpg"
100106
},
101-
"medium": {
102-
"url": "https://cdn.pixabay.com/vimeo/784129635/cat-143654.mp4?width=1280&hash=5cbce9ea3870804760bc923b0d3bfc33410f5a67",
103-
"width": 1280,
104-
"height": 720,
105-
"size": 27164139
107+
"medium":{
108+
"url":"https://cdn.pixabay.com/video/2020/08/08/46695-448489495_medium.mp4",
109+
"width":1280,
110+
"height":720,
111+
"size":8601040,
112+
"thumbnail":"https://cdn.pixabay.com/video/2020/08/08/46695-448489495_medium.jpg"
106113
},
107-
"small": {
108-
"url": "https://cdn.pixabay.com/vimeo/784129635/cat-143654.mp4?width=960&hash=cc246ba7a09e075df9f8df0a0a0812faafcb7fa8",
109-
"width": 960,
110-
"height": 540,
111-
"size": 16116099
114+
"small":{
115+
"url":"https://cdn.pixabay.com/video/2020/08/08/46695-448489495_small.mp4",
116+
"width":960,
117+
"height":540,
118+
"size":4625703,
119+
"thumbnail":"https://cdn.pixabay.com/video/2020/08/08/46695-448489495_small.jpg"
112120
},
113-
"tiny": {
114-
"url": "https://cdn.pixabay.com/vimeo/784129635/cat-143654.mp4?width=640&hash=e67bcab20be8278476ff35b83240c96401185701",
115-
"width": 640,
116-
"height": 360,
117-
"size": 7567345
121+
"tiny":{
122+
"url":"https://cdn.pixabay.com/video/2020/08/08/46695-448489495_tiny.mp4",
123+
"width":640,
124+
"height":360,
125+
"size":1680249,
126+
"thumbnail":"https://cdn.pixabay.com/video/2020/08/08/46695-448489495_tiny.jpg"
118127
}
119128
},
120-
"views": 1988,
121-
"downloads": 1096,
122-
"likes": 29,
123-
"comments": 1,
124-
"user_id": 26479159,
125-
"user": "colorful_square",
126-
"userImageURL": "https://cdn.pixabay.com/user/2022/09/23/04-26-24-253_250x250.jpg"
129+
"views":10966,
130+
"downloads":5552,
131+
"likes":53,
132+
"comments":23,
133+
"user_id":6149479,
134+
"user":"ElenLackner",
135+
"userImageURL":"https://cdn.pixabay.com/user/2020/02/26/17-33-01-918_250x250.jpg"
136+
},
137+
{
138+
"id":60280,
139+
"pageURL":"https://pixabay.com/videos/id-60280/",
140+
"type":"film",
141+
"tags":"xylophone, music, baby",
142+
"duration":13,
143+
"videos":{
144+
"large":{
145+
"url":"https://cdn.pixabay.com/video/2020/12/25/60280-495376594_large.mp4",
146+
"width":1920,
147+
"height":1080,
148+
"size":6848634,
149+
"thumbnail":"https://cdn.pixabay.com/video/2020/12/25/60280-495376594_large.jpg"
150+
},
151+
"medium":{
152+
"url":"https://cdn.pixabay.com/video/2020/12/25/60280-495376594_medium.mp4",
153+
"width":1280,
154+
"height":720,
155+
"size":3037037,
156+
"thumbnail":"https://cdn.pixabay.com/video/2020/12/25/60280-495376594_medium.jpg"
157+
},
158+
"small":{
159+
"url":"https://cdn.pixabay.com/video/2020/12/25/60280-495376594_small.mp4",
160+
"width":960,
161+
"height":540,
162+
"size":2034397,
163+
"thumbnail":"https://cdn.pixabay.com/video/2020/12/25/60280-495376594_small.jpg"
164+
},
165+
"tiny":{
166+
"url":"https://cdn.pixabay.com/video/2020/12/25/60280-495376594_tiny.mp4",
167+
"width":640,
168+
"height":360,
169+
"size":957738,
170+
"thumbnail":"https://cdn.pixabay.com/video/2020/12/25/60280-495376594_tiny.jpg"
171+
}
172+
},
173+
"views":7734,
174+
"downloads":4235,
175+
"likes":28,
176+
"comments":8,
177+
"user_id":2851152,
178+
"user":"tiburi",
179+
"userImageURL":"https://cdn.pixabay.com/user/2020/09/25/12-12-02-337_250x250.jpg"
127180
}
128181
]
129182
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"total": 3,
3-
"totalHits": 3,
2+
"total": 4,
3+
"totalHits": 4,
44
"hits": []
55
}

core/network/src/main/java/com/wei/picquest/core/network/model/NetworkSearchVideos.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ data class NetworkVideoDetail(
2828
val tags: String,
2929
@SerialName("duration")
3030
val duration: Int,
31-
@SerialName("picture_id")
32-
val pictureId: String,
3331
@SerialName("videos")
3432
val videos: NetworkVideoStreams,
3533
@SerialName("views")
@@ -70,4 +68,6 @@ data class NetworkVideoDetailSize(
7068
val height: Int,
7169
@SerialName("size")
7270
val size: Long,
71+
@SerialName("thumbnail")
72+
val thumbnail: String,
7373
)

feature/video/src/main/java/com/wei/picquest/feature/video/videolibrary/VideoLibraryScreen.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,13 @@ fun rememberExoPlayerInstance(
174174
videoScalingMode = C.VIDEO_SCALING_MODE_SCALE_TO_FIT
175175
repeatMode = Player.REPEAT_MODE_ONE
176176

177-
addListener(object : Player.Listener {
178-
override fun onPlaybackStateChanged(state: Int) {
179-
isPlayerReady.value = (state == Player.STATE_READY)
180-
}
181-
})
177+
addListener(
178+
object : Player.Listener {
179+
override fun onPlaybackStateChanged(state: Int) {
180+
isPlayerReady.value = (state == Player.STATE_READY)
181+
}
182+
},
183+
)
182184
}
183185
}
184186
}
@@ -254,31 +256,34 @@ val fakeVideoDetails = listOf(
254256
type = "",
255257
tags = "",
256258
duration = 0,
257-
pictureId = "",
258259
videos = VideoStreams(
259260
large = VideoDetailSize(
260261
url = "",
261262
width = 0,
262263
height = 0,
263264
size = 0,
265+
thumbnail = "",
264266
),
265267
medium = VideoDetailSize(
266268
url = "",
267269
width = 0,
268270
height = 0,
269271
size = 0,
272+
thumbnail = "",
270273
),
271274
small = VideoDetailSize(
272275
url = "",
273276
width = 0,
274277
height = 0,
275278
size = 0,
279+
thumbnail = "",
276280
),
277281
tiny = VideoDetailSize(
278282
url = "",
279283
width = 0,
280284
height = 0,
281285
size = 0,
286+
thumbnail = "",
282287
),
283288
),
284289
views = 0,

0 commit comments

Comments
 (0)