This repository has been archived by the owner on Jan 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathYtmApi.kt
79 lines (64 loc) · 2.78 KB
/
YtmApi.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package dev.toastbits.ytmkt.model
import dev.toastbits.ytmkt.endpoint.*
import dev.toastbits.ytmkt.formats.VideoFormatsEndpoint
import dev.toastbits.ytmkt.itemcache.MediaItemCache
import dev.toastbits.ytmkt.model.external.mediaitem.YtmMediaItem
import io.ktor.client.HttpClient
import io.ktor.client.request.HttpRequestBuilder
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonObjectBuilder
import kotlinx.serialization.json.Json
/**
* Contains all non-authenticated YouTube endpoints.
*
* Deriving classes must provide implememtations for each endpoint.
* [dev.toastbits.ytmkt.impl.unimplemented.UnimplementedYtmApi] may be used as a base for partial implementations of this interface.
* See endpoint class definitions for usage documentation.
*
* @property client Ktor [HttpClient] to be used by endpoints.
* @property item_cache Provides cached [YtmMediaItem]s to endpoints.
* @property user_auth_state The user authentication information to be used by endpoints.
*/
interface YtmApi {
val client: HttpClient
val json: Json
val item_cache: MediaItemCache
val user_auth_state: ApiAuthenticationState?
fun HttpRequestBuilder.endpointPath(path: String, non_music_api: Boolean = false)
fun HttpRequestBuilder.postWithBody(
base: JsonObject? = null,
buildPostBody: (JsonObjectBuilder.() -> Unit)? = null
)
fun HttpRequestBuilder.addUnauthenticatedApiHeaders(include: List<String>? = null, non_music_api: Boolean = false)
fun HttpRequestBuilder.addAuthenticatedApiHeaders(include: List<String>? = null, non_music_api: Boolean = false) {
addUnauthenticatedApiHeaders(include, non_music_api)
user_auth_state?.addHeadersToRequest(this, include)
}
// -- User auth ---
val YoutubeChannelCreationForm: YoutubeChannelCreationFormEndpoint
val CreateYoutubeChannel: CreateYoutubeChannelEndpoint
// --- Item loading ---
val LoadSong: LoadSongEndpoint
val LoadArtist: LoadArtistEndpoint
val LoadPlaylist: LoadPlaylistEndpoint
// --- Video formats ---
val VideoFormats: VideoFormatsEndpoint
// --- Feed ---
val SongFeed: SongFeedEndpoint
val GenericFeedViewMorePage: GenericFeedViewMorePageEndpoint
val SongRadio: SongRadioEndpoint
// --- Artists ---
val ArtistWithParams: ArtistWithParamsEndpoint
val ArtistRadio: ArtistRadioEndpoint
val ArtistShuffle: ArtistShuffleEndpoint
// --- Playlists ---
val PlaylistContinuation: PlaylistContinuationEndpoint
// --- Search ---
val Search: SearchEndpoint
val SearchSuggestions: SearchSuggestionsEndpoint
// --- Radio builder ---
val RadioBuilder: RadioBuilderEndpoint
// --- Song content ---
val SongRelatedContent: SongRelatedContentEndpoint
val SongLyrics: SongLyricsEndpoint
}