Skip to content

Commit

Permalink
fix(video): Align data model with Pixabay's new API, add 'thumbnail' …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
azrael8576 committed Apr 17, 2024
1 parent ef68906 commit 65f910e
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ fun NetworkVideoDetail.asExternalModel() = VideoDetail(
type = this.type,
tags = this.tags,
duration = this.duration,
pictureId = this.pictureId,
videos = this.videos.asExternalModel(),
views = this.views,
downloads = this.downloads,
Expand All @@ -36,4 +35,5 @@ fun NetworkVideoDetailSize.asExternalModel() = VideoDetailSize(
width = this.width,
height = this.height,
size = this.size,
thumbnail = this.thumbnail,
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ data class VideoDetail(
val type: String,
val tags: String,
val duration: Int,
val pictureId: String,
val videos: VideoStreams,
val views: Int,
val downloads: Int,
Expand All @@ -29,4 +28,5 @@ data class VideoDetailSize(
val width: Int,
val height: Int,
val size: Long,
val thumbnail: String,
)
263 changes: 158 additions & 105 deletions core/network/src/main/assets/videos_page1.json
Original file line number Diff line number Diff line change
@@ -1,129 +1,182 @@
{
"total": 3,
"totalHits": 3,
"hits": [
"total":4,
"totalHits":4,
"hits":[
{
"id": 26451,
"pageURL": "https://pixabay.com/videos/id-26451/",
"type": "film",
"tags": "cat, happy, animal",
"duration": 13,
"picture_id": "812497041-23341c0640e56f02b0026e5b218ed3d904c28c2659fc45b01f955081ae5bcf59-d",
"videos": {
"large": {
"url": "https://cdn.pixabay.com/vimeo/358778852/cat-26451.mp4?width=1920&hash=c8cdad290d1a1f4769d27507dd118d5fa516c4d8",
"width": 1920,
"height": 1080,
"size": 4880942
"id":11543,
"pageURL":"https://pixabay.com/videos/id-11543/",
"type":"film",
"tags":"music box, carousel, music",
"duration":64,
"videos":{
"large":{
"url":"https://cdn.pixabay.com/video/2017/08/23/11543-231232163_large.mp4",
"width":1920,
"height":1080,
"size":25726331,
"thumbnail":"https://cdn.pixabay.com/video/2017/08/23/11543-231232163_large.jpg"
},
"medium": {
"url": "https://cdn.pixabay.com/vimeo/358778852/cat-26451.mp4?width=1280&hash=3881821c4ebfbcff7ad26565e0e7d4799d89489a",
"width": 1280,
"height": 720,
"size": 2400471
"medium":{
"url":"https://cdn.pixabay.com/video/2017/08/23/11543-231232163_medium.mp4",
"width":1280,
"height":720,
"size":11295563,
"thumbnail":"https://cdn.pixabay.com/video/2017/08/23/11543-231232163_medium.jpg"
},
"small": {
"url": "https://cdn.pixabay.com/vimeo/358778852/cat-26451.mp4?width=960&hash=7c54108fa571d78b323b9354b13b0e2bb22f265a",
"width": 960,
"height": 540,
"size": 1606121
"small":{
"url":"https://cdn.pixabay.com/video/2017/08/23/11543-231232163_small.mp4",
"width":960,
"height":540,
"size":7681183,
"thumbnail":"https://cdn.pixabay.com/video/2017/08/23/11543-231232163_small.jpg"
},
"tiny": {
"url": "https://cdn.pixabay.com/vimeo/358778852/cat-26451.mp4?width=640&hash=e31e3b41a6c9e838e934bfa9bcfc6c8d4686cf34",
"width": 640,
"height": 360,
"size": 671151
"tiny":{
"url":"https://cdn.pixabay.com/video/2017/08/23/11543-231232163_tiny.mp4",
"width":640,
"height":360,
"size":3389174,
"thumbnail":"https://cdn.pixabay.com/video/2017/08/23/11543-231232163_tiny.jpg"
}
},
"views": 24055,
"downloads": 9349,
"likes": 92,
"comments": 20,
"user_id": 13034296,
"user": "talipozer",
"userImageURL": ""
"views":189557,
"downloads":81491,
"likes":750,
"comments":202,
"user_id":2336747,
"user":"isakarakus",
"userImageURL":"https://cdn.pixabay.com/user/2016/09/21/21-33-28-7_250x250.jpg"
},
{
"id": 2911,
"pageURL": "https://pixabay.com/videos/id-2911/",
"type": "film",
"tags": "cat, cats, lazy",
"duration": 20,
"picture_id": "568296387-20dc5252018653569acaab9576e70bc7c7e407eb9497db84db1f0a221c39e32d-d",
"videos": {
"large": {
"url": "https://cdn.pixabay.com/vimeo/164639743/cat-2911.mp4?width=1920&hash=ea47340c69dce271c915bf2bc6bb5efef3da797c",
"width": 1920,
"height": 1080,
"size": 11063802
"id":5317,
"pageURL":"https://pixabay.com/videos/id-5317/",
"type":"film",
"tags":"music box, carousel, toy",
"duration":78,
"videos":{
"large":{
"url":"",
"width":0,
"height":0,
"size":0,
"thumbnail":""
},
"medium": {
"url": "https://cdn.pixabay.com/vimeo/164639743/cat-2911.mp4?width=1280&hash=438c8c8033af16e66a03c9236957e0ab82ccebea",
"width": 1280,
"height": 720,
"size": 6160427
"medium":{
"url":"https://cdn.pixabay.com/video/2016/09/18/5317-183300227_medium.mp4",
"width":1280,
"height":720,
"size":20090630,
"thumbnail":"https://cdn.pixabay.com/video/2016/09/18/5317-183300227_medium.jpg"
},
"small": {
"url": "https://cdn.pixabay.com/vimeo/164639743/cat-2911.mp4?width=960&hash=75923149aa3c2e036435aa17abc45912a26cfa94",
"width": 960,
"height": 540,
"size": 3572267
"small":{
"url":"https://cdn.pixabay.com/video/2016/09/18/5317-183300227_small.mp4",
"width":960,
"height":540,
"size":11907779,
"thumbnail":"https://cdn.pixabay.com/video/2016/09/18/5317-183300227_small.jpg"
},
"tiny": {
"url": "https://cdn.pixabay.com/vimeo/164639743/cat-2911.mp4?width=640&hash=e0685c1462618d5573e047d85022acbba86d8aa1",
"width": 640,
"height": 360,
"size": 1219438
"tiny":{
"url":"https://cdn.pixabay.com/video/2016/09/18/5317-183300227_tiny.mp4",
"width":640,
"height":360,
"size":5705698,
"thumbnail":"https://cdn.pixabay.com/video/2016/09/18/5317-183300227_tiny.jpg"
}
},
"views": 18617,
"downloads": 10409,
"likes": 104,
"comments": 26,
"user_id": 1,
"user": "Pixabay",
"userImageURL": "https://cdn.pixabay.com/user/2014/10/13/11-29-23-818_250x250.png"
"views":109748,
"downloads":43833,
"likes":380,
"comments":98,
"user_id":2114853,
"user":"Luiz-Jorge-Artista",
"userImageURL":"https://cdn.pixabay.com/user/2017/06/27/01-52-28-5_250x250.jpg"
},
{
"id": 143654,
"pageURL": "https://pixabay.com/videos/id-143654/",
"type": "film",
"tags": "cat, kitten, stray cat",
"duration": 77,
"picture_id": "1574564044-6813360a2af587b3a9fbb58ec9497fd15f06a189129c18e044f52715eacf6ef0-d",
"videos": {
"large": {
"url": "https://cdn.pixabay.com/vimeo/784129635/cat-143654.mp4?width=1920&hash=b4f0f888802678d03b66ae5c7d0ed846314b88ab",
"width": 1920,
"height": 1080,
"size": 54308977
"id":46695,
"pageURL":"https://pixabay.com/videos/id-46695/",
"type":"film",
"tags":"toy poodle, cute, animals",
"duration":27,
"videos":{
"large":{
"url":"https://cdn.pixabay.com/video/2020/08/08/46695-448489495_large.mp4",
"width":1920,
"height":1080,
"size":18859416,
"thumbnail":"https://cdn.pixabay.com/video/2020/08/08/46695-448489495_large.jpg"
},
"medium": {
"url": "https://cdn.pixabay.com/vimeo/784129635/cat-143654.mp4?width=1280&hash=5cbce9ea3870804760bc923b0d3bfc33410f5a67",
"width": 1280,
"height": 720,
"size": 27164139
"medium":{
"url":"https://cdn.pixabay.com/video/2020/08/08/46695-448489495_medium.mp4",
"width":1280,
"height":720,
"size":8601040,
"thumbnail":"https://cdn.pixabay.com/video/2020/08/08/46695-448489495_medium.jpg"
},
"small": {
"url": "https://cdn.pixabay.com/vimeo/784129635/cat-143654.mp4?width=960&hash=cc246ba7a09e075df9f8df0a0a0812faafcb7fa8",
"width": 960,
"height": 540,
"size": 16116099
"small":{
"url":"https://cdn.pixabay.com/video/2020/08/08/46695-448489495_small.mp4",
"width":960,
"height":540,
"size":4625703,
"thumbnail":"https://cdn.pixabay.com/video/2020/08/08/46695-448489495_small.jpg"
},
"tiny": {
"url": "https://cdn.pixabay.com/vimeo/784129635/cat-143654.mp4?width=640&hash=e67bcab20be8278476ff35b83240c96401185701",
"width": 640,
"height": 360,
"size": 7567345
"tiny":{
"url":"https://cdn.pixabay.com/video/2020/08/08/46695-448489495_tiny.mp4",
"width":640,
"height":360,
"size":1680249,
"thumbnail":"https://cdn.pixabay.com/video/2020/08/08/46695-448489495_tiny.jpg"
}
},
"views": 1988,
"downloads": 1096,
"likes": 29,
"comments": 1,
"user_id": 26479159,
"user": "colorful_square",
"userImageURL": "https://cdn.pixabay.com/user/2022/09/23/04-26-24-253_250x250.jpg"
"views":10966,
"downloads":5552,
"likes":53,
"comments":23,
"user_id":6149479,
"user":"ElenLackner",
"userImageURL":"https://cdn.pixabay.com/user/2020/02/26/17-33-01-918_250x250.jpg"
},
{
"id":60280,
"pageURL":"https://pixabay.com/videos/id-60280/",
"type":"film",
"tags":"xylophone, music, baby",
"duration":13,
"videos":{
"large":{
"url":"https://cdn.pixabay.com/video/2020/12/25/60280-495376594_large.mp4",
"width":1920,
"height":1080,
"size":6848634,
"thumbnail":"https://cdn.pixabay.com/video/2020/12/25/60280-495376594_large.jpg"
},
"medium":{
"url":"https://cdn.pixabay.com/video/2020/12/25/60280-495376594_medium.mp4",
"width":1280,
"height":720,
"size":3037037,
"thumbnail":"https://cdn.pixabay.com/video/2020/12/25/60280-495376594_medium.jpg"
},
"small":{
"url":"https://cdn.pixabay.com/video/2020/12/25/60280-495376594_small.mp4",
"width":960,
"height":540,
"size":2034397,
"thumbnail":"https://cdn.pixabay.com/video/2020/12/25/60280-495376594_small.jpg"
},
"tiny":{
"url":"https://cdn.pixabay.com/video/2020/12/25/60280-495376594_tiny.mp4",
"width":640,
"height":360,
"size":957738,
"thumbnail":"https://cdn.pixabay.com/video/2020/12/25/60280-495376594_tiny.jpg"
}
},
"views":7734,
"downloads":4235,
"likes":28,
"comments":8,
"user_id":2851152,
"user":"tiburi",
"userImageURL":"https://cdn.pixabay.com/user/2020/09/25/12-12-02-337_250x250.jpg"
}
]
}
4 changes: 2 additions & 2 deletions core/network/src/main/assets/videos_page_end.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"total": 3,
"totalHits": 3,
"total": 4,
"totalHits": 4,
"hits": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ data class NetworkVideoDetail(
val tags: String,
@SerialName("duration")
val duration: Int,
@SerialName("picture_id")
val pictureId: String,
@SerialName("videos")
val videos: NetworkVideoStreams,
@SerialName("views")
Expand Down Expand Up @@ -70,4 +68,6 @@ data class NetworkVideoDetailSize(
val height: Int,
@SerialName("size")
val size: Long,
@SerialName("thumbnail")
val thumbnail: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,13 @@ fun rememberExoPlayerInstance(
videoScalingMode = C.VIDEO_SCALING_MODE_SCALE_TO_FIT
repeatMode = Player.REPEAT_MODE_ONE

addListener(object : Player.Listener {
override fun onPlaybackStateChanged(state: Int) {
isPlayerReady.value = (state == Player.STATE_READY)
}
})
addListener(
object : Player.Listener {
override fun onPlaybackStateChanged(state: Int) {
isPlayerReady.value = (state == Player.STATE_READY)
}
},
)
}
}
}
Expand Down Expand Up @@ -254,31 +256,34 @@ val fakeVideoDetails = listOf(
type = "",
tags = "",
duration = 0,
pictureId = "",
videos = VideoStreams(
large = VideoDetailSize(
url = "",
width = 0,
height = 0,
size = 0,
thumbnail = "",
),
medium = VideoDetailSize(
url = "",
width = 0,
height = 0,
size = 0,
thumbnail = "",
),
small = VideoDetailSize(
url = "",
width = 0,
height = 0,
size = 0,
thumbnail = "",
),
tiny = VideoDetailSize(
url = "",
width = 0,
height = 0,
size = 0,
thumbnail = "",
),
),
views = 0,
Expand Down
Loading

0 comments on commit 65f910e

Please sign in to comment.