toasterofbread / spmp

A YouTube Music client with a focus on customisation of colours and song metadata. Built with Compose Multiplatform for Android and desktop.
GNU General Public License v3.0
1.16k stars 44 forks source link

[Bug] Add song to playlist problem #100

Closed Zaxx69 closed 1 year ago

Zaxx69 commented 1 year ago

Whenever i want to add a song to my playlist, it generates this text java.lang.NullPointerException at com.toasterofbread.spmp.api.AccountPlaylistsKt.editAccountPlaylist(Unknown Source:63) at com.toasterofbread.spmp.model.mediaitem.AccountPlaylist.saveItems-IoAF18A(Unknown Source:74) at com.toasterofbread.spmp.ui.component.mediaitempreview.SongPreviewKt$SongLongPressMenuActions$1$5$1$3$1$1.invokeSuspend(Unknown Source:69) at com.toasterofbread.spmp.ui.component.mediaitempreview.SongPreviewKt$SongLongPressMenuActions$1$5$1$3$1$1.invoke(Unknown Source:8) at com.toasterofbread.spmp.ui.component.mediaitempreview.SongPreviewKt$SongLongPressMenuActions$1$5$1$3$1$1.invoke(Unknown Source:4) at com.toasterofbread.spmp.ui.component.longpressmenu.LongPressMenuData$Actions$1$1$1.invokeSuspend(Unknown Source:63) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(Unknown Source:8) at kotlinx.coroutines.DispatchedTask.run(Unknown Source:100) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:240) at android.os.Looper.loop(Looper.java:351) at android.app.ActivityThread.main(ActivityThread.java:8374) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013) Suppressed: coil.network.HttpException: [StandaloneCoroutine{Cancelling}@e0984b0, Dispatchers.Main]

toasterofbread commented 1 year ago

Seems like this might be related to #84

A few questions:

If so,

It would be helpful if you could share the URL of a playlist that this happens with.

Zaxx69 commented 1 year ago
  1. Yes it happens every time but when i do it for a second time, it adds the song to the playlist. For example, let's say i wanted to add crystal song to my playlist, upon clicking on add to playlist, this error pops up. But when i do it for a second time it adds the song. Now if i want to add land of fire as my second song, the error agains pops up but upon clicking add to playlist again it adds the song. Hope you understand, it will appreciated if you would open a telegram channel for discussion because we can't send video here
  2. I have only one playlist
Subbarao6338 commented 1 year ago

For me also same problem. I have multiple playlists in my YouTube. For every song I have faced the problem. Please fix this problem.

toasterofbread commented 1 year ago

For me also same problem. I have multiple playlists in my YouTube. For every song I have faced the problem. Please fix this problem.

Are you using v0.2.0? If so please upload the stacktrace from the error, as the functions in the original one don't even exist anymore.

Subbarao6338 commented 1 year ago

android.database.sqlite.SQLiteException: no such function: IIF (code 1 SQLITE_ERROR): , while compiling: SELECT COUNT(IIF(PlaylistItem.playlist_id = ?, 1, NULL)) FROM PlaylistItem at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:986) at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:593) at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:590) at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:61) at android.database.sqlite.SQLiteQuery.(SQLiteQuery.java:37) at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:46) at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1443) at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1418) at app.cash.sqldelight.driver.android.AndroidQuery.executeQuery(Unknown Source:30) at mediaitem.MediaItemQueries$titleById$1.invoke(SourceFile:39) at app.cash.sqldelight.driver.android.AndroidSqliteDriver.execute-zeHU3Mk(Unknown Source:26) at app.cash.sqldelight.driver.android.AndroidSqliteDriver.executeQuery(Unknown Source:22) at mediaitem.PlaylistItemQueries$ItemCountQuery.execute(Unknown Source:31) at app.cash.sqldelight.Query.executeAsOneOrNull(Unknown Source:6) at app.cash.sqldelight.Query.executeAsOne(Unknown Source:0) at com.toasterofbread.spmp.model.mediaitem.playlist.Playlist$Items$3.invoke(SourceFile:2) at com.toasterofbread.spmp.model.mediaitem.playlist.Playlist$Items$3.invoke(SourceFile:3) at com.toasterofbread.spmp.model.mediaitem.PropertyRememberer$rememberListQueryProperty$1$3.invoke(SourceFile:1) at com.toasterofbread.spmp.model.mediaitem.PropertyRememberer$rememberListQueryProperty$1$3.invoke(SourceFile:2) at com.toasterofbread.spmp.model.mediaitem.db.ListPropertyImpl$addItem$1$1.invoke(SourceFile:2) at com.toasterofbread.spmp.model.mediaitem.db.ListPropertyImpl$addItem$1$1.invoke(SourceFile:1) at app.cash.sqldelight.TransacterImpl.transactionWithWrapper(Unknown Source:52) at okio._UtilKt.transaction$default(Unknown Source:6) at com.toasterofbread.spmp.model.mediaitem.db.ListPropertyImpl.addItem(Unknown Source:42) at com.toasterofbread.spmp.ui.component.mediaitempreview.SongPreviewKt$SongLongPressMenuActions$1$5$1$3$1$1$1.invoke(SourceFile:3) at com.toasterofbread.spmp.ui.component.mediaitempreview.SongPreviewKt$SongLongPressMenuActions$1$5$1$3$1$1$1.invoke(SourceFile:1) at app.cash.sqldelight.TransacterImpl.transactionWithWrapper(Unknown Source:52) at okio._UtilKt.transaction$default(Unknown Source:6) at com.toasterofbread.spmp.ui.component.mediaitempreview.SongPreviewKt$SongLongPressMenuActions$1$5$1$3$1$1.invokeSuspend(Unknown Source:30) at com.toasterofbread.spmp.ui.component.mediaitempreview.SongPreviewKt$SongLongPressMenuActions$1$5$1$3$1$1.invoke(SourceFile:1) at com.toasterofbread.spmp.ui.component.mediaitempreview.SongPreviewKt$SongLongPressMenuActions$1$5$1$3$1$1.invoke(SourceFile:2) at com.toasterofbread.spmp.ui.component.longpressmenu.LongPressMenuData$Actions$1$1$1.invokeSuspend(Unknown Source:64) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(Unknown Source:8) at kotlinx.coroutines.DispatchedTask.run(Unknown Source:102) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:224) at android.app.ActivityThread.main(ActivityThread.java:7592) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) Suppressed: coil.network.HttpException: [StandaloneCoroutine{Cancelling}@986a402, Dispatchers.Main]

