mirror of
https://github.com/Shabinder/SpotiFlyer.git
synced 2024-11-22 09:04:32 +01:00
App Builds!
This commit is contained in:
parent
77d6996f5d
commit
85a8dfec68
@ -19,7 +19,7 @@ package com.shabinder.android
|
||||
import android.app.Application
|
||||
import com.shabinder.android.di.appModule
|
||||
import com.shabinder.common.database.appContext
|
||||
import com.shabinder.common.initKoin
|
||||
import com.shabinder.common.di.initKoin
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
import org.koin.android.ext.koin.androidLogger
|
||||
import org.koin.core.KoinComponent
|
||||
|
@ -7,8 +7,8 @@ import androidx.compose.ui.platform.setContent
|
||||
import com.arkivanov.decompose.extensions.compose.jetbrains.rootComponent
|
||||
import com.arkivanov.mvikotlin.logging.store.LoggingStoreFactory
|
||||
import com.arkivanov.mvikotlin.main.store.DefaultStoreFactory
|
||||
import com.shabinder.common.Dir
|
||||
import com.shabinder.common.FetchPlatformQueryResult
|
||||
import com.shabinder.common.di.Dir
|
||||
import com.shabinder.common.di.FetchPlatformQueryResult
|
||||
import com.shabinder.common.root.SpotiFlyerRoot
|
||||
import com.shabinder.common.root.SpotiFlyerRootContent
|
||||
import com.shabinder.common.ui.SpotiFlyerTheme
|
||||
|
@ -1,23 +1,15 @@
|
||||
package com.shabinder.common.ui
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.preferredHeight
|
||||
import androidx.compose.foundation.layout.preferredWidth
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.ImageBitmap
|
||||
import androidx.compose.ui.graphics.asImageBitmap
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.res.vectorResource
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.core.net.toUri
|
||||
import com.shabinder.common.Picture
|
||||
import com.shabinder.common.di.Picture
|
||||
import com.shabinder.common.database.appContext
|
||||
import dev.chrisbanes.accompanist.coil.CoilImage
|
||||
|
||||
@Composable
|
||||
actual fun ImageLoad(
|
||||
|
@ -1,13 +1,15 @@
|
||||
package com.shabinder.common.list
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import com.arkivanov.decompose.ComponentContext
|
||||
import com.arkivanov.mvikotlin.core.store.StoreFactory
|
||||
import com.shabinder.common.*
|
||||
import com.shabinder.common.di.Dir
|
||||
import com.shabinder.common.di.FetchPlatformQueryResult
|
||||
import com.shabinder.common.di.Picture
|
||||
import com.shabinder.common.list.integration.SpotiFlyerListImpl
|
||||
import com.shabinder.common.spotify.Source
|
||||
import com.shabinder.common.models.spotify.Source
|
||||
import com.shabinder.common.utils.Consumer
|
||||
import com.shabinder.database.Database
|
||||
import com.shabinder.common.models.PlatformQueryResult
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface SpotiFlyerList {
|
||||
@ -21,7 +23,7 @@ interface SpotiFlyerList {
|
||||
/*
|
||||
* Download All Tracks(after filtering already Downloaded)
|
||||
* */
|
||||
fun onDownloadClicked(wholeTrackList:List<TrackDetails>,trackIndex:Int)
|
||||
fun onDownloadClicked(wholeTrackList:List<TrackDetails>, trackIndex:Int)
|
||||
|
||||
/*
|
||||
* To Pop and return back to Main Screen
|
||||
@ -31,7 +33,7 @@ interface SpotiFlyerList {
|
||||
/*
|
||||
* Load Image from cache/Internet and cache it
|
||||
* */
|
||||
fun loadImage(url:String):Picture?
|
||||
fun loadImage(url:String): Picture?
|
||||
|
||||
interface Dependencies {
|
||||
val storeFactory: StoreFactory
|
||||
@ -44,7 +46,7 @@ interface SpotiFlyerList {
|
||||
object Finished : Output()
|
||||
}
|
||||
data class State(
|
||||
val queryResult:PlatformQueryResult? = PlatformQueryResult(
|
||||
val queryResult: PlatformQueryResult? = PlatformQueryResult(
|
||||
"","",
|
||||
"Loading","", emptyList(),
|
||||
Source.Spotify),
|
||||
|
@ -17,9 +17,9 @@ import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.shabinder.common.DownloadStatus
|
||||
import com.shabinder.common.Picture
|
||||
import com.shabinder.common.TrackDetails
|
||||
import com.shabinder.common.models.DownloadStatus
|
||||
import com.shabinder.common.di.Picture
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
import com.shabinder.common.ui.*
|
||||
import com.shabinder.common.ui.SpotiFlyerTypography
|
||||
import com.shabinder.common.ui.colorAccent
|
||||
@ -64,10 +64,10 @@ fun SpotiFlyerListContent(
|
||||
fun TrackCard(
|
||||
track: TrackDetails,
|
||||
downloadTrack:()->Unit,
|
||||
loadImage:(String)->Picture?
|
||||
loadImage:(String)-> Picture?
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically,modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp)) {
|
||||
val pic:Picture? = loadImage(track.albumArtURL)
|
||||
val pic: Picture? = loadImage(track.albumArtURL)
|
||||
ImageLoad(
|
||||
pic = pic,
|
||||
modifier = Modifier
|
||||
|
@ -2,8 +2,8 @@ package com.shabinder.common.list.integration
|
||||
|
||||
import com.arkivanov.decompose.ComponentContext
|
||||
import com.arkivanov.mvikotlin.extensions.coroutines.states
|
||||
import com.shabinder.common.Picture
|
||||
import com.shabinder.common.TrackDetails
|
||||
import com.shabinder.common.di.Picture
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
import com.shabinder.common.list.SpotiFlyerList
|
||||
import com.shabinder.common.list.SpotiFlyerList.Dependencies
|
||||
import com.shabinder.common.list.SpotiFlyerList.State
|
||||
|
@ -1,9 +1,7 @@
|
||||
package com.shabinder.common.list.store
|
||||
|
||||
import com.arkivanov.mvikotlin.core.store.Store
|
||||
import com.shabinder.common.PlatformQueryResult
|
||||
import com.shabinder.common.TrackDetails
|
||||
import com.shabinder.common.list.SpotiFlyerList
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
import com.shabinder.common.list.SpotiFlyerList.State
|
||||
import com.shabinder.common.list.store.SpotiFlyerListStore.*
|
||||
|
||||
|
@ -2,9 +2,13 @@ package com.shabinder.common.list.store
|
||||
|
||||
import com.arkivanov.mvikotlin.core.store.*
|
||||
import com.arkivanov.mvikotlin.extensions.coroutines.SuspendExecutor
|
||||
import com.shabinder.common.*
|
||||
import com.shabinder.common.di.FetchPlatformQueryResult
|
||||
import com.shabinder.common.di.downloadTracks
|
||||
import com.shabinder.common.list.SpotiFlyerList.State
|
||||
import com.shabinder.common.list.store.SpotiFlyerListStore.Intent
|
||||
import com.shabinder.common.models.DownloadStatus
|
||||
import com.shabinder.common.models.PlatformQueryResult
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
|
||||
internal class SpotiFlyerListStoreProvider(
|
||||
private val storeFactory: StoreFactory,
|
||||
|
@ -2,9 +2,9 @@ package com.shabinder.common.main
|
||||
|
||||
import com.arkivanov.decompose.ComponentContext
|
||||
import com.arkivanov.mvikotlin.core.store.StoreFactory
|
||||
import com.shabinder.common.Dir
|
||||
import com.shabinder.common.DownloadRecord
|
||||
import com.shabinder.common.Picture
|
||||
import com.shabinder.common.di.Dir
|
||||
import com.shabinder.common.models.DownloadRecord
|
||||
import com.shabinder.common.di.Picture
|
||||
import com.shabinder.common.main.integration.SpotiFlyerMainImpl
|
||||
import com.shabinder.common.utils.Consumer
|
||||
import com.shabinder.database.Database
|
||||
@ -33,7 +33,7 @@ interface SpotiFlyerMain {
|
||||
/*
|
||||
* Load Image from cache/Internet and cache it
|
||||
* */
|
||||
fun loadImage(url:String):Picture?
|
||||
fun loadImage(url:String): Picture?
|
||||
|
||||
interface Dependencies {
|
||||
fun mainOutput(searched: Output): Consumer<Output>
|
||||
|
@ -25,10 +25,10 @@ import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.shabinder.common.DownloadRecord
|
||||
import com.shabinder.common.Picture
|
||||
import com.shabinder.common.models.DownloadRecord
|
||||
import com.shabinder.common.di.Picture
|
||||
import com.shabinder.common.main.SpotiFlyerMain.HomeCategory
|
||||
import com.shabinder.common.openPlatform
|
||||
import com.shabinder.common.di.openPlatform
|
||||
import com.shabinder.common.ui.*
|
||||
import com.shabinder.common.ui.SpotiFlyerTypography
|
||||
|
||||
@ -120,7 +120,7 @@ fun SearchPanel(
|
||||
value = link,
|
||||
onValueChange = updateLink ,
|
||||
leadingIcon = {
|
||||
Icon(Icons.Rounded.AddLink,"Link Text Box",tint = Color(0xFFCCCCCC))//LightGray
|
||||
Icon(Icons.Rounded.Edit,"Link Text Box",tint = Color(0xFFCCCCCC))//LightGray
|
||||
},
|
||||
label = { Text(text = "Paste Link Here...",color = Color(0xFFCCCCCC)) },
|
||||
singleLine = true,
|
||||
@ -300,7 +300,7 @@ fun AboutColumn(modifier: Modifier = Modifier) {
|
||||
@Composable
|
||||
fun HistoryColumn(
|
||||
list: List<DownloadRecord>,
|
||||
loadImage:(String)->Picture?,
|
||||
loadImage:(String)-> Picture?,
|
||||
onItemClicked: (String) -> Unit
|
||||
) {
|
||||
LazyColumn(
|
||||
@ -321,7 +321,7 @@ fun HistoryColumn(
|
||||
@Composable
|
||||
fun DownloadRecordItem(
|
||||
item: DownloadRecord,
|
||||
loadImage:(String)->Picture?,
|
||||
loadImage:(String)-> Picture?,
|
||||
onItemClicked:(String)->Unit
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically,modifier = Modifier.fillMaxWidth().padding(end = 8.dp)) {
|
||||
|
@ -2,7 +2,7 @@ package com.shabinder.common.main.integration
|
||||
|
||||
import com.arkivanov.decompose.ComponentContext
|
||||
import com.arkivanov.mvikotlin.extensions.coroutines.states
|
||||
import com.shabinder.common.Picture
|
||||
import com.shabinder.common.di.Picture
|
||||
import com.shabinder.common.main.SpotiFlyerMain
|
||||
import com.shabinder.common.main.SpotiFlyerMain.*
|
||||
import com.shabinder.common.main.store.SpotiFlyerMainStore.Intent
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.shabinder.common.main.store
|
||||
|
||||
import com.arkivanov.mvikotlin.core.store.Store
|
||||
import com.shabinder.common.DownloadRecord
|
||||
import com.shabinder.common.main.SpotiFlyerMain
|
||||
import com.shabinder.common.main.store.SpotiFlyerMainStore.*
|
||||
|
||||
|
@ -5,13 +5,13 @@ import com.arkivanov.mvikotlin.core.store.SimpleBootstrapper
|
||||
import com.arkivanov.mvikotlin.core.store.Store
|
||||
import com.arkivanov.mvikotlin.core.store.StoreFactory
|
||||
import com.arkivanov.mvikotlin.extensions.coroutines.SuspendExecutor
|
||||
import com.shabinder.common.DownloadRecord
|
||||
import com.shabinder.common.giveDonation
|
||||
import com.shabinder.common.models.DownloadRecord
|
||||
import com.shabinder.common.di.giveDonation
|
||||
import com.shabinder.common.main.SpotiFlyerMain
|
||||
import com.shabinder.common.main.SpotiFlyerMain.State
|
||||
import com.shabinder.common.main.store.SpotiFlyerMainStore.Intent
|
||||
import com.shabinder.common.openPlatform
|
||||
import com.shabinder.common.shareApp
|
||||
import com.shabinder.common.di.openPlatform
|
||||
import com.shabinder.common.di.shareApp
|
||||
import com.shabinder.database.Database
|
||||
import com.squareup.sqldelight.runtime.coroutines.asFlow
|
||||
import com.squareup.sqldelight.runtime.coroutines.mapToList
|
||||
|
@ -4,8 +4,8 @@ import com.arkivanov.decompose.ComponentContext
|
||||
import com.arkivanov.decompose.RouterState
|
||||
import com.arkivanov.decompose.value.Value
|
||||
import com.arkivanov.mvikotlin.core.store.StoreFactory
|
||||
import com.shabinder.common.Dir
|
||||
import com.shabinder.common.FetchPlatformQueryResult
|
||||
import com.shabinder.common.di.Dir
|
||||
import com.shabinder.common.di.FetchPlatformQueryResult
|
||||
import com.shabinder.common.list.SpotiFlyerList
|
||||
import com.shabinder.common.main.SpotiFlyerMain
|
||||
import com.shabinder.common.root.SpotiFlyerRoot.Dependencies
|
||||
|
@ -8,7 +8,7 @@ import com.arkivanov.decompose.router
|
||||
import com.arkivanov.decompose.statekeeper.Parcelable
|
||||
import com.arkivanov.decompose.statekeeper.Parcelize
|
||||
import com.arkivanov.decompose.value.Value
|
||||
import com.shabinder.common.Dir
|
||||
import com.shabinder.common.di.Dir
|
||||
import com.shabinder.common.list.SpotiFlyerList
|
||||
import com.shabinder.common.main.SpotiFlyerMain
|
||||
import com.shabinder.common.root.SpotiFlyerRoot
|
||||
|
@ -16,15 +16,8 @@
|
||||
|
||||
package com.shabinder.common.ui
|
||||
|
||||
import androidx.compose.material.Colors
|
||||
import androidx.compose.material.darkColors
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.colorspace.ColorSpaces
|
||||
import androidx.compose.ui.graphics.colorspace.Illuminant
|
||||
import androidx.compose.ui.graphics.colorspace.Rgb
|
||||
import androidx.compose.ui.graphics.colorspace.TransferParameters
|
||||
import androidx.compose.ui.graphics.compositeOver
|
||||
|
||||
val colorPrimary = Color(0xFFFC5C7D)
|
||||
val colorPrimaryDark = Color(0xFFCE1CFF)
|
||||
|
@ -2,7 +2,7 @@ package com.shabinder.common.ui
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.shabinder.common.Picture
|
||||
import com.shabinder.common.di.Picture
|
||||
|
||||
@Composable
|
||||
expect fun ImageLoad(
|
||||
|
@ -26,7 +26,6 @@ import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.rememberUpdatedState
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.shabinder.common.ui.*
|
||||
|
@ -16,11 +16,6 @@
|
||||
|
||||
package com.shabinder.common.ui.utils
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.compositeOver
|
||||
import androidx.compose.ui.graphics.luminance
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
/*
|
||||
|
||||
fun Color.contrastAgainst(background: Color): Float {
|
||||
|
@ -16,17 +16,6 @@
|
||||
|
||||
package com.shabinder.common.ui.utils
|
||||
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.composed
|
||||
import androidx.compose.ui.draw.drawBehind
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import kotlin.math.pow
|
||||
|
||||
/**
|
||||
* Draws a vertical gradient scrim in the foreground.
|
||||
*
|
||||
|
@ -5,7 +5,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.asImageBitmap
|
||||
import androidx.compose.ui.res.vectorXmlResource
|
||||
import com.shabinder.common.Picture
|
||||
import com.shabinder.common.di.Picture
|
||||
import java.awt.image.BufferedImage
|
||||
import java.io.ByteArrayOutputStream
|
||||
import javax.imageio.ImageIO
|
||||
@ -18,6 +18,7 @@ actual fun ImageLoad(
|
||||
if(pic == null) {
|
||||
Image(
|
||||
vectorXmlResource("common/compose-ui/src/main/res/drawable/music.xml"),
|
||||
"",
|
||||
modifier
|
||||
)
|
||||
}
|
||||
@ -26,6 +27,7 @@ actual fun ImageLoad(
|
||||
org.jetbrains.skija.Image.makeFromEncoded(
|
||||
toByteArray(pic.image)
|
||||
).asImageBitmap(),
|
||||
"Image",
|
||||
modifier = modifier
|
||||
)
|
||||
}
|
||||
|
@ -14,9 +14,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.models
|
||||
|
||||
import com.shabinder.common.spotify.Source
|
||||
import com.shabinder.common.models.spotify.Source
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
@ -1,4 +1,4 @@
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.models
|
||||
|
||||
data class DownloadRecord(
|
||||
var id:Long = 0,
|
@ -1,4 +1,4 @@
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.models
|
||||
|
||||
sealed class DownloadResult {
|
||||
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.models
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -14,9 +14,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.models
|
||||
|
||||
import com.shabinder.common.spotify.Source
|
||||
import com.shabinder.common.models.spotify.Source
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.models
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.gaana
|
||||
package com.shabinder.common.models.gaana
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.gaana
|
||||
package com.shabinder.common.models.gaana
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.gaana
|
||||
package com.shabinder.common.models.gaana
|
||||
|
||||
data class GaanaAlbum (
|
||||
val tracks : List<GaanaTrack>,
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.gaana
|
||||
package com.shabinder.common.models.gaana
|
||||
|
||||
data class GaanaArtistDetails(
|
||||
val artist : List<Artist>,
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.gaana
|
||||
package com.shabinder.common.models.gaana
|
||||
|
||||
data class GaanaArtistTracks(
|
||||
val count : Int,
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.gaana
|
||||
package com.shabinder.common.models.gaana
|
||||
|
||||
data class GaanaPlaylist (
|
||||
val modified_on : String,
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.gaana
|
||||
package com.shabinder.common.models.gaana
|
||||
|
||||
data class GaanaSong(
|
||||
val tracks : List<GaanaTrack>
|
@ -14,9 +14,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.gaana
|
||||
package com.shabinder.common.models.gaana
|
||||
|
||||
import com.shabinder.common.DownloadStatus
|
||||
import com.shabinder.common.models.DownloadStatus
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.gaana
|
||||
package com.shabinder.common.models.gaana
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.gaana
|
||||
package com.shabinder.common.models.gaana
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.spotify
|
||||
package com.shabinder.common.models.spotify
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.spotify
|
||||
package com.shabinder.common.models.spotify
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.spotify
|
||||
package com.shabinder.common.models.spotify
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.spotify
|
||||
package com.shabinder.common.models.spotify
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.spotify
|
||||
package com.shabinder.common.models.spotify
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.spotify
|
||||
package com.shabinder.common.models.spotify
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.spotify
|
||||
package com.shabinder.common.models.spotify
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.spotify
|
||||
package com.shabinder.common.models.spotify
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.spotify
|
||||
package com.shabinder.common.models.spotify
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.spotify
|
||||
package com.shabinder.common.models.spotify
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.spotify
|
||||
package com.shabinder.common.models.spotify
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.spotify
|
||||
package com.shabinder.common.models.spotify
|
||||
|
||||
enum class Source {
|
||||
Spotify,
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.spotify
|
||||
package com.shabinder.common.models.spotify
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
@ -14,9 +14,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.spotify
|
||||
package com.shabinder.common.models.spotify
|
||||
|
||||
import com.shabinder.common.DownloadStatus
|
||||
import com.shabinder.common.models.DownloadStatus
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.spotify
|
||||
package com.shabinder.common.models.spotify
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -14,7 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.spotify
|
||||
package com.shabinder.common.models.spotify
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
@ -1,5 +1,5 @@
|
||||
CREATE TABLE Token (
|
||||
index INTEGER NOT NULL DEFAULT 0 PRIMARY KEY ON CONFLICT REPLACE,
|
||||
tokenIndex INTEGER NOT NULL DEFAULT 0 PRIMARY KEY ON CONFLICT REPLACE,
|
||||
accessToken TEXT NOT NULL,
|
||||
expiry INTEGER NOT NULL
|
||||
);
|
||||
@ -11,7 +11,7 @@ VALUES (?,?);
|
||||
select:
|
||||
SELECT *
|
||||
FROM Token
|
||||
WHERE index = 0;
|
||||
WHERE tokenIndex = 0;
|
||||
|
||||
clear:
|
||||
DELETE FROM Token;
|
@ -11,6 +11,7 @@ kotlin {
|
||||
implementation(project(":common:data-models"))
|
||||
implementation(project(":common:database"))
|
||||
implementation(project(":fuzzywuzzy:app"))
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.1")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.1.1")
|
||||
implementation(Ktor.clientCore)
|
||||
|
@ -1,25 +0,0 @@
|
||||
package com.shabinder.common
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.os.Environment
|
||||
import co.touchlab.kermit.Kermit
|
||||
import com.shabinder.common.database.appContext
|
||||
import java.io.*
|
||||
import java.nio.charset.StandardCharsets
|
||||
|
||||
actual fun openPlatform(platformID:String ,platformLink:String){
|
||||
//TODO
|
||||
}
|
||||
|
||||
actual fun shareApp(){
|
||||
//TODO
|
||||
}
|
||||
|
||||
actual fun giveDonation(){
|
||||
//TODO
|
||||
}
|
||||
|
||||
actual fun downloadTracks(list: List<TrackDetails>){
|
||||
//TODO
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.di
|
||||
|
||||
import co.touchlab.kermit.Kermit
|
||||
import java.io.*
|
||||
import java.nio.charset.StandardCharsets
|
||||
import javax.imageio.ImageIO
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
|
||||
actual fun openPlatform(platformID:String ,platformLink:String){
|
||||
//TODO
|
@ -1,4 +1,4 @@
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.di
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
@ -6,6 +6,7 @@ import android.graphics.BitmapFactory
|
||||
import android.os.Environment
|
||||
import co.touchlab.kermit.Kermit
|
||||
import com.mpatric.mp3agic.Mp3File
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
import com.shabinder.common.database.appContext
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
@ -95,7 +96,7 @@ actual class Dir actual constructor(
|
||||
.setId3v2TagsAndSaveFile(trackDetails,path)
|
||||
}
|
||||
|
||||
actual fun loadImage(url: String):Picture? {
|
||||
actual fun loadImage(url: String): Picture? {
|
||||
val cachePath = imageCacheDir() + getNameURL(url)
|
||||
var picture: Picture? = loadCachedImage(cachePath)
|
||||
if (picture == null) picture = freshImage(url)
|
||||
@ -120,7 +121,7 @@ actual class Dir actual constructor(
|
||||
val result: Bitmap? = BitmapFactory.decodeFile(cachePath)
|
||||
|
||||
if (result != null) {
|
||||
Picture(
|
||||
com.shabinder.common.di.Picture(
|
||||
source,
|
||||
getNameURL(source),
|
||||
result,
|
||||
@ -133,7 +134,7 @@ actual class Dir actual constructor(
|
||||
null
|
||||
}
|
||||
}
|
||||
private fun freshImage(url:String):Picture?{
|
||||
private fun freshImage(url:String): Picture?{
|
||||
return try {
|
||||
val source = URL(url)
|
||||
val connection: HttpURLConnection = source.openConnection() as HttpURLConnection
|
||||
@ -144,7 +145,7 @@ actual class Dir actual constructor(
|
||||
val result: Bitmap? = BitmapFactory.decodeStream(input)
|
||||
|
||||
if (result != null) {
|
||||
val picture = Picture(
|
||||
val picture = com.shabinder.common.di.Picture(
|
||||
url,
|
||||
getNameURL(url),
|
||||
result,
|
@ -1,11 +1,11 @@
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.di
|
||||
|
||||
import com.mpatric.mp3agic.ID3v1Tag
|
||||
import com.mpatric.mp3agic.ID3v24Tag
|
||||
import com.mpatric.mp3agic.Mp3File
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import com.shabinder.common.models.DownloadResult
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
|
||||
@ -32,7 +32,7 @@ fun Mp3File.setId3v1Tags(track: TrackDetails): Mp3File {
|
||||
}
|
||||
|
||||
@Suppress("BlockingMethodInNonBlockingContext")
|
||||
suspend fun Mp3File.setId3v2TagsAndSaveFile(track: TrackDetails,filePath:String){
|
||||
suspend fun Mp3File.setId3v2TagsAndSaveFile(track: TrackDetails, filePath:String){
|
||||
val id3v2Tag = ID3v24Tag().apply {
|
||||
artist = track.artists.joinToString(",")
|
||||
title = track.title
|
@ -1,4 +1,4 @@
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.di
|
||||
|
||||
import android.graphics.Bitmap
|
||||
|
@ -14,13 +14,15 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.di
|
||||
|
||||
import co.touchlab.kermit.Kermit
|
||||
import com.github.kiulian.downloader.YoutubeDownloader
|
||||
import com.shabinder.common.models.DownloadStatus
|
||||
import com.shabinder.common.models.PlatformQueryResult
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
import com.shabinder.common.database.DownloadRecordDatabaseQueries
|
||||
import com.shabinder.common.spotify.Source
|
||||
import com.shabinder.common.utils.removeIllegalChars
|
||||
import com.shabinder.common.models.spotify.Source
|
||||
import com.shabinder.database.Database
|
||||
import io.ktor.client.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -80,7 +82,7 @@ actual class YoutubeProvider actual constructor(
|
||||
|
||||
private suspend fun getYTPlaylist(
|
||||
searchId: String
|
||||
):PlatformQueryResult?{
|
||||
): PlatformQueryResult?{
|
||||
val result = PlatformQueryResult(
|
||||
folderType = "",
|
||||
subFolder = "",
|
||||
@ -155,7 +157,7 @@ actual class YoutubeProvider actual constructor(
|
||||
@Suppress("DefaultLocale")
|
||||
private suspend fun getYTTrack(
|
||||
searchId:String,
|
||||
):PlatformQueryResult? {
|
||||
): PlatformQueryResult? {
|
||||
val result = PlatformQueryResult(
|
||||
folderType = "",
|
||||
subFolder = "",
|
@ -1,17 +1,18 @@
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.di
|
||||
|
||||
import co.touchlab.kermit.Kermit
|
||||
import com.shabinder.common.database.createDatabase
|
||||
import com.shabinder.common.database.getLogger
|
||||
import com.shabinder.common.providers.GaanaProvider
|
||||
import com.shabinder.common.providers.SpotifyProvider
|
||||
import com.shabinder.common.providers.YoutubeMusic
|
||||
import com.shabinder.common.di.providers.GaanaProvider
|
||||
import com.shabinder.common.di.providers.SpotifyProvider
|
||||
import com.shabinder.common.di.providers.YoutubeMusic
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.features.json.*
|
||||
import io.ktor.client.features.json.serializer.*
|
||||
import io.ktor.client.features.logging.*
|
||||
import io.ktor.client.request.*
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.serialization.json.Json
|
||||
import org.koin.core.context.startKoin
|
||||
import org.koin.dsl.KoinAppDeclaration
|
||||
@ -40,17 +41,22 @@ val kotlinxSerializer = KotlinxSerializer( Json {
|
||||
isLenient = true
|
||||
ignoreUnknownKeys = true
|
||||
})
|
||||
|
||||
/*
|
||||
* Refactor This
|
||||
* */
|
||||
fun isInternetAvailable(): Boolean {
|
||||
return runBlocking {
|
||||
var result = false
|
||||
val job = GlobalScope.launch {
|
||||
try {
|
||||
ktorHttpClient.head<String>("http://google.com")
|
||||
true
|
||||
result = true
|
||||
} catch (e: Exception) {
|
||||
println(e.message)
|
||||
false
|
||||
result = false
|
||||
}
|
||||
}
|
||||
while (job.isActive){}
|
||||
return result
|
||||
}
|
||||
fun createHttpClient(enableNetworkLogs: Boolean = false,serializer: KotlinxSerializer = kotlinxSerializer) = HttpClient {
|
||||
install(JsonFeature) {
|
@ -1,7 +1,8 @@
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.di
|
||||
|
||||
import co.touchlab.kermit.Kermit
|
||||
import com.shabinder.common.utils.removeIllegalChars
|
||||
import com.shabinder.common.models.DownloadResult
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.client.statement.*
|
||||
import io.ktor.http.*
|
||||
@ -18,7 +19,7 @@ expect class Dir(
|
||||
fun imageCacheDir(): String
|
||||
fun createDirectory(dirPath:String)
|
||||
suspend fun cacheImage(picture: Picture)
|
||||
fun loadImage(url:String):Picture?
|
||||
fun loadImage(url:String): Picture?
|
||||
suspend fun clearCache()
|
||||
suspend fun saveFileWithMetadata(mp3ByteArray: ByteArray, path: String, trackDetails: TrackDetails)
|
||||
}
|
||||
@ -59,7 +60,7 @@ fun Dir.createDirectories() {
|
||||
createDirectory(defaultDir() + "Playlists/")
|
||||
createDirectory(defaultDir() + "YT_Downloads/")
|
||||
}
|
||||
fun Dir.finalOutputDir(itemName:String ,type:String, subFolder:String,defaultDir:String,extension:String = ".mp3" ): String =
|
||||
fun Dir.finalOutputDir(itemName:String, type:String, subFolder:String, defaultDir:String, extension:String = ".mp3" ): String =
|
||||
defaultDir + removeIllegalChars(type) + this.fileSeparator() +
|
||||
if(subFolder.isEmpty())"" else { removeIllegalChars(subFolder) + this.fileSeparator()} +
|
||||
removeIllegalChars(itemName) + extension
|
@ -1,7 +1,6 @@
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.di
|
||||
|
||||
import co.touchlab.kermit.Kermit
|
||||
import com.shabinder.common.utils.removeIllegalChars
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
|
||||
expect class Picture
|
||||
|
@ -1,8 +1,9 @@
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.di
|
||||
|
||||
import com.shabinder.common.models.PlatformQueryResult
|
||||
import com.shabinder.common.database.DownloadRecordDatabaseQueries
|
||||
import com.shabinder.common.providers.GaanaProvider
|
||||
import com.shabinder.common.providers.SpotifyProvider
|
||||
import com.shabinder.common.di.providers.GaanaProvider
|
||||
import com.shabinder.common.di.providers.SpotifyProvider
|
||||
import com.shabinder.database.Database
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
@ -1,9 +1,9 @@
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.di
|
||||
|
||||
import co.touchlab.kermit.Kermit
|
||||
import com.shabinder.common.database.TokenDBQueries
|
||||
import com.shabinder.common.spotify.TokenData
|
||||
import com.shabinder.common.spotify.authenticateSpotify
|
||||
import com.shabinder.common.models.spotify.TokenData
|
||||
import com.shabinder.common.di.spotify.authenticateSpotify
|
||||
import com.shabinder.database.Database
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
@ -21,8 +21,8 @@ class TokenStore(
|
||||
db.add(token.access_token!!, token.expiry!! + Clock.System.now().epochSeconds)
|
||||
}
|
||||
|
||||
suspend fun getToken(): TokenData{
|
||||
var token:TokenData? = db.select().executeAsOneOrNull()?.let {
|
||||
suspend fun getToken(): TokenData {
|
||||
var token: TokenData? = db.select().executeAsOneOrNull()?.let {
|
||||
TokenData(it.accessToken,null,it.expiry)
|
||||
}
|
||||
if(Clock.System.now().epochSeconds > token?.expiry ?:0 || token == null){
|
@ -1,4 +1,4 @@
|
||||
package com.shabinder.common.utils
|
||||
package com.shabinder.common.di
|
||||
|
||||
/**
|
||||
* Removing Illegal Chars from File Name
|
@ -1,6 +1,7 @@
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.di
|
||||
|
||||
import co.touchlab.kermit.Kermit
|
||||
import com.shabinder.common.models.PlatformQueryResult
|
||||
import com.shabinder.database.Database
|
||||
import io.ktor.client.*
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.shabinder.common.gaana
|
||||
package com.shabinder.common.di.gaana
|
||||
|
||||
import com.shabinder.common.models.gaana.*
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.request.*
|
||||
|
||||
@ -21,7 +22,7 @@ interface GaanaRequests {
|
||||
seokey: String,
|
||||
format: String = "JSON",
|
||||
limit: Int = 2000
|
||||
): GaanaPlaylist{
|
||||
): GaanaPlaylist {
|
||||
return httpClient.get(
|
||||
"$BASE_URL/?type=$type&subtype=$subtype&seokey=$seokey&token=$TOKEN&format=$format&limit=$limit"
|
||||
)
|
||||
@ -38,7 +39,7 @@ interface GaanaRequests {
|
||||
seokey: String,
|
||||
format: String = "JSON",
|
||||
limit: Int = 2000
|
||||
): GaanaAlbum{
|
||||
): GaanaAlbum {
|
||||
return httpClient.get(
|
||||
"$BASE_URL/?type=$type&subtype=$subtype&seokey=$seokey&token=$TOKEN&format=$format&limit=$limit"
|
||||
)
|
||||
@ -54,7 +55,7 @@ interface GaanaRequests {
|
||||
subtype: String = "song_detail",
|
||||
seokey: String,
|
||||
format: String = "JSON",
|
||||
): GaanaSong{
|
||||
): GaanaSong {
|
||||
return httpClient.get(
|
||||
"$BASE_URL/?type=$type&subtype=$subtype&seokey=$seokey&token=$TOKEN&format=$format"
|
||||
)
|
||||
@ -70,7 +71,7 @@ interface GaanaRequests {
|
||||
subtype: String = "artist_details_info",
|
||||
seokey: String,
|
||||
format: String = "JSON",
|
||||
): GaanaArtistDetails{
|
||||
): GaanaArtistDetails {
|
||||
return httpClient.get(
|
||||
"$BASE_URL/?type=$type&subtype=$subtype&seokey=$seokey&token=$TOKEN&format=$format"
|
||||
)
|
||||
@ -86,7 +87,7 @@ interface GaanaRequests {
|
||||
seokey: String,
|
||||
format: String = "JSON",
|
||||
limit: Int = 50
|
||||
): GaanaArtistTracks{
|
||||
): GaanaArtistTracks {
|
||||
return httpClient.get(
|
||||
"$BASE_URL/?type=$type&subtype=$subtype&seokey=$seokey&token=$TOKEN&format=$format&limit=$limit"
|
||||
)
|
@ -14,14 +14,18 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.providers
|
||||
package com.shabinder.common.di.providers
|
||||
|
||||
import co.touchlab.kermit.Kermit
|
||||
import com.shabinder.common.*
|
||||
import com.shabinder.common.database.DownloadRecordDatabaseQueries
|
||||
import com.shabinder.common.gaana.GaanaRequests
|
||||
import com.shabinder.common.gaana.GaanaTrack
|
||||
import com.shabinder.common.spotify.Source
|
||||
import com.shabinder.common.di.Dir
|
||||
import com.shabinder.common.di.finalOutputDir
|
||||
import com.shabinder.common.di.gaana.GaanaRequests
|
||||
import com.shabinder.common.models.gaana.GaanaTrack
|
||||
import com.shabinder.common.models.DownloadStatus
|
||||
import com.shabinder.common.models.PlatformQueryResult
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
import com.shabinder.common.models.spotify.Source
|
||||
import com.shabinder.database.Database
|
||||
import io.ktor.client.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -81,7 +85,7 @@ class GaanaProvider(
|
||||
dir.defaultDir()
|
||||
)
|
||||
)) {//Download Already Present!!
|
||||
it.downloaded = DownloadStatus.Downloaded
|
||||
it.downloaded = com.shabinder.common.models.DownloadStatus.Downloaded
|
||||
}
|
||||
trackList = listOf(it).toTrackDetailsList(folderType, subFolder)
|
||||
title = it.track_title
|
||||
@ -111,7 +115,7 @@ class GaanaProvider(
|
||||
)
|
||||
)
|
||||
) {//Download Already Present!!
|
||||
track.downloaded = DownloadStatus.Downloaded
|
||||
track.downloaded = com.shabinder.common.models.DownloadStatus.Downloaded
|
||||
}
|
||||
}
|
||||
trackList = it.tracks.toTrackDetailsList(folderType, subFolder)
|
||||
@ -142,7 +146,7 @@ class GaanaProvider(
|
||||
)
|
||||
)
|
||||
) {//Download Already Present!!
|
||||
track.downloaded = DownloadStatus.Downloaded
|
||||
track.downloaded = com.shabinder.common.models.DownloadStatus.Downloaded
|
||||
}
|
||||
}
|
||||
trackList = it.tracks.toTrackDetailsList(folderType, subFolder)
|
||||
@ -181,7 +185,7 @@ class GaanaProvider(
|
||||
)
|
||||
)
|
||||
) {//Download Already Present!!
|
||||
track.downloaded = DownloadStatus.Downloaded
|
||||
track.downloaded = com.shabinder.common.models.DownloadStatus.Downloaded
|
||||
}
|
||||
}
|
||||
trackList = it.tracks.toTrackDetailsList(folderType, subFolder)
|
@ -14,12 +14,19 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common.providers
|
||||
package com.shabinder.common.di.providers
|
||||
|
||||
import co.touchlab.kermit.Kermit
|
||||
import com.shabinder.common.*
|
||||
import com.shabinder.common.database.DownloadRecordDatabaseQueries
|
||||
import com.shabinder.common.spotify.*
|
||||
import com.shabinder.common.di.Dir
|
||||
import com.shabinder.common.di.finalOutputDir
|
||||
import com.shabinder.common.di.spotify.SpotifyRequests
|
||||
import com.shabinder.common.models.PlatformQueryResult
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
import com.shabinder.common.models.spotify.Album
|
||||
import com.shabinder.common.models.spotify.Image
|
||||
import com.shabinder.common.models.spotify.Source
|
||||
import com.shabinder.common.models.spotify.Track
|
||||
import com.shabinder.database.Database
|
||||
import io.ktor.client.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -30,7 +37,7 @@ class SpotifyProvider(
|
||||
private val database: Database,
|
||||
private val logger: Kermit,
|
||||
private val dir: Dir,
|
||||
) :SpotifyRequests {
|
||||
) : SpotifyRequests {
|
||||
|
||||
private val db:DownloadRecordDatabaseQueries
|
||||
get() = database.downloadRecordDatabaseQueries
|
||||
@ -90,7 +97,7 @@ class SpotifyProvider(
|
||||
)
|
||||
)
|
||||
) {//Download Already Present!!
|
||||
it.downloaded = DownloadStatus.Downloaded
|
||||
it.downloaded = com.shabinder.common.models.DownloadStatus.Downloaded
|
||||
}
|
||||
trackList = listOf(it).toTrackDetailsList(folderType, subFolder)
|
||||
title = it.name.toString()
|
||||
@ -122,7 +129,7 @@ class SpotifyProvider(
|
||||
)
|
||||
)
|
||||
) {//Download Already Present!!
|
||||
it.downloaded = DownloadStatus.Downloaded
|
||||
it.downloaded = com.shabinder.common.models.DownloadStatus.Downloaded
|
||||
}
|
||||
it.album = Album(
|
||||
images = listOf(
|
||||
@ -171,7 +178,7 @@ class SpotifyProvider(
|
||||
)
|
||||
)
|
||||
) {//Download Already Present!!
|
||||
it1.downloaded = DownloadStatus.Downloaded
|
||||
it1.downloaded = com.shabinder.common.models.DownloadStatus.Downloaded
|
||||
}
|
||||
tempTrackList.add(it1)
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package com.shabinder.common.providers
|
||||
package com.shabinder.common.di.providers
|
||||
|
||||
import co.touchlab.kermit.Logger
|
||||
import com.shabinder.common.YoutubeTrack
|
||||
import com.shabinder.common.models.YoutubeTrack
|
||||
import com.willowtreeapps.fuzzywuzzy.diffutils.FuzzySearch
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.request.*
|
@ -1,11 +1,11 @@
|
||||
package com.shabinder.common.spotify
|
||||
package com.shabinder.common.di.spotify
|
||||
|
||||
import com.shabinder.common.kotlinxSerializer
|
||||
import com.shabinder.common.di.kotlinxSerializer
|
||||
import com.shabinder.common.models.spotify.TokenData
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.features.auth.*
|
||||
import io.ktor.client.features.auth.providers.*
|
||||
import io.ktor.client.features.json.*
|
||||
import io.ktor.client.features.json.serializer.*
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.client.request.forms.*
|
||||
import io.ktor.http.*
|
@ -1,5 +1,9 @@
|
||||
package com.shabinder.common.spotify
|
||||
package com.shabinder.common.di.spotify
|
||||
|
||||
import com.shabinder.common.models.spotify.Album
|
||||
import com.shabinder.common.models.spotify.PagingObjectPlaylistTrack
|
||||
import com.shabinder.common.models.spotify.Playlist
|
||||
import com.shabinder.common.models.spotify.Track
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.request.*
|
||||
|
||||
@ -9,7 +13,7 @@ interface SpotifyRequests {
|
||||
|
||||
val httpClient:HttpClient
|
||||
|
||||
suspend fun getPlaylist(playlistID: String):Playlist{
|
||||
suspend fun getPlaylist(playlistID: String): Playlist {
|
||||
return httpClient.get("$BASE_URL/playlists/$playlistID")
|
||||
}
|
||||
|
||||
@ -17,23 +21,23 @@ interface SpotifyRequests {
|
||||
playlistID: String?,
|
||||
offset: Int = 0,
|
||||
limit: Int = 100
|
||||
):PagingObjectPlaylistTrack{
|
||||
): PagingObjectPlaylistTrack {
|
||||
return httpClient.get("$BASE_URL/playlists/$playlistID/tracks?offset=$offset&limit=$limit")
|
||||
}
|
||||
|
||||
suspend fun getTrack(id: String?):Track{
|
||||
suspend fun getTrack(id: String?): Track {
|
||||
return httpClient.get("$BASE_URL/tracks/$id")
|
||||
}
|
||||
|
||||
suspend fun getEpisode(id: String?) :Track{
|
||||
suspend fun getEpisode(id: String?) : Track {
|
||||
return httpClient.get("$BASE_URL/episodes/$id")
|
||||
}
|
||||
|
||||
suspend fun getShow(id: String?): Track{
|
||||
suspend fun getShow(id: String?): Track {
|
||||
return httpClient.get("$BASE_URL/shows/$id")
|
||||
}
|
||||
|
||||
suspend fun getAlbum(id: String):Album{
|
||||
suspend fun getAlbum(id: String): Album {
|
||||
return httpClient.get("$BASE_URL/albums/$id")
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.shabinder.common.di
|
||||
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
|
||||
actual fun openPlatform(platformID:String ,platformLink:String){
|
||||
//TODO
|
||||
}
|
||||
|
||||
actual fun shareApp(){
|
||||
//TODO
|
||||
}
|
||||
|
||||
actual fun giveDonation(){
|
||||
//TODO
|
||||
}
|
||||
|
||||
actual fun downloadTracks(list: List<TrackDetails>){
|
||||
//TODO
|
||||
}
|
@ -1,13 +1,13 @@
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.di
|
||||
|
||||
import co.touchlab.kermit.Kermit
|
||||
import com.mpatric.mp3agic.Mp3File
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import java.awt.image.BufferedImage
|
||||
import java.io.*
|
||||
import java.lang.Exception
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import java.nio.charset.StandardCharsets
|
||||
@ -85,7 +85,7 @@ actual class Dir actual constructor(private val logger: Kermit) {
|
||||
.setId3v2TagsAndSaveFile(trackDetails,path)
|
||||
}
|
||||
|
||||
actual fun loadImage(url: String):Picture? {
|
||||
actual fun loadImage(url: String): Picture? {
|
||||
val cachePath = imageCacheDir() + getNameURL(url)
|
||||
var picture: Picture? = loadCachedImage(cachePath)
|
||||
if (picture == null) picture = freshImage(url,cachePath)
|
||||
@ -110,7 +110,7 @@ actual class Dir actual constructor(private val logger: Kermit) {
|
||||
val result: BufferedImage? = ImageIO.read(File(cachePath))
|
||||
|
||||
if (result != null) {
|
||||
Picture(
|
||||
com.shabinder.common.di.Picture(
|
||||
source,
|
||||
getNameURL(source),
|
||||
result,
|
||||
@ -123,7 +123,7 @@ actual class Dir actual constructor(private val logger: Kermit) {
|
||||
null
|
||||
}
|
||||
}
|
||||
private fun freshImage(url:String,cachePath: String):Picture?{
|
||||
private fun freshImage(url:String,cachePath: String): Picture?{
|
||||
return try {
|
||||
val source = URL(url)
|
||||
val connection: HttpURLConnection = source.openConnection() as HttpURLConnection
|
||||
@ -134,7 +134,7 @@ actual class Dir actual constructor(private val logger: Kermit) {
|
||||
val result: BufferedImage? = ImageIO.read(input)
|
||||
|
||||
if (result != null) {
|
||||
val picture = Picture(
|
||||
val picture = com.shabinder.common.di.Picture(
|
||||
url,
|
||||
getNameURL(url),
|
||||
result,
|
@ -1,11 +1,11 @@
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.di
|
||||
|
||||
import com.mpatric.mp3agic.ID3v1Tag
|
||||
import com.mpatric.mp3agic.ID3v24Tag
|
||||
import com.mpatric.mp3agic.Mp3File
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import com.shabinder.common.models.DownloadResult
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
|
||||
@ -33,7 +33,7 @@ fun Mp3File.setId3v1Tags(track: TrackDetails): Mp3File {
|
||||
}
|
||||
|
||||
@Suppress("BlockingMethodInNonBlockingContext")
|
||||
suspend fun Mp3File.setId3v2TagsAndSaveFile(track: TrackDetails,filePath:String){
|
||||
suspend fun Mp3File.setId3v2TagsAndSaveFile(track: TrackDetails, filePath:String){
|
||||
val id3v2Tag = ID3v24Tag().apply {
|
||||
artist = track.artists.joinToString(",")
|
||||
title = track.title
|
@ -1,4 +1,4 @@
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.di
|
||||
|
||||
import java.awt.image.BufferedImage
|
||||
|
@ -14,13 +14,15 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.shabinder.common
|
||||
package com.shabinder.common.di
|
||||
|
||||
import co.touchlab.kermit.Kermit
|
||||
import com.github.kiulian.downloader.YoutubeDownloader
|
||||
import com.shabinder.common.models.DownloadStatus
|
||||
import com.shabinder.common.models.PlatformQueryResult
|
||||
import com.shabinder.common.models.TrackDetails
|
||||
import com.shabinder.common.database.DownloadRecordDatabaseQueries
|
||||
import com.shabinder.common.spotify.Source
|
||||
import com.shabinder.common.utils.removeIllegalChars
|
||||
import com.shabinder.common.models.spotify.Source
|
||||
import com.shabinder.database.Database
|
||||
import io.ktor.client.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -81,7 +83,7 @@ actual class YoutubeProvider actual constructor(
|
||||
|
||||
private suspend fun getYTPlaylist(
|
||||
searchId: String
|
||||
):PlatformQueryResult?{
|
||||
): PlatformQueryResult?{
|
||||
val result = PlatformQueryResult(
|
||||
folderType = "",
|
||||
subFolder = "",
|
||||
@ -156,7 +158,7 @@ actual class YoutubeProvider actual constructor(
|
||||
@Suppress("DefaultLocale")
|
||||
private suspend fun getYTTrack(
|
||||
searchId:String,
|
||||
):PlatformQueryResult? {
|
||||
): PlatformQueryResult? {
|
||||
val result = PlatformQueryResult(
|
||||
folderType = "",
|
||||
subFolder = "",
|
@ -1,7 +1,7 @@
|
||||
import androidx.compose.desktop.Window
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.material.Text
|
||||
import com.shabinder.common.initKoin
|
||||
import com.shabinder.common.di.initKoin
|
||||
|
||||
private val koin = initKoin(enableNetworkLogs = true).koin
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user