Skip to content

Commit d7f874f

Browse files
authored
Merge pull request libre-tube#7151 from Bnyro/local-npe
feat: add support for using local NewPipe Extractor
2 parents b67b152 + 676c62a commit d7f874f

41 files changed

Lines changed: 927 additions & 459 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/src/main/java/com/github/libretube/api/ExternalApi.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.github.libretube.api
22

33
import com.github.libretube.api.obj.DeArrowBody
4+
import com.github.libretube.api.obj.PipedConfig
45
import com.github.libretube.api.obj.PipedInstance
56
import com.github.libretube.api.obj.SubmitSegmentResponse
67
import com.github.libretube.api.obj.VoteInfo
@@ -20,6 +21,9 @@ interface ExternalApi {
2021
@GET
2122
suspend fun getInstances(@Url url: String): List<PipedInstance>
2223

24+
@GET("config")
25+
suspend fun getInstanceConfig(@Url url: String): PipedConfig
26+
2327
// fetch latest version info
2428
@GET(GITHUB_API_URL)
2529
suspend fun getLatestRelease(): UpdateInfo
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.github.libretube.api
2+
3+
class LocalStreamsExtractionPipedMediaServiceRepository: PipedMediaServiceRepository() {
4+
private val newPipeDelegate = NewPipeMediaServiceRepository()
5+
6+
override suspend fun getStreams(videoId: String) = newPipeDelegate.getStreams(videoId)
7+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.github.libretube.api
2+
3+
import com.github.libretube.api.obj.Channel
4+
import com.github.libretube.api.obj.ChannelTabResponse
5+
import com.github.libretube.api.obj.CommentsPage
6+
import com.github.libretube.api.obj.DeArrowContent
7+
import com.github.libretube.api.obj.Playlist
8+
import com.github.libretube.api.obj.SearchResult
9+
import com.github.libretube.api.obj.SegmentData
10+
import com.github.libretube.api.obj.StreamItem
11+
import com.github.libretube.api.obj.Streams
12+
import com.github.libretube.helpers.PlayerHelper
13+
14+
interface MediaServiceRepository {
15+
suspend fun getTrending(region: String): List<StreamItem>
16+
suspend fun getStreams(videoId: String): Streams
17+
suspend fun getComments(videoId: String): CommentsPage
18+
suspend fun getSegments(
19+
videoId: String,
20+
category: String,
21+
actionType: String? = null
22+
): SegmentData
23+
24+
suspend fun getDeArrowContent(videoIds: String): Map<String, DeArrowContent>
25+
suspend fun getCommentsNextPage(videoId: String, nextPage: String): CommentsPage
26+
suspend fun getSearchResults(searchQuery: String, filter: String): SearchResult
27+
suspend fun getSearchResultsNextPage(
28+
searchQuery: String,
29+
filter: String,
30+
nextPage: String
31+
): SearchResult
32+
33+
suspend fun getSuggestions(query: String): List<String>
34+
suspend fun getChannel(channelId: String): Channel
35+
suspend fun getChannelTab(data: String, nextPage: String? = null): ChannelTabResponse
36+
suspend fun getChannelByName(channelName: String): Channel
37+
suspend fun getChannelNextPage(channelId: String, nextPage: String): Channel
38+
suspend fun getPlaylist(playlistId: String): Playlist
39+
suspend fun getPlaylistNextPage(playlistId: String, nextPage: String): Playlist
40+
41+
companion object {
42+
val instance: MediaServiceRepository
43+
get() = when {
44+
PlayerHelper.fullLocalMode -> NewPipeMediaServiceRepository()
45+
PlayerHelper.localStreamExtraction -> LocalStreamsExtractionPipedMediaServiceRepository()
46+
else -> PipedMediaServiceRepository()
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)