Skip to content

Commit

Permalink
feat(download): Implement download functionality with progress tracki…
Browse files Browse the repository at this point in the history
…ng and merging for audio and video
  • Loading branch information
maxrave-dev committed Feb 8, 2025
1 parent cdea1ab commit b12fe4b
Show file tree
Hide file tree
Showing 13 changed files with 853 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.maxrave.kotlinytmusicscraper.models.SearchSuggestions
import com.maxrave.kotlinytmusicscraper.models.SongItem
import com.maxrave.kotlinytmusicscraper.models.WatchEndpoint
import com.maxrave.kotlinytmusicscraper.models.YouTubeLocale
import com.maxrave.kotlinytmusicscraper.models.response.DownloadProgress
import com.maxrave.kotlinytmusicscraper.models.response.LikeStatus
import com.maxrave.kotlinytmusicscraper.models.response.SearchResponse
import com.maxrave.kotlinytmusicscraper.models.simpmusic.GithubResponse
Expand Down Expand Up @@ -1039,7 +1040,7 @@ class MainRepository(
Log.w("Repository", "data: ${data.size}")
val playlistBrowse =
PlaylistBrowse(
author = Author(id = "", name = "youTube Music"),
author = Author(id = "", name = "YouTube Music"),
description =
context.getString(
R.string.auto_created_by_youtube_music,
Expand Down Expand Up @@ -1482,7 +1483,7 @@ class MainRepository(
Resource.Success(
Pair(
playlist.copy(
author = Author("", "youTube Music"),
author = Author("", "YouTube Music"),
),
finalContinueParam,
),
Expand Down Expand Up @@ -3068,4 +3069,10 @@ class MainRepository(
}
}
}.flowOn(Dispatchers.IO)

fun downloadToFile(
path: String,
videoId: String,
isVideo: Boolean,
): Flow<DownloadProgress> = youTube.download(path, videoId, isVideo)
}
6 changes: 6 additions & 0 deletions app/src/main/java/com/maxrave/simpmusic/di/ViewModelModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.maxrave.simpmusic.di

import androidx.media3.common.util.UnstableApi
import com.maxrave.simpmusic.viewModel.AlbumViewModel
import com.maxrave.simpmusic.viewModel.HomeViewModel
import com.maxrave.simpmusic.viewModel.LibraryDynamicPlaylistViewModel
import com.maxrave.simpmusic.viewModel.LibraryViewModel
import com.maxrave.simpmusic.viewModel.NowPlayingBottomSheetViewModel
Expand Down Expand Up @@ -33,6 +34,11 @@ val viewModelModule =
application = androidApplication(),
)
}
viewModel {
HomeViewModel(
application = androidApplication(),
)
}
viewModel {
SettingsViewModel(
application = androidApplication(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ import com.maxrave.simpmusic.service.PlaylistType
import com.maxrave.simpmusic.service.QueueData
import com.maxrave.simpmusic.ui.theme.typo
import com.maxrave.simpmusic.viewModel.HomeViewModel
import org.koin.androidx.compose.koinViewModel

@UnstableApi
@Composable
fun HomeItem(
homeViewModel: HomeViewModel,
homeViewModel: HomeViewModel = koinViewModel(),
navController: NavController,
data: HomeItem,
) {
Expand Down
Loading

0 comments on commit b12fe4b

Please sign in to comment.