-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from Fmaldonado6/development
Development
- Loading branch information
Showing
29 changed files
with
658 additions
and
257 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
Binary file not shown.
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
File renamed without changes.
24 changes: 24 additions & 0 deletions
24
mobile_app/app/src/main/java/com/fmaldonado/akiyama/data/models/video/VideoResponse.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,24 @@ | ||
package com.fmaldonado.akiyama.data.models.video | ||
|
||
data class VideoResponse( | ||
val file: String = "", | ||
val useWebView:Boolean = false | ||
) | ||
|
||
data class FembedVideoResponse( | ||
val data: List<FembedData> | ||
) | ||
|
||
data class FembedData( | ||
val label: String, | ||
val file: String | ||
) | ||
|
||
enum class ServerTypes(val value: String) { | ||
GoCdn("gocdn"), | ||
Fembed("fembed"), | ||
Mega("Mega"), | ||
Stape("stape"), | ||
Okru("okru"), | ||
Netu("netu") | ||
} |
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
73 changes: 73 additions & 0 deletions
73
mobile_app/app/src/main/java/com/fmaldonado/akiyama/data/network/VideoDataSource.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,73 @@ | ||
package com.fmaldonado.akiyama.data.network | ||
|
||
import android.util.Log | ||
import com.fmaldonado.akiyama.data.models.video.FembedVideoResponse | ||
import com.fmaldonado.akiyama.data.models.video.VideoResponse | ||
import com.google.gson.Gson | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.withContext | ||
import okhttp3.OkHttpClient | ||
import okhttp3.Request | ||
import okhttp3.RequestBody | ||
import org.jsoup.Jsoup | ||
import ru.gildor.coroutines.okhttp.await | ||
import java.lang.Exception | ||
import javax.inject.Inject | ||
import kotlin.coroutines.CoroutineContext | ||
|
||
class VideoDataSource | ||
@Inject | ||
constructor( | ||
private val client: OkHttpClient, | ||
private val gson: Gson | ||
) { | ||
private val goCdnUrl = "https://streamium.xyz/gocdn.php?v=" | ||
private val fembedUrl = "https://www.fembed.com/api/source/" | ||
private val hdLabel = "720p" | ||
|
||
suspend fun fetchGocdnVideo(id: String): VideoResponse { | ||
|
||
val req = Request.Builder().url(goCdnUrl + id).build() | ||
val response = client.newCall(req).await() | ||
val body = withContext(Dispatchers.IO) { | ||
kotlin.runCatching { response.body()?.string() }.getOrThrow() | ||
} | ||
return gson.fromJson(body, VideoResponse::class.java) | ||
} | ||
|
||
suspend fun fetchFembedVideo(id: String): VideoResponse { | ||
val req = | ||
Request.Builder().url(fembedUrl + id) | ||
.post(RequestBody.create(null, byteArrayOf())).build() | ||
val response = client.newCall(req).await() | ||
val body = withContext(Dispatchers.IO) { | ||
kotlin.runCatching { response.body()?.string() }.getOrThrow() | ||
} | ||
val fembedVideoResponse = gson.fromJson(body, FembedVideoResponse::class.java) | ||
|
||
var videoResponse = VideoResponse(fembedVideoResponse.data.first().file) | ||
|
||
if (fembedVideoResponse.data.size == 1) | ||
return videoResponse | ||
|
||
fembedVideoResponse.data.forEach { | ||
if (it.label == hdLabel) | ||
videoResponse = VideoResponse(it.file) | ||
} | ||
|
||
return videoResponse | ||
} | ||
|
||
suspend fun fetchStapeVideo(url: String) { | ||
Log.d("Url", url) | ||
val req = Request.Builder().url("https://streamtape.com/e/VrGka6PrmLIKd6O").build() | ||
val response = client.newCall(req).await() | ||
val body = withContext(Dispatchers.IO) { | ||
kotlin.runCatching { response.body()?.string() }.getOrThrow() | ||
} | ||
val document = Jsoup.parse(body) | ||
val link = document.getElementById("videolink") | ||
Log.d("Link", link.html()) | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...p/app/src/main/java/com/fmaldonado/akiyama/data/network/interceptor/NetworkInterceptor.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
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
39 changes: 39 additions & 0 deletions
39
..._app/app/src/main/java/com/fmaldonado/akiyama/data/repositories/videos/VideoRepository.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,39 @@ | ||
package com.fmaldonado.akiyama.data.repositories.videos | ||
|
||
import android.util.Log | ||
import com.fmaldonado.akiyama.data.models.content.Server | ||
import com.fmaldonado.akiyama.data.models.video.ServerTypes | ||
import com.fmaldonado.akiyama.data.models.video.VideoResponse | ||
import com.fmaldonado.akiyama.data.network.VideoDataSource | ||
import javax.inject.Inject | ||
|
||
class VideoRepository | ||
@Inject | ||
constructor( | ||
private val videoDataSource: VideoDataSource | ||
) { | ||
|
||
suspend fun getVideoUrl(server: Server): VideoResponse { | ||
return when (server.server) { | ||
ServerTypes.GoCdn.value -> getGoCdnVideo(server.code) | ||
ServerTypes.Fembed.value -> getFembedVideo(server.code) | ||
else -> VideoResponse(server.code, true) | ||
} | ||
} | ||
|
||
suspend fun getGoCdnVideo(url: String): VideoResponse { | ||
val value = url.split("#").last() | ||
return videoDataSource.fetchGocdnVideo(value) | ||
} | ||
|
||
suspend fun getFembedVideo(url: String): VideoResponse { | ||
val value = url.split("/").last() | ||
return videoDataSource.fetchFembedVideo(value) | ||
} | ||
|
||
suspend fun getStapeVideo(url: String): VideoResponse { | ||
videoDataSource.fetchStapeVideo(url) | ||
return VideoResponse("") | ||
} | ||
|
||
} |
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
Oops, something went wrong.