fix: uncaught local streams extractor exceptions

This commit is contained in:
Bnyro 2024-09-25 14:33:13 +02:00
parent e6406440cf
commit f1d93b6840
2 changed files with 9 additions and 4 deletions

View File

@ -387,7 +387,9 @@ class DownloadService : LifecycleService() {
* Regenerate stream url using available info format and quality. * Regenerate stream url using available info format and quality.
*/ */
private suspend fun regenerateLink(item: DownloadItem) { private suspend fun regenerateLink(item: DownloadItem) {
val streams = StreamsExtractor.extractStreams(item.videoId) val streams = runCatching {
StreamsExtractor.extractStreams(item.videoId)
}.getOrNull() ?: return
val stream = when (item.type) { val stream = when (item.type) {
FileType.AUDIO -> streams.audioStreams FileType.AUDIO -> streams.audioStreams
FileType.VIDEO -> streams.videoStreams FileType.VIDEO -> streams.videoStreams

View File

@ -85,14 +85,17 @@ class DownloadDialog : DialogFragment() {
StreamsExtractor.extractStreams(videoId) StreamsExtractor.extractStreams(videoId)
} }
} catch (e: IOException) { } catch (e: IOException) {
println(e) Log.e(TAG(), e.stackTraceToString())
Log.e(TAG(), "IOException, you might not have internet connection")
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
return@launch return@launch
} catch (e: HttpException) { } catch (e: HttpException) {
Log.e(TAG(), "HttpException, unexpected response") Log.e(TAG(), e.stackTraceToString())
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
return@launch return@launch
} catch (e: Exception) {
Log.e(TAG(), e.stackTraceToString())
Toast.makeText(context, e.localizedMessage, Toast.LENGTH_SHORT).show()
return@launch
} }
initDownloadOptions(binding, response) initDownloadOptions(binding, response)
} }