Version Bumped to 2.3.0

This commit is contained in:
shabinder 2021-05-07 00:39:33 +05:30
parent 60b2f04780
commit 5118aa10c4
2 changed files with 67 additions and 69 deletions

View File

@ -18,7 +18,7 @@
object Versions { object Versions {
// App's Version (To be bumped at each update) // App's Version (To be bumped at each update)
const val versionName = "2.2.5" const val versionName = "2.3.0"
// Kotlin // Kotlin
const val kotlinVersion = "1.4.32" const val kotlinVersion = "1.4.32"
@ -45,7 +45,7 @@ object Versions {
const val slf4j = "1.7.30" const val slf4j = "1.7.30"
// Android // Android
const val versionCode = 16 const val versionCode = 17
const val minSdkVersion = 21 const val minSdkVersion = 21
const val compileSdkVersion = 29 const val compileSdkVersion = 29
const val targetSdkVersion = 29 const val targetSdkVersion = 29

View File

@ -163,19 +163,21 @@ class ForegroundService : Service(), CoroutineScope {
private fun downloadAllTracks(trackList: List<TrackDetails>) { private fun downloadAllTracks(trackList: List<TrackDetails>) {
trackList.forEach { trackList.forEach {
launch(Dispatchers.IO) { launch(Dispatchers.IO) {
if (!it.videoID.isNullOrBlank()) { // Video ID already known! downloadService.execute {
downloadTrack(it.videoID!!, it) if (!it.videoID.isNullOrBlank()) { // Video ID already known!
} else { downloadTrack(it.videoID!!, it)
val searchQuery = "${it.title} - ${it.artists.joinToString(",")}" } else {
val videoID = fetcher.youtubeMusic.getYTIDBestMatch(searchQuery, it) val searchQuery = "${it.title} - ${it.artists.joinToString(",")}"
logger.d("Service VideoID") { videoID ?: "Not Found" } val videoID = fetcher.youtubeMusic.getYTIDBestMatch(searchQuery, it)
if (videoID.isNullOrBlank()) { logger.d("Service VideoID") { videoID ?: "Not Found" }
sendTrackBroadcast(Status.FAILED.name, it) if (videoID.isNullOrBlank()) {
failed++ sendTrackBroadcast(Status.FAILED.name, it)
updateNotification() failed++
allTracksStatus[it.title] = DownloadStatus.Failed updateNotification()
} else { // Found Youtube Video ID allTracksStatus[it.title] = DownloadStatus.Failed
downloadTrack(videoID, it) } else { // Found Youtube Video ID
downloadTrack(videoID, it)
}
} }
} }
} }
@ -197,7 +199,7 @@ class ForegroundService : Service(), CoroutineScope {
} }
} }
private fun enqueueDownload(url: String, track: TrackDetails) { private suspend fun enqueueDownload(url: String, track: TrackDetails) {
// Initiating Download // Initiating Download
addToNotification("Downloading ${track.title}") addToNotification("Downloading ${track.title}")
logger.d(tag) { "${track.title} Download Started" } logger.d(tag) { "${track.title} Download Started" }
@ -205,60 +207,56 @@ class ForegroundService : Service(), CoroutineScope {
sendTrackBroadcast(Status.DOWNLOADING.name, track) sendTrackBroadcast(Status.DOWNLOADING.name, track)
// Enqueueing Download // Enqueueing Download
launch { downloadFile(url).collect {
downloadService.execute { when (it) {
downloadFile(url).collect { is DownloadResult.Error -> {
when (it) { launch {
is DownloadResult.Error -> { logger.d(tag) { it.message }
launch { logger.d(tag) { "${track.title} Requesting Download thru Android DM" }
logger.d(tag) { it.message } downloadUsingDM(url, track.outputFilePath, track)
logger.d(tag) { "${track.title} Requesting Download thru Android DM" } removeFromNotification("Downloading ${track.title}")
downloadUsingDM(url, track.outputFilePath, track) downloaded++
removeFromNotification("Downloading ${track.title}")
downloaded++
}
updateNotification()
sendTrackBroadcast(Status.FAILED.name,track)
}
is DownloadResult.Progress -> {
allTracksStatus[track.title] = DownloadStatus.Downloading(it.progress)
logger.d(tag) { "${track.title} Progress: ${it.progress} %" }
val intent = Intent().apply {
action = "Progress"
putExtra("progress", it.progress)
putExtra("track", track)
}
sendBroadcast(intent)
}
is DownloadResult.Success -> {
try {
// Save File and Embed Metadata
val job = launch(Dispatchers.Default) { dir.saveFileWithMetadata(it.byteArray, track){} }
allTracksStatus[track.title] = DownloadStatus.Converting
sendTrackBroadcast("Converting", track)
addToNotification("Processing ${track.title}")
job.invokeOnCompletion {
converted++
allTracksStatus[track.title] = DownloadStatus.Downloaded
sendTrackBroadcast(Status.COMPLETED.name, track)
removeFromNotification("Processing ${track.title}")
}
logger.d(tag) { "${track.title} Download Completed" }
} catch (
e: KotlinNullPointerException
) {
// Try downloading using android DM
logger.d(tag) { "${track.title} Download Failed! Error:Fetch!!!!" }
logger.d(tag) { "${track.title} Requesting Download thru Android DM" }
downloadUsingDM(url, track.outputFilePath, track)
}
downloaded++
removeFromNotification("Downloading ${track.title}")
}
} }
updateNotification()
sendTrackBroadcast(Status.FAILED.name,track)
}
is DownloadResult.Progress -> {
allTracksStatus[track.title] = DownloadStatus.Downloading(it.progress)
logger.d(tag) { "${track.title} Progress: ${it.progress} %" }
val intent = Intent().apply {
action = "Progress"
putExtra("progress", it.progress)
putExtra("track", track)
}
sendBroadcast(intent)
}
is DownloadResult.Success -> {
try {
// Save File and Embed Metadata
val job = launch(Dispatchers.Default) { dir.saveFileWithMetadata(it.byteArray, track){} }
allTracksStatus[track.title] = DownloadStatus.Converting
sendTrackBroadcast("Converting", track)
addToNotification("Processing ${track.title}")
job.invokeOnCompletion {
converted++
allTracksStatus[track.title] = DownloadStatus.Downloaded
sendTrackBroadcast(Status.COMPLETED.name, track)
removeFromNotification("Processing ${track.title}")
}
logger.d(tag) { "${track.title} Download Completed" }
} catch (
e: KotlinNullPointerException
) {
// Try downloading using android DM
logger.d(tag) { "${track.title} Download Failed! Error:Fetch!!!!" }
logger.d(tag) { "${track.title} Requesting Download thru Android DM" }
downloadUsingDM(url, track.outputFilePath, track)
}
downloaded++
removeFromNotification("Downloading ${track.title}")
} }
} }
} }