-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement generic 'view more' page (closes #52)
Kind of fix long press menu positioning (again)
- Loading branch information
1 parent
7bf4f52
commit cffaa16
Showing
19 changed files
with
272 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
shared/src/commonMain/kotlin/com/spectre7/spmp/api/FeedViewMorePage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.spectre7.spmp.api | ||
|
||
import com.spectre7.spmp.api.Api.Companion.addYtHeaders | ||
import com.spectre7.spmp.api.Api.Companion.getStream | ||
import com.spectre7.spmp.api.Api.Companion.ytUrl | ||
import com.spectre7.spmp.model.mediaitem.MediaItem | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.withContext | ||
import okhttp3.Request | ||
|
||
suspend fun getGenericFeedViewMorePage(browse_id: String): Result<List<MediaItem>> = withContext(Dispatchers.IO) { | ||
|
||
val hl = SpMp.data_language | ||
val request = Request.Builder() | ||
.ytUrl("/youtubei/v1/browse") | ||
.addYtHeaders() | ||
.post(Api.getYoutubeiRequestBody( | ||
mapOf("browseId" to browse_id) | ||
)) | ||
.build() | ||
|
||
val result = Api.request(request) | ||
val stream = result.getOrNull()?.getStream() ?: return@withContext result.cast() | ||
|
||
val parsed: YoutubeiBrowseResponse = Api.klaxon.parse(stream)!! | ||
stream.close() | ||
|
||
val items = parsed | ||
.contents!! | ||
.singleColumnBrowseResultsRenderer | ||
.tabs | ||
.first() | ||
.tabRenderer | ||
.content!! | ||
.sectionListRenderer | ||
.contents!! | ||
.first() | ||
.getMediaItems(hl) | ||
|
||
return@withContext Result.success(items) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.