toasterofbread commented 1 year ago

Seems like the IIF function isn't available on Android versions 11 and below (no idea why SQLITE version is tied to the OS version). I'll replace it with a compatible call.

Subbarao6338 commented 1 year ago

android.database.sqlite.SQLiteException: no such function: IIF (code 1 SQLITE_ERROR): , while compiling: SELECT COUNT(IIF(PlaylistItem.playlist_id = ?, 1, NULL)) FROM PlaylistItem at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:986) at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:593) at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:590) at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:61) at android.database.sqlite.SQLiteQuery.(SQLiteQuery.java:37) at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:46) at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1443) at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1418) at app.cash.sqldelight.driver.android.AndroidQuery.executeQuery(Unknown Source:30) at mediaitem.MediaItemQueries$titleById$1.invoke(SourceFile:39) at app.cash.sqldelight.driver.android.AndroidSqliteDriver.execute-zeHU3Mk(Unknown Source:26) at app.cash.sqldelight.driver.android.AndroidSqliteDriver.executeQuery(Unknown Source:22) at mediaitem.PlaylistItemQueries$ItemCountQuery.execute(Unknown Source:31) at app.cash.sqldelight.Query.executeAsOneOrNull(Unknown Source:6) at app.cash.sqldelight.Query.executeAsOne(Unknown Source:0) at com.toasterofbread.spmp.model.mediaitem.playlist.Playlist$Items$3.invoke(SourceFile:2) at com.toasterofbread.spmp.model.mediaitem.playlist.Playlist$Items$3.invoke(SourceFile:3) at com.toasterofbread.spmp.model.mediaitem.PropertyRememberer$rememberListQueryProperty$1$3.invoke(SourceFile:1) at com.toasterofbread.spmp.model.mediaitem.PropertyRememberer$rememberListQueryProperty$1$3.invoke(SourceFile:2) at com.toasterofbread.spmp.model.mediaitem.db.ListPropertyImpl$addItem$1$1.invoke(SourceFile:2) at com.toasterofbread.spmp.model.mediaitem.db.ListPropertyImpl$addItem$1$1.invoke(SourceFile:1) at app.cash.sqldelight.TransacterImpl.transactionWithWrapper(Unknown Source:52) at okio._UtilKt.transaction$default(Unknown Source:6) at com.toasterofbread.spmp.model.mediaitem.db.ListPropertyImpl.addItem(Unknown Source:42) at com.toasterofbread.spmp.youtubeapi.impl.youtubemusic.endpoint.AccountPlaylistEditor.performActionOrGetRequestData(Unknown Source:143) at com.toasterofbread.spmp.youtubeapi.impl.youtubemusic.endpoint.AccountPlaylistEditor.access$performActionOrGetRequestData(Unknown Source:0) at com.toasterofbread.spmp.youtubeapi.impl.youtubemusic.endpoint.AccountPlaylistEditor$performAndCommitActions$3.invokeSuspend(Unknown Source:73) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(Unknown Source:8) at kotlinx.coroutines.DispatchedTask.run(Unknown Source:102) at kotlinx.coroutines.internal.LimitedDispatcher.run(Unknown Source:12) at kotlinx.coroutines.scheduling.TaskImpl.run(Unknown Source:2) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(Unknown Source:76) Suppressed: coil.network.HttpException: [androidx.compose.ui.platform.MotionDurationScaleImpl@6e253d4, androidx.compose.runtime.BroadcastFrameClock@de0797d, StandaloneCoroutine{Cancelling}@1460072, AndroidUiDispatcher@91d1cc3]

Subbarao6338 commented 1 year ago

Still not working

toasterofbread commented 1 year ago

Are you sure you're using the right build (3624436 or later)? The IIF function mentioned in the stacktrace doesn't exist in the source code anymore. You might have to clear the app's data to rebuild the database but I doubt that's the issue.