From 92e699075c0e3d534db88107c57a108376427500 Mon Sep 17 00:00:00 2001 From: Shabinder Date: Mon, 9 Nov 2020 17:01:28 +0530 Subject: [PATCH] YT Scraper issue Fix --- .../shabinder/spotiflyer/downloadHelper/DownloadHelper.kt | 1 + .../shabinder/spotiflyer/downloadHelper/YoutubeProvider.kt | 4 ++-- .../com/shabinder/spotiflyer/worker/ForegroundService.kt | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/shabinder/spotiflyer/downloadHelper/DownloadHelper.kt b/app/src/main/java/com/shabinder/spotiflyer/downloadHelper/DownloadHelper.kt index fedb4d13..d764162f 100755 --- a/app/src/main/java/com/shabinder/spotiflyer/downloadHelper/DownloadHelper.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/downloadHelper/DownloadHelper.kt @@ -130,6 +130,7 @@ object DownloadHelper { } } override fun onFailure(call: Call, t: Throwable) { + if(t.message.toString().contains("Failed to connect")) showMessage("Failed, Check Your Internet Connection!") Log.i("YT API Req. Fail",t.message.toString()) } } diff --git a/app/src/main/java/com/shabinder/spotiflyer/downloadHelper/YoutubeProvider.kt b/app/src/main/java/com/shabinder/spotiflyer/downloadHelper/YoutubeProvider.kt index 743f2dd0..2ffe02ea 100644 --- a/app/src/main/java/com/shabinder/spotiflyer/downloadHelper/YoutubeProvider.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/downloadHelper/YoutubeProvider.kt @@ -128,12 +128,12 @@ fun getYTTracks(response: String):List{ ) } } - //Log.i("Text Api",availableDetails.toString()) + Log.i("Text Api",availableDetails.toString()) /* ! Filter Out non-Song/Video results and incomplete results here itself ! From what we know about detail order, note that [1] - indicate result type */ - if ( availableDetails.size > 1 && availableDetails[1] in listOf("Song","Video") ){ + if ( availableDetails.size == 5 && availableDetails[1] in listOf("Song","Video") ){ // skip if result is in hours instead of minutes (no song is that long) if(availableDetails[4].split(':').size != 2) continue //Has Been Giving Issues diff --git a/app/src/main/java/com/shabinder/spotiflyer/worker/ForegroundService.kt b/app/src/main/java/com/shabinder/spotiflyer/worker/ForegroundService.kt index 430de1c9..edb8b844 100755 --- a/app/src/main/java/com/shabinder/spotiflyer/worker/ForegroundService.kt +++ b/app/src/main/java/com/shabinder/spotiflyer/worker/ForegroundService.kt @@ -630,9 +630,9 @@ class ForegroundService : Service(){ ) } "gaana" -> { - File( - Environment.getExternalStorageDirectory(), - Provider.defaultDir +".Images/" + (url.substringBeforeLast('/').substringAfterLast('/')) + ".jpeg") + File( + Environment.getExternalStorageDirectory(), + Provider.defaultDir +".Images/" + (url.substringBeforeLast('/').substringAfterLast('/')) + ".jpeg") } else -> File( Environment.getExternalStorageDirectory(),