-
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.
- Loading branch information
1 parent
b825eaf
commit 3ba82a1
Showing
14 changed files
with
193 additions
and
100 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
32 changes: 32 additions & 0 deletions
32
library/src/main/java/com/gapps/library/api/models/api/TikTokVideoInfoModel.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,32 @@ | ||
package com.gapps.library.api.models.api | ||
|
||
import com.gapps.library.api.FORMAT | ||
import com.gapps.library.api.FORMAT_JSON | ||
import com.gapps.library.api.URL | ||
import com.gapps.library.api.models.api.base.VideoInfoModel | ||
import com.gapps.library.api.models.video.tiktok.TikTokResponse | ||
import com.gapps.library.api.models.video.youtube.YoutubeResponse | ||
|
||
open class TikTokVideoInfoModel : VideoInfoModel<TikTokResponse>() { | ||
override val baseUrl: String | ||
get() = "https://www.tiktok.com" | ||
//https://regex101.com/r/nJzgG0/1 | ||
override val pattern: String | ||
get() = "(?:http[s]?:\\/\\/)(?:www.)?(?:m.)?youtu(?:be|.be)?(?:\\.com)?(?:(?:\\w*.?:\\/\\/)?\\w*.?\\w*-?.?\\w*\\/(?:embed|e|v|watch|.*\\/)?\\??(?:feature=\\w*\\.?\\w*)?&?(?:v=)?\\/?)([\\w\\d_-]{11})[^,;\\s]*" | ||
override val idPattern: String | ||
get() = pattern | ||
override val type: Class<TikTokResponse> | ||
get() = TikTokResponse::class.java | ||
override val hostingName: String | ||
get() = "YouTube" | ||
|
||
override fun getInfoUrl(incomingUrl: String?): String? { | ||
val id = parseVideoId(incomingUrl) | ||
|
||
return "$baseUrl/oembed?$FORMAT=$FORMAT_JSON&$URL=https://www.youtube.com/watch?v=$id" | ||
} | ||
|
||
override fun getPlayLink(videoId: String): String { | ||
return "https://www.youtube.com/embed/${videoId}?autoplay=1&vq=small" | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
library/src/main/java/com/gapps/library/api/models/video/tiktok/TikTokResponse.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,45 @@ | ||
package com.gapps.library.api.models.video.tiktok | ||
|
||
|
||
import com.gapps.library.api.models.video.VideoPreviewModel | ||
import com.gapps.library.api.models.video.base.BaseVideoResponse | ||
import com.google.gson.annotations.SerializedName | ||
|
||
data class TikTokResponse( | ||
@SerializedName("version") | ||
val version: String = "", | ||
@SerializedName("type") | ||
val type: String = "", | ||
@SerializedName("title") | ||
val title: String = "", | ||
@SerializedName("author_url") | ||
val authorUrl: String = "", | ||
@SerializedName("author_name") | ||
val authorName: String = "", | ||
@SerializedName("width") | ||
val width: String = "", | ||
@SerializedName("height") | ||
val height: String = "", | ||
@SerializedName("html") | ||
val html: String = "", | ||
@SerializedName("thumbnail_width") | ||
val thumbnailWidth: Int = 0, | ||
@SerializedName("thumbnail_height") | ||
val thumbnailHeight: Int = 0, | ||
@SerializedName("thumbnail_url") | ||
val thumbnailUrl: String = "", | ||
@SerializedName("provider_url") | ||
val providerUrl: String = "", | ||
@SerializedName("provider_name") | ||
val providerName: String = "" | ||
) : BaseVideoResponse { | ||
override fun toPreview(url: String?, linkToPlay: String, hostingName: String, videoId: String): VideoPreviewModel { | ||
return VideoPreviewModel(url, linkToPlay, hostingName, videoId).apply { | ||
this.thumbnailUrl = this@TikTokResponse.thumbnailUrl | ||
this.videoTitle = this@TikTokResponse.authorName | ||
this.width = this@TikTokResponse.width.toInt() | ||
this.height = this@TikTokResponse.height.toInt() | ||
} | ||
} | ||
|
||
} |
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
Oops, something went wrong.