-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring code and adding encrypted video cdn
- Loading branch information
Showing
22 changed files
with
251 additions
and
99 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
36 changes: 24 additions & 12 deletions
36
app/src/main/java/com/kl3jvi/animity/data/repository/HomeRepositoryImpl.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 |
---|---|---|
@@ -1,49 +1,61 @@ | ||
package com.kl3jvi.animity.data.repository | ||
|
||
import com.kl3jvi.animity.domain.repositories.HomeRepository | ||
import com.kl3jvi.animity.data.model.AnimeMetaModel | ||
import com.kl3jvi.animity.data.network.AnimeApiClient | ||
import com.kl3jvi.animity.domain.repositories.HomeRepository | ||
import com.kl3jvi.animity.utils.Constants.Companion.TYPE_MOVIE | ||
import com.kl3jvi.animity.utils.Constants.Companion.TYPE_POPULAR_ANIME | ||
import com.kl3jvi.animity.utils.Constants.Companion.TYPE_RECENT_SUB | ||
import com.kl3jvi.animity.utils.parser.HtmlParser | ||
import kotlinx.coroutines.CoroutineDispatcher | ||
import kotlinx.coroutines.withContext | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class HomeRepositoryImpl @Inject constructor(private val apiClient: AnimeApiClient) : | ||
HomeRepository { | ||
@Suppress("BlockingMethodInNonBlockingContext") | ||
class HomeRepositoryImpl @Inject constructor( | ||
private val apiClient: AnimeApiClient, | ||
private val ioDispatcher: CoroutineDispatcher | ||
) : HomeRepository { | ||
override val parser: HtmlParser | ||
get() = HtmlParser | ||
|
||
override suspend fun fetchRecentSubOrDub( | ||
header: Map<String, String>, | ||
page: Int, | ||
type: Int | ||
): ArrayList<AnimeMetaModel> { | ||
return parser.parseRecentSubOrDub( | ||
apiClient.fetchRecentSubOrDub(header, page, type).string(), TYPE_RECENT_SUB | ||
): List<AnimeMetaModel> = withContext(ioDispatcher) { | ||
parser.parseRecentSubOrDub( | ||
apiClient.fetchRecentSubOrDub(header = header, page = page, type = type).string(), | ||
TYPE_RECENT_SUB | ||
) | ||
} | ||
|
||
override suspend fun fetchPopularFromAjax( | ||
header: Map<String, String>, | ||
page: Int | ||
): ArrayList<AnimeMetaModel> { | ||
return parser.parsePopular(apiClient.fetchPopularFromAjax(header, page).string(), TYPE_POPULAR_ANIME) | ||
): List<AnimeMetaModel> = withContext(ioDispatcher) { | ||
parser.parsePopular( | ||
apiClient.fetchPopularFromAjax(header = header, page = page).string(), | ||
TYPE_POPULAR_ANIME | ||
) | ||
} | ||
|
||
override suspend fun fetchNewSeason( | ||
header: Map<String, String>, | ||
page: Int | ||
): ArrayList<AnimeMetaModel> { | ||
return parser.parseMovie(apiClient.fetchNewSeason(header, page).string(),TYPE_MOVIE) | ||
): List<AnimeMetaModel> = withContext(ioDispatcher) { | ||
parser.parseMovie( | ||
apiClient.fetchNewSeason(header = header, page = page).string(), | ||
TYPE_MOVIE | ||
) | ||
} | ||
|
||
override suspend fun fetchMovies( | ||
header: Map<String, String>, | ||
page: Int | ||
): ArrayList<AnimeMetaModel> { | ||
return parser.parseMovie(apiClient.fetchMovies(header, page).string(),TYPE_MOVIE) | ||
): List<AnimeMetaModel> = withContext(ioDispatcher) { | ||
parser.parseMovie(apiClient.fetchMovies(header = header, page = page).string(), TYPE_MOVIE) | ||
} | ||
} |
29 changes: 22 additions & 7 deletions
29
app/src/main/java/com/kl3jvi/animity/data/repository/PlayerRepositoryImpl.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 |
---|---|---|
@@ -1,27 +1,42 @@ | ||
package com.kl3jvi.animity.data.repository | ||
|
||
import com.kl3jvi.animity.domain.repositories.PlayerRepository | ||
import com.kl3jvi.animity.data.model.EpisodeInfo | ||
import com.kl3jvi.animity.data.network.AnimeApiClient | ||
import com.kl3jvi.animity.domain.repositories.PlayerRepository | ||
import com.kl3jvi.animity.utils.parser.HtmlParser | ||
import kotlinx.coroutines.CoroutineDispatcher | ||
import kotlinx.coroutines.withContext | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
@Suppress("BlockingMethodInNonBlockingContext") | ||
class PlayerRepositoryImpl @Inject constructor( | ||
private val apiClient: AnimeApiClient | ||
private val apiClient: AnimeApiClient, | ||
private val ioDispatcher: CoroutineDispatcher | ||
) : PlayerRepository { | ||
override val parser: HtmlParser | ||
get() = HtmlParser | ||
|
||
override suspend fun fetchEpisodeMediaUrl( | ||
header: Map<String, String>, | ||
url: String | ||
): EpisodeInfo { | ||
return parser.parseMediaUrl(apiClient.fetchEpisodeMediaUrl(header, url).string()) | ||
): EpisodeInfo = withContext(ioDispatcher) { | ||
parser.parseMediaUrl(apiClient.fetchEpisodeMediaUrl(header = header, url = url).string()) | ||
} | ||
|
||
override suspend fun fetchM3u8Url(header: Map<String, String>, url: String): String { | ||
return parser.parseM3U8Url(apiClient.fetchM3u8Url(header, url).string())?:"" | ||
} | ||
|
||
override suspend fun fetchM3u8Url(header: Map<String, String>, url: String): String = | ||
withContext(ioDispatcher) { | ||
parser.parseEncryptAjax(apiClient.fetchM3u8Url(header = header, url = url).string()) ?: "" | ||
} | ||
|
||
override suspend fun fetchEncryptedAjaxUrl(header: Map<String, String>, url: String): String = | ||
withContext(ioDispatcher) { | ||
parser.parseEncryptAjax( | ||
apiClient.fetchM3u8PreProcessor(header = header, url = url).string() | ||
) | ||
} | ||
|
||
} | ||
|
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
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.