-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
20 changed files
with
253 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
library/src/main/java/com/gapps/library/api/models/api/DailymotionVideoInfoModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.gapps.library.api.models.api | ||
|
||
import com.gapps.library.api.DAILYMOTION_PATTERN | ||
import com.gapps.library.api.models.video.dailymotion.DailymotionResponse | ||
import com.gapps.library.utils.getGroupValue | ||
|
||
class DailymotionVideoInfoModel : VideoInfoModel<DailymotionResponse> { | ||
override var pattern: String = DAILYMOTION_PATTERN | ||
override val idPattern: String | ||
get() = pattern | ||
|
||
override val type: Class<DailymotionResponse> = DailymotionResponse::class.java | ||
|
||
override fun parseVideoId(url: String?): String? { | ||
return idPattern.getGroupValue(url, 1) | ||
} | ||
|
||
override fun checkHostAffiliation(url: String?): Boolean { | ||
url ?: return false | ||
|
||
return url.matches(pattern.toRegex()) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
library/src/main/java/com/gapps/library/api/models/api/VideoInfoModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.gapps.library.api.models.api | ||
|
||
interface VideoInfoModel<T> { | ||
val pattern: String | ||
val idPattern: String | ||
val type: Class<T> | ||
|
||
/** | ||
* | ||
*/ | ||
fun parseVideoId(url: String?): String? | ||
|
||
fun checkHostAffiliation(url: String?): Boolean | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
library/src/main/java/com/gapps/library/api/models/video/coub/CoubResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.gapps.library.api.models.video.coub | ||
|
||
|
||
import com.gapps.library.api.COUB_PATTERN | ||
import com.gapps.library.api.FACEBOOK_PATTERN | ||
import com.gapps.library.api.models.video.VideoPreviewModel | ||
import com.gapps.library.api.models.video.base.BaseVideoResponse | ||
import com.gapps.library.utils.getGroupValue | ||
import com.google.gson.annotations.SerializedName | ||
|
||
data class CoubResponse( | ||
@SerializedName("type") | ||
val type: String = "", | ||
@SerializedName("version") | ||
val version: String = "", | ||
@SerializedName("width") | ||
val width: String = "", | ||
@SerializedName("height") | ||
val height: String = "", | ||
@SerializedName("title") | ||
val title: String = "", | ||
@SerializedName("url") | ||
val url: String = "", | ||
@SerializedName("thumbnail_url") | ||
val thumbnailUrl: String = "", | ||
@SerializedName("thumbnail_width") | ||
val thumbnailWidth: String = "", | ||
@SerializedName("thumbnail_height") | ||
val thumbnailHeight: String = "", | ||
@SerializedName("author_name") | ||
val authorName: String = "", | ||
@SerializedName("channel_url") | ||
val channelUrl: String = "", | ||
@SerializedName("provider_name") | ||
val providerName: String = "", | ||
@SerializedName("provider_url") | ||
val providerUrl: String = "", | ||
@SerializedName("html") | ||
val html: String = "" | ||
): BaseVideoResponse{ | ||
override fun toPreview(url: String?): VideoPreviewModel { | ||
return VideoPreviewModel().apply { | ||
this.thumbnailUrl = this@CoubResponse.thumbnailUrl | ||
this.videoTitle = this@CoubResponse.title | ||
this.url = url | ||
this.videoHosting = VideoPreviewModel.DAILYMOTION | ||
this.videoId = getVideoId(url) | ||
this.linkToPlay = "https://coub.com/embed/${videoId}" | ||
this.width = this@CoubResponse.width.toInt() | ||
this.height = this@CoubResponse.height.toInt() | ||
} | ||
} | ||
|
||
override fun getVideoId(url: String?): String? { | ||
url ?: return null | ||
|
||
return COUB_PATTERN.getGroupValue(url, 1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.