@@ -299,9 +299,9 @@ class ErrorInfo private constructor(
299299 // indicates that it's important and is thus reportable
300300 null -> true
301301
302- // the service explicitly said that content is not available (e.g. age restrictions,
303- // video deleted, etc.), there is no use in letting users report it
304- is ContentNotAvailableException -> false
302+ // if the service explicitly said that content is not available (e.g. age
303+ // restrictions, video deleted, etc.), there is no use in letting users report it
304+ is ContentNotAvailableException -> ! isContentSurelyNotAvailable(throwable)
305305
306306 // we know the content is not supported, no need to let the user report it
307307 is ContentNotSupportedException -> false
@@ -318,8 +318,8 @@ class ErrorInfo private constructor(
318318
319319 fun isRetryable (throwable : Throwable ? ): Boolean {
320320 return when (throwable) {
321- // we know the content is not available, retrying won't help
322- is ContentNotAvailableException -> false
321+ // if we know the content is surely not available, retrying won't help
322+ is ContentNotAvailableException -> ! isContentSurelyNotAvailable(throwable)
323323
324324 // we know the content is not supported, retrying won't help
325325 is ContentNotSupportedException -> false
@@ -329,5 +329,28 @@ class ErrorInfo private constructor(
329329 else -> true
330330 }
331331 }
332+
333+ /* *
334+ * Unfortunately sometimes [ContentNotAvailableException] may not indicate that the content
335+ * is blocked/deleted/paid, but may just indicate that we could not extract it. This is an
336+ * inconsistency in the exceptions thrown by the extractor, but until it is fixed, this
337+ * function will distinguish between the two types.
338+ * @return `true` if the content is not available because of a limitation imposed by the
339+ * service or the owner, `false` if the extractor could not extract info about it
340+ */
341+ fun isContentSurelyNotAvailable (e : ContentNotAvailableException ): Boolean {
342+ return when (e) {
343+ is AccountTerminatedException ,
344+ is AgeRestrictedContentException ,
345+ is GeographicRestrictionException ,
346+ is PaidContentException ,
347+ is PrivateContentException ,
348+ is SoundCloudGoPlusContentException ,
349+ is UnsupportedContentInCountryException ,
350+ is YoutubeMusicPremiumContentException -> true
351+
352+ else -> false
353+ }
354+ }
332355 }
333356}
0 commit comments