|
| 1 | +package org.schabi.newpipe.player.mediabrowser |
| 2 | + |
| 3 | +import org.schabi.newpipe.BuildConfig |
| 4 | +import org.schabi.newpipe.extractor.InfoItem.InfoType |
| 5 | +import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException |
| 6 | + |
| 7 | +internal const val ID_AUTHORITY = BuildConfig.APPLICATION_ID |
| 8 | +internal const val ID_ROOT = "//$ID_AUTHORITY" |
| 9 | +internal const val ID_BOOKMARKS = "playlists" |
| 10 | +internal const val ID_HISTORY = "history" |
| 11 | +internal const val ID_INFO_ITEM = "item" |
| 12 | + |
| 13 | +internal const val ID_LOCAL = "local" |
| 14 | +internal const val ID_REMOTE = "remote" |
| 15 | +internal const val ID_URL = "url" |
| 16 | +internal const val ID_STREAM = "stream" |
| 17 | +internal const val ID_PLAYLIST = "playlist" |
| 18 | +internal const val ID_CHANNEL = "channel" |
| 19 | + |
| 20 | +internal fun infoItemTypeToString(type: InfoType): String { |
| 21 | + return when (type) { |
| 22 | + InfoType.STREAM -> ID_STREAM |
| 23 | + InfoType.PLAYLIST -> ID_PLAYLIST |
| 24 | + InfoType.CHANNEL -> ID_CHANNEL |
| 25 | + else -> throw IllegalStateException("Unexpected value: $type") |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +internal fun infoItemTypeFromString(type: String): InfoType { |
| 30 | + return when (type) { |
| 31 | + ID_STREAM -> InfoType.STREAM |
| 32 | + ID_PLAYLIST -> InfoType.PLAYLIST |
| 33 | + ID_CHANNEL -> InfoType.CHANNEL |
| 34 | + else -> throw IllegalStateException("Unexpected value: $type") |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +internal fun parseError(mediaId: String): ContentNotAvailableException { |
| 39 | + return ContentNotAvailableException("Failed to parse media ID $mediaId") |
| 40 | +} |
0 commit comments