diff --git a/app/src/main/java/org/fnives/tiktokdownloader/data/model/ProcessState.kt b/app/src/main/java/org/fnives/tiktokdownloader/data/model/ProcessState.kt index bb6489f..3078140 100644 --- a/app/src/main/java/org/fnives/tiktokdownloader/data/model/ProcessState.kt +++ b/app/src/main/java/org/fnives/tiktokdownloader/data/model/ProcessState.kt @@ -7,6 +7,7 @@ sealed class ProcessState { data object NetworkError : ProcessState() data object ParsingError : ProcessState() data object VideoDeletedError : ProcessState() + data object VideoPrivateError : ProcessState() data object CaptchaError : ProcessState() data object UnknownError : ProcessState() data object StorageError : ProcessState() diff --git a/app/src/main/java/org/fnives/tiktokdownloader/data/network/TikTokDownloadRemoteSource.kt b/app/src/main/java/org/fnives/tiktokdownloader/data/network/TikTokDownloadRemoteSource.kt index e0ab21e..9e35990 100644 --- a/app/src/main/java/org/fnives/tiktokdownloader/data/network/TikTokDownloadRemoteSource.kt +++ b/app/src/main/java/org/fnives/tiktokdownloader/data/network/TikTokDownloadRemoteSource.kt @@ -11,6 +11,7 @@ import org.fnives.tiktokdownloader.data.network.exceptions.HtmlException import org.fnives.tiktokdownloader.data.network.exceptions.NetworkException import org.fnives.tiktokdownloader.data.network.exceptions.ParsingException import org.fnives.tiktokdownloader.data.network.exceptions.VideoDeletedException +import org.fnives.tiktokdownloader.data.network.exceptions.VideoPrivateException import org.fnives.tiktokdownloader.data.network.parsing.converter.VideoFileUrlConverter import org.fnives.tiktokdownloader.data.network.parsing.response.VideoFileUrl import org.fnives.tiktokdownloader.data.network.session.CookieStore @@ -68,6 +69,8 @@ class TikTokDownloadRemoteSource( throw captchaRequiredException } catch (videoDeletedException: VideoDeletedException) { throw videoDeletedException + } catch (videoPrivateException: VideoPrivateException) { + throw videoPrivateException } catch (throwable: Throwable) { throw NetworkException( cause = throwable, diff --git a/app/src/main/java/org/fnives/tiktokdownloader/data/network/exceptions/VideoPrivateException.kt b/app/src/main/java/org/fnives/tiktokdownloader/data/network/exceptions/VideoPrivateException.kt new file mode 100644 index 0000000..073c5ef --- /dev/null +++ b/app/src/main/java/org/fnives/tiktokdownloader/data/network/exceptions/VideoPrivateException.kt @@ -0,0 +1,4 @@ +package org.fnives.tiktokdownloader.data.network.exceptions + +class VideoPrivateException(override val html: String) : Throwable(), + HtmlException \ No newline at end of file diff --git a/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/TikTokWebPageConverterFactory.kt b/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/TikTokWebPageConverterFactory.kt index 3d47d77..9243b2a 100644 --- a/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/TikTokWebPageConverterFactory.kt +++ b/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/TikTokWebPageConverterFactory.kt @@ -4,6 +4,7 @@ import okhttp3.ResponseBody import org.fnives.tiktokdownloader.data.network.parsing.converter.ActualVideoPageUrlConverter import org.fnives.tiktokdownloader.data.network.parsing.converter.ThrowIfIsCaptchaResponse import org.fnives.tiktokdownloader.data.network.parsing.converter.ThrowIfVideoIsDeletedResponse +import org.fnives.tiktokdownloader.data.network.parsing.converter.ThrowIfVideoIsPrivateResponse import org.fnives.tiktokdownloader.data.network.parsing.converter.VideoFileUrlConverter import org.fnives.tiktokdownloader.data.network.parsing.converter.VideoResponseConverter import org.fnives.tiktokdownloader.data.network.parsing.response.ActualVideoPageUrl @@ -15,7 +16,8 @@ import java.lang.reflect.Type class TikTokWebPageConverterFactory( private val throwIfIsCaptchaResponse: ThrowIfIsCaptchaResponse, - private val throwIfVideoIsDeletedResponse: ThrowIfVideoIsDeletedResponse + private val throwIfVideoIsDeletedResponse: ThrowIfVideoIsDeletedResponse, + private val throwIfVideoIsPrivateResponse: ThrowIfVideoIsPrivateResponse, ) : Converter.Factory() { override fun responseBodyConverter( @@ -26,10 +28,16 @@ class TikTokWebPageConverterFactory( when (type) { ActualVideoPageUrl::class.java -> ActualVideoPageUrlConverter( throwIfIsCaptchaResponse, - throwIfVideoIsDeletedResponse + throwIfVideoIsDeletedResponse, + throwIfVideoIsPrivateResponse, + ) + + VideoFileUrl::class.java -> VideoFileUrlConverter( + throwIfIsCaptchaResponse, + throwIfVideoIsDeletedResponse, + throwIfVideoIsPrivateResponse ) - VideoFileUrl::class.java -> VideoFileUrlConverter(throwIfIsCaptchaResponse, throwIfVideoIsDeletedResponse) VideoResponse::class.java -> VideoResponseConverter() else -> super.responseBodyConverter(type, annotations, retrofit) } diff --git a/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/converter/ActualVideoPageUrlConverter.kt b/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/converter/ActualVideoPageUrlConverter.kt index 8c04a94..7d4afb3 100644 --- a/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/converter/ActualVideoPageUrlConverter.kt +++ b/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/converter/ActualVideoPageUrlConverter.kt @@ -2,26 +2,33 @@ package org.fnives.tiktokdownloader.data.network.parsing.converter import okhttp3.ResponseBody import org.fnives.tiktokdownloader.data.network.exceptions.CaptchaRequiredException +import org.fnives.tiktokdownloader.data.network.exceptions.VideoDeletedException +import org.fnives.tiktokdownloader.data.network.exceptions.VideoPrivateException import org.fnives.tiktokdownloader.data.network.parsing.response.ActualVideoPageUrl -import kotlin.jvm.Throws class ActualVideoPageUrlConverter( private val throwIfIsCaptchaResponse: ThrowIfIsCaptchaResponse, - private val throwIfVideoIsDeletedResponse: ThrowIfVideoIsDeletedResponse + private val throwIfVideoIsDeletedResponse: ThrowIfVideoIsDeletedResponse, + private val throwIfVideoIsPrivateResponse: ThrowIfVideoIsPrivateResponse ) : ParsingExceptionThrowingConverter() { - @Throws(IndexOutOfBoundsException::class, CaptchaRequiredException::class) + @Throws( + IndexOutOfBoundsException::class, CaptchaRequiredException::class, + VideoDeletedException::class, + VideoPrivateException::class, + ) override fun convertSafely(responseBody: ResponseBody): ActualVideoPageUrl { - val responseBodyAsString =responseBody.string() + val responseBodyAsString = responseBody.string() return try { val actualVideoPageUrl = responseBodyAsString .also(throwIfIsCaptchaResponse::invoke) .also(throwIfVideoIsDeletedResponse::invoke) + .also(throwIfVideoIsPrivateResponse::invoke) .split("rel=\"canonical\" href=\"")[1] .split("\"")[0] ActualVideoPageUrl(actualVideoPageUrl, responseBodyAsString) - } catch(_: Throwable) { + } catch (_: Throwable) { ActualVideoPageUrl(null, responseBodyAsString) } diff --git a/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/converter/ParsingExceptionThrowingConverter.kt b/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/converter/ParsingExceptionThrowingConverter.kt index 8fd27da..cb71d60 100644 --- a/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/converter/ParsingExceptionThrowingConverter.kt +++ b/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/converter/ParsingExceptionThrowingConverter.kt @@ -5,24 +5,37 @@ import org.fnives.tiktokdownloader.data.network.exceptions.CaptchaRequiredExcept import org.fnives.tiktokdownloader.data.network.exceptions.HtmlException import org.fnives.tiktokdownloader.data.network.exceptions.ParsingException import org.fnives.tiktokdownloader.data.network.exceptions.VideoDeletedException +import org.fnives.tiktokdownloader.data.network.exceptions.VideoPrivateException import retrofit2.Converter abstract class ParsingExceptionThrowingConverter : Converter { - @Throws(ParsingException::class, CaptchaRequiredException::class, VideoDeletedException::class) + @Throws( + ParsingException::class, + CaptchaRequiredException::class, + VideoDeletedException::class, + VideoPrivateException::class + ) final override fun convert(value: ResponseBody): T? = doActionSafely { convertSafely(value) } - @Throws(ParsingException::class, CaptchaRequiredException::class, VideoDeletedException::class) + @Throws( + ParsingException::class, + CaptchaRequiredException::class, + VideoDeletedException::class, + VideoPrivateException::class + ) fun doActionSafely(action: () -> T): T { try { return action() } catch (captchaRequiredException: CaptchaRequiredException) { throw captchaRequiredException - } catch(videoDeletedException: VideoDeletedException) { + } catch (videoDeletedException: VideoDeletedException) { throw videoDeletedException + } catch (videoPrivateException: VideoPrivateException) { + throw videoPrivateException } catch (throwable: Throwable) { throw ParsingException( cause = throwable, diff --git a/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/converter/ThrowIfVideoIsDeletedResponse.kt b/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/converter/ThrowIfVideoIsDeletedResponse.kt index 820f96c..5aa21dc 100644 --- a/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/converter/ThrowIfVideoIsDeletedResponse.kt +++ b/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/converter/ThrowIfVideoIsDeletedResponse.kt @@ -6,7 +6,7 @@ class ThrowIfVideoIsDeletedResponse { @Throws(VideoDeletedException::class) fun invoke(html: String) { - if (html.contains("\"statusMsg\":\"status_deleted\"")) { + if (html.contains("\"statusMsg\":\"status_deleted")) { throw VideoDeletedException(html = html) } } diff --git a/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/converter/ThrowIfVideoIsPrivateResponse.kt b/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/converter/ThrowIfVideoIsPrivateResponse.kt new file mode 100644 index 0000000..59f3503 --- /dev/null +++ b/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/converter/ThrowIfVideoIsPrivateResponse.kt @@ -0,0 +1,15 @@ +package org.fnives.tiktokdownloader.data.network.parsing.converter + +import org.fnives.tiktokdownloader.data.network.exceptions.VideoPrivateException + +class ThrowIfVideoIsPrivateResponse { + + @Throws(VideoPrivateException::class) + fun invoke(html: String) { + if (html.contains("\"statusMsg\":\"status_friend_see")) { + throw VideoPrivateException(html = html) + } else if (html.contains("\"statusMsg\":\"author_secret")) { + throw VideoPrivateException(html = html) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/converter/VideoFileUrlConverter.kt b/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/converter/VideoFileUrlConverter.kt index f337798..88858b7 100644 --- a/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/converter/VideoFileUrlConverter.kt +++ b/app/src/main/java/org/fnives/tiktokdownloader/data/network/parsing/converter/VideoFileUrlConverter.kt @@ -4,14 +4,21 @@ import okhttp3.ResponseBody import org.fnives.tiktokdownloader.Logger import org.fnives.tiktokdownloader.data.network.exceptions.CaptchaRequiredException import org.fnives.tiktokdownloader.data.network.exceptions.ParsingException +import org.fnives.tiktokdownloader.data.network.exceptions.VideoDeletedException +import org.fnives.tiktokdownloader.data.network.exceptions.VideoPrivateException import org.fnives.tiktokdownloader.data.network.parsing.response.VideoFileUrl class VideoFileUrlConverter( private val throwIfIsCaptchaResponse: ThrowIfIsCaptchaResponse, private val throwIfVideoIsDeletedResponse: ThrowIfVideoIsDeletedResponse, + private val throwIfVideoIsPrivateResponse: ThrowIfVideoIsPrivateResponse ) : ParsingExceptionThrowingConverter() { - @Throws(IllegalArgumentException::class, IndexOutOfBoundsException::class, CaptchaRequiredException::class) + @Throws( + IllegalArgumentException::class, + IndexOutOfBoundsException::class, + CaptchaRequiredException::class + ) override fun convertSafely(responseBody: ResponseBody): VideoFileUrl { return convert(responseBody.string()) } @@ -21,13 +28,21 @@ class VideoFileUrlConverter( return doActionSafely { convert(responseBody) } } - @Throws(IllegalArgumentException::class, IndexOutOfBoundsException::class, CaptchaRequiredException::class) + @Throws( + IllegalArgumentException::class, + IndexOutOfBoundsException::class, + CaptchaRequiredException::class, + VideoDeletedException::class, + VideoPrivateException::class, + ) private fun convert(responseBody: String): VideoFileUrl { val html = responseBody.also(throwIfIsCaptchaResponse::invoke) .also(throwIfVideoIsDeletedResponse::invoke) - val url = tryToParseDownloadLink(html).also { Logger.logMessage("parsed download link = $it") } - ?: tryToParseVideoSrc(html).also { Logger.logMessage("parsed video src = $it") } - ?: throw IllegalArgumentException("Couldn't parse url from HTML: $html") + .also(throwIfVideoIsPrivateResponse::invoke) + val url = + tryToParseDownloadLink(html).also { Logger.logMessage("parsed download link = $it") } + ?: tryToParseVideoSrc(html).also { Logger.logMessage("parsed video src = $it") } + ?: throw IllegalArgumentException("Couldn't parse url from HTML: $html") return VideoFileUrl(url) } diff --git a/app/src/main/java/org/fnives/tiktokdownloader/data/usecase/VideoDownloadingProcessorUseCase.kt b/app/src/main/java/org/fnives/tiktokdownloader/data/usecase/VideoDownloadingProcessorUseCase.kt index fb8e2a6..5dd72ab 100644 --- a/app/src/main/java/org/fnives/tiktokdownloader/data/usecase/VideoDownloadingProcessorUseCase.kt +++ b/app/src/main/java/org/fnives/tiktokdownloader/data/usecase/VideoDownloadingProcessorUseCase.kt @@ -32,6 +32,7 @@ import org.fnives.tiktokdownloader.data.network.exceptions.CaptchaRequiredExcept import org.fnives.tiktokdownloader.data.network.exceptions.NetworkException import org.fnives.tiktokdownloader.data.network.exceptions.ParsingException import org.fnives.tiktokdownloader.data.network.exceptions.VideoDeletedException +import org.fnives.tiktokdownloader.data.network.exceptions.VideoPrivateException @OptIn(FlowPreview::class) class VideoDownloadingProcessorUseCase( @@ -112,6 +113,8 @@ class VideoDownloadingProcessorUseCase( ProcessState.ParsingError } catch (videoDeletedException: VideoDeletedException) { ProcessState.VideoDeletedError + } catch (videoPrivateException: VideoPrivateException) { + ProcessState.VideoPrivateError } catch (storageException: StorageException) { ProcessState.StorageError } catch (captchaRequiredException: CaptchaRequiredException) { @@ -140,6 +143,7 @@ class VideoDownloadingProcessorUseCase( ProcessState.StorageError, ProcessState.UnknownError, ProcessState.VideoDeletedError, + ProcessState.VideoPrivateError, ProcessState.CaptchaError -> true } diff --git a/app/src/main/java/org/fnives/tiktokdownloader/di/module/NetworkModule.kt b/app/src/main/java/org/fnives/tiktokdownloader/di/module/NetworkModule.kt index 507bfa1..d87cf73 100644 --- a/app/src/main/java/org/fnives/tiktokdownloader/di/module/NetworkModule.kt +++ b/app/src/main/java/org/fnives/tiktokdownloader/di/module/NetworkModule.kt @@ -8,6 +8,7 @@ import org.fnives.tiktokdownloader.data.network.TikTokRetrofitService import org.fnives.tiktokdownloader.data.network.parsing.TikTokWebPageConverterFactory import org.fnives.tiktokdownloader.data.network.parsing.converter.ThrowIfIsCaptchaResponse import org.fnives.tiktokdownloader.data.network.parsing.converter.ThrowIfVideoIsDeletedResponse +import org.fnives.tiktokdownloader.data.network.parsing.converter.ThrowIfVideoIsPrivateResponse import org.fnives.tiktokdownloader.data.network.parsing.converter.VideoFileUrlConverter import org.fnives.tiktokdownloader.data.network.session.CookieSavingInterceptor import org.fnives.tiktokdownloader.data.network.session.CookieStore @@ -22,8 +23,15 @@ class NetworkModule(private val delayBeforeRequest: Long) { private val throwIfVideoIsDeletedResponse: ThrowIfVideoIsDeletedResponse get() = ThrowIfVideoIsDeletedResponse() + private val throwIfVideoIsPrivateResponse: ThrowIfVideoIsPrivateResponse + get() = ThrowIfVideoIsPrivateResponse() + private val tikTokConverterFactory: Converter.Factory - get() = TikTokWebPageConverterFactory(throwIfIsCaptchaResponse, throwIfVideoIsDeletedResponse) + get() = TikTokWebPageConverterFactory( + throwIfIsCaptchaResponse, + throwIfVideoIsDeletedResponse, + throwIfVideoIsPrivateResponse + ) private val cookieSavingInterceptor: CookieSavingInterceptor by lazy { CookieSavingInterceptor() } @@ -34,7 +42,9 @@ class NetworkModule(private val delayBeforeRequest: Long) { .addInterceptor(cookieSavingInterceptor) .let { if (BuildConfig.DEBUG) { - it.addInterceptor(HttpLoggingInterceptor().apply { level = HttpLoggingInterceptor.Level.BODY }) + it.addInterceptor(HttpLoggingInterceptor().apply { + level = HttpLoggingInterceptor.Level.BODY + }) } else { it } @@ -52,5 +62,14 @@ class NetworkModule(private val delayBeforeRequest: Long) { get() = retrofit.create(TikTokRetrofitService::class.java) val tikTokDownloadRemoteSource: TikTokDownloadRemoteSource - get() = TikTokDownloadRemoteSource(delayBeforeRequest, tikTokRetrofitService, cookieStore, VideoFileUrlConverter(throwIfIsCaptchaResponse, throwIfVideoIsDeletedResponse)) + get() = TikTokDownloadRemoteSource( + delayBeforeRequest, + tikTokRetrofitService, + cookieStore, + VideoFileUrlConverter( + throwIfIsCaptchaResponse, + throwIfVideoIsDeletedResponse, + throwIfVideoIsPrivateResponse + ) + ) } \ No newline at end of file diff --git a/app/src/main/java/org/fnives/tiktokdownloader/ui/main/MainActivity.kt b/app/src/main/java/org/fnives/tiktokdownloader/ui/main/MainActivity.kt index 55aa62e..d3a046a 100644 --- a/app/src/main/java/org/fnives/tiktokdownloader/ui/main/MainActivity.kt +++ b/app/src/main/java/org/fnives/tiktokdownloader/ui/main/MainActivity.kt @@ -105,6 +105,7 @@ class MainActivity : AppCompatActivity() { MainViewModel.ErrorMessage.CAPTCHA -> R.string.captcha_error MainViewModel.ErrorMessage.UNKNOWN -> R.string.unexpected_error MainViewModel.ErrorMessage.DELETED -> R.string.video_deleted_error + MainViewModel.ErrorMessage.PRIVATE -> R.string.video_private_error } private fun animateFabClicked(downloadFab: FloatingActionButton) { diff --git a/app/src/main/java/org/fnives/tiktokdownloader/ui/main/MainViewModel.kt b/app/src/main/java/org/fnives/tiktokdownloader/ui/main/MainViewModel.kt index c205f64..8107e05 100644 --- a/app/src/main/java/org/fnives/tiktokdownloader/ui/main/MainViewModel.kt +++ b/app/src/main/java/org/fnives/tiktokdownloader/ui/main/MainViewModel.kt @@ -5,7 +5,6 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import kotlinx.coroutines.flow.collect import kotlinx.coroutines.launch import org.fnives.tiktokdownloader.data.model.ProcessState import org.fnives.tiktokdownloader.data.usecase.AddVideoToQueueUseCase @@ -22,13 +21,15 @@ class MainViewModel( private val _refreshActionVisibility = MutableLiveData() private val currentScreen = MutableLiveData() - val refreshActionVisibility: LiveData = combineNullable(_refreshActionVisibility, currentScreen) { refreshVisibility, screen -> - refreshVisibility == true && screen == Screen.QUEUE - } + val refreshActionVisibility: LiveData = + combineNullable(_refreshActionVisibility, currentScreen) { refreshVisibility, screen -> + refreshVisibility == true && screen == Screen.QUEUE + } private val _errorMessage = MutableLiveData>() - val errorMessage: LiveData?> = combineNullable(_errorMessage, currentScreen) { event, screen -> - event?.takeIf { screen == Screen.QUEUE } - } + val errorMessage: LiveData?> = + combineNullable(_errorMessage, currentScreen) { event, screen -> + event?.takeIf { screen == Screen.QUEUE } + } init { savedStateHandle.get(INTENT_EXTRA_URL)?.let(addVideoToQueueUseCase::invoke) @@ -40,22 +41,26 @@ class MainViewModel( is ProcessState.Processing, is ProcessState.Processed, ProcessState.Finished -> null + ProcessState.NetworkError -> ErrorMessage.NETWORK ProcessState.ParsingError -> ErrorMessage.PARSING ProcessState.StorageError -> ErrorMessage.STORAGE ProcessState.CaptchaError -> ErrorMessage.CAPTCHA ProcessState.UnknownError -> ErrorMessage.UNKNOWN ProcessState.VideoDeletedError -> ErrorMessage.DELETED + ProcessState.VideoPrivateError -> ErrorMessage.PRIVATE } val refreshActionVisibility = when (it) { is ProcessState.Processing, is ProcessState.Processed, ProcessState.Finished -> false + ProcessState.NetworkError, ProcessState.ParsingError, ProcessState.StorageError, ProcessState.UnknownError, ProcessState.VideoDeletedError, + ProcessState.VideoPrivateError, ProcessState.CaptchaError -> true } _errorMessage.postValue(errorMessage?.let(::Event)) @@ -73,7 +78,7 @@ class MainViewModel( } enum class ErrorMessage { - NETWORK, PARSING, STORAGE, CAPTCHA, UNKNOWN, DELETED + NETWORK, PARSING, STORAGE, CAPTCHA, UNKNOWN, DELETED, PRIVATE } enum class Screen { diff --git a/app/src/main/java/org/fnives/tiktokdownloader/ui/service/QueueServiceViewModel.kt b/app/src/main/java/org/fnives/tiktokdownloader/ui/service/QueueServiceViewModel.kt index 09f810b..b655eb9 100644 --- a/app/src/main/java/org/fnives/tiktokdownloader/ui/service/QueueServiceViewModel.kt +++ b/app/src/main/java/org/fnives/tiktokdownloader/ui/service/QueueServiceViewModel.kt @@ -54,6 +54,7 @@ class QueueServiceViewModel( NotificationState.Error(R.string.captcha_error) ProcessState.VideoDeletedError -> NotificationState.Error(R.string.video_deleted_error) + ProcessState.VideoPrivateError -> NotificationState.Error(R.string.video_private_error) } _notificationState.postValue(value) } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ed48072..85dfafb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -19,7 +19,8 @@ Parsing Error Failed to Store Video Unexpected Error - Video seems to be Deleted + Video seems to be DELETED + Video seems to be PRIVATE Permission Needed External Storage permission is needed in order to save the video to your device OK diff --git a/app/src/test/java/org/fnives/uptodate/TikTokDownloadRemoteSourceUpToDateTest.kt b/app/src/test/java/org/fnives/uptodate/TikTokDownloadRemoteSourceUpToDateTest.kt index 50905e2..30b9fe1 100644 --- a/app/src/test/java/org/fnives/uptodate/TikTokDownloadRemoteSourceUpToDateTest.kt +++ b/app/src/test/java/org/fnives/uptodate/TikTokDownloadRemoteSourceUpToDateTest.kt @@ -5,6 +5,7 @@ import org.apache.commons.io.FileUtils import org.fnives.tiktokdownloader.data.model.VideoInPending import org.fnives.tiktokdownloader.data.network.TikTokDownloadRemoteSource import org.fnives.tiktokdownloader.data.network.exceptions.VideoDeletedException +import org.fnives.tiktokdownloader.data.network.exceptions.VideoPrivateException import org.fnives.tiktokdownloader.di.module.NetworkModule import org.fnives.tiktokdownloader.helper.getResourceFile import org.junit.jupiter.api.Assertions @@ -64,6 +65,15 @@ class TikTokDownloadRemoteSourceUpToDateTest { } } + @Timeout(value = 120) + @Test + fun GIVEN_private_WHEN_downloading_THEN_proper_exception_is_thrown() { + val parameter = VideoInPending("123", PRIVATE_VIDEO_URL) + Assertions.assertThrows(VideoPrivateException::class.java) { + runBlocking { sut.getVideo(parameter) } + } + } + companion object { private const val ACTUAL_FILE_PATH = "actual.mp4" private val EXPECTED_FILE_PATHS =