Allow reporting ContentNotAvailableException
This commit is contained in:
parent
03abf7a950
commit
403897af39
1 changed files with 28 additions and 5 deletions
|
|
@ -299,9 +299,9 @@ class ErrorInfo private constructor(
|
||||||
// indicates that it's important and is thus reportable
|
// indicates that it's important and is thus reportable
|
||||||
null -> true
|
null -> true
|
||||||
|
|
||||||
// the service explicitly said that content is not available (e.g. age restrictions,
|
// if the service explicitly said that content is not available (e.g. age
|
||||||
// video deleted, etc.), there is no use in letting users report it
|
// restrictions, video deleted, etc.), there is no use in letting users report it
|
||||||
is ContentNotAvailableException -> false
|
is ContentNotAvailableException -> !isContentSurelyNotAvailable(throwable)
|
||||||
|
|
||||||
// we know the content is not supported, no need to let the user report it
|
// we know the content is not supported, no need to let the user report it
|
||||||
is ContentNotSupportedException -> false
|
is ContentNotSupportedException -> false
|
||||||
|
|
@ -318,8 +318,8 @@ class ErrorInfo private constructor(
|
||||||
|
|
||||||
fun isRetryable(throwable: Throwable?): Boolean {
|
fun isRetryable(throwable: Throwable?): Boolean {
|
||||||
return when (throwable) {
|
return when (throwable) {
|
||||||
// we know the content is not available, retrying won't help
|
// if we know the content is surely not available, retrying won't help
|
||||||
is ContentNotAvailableException -> false
|
is ContentNotAvailableException -> !isContentSurelyNotAvailable(throwable)
|
||||||
|
|
||||||
// we know the content is not supported, retrying won't help
|
// we know the content is not supported, retrying won't help
|
||||||
is ContentNotSupportedException -> false
|
is ContentNotSupportedException -> false
|
||||||
|
|
@ -329,5 +329,28 @@ class ErrorInfo private constructor(
|
||||||
else -> true
|
else -> true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unfortunately sometimes [ContentNotAvailableException] may not indicate that the content
|
||||||
|
* is blocked/deleted/paid, but may just indicate that we could not extract it. This is an
|
||||||
|
* inconsistency in the exceptions thrown by the extractor, but until it is fixed, this
|
||||||
|
* function will distinguish between the two types.
|
||||||
|
* @return `true` if the content is not available because of a limitation imposed by the
|
||||||
|
* service or the owner, `false` if the extractor could not extract info about it
|
||||||
|
*/
|
||||||
|
fun isContentSurelyNotAvailable(e: ContentNotAvailableException): Boolean {
|
||||||
|
return when (e) {
|
||||||
|
is AccountTerminatedException,
|
||||||
|
is AgeRestrictedContentException,
|
||||||
|
is GeographicRestrictionException,
|
||||||
|
is PaidContentException,
|
||||||
|
is PrivateContentException,
|
||||||
|
is SoundCloudGoPlusContentException,
|
||||||
|
is UnsupportedContentInCountryException,
|
||||||
|
is YoutubeMusicPremiumContentException -> true
|
||||||
|
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue