-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Architecture] Cleanup and preparation for Emby
- Loading branch information
Showing
56 changed files
with
222 additions
and
458 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
5 changes: 0 additions & 5 deletions
5
src/main/kotlin/com/github/schaka/janitorr/jellyfin/library/CollectionResponse.kt
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
src/main/kotlin/com/github/schaka/janitorr/jellyseerr/JellyseerrClient.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
1 change: 0 additions & 1 deletion
1
src/main/kotlin/com/github/schaka/janitorr/jellyseerr/JellyseerrNoOpService.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
15 changes: 8 additions & 7 deletions
15
.../janitorr/jellyfin/JellyfinNoOpService.kt → ...orr/mediaserver/MediaServerNoOpService.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 |
---|---|---|
@@ -1,31 +1,32 @@ | ||
package com.github.schaka.janitorr.jellyfin | ||
package com.github.schaka.janitorr.mediaserver | ||
|
||
import com.github.schaka.janitorr.jellyfin.library.LibraryType | ||
import com.github.schaka.janitorr.mediaserver.jellyfin.library.LibraryType | ||
import com.github.schaka.janitorr.servarr.LibraryItem | ||
import org.slf4j.LoggerFactory | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty | ||
import org.springframework.stereotype.Service | ||
|
||
/** | ||
* Does nothing. Used in case the user does not supply Jellyfin configuration. | ||
*/ | ||
@Service | ||
@ConditionalOnProperty("clients.jellyfin.enabled", havingValue = "false", matchIfMissing = true) | ||
class JellyfinNoOpService : JellyfinService { | ||
@ConditionalOnProperty(value = ["clients.emby.enabled", "clients.jellyfin.enabled"], havingValue = "false") | ||
class MediaServerNoOpService : MediaServerService { | ||
|
||
companion object { | ||
private val log = LoggerFactory.getLogger(this::class.java.enclosingClass) | ||
} | ||
|
||
override fun cleanupTvShows(items: List<LibraryItem>) { | ||
log.info("Jellyfin not implemented. No TV shows deleted.") | ||
log.info("Media Server not implemented. No TV shows deleted.") | ||
} | ||
|
||
override fun cleanupMovies(items: List<LibraryItem>) { | ||
log.info("Jellyfin not implemented. No movies deleted.") | ||
log.info("Media Server not implemented. No movies deleted.") | ||
} | ||
|
||
override fun updateGoneSoon(type: LibraryType, items: List<LibraryItem>, onlyAddLinks: Boolean) { | ||
log.info("Jellyfin not implemented. No 'Gone Soon' library created.") | ||
log.info("Media Server not implemented. No 'Gone Soon' library created.") | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
...haka/janitorr/jellyfin/JellyfinService.kt → ...anitorr/mediaserver/MediaServerService.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
48 changes: 48 additions & 0 deletions
48
src/main/kotlin/com/github/schaka/janitorr/mediaserver/emby/EmbyClient.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,48 @@ | ||
package com.github.schaka.janitorr.mediaserver.emby | ||
|
||
import com.github.schaka.janitorr.mediaserver.jellyfin.api.User | ||
import com.github.schaka.janitorr.mediaserver.jellyfin.library.* | ||
import com.github.schaka.janitorr.mediaserver.jellyfin.library.items.ItemPage | ||
import com.github.schaka.janitorr.mediaserver.jellyfin.library.items.MediaFolderItem | ||
import feign.Param | ||
import feign.RequestLine | ||
|
||
interface EmbyClient { | ||
|
||
@RequestLine("GET /Users") | ||
fun listUsers(): List<User> | ||
|
||
@RequestLine("GET /Library/VirtualFolders") | ||
fun listLibraries(): List<VirtualFolderResponse> | ||
|
||
@RequestLine("POST /Library/VirtualFolders?name={name}&collectionType={type}&paths={paths}&refreshLibrary=false") | ||
fun createLibrary(@Param("name") name: String, @Param("type") collectionType: String, request: AddLibraryRequest, @Param("paths") paths: List<String> = listOf()) | ||
|
||
@RequestLine("POST /Collections?name={name}&ids&parentId={parentId}&isLocked=true") | ||
fun createCollection(@Param("name") name: String, @Param("parentId") parentId: String? = null): CollectionResponse | ||
|
||
@RequestLine("POST /Library/VirtualFolders/Paths?refreshLibrary={refresh}") | ||
fun addPathToLibrary(request: AddPathRequest, @Param("refresh") refresh: Boolean = true) | ||
|
||
@RequestLine("DELETE /Library/VirtualFolders/Paths?name={name}&path={path}&refreshLibrary={refresh}") | ||
fun removePathFromLibrary(@Param("name") name: String, @Param("path") path: String, @Param("refresh") refresh: Boolean = true) | ||
|
||
@RequestLine("POST /Collections/{id}/Items?ids={itemIds}") | ||
fun addItemToCollection(@Param("id") id: String, itemIds: List<String>) | ||
|
||
@RequestLine("GET /Library/MediaFolders") | ||
fun getAllItems(): ItemPage<MediaFolderItem> | ||
|
||
@RequestLine("GET /Items?limit=10000&includeItemTypes=Series&parentId={parentId}&fields=Path,ProviderIds") | ||
fun getAllTvShows(@Param("parentId") parentId: String): ItemPage<LibraryContent> | ||
|
||
@RequestLine("GET /Items?limit=10000&includeItemTypes=Movies&parentId={parentId}&fields=Path,ProviderIds") | ||
fun getAllMovies(@Param("parentId") parentId: String): ItemPage<LibraryContent> | ||
|
||
|
||
@RequestLine("GET /Shows/{tvshow}/Seasons?fields=Path,ProviderIds") | ||
fun getAllSeasons(@Param("tvshow") showId: String): ItemPage<LibraryContent> | ||
|
||
@RequestLine("GET /Movies/{movieId}?fields=Path,ProviderIds") | ||
fun getMovie(@Param("movieId") movieId: String): ItemPage<LibraryContent> | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/kotlin/com/github/schaka/janitorr/mediaserver/emby/EmbyClientConfig.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,35 @@ | ||
package com.github.schaka.janitorr.mediaserver.emby | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import feign.Feign | ||
import feign.jackson.JacksonDecoder | ||
import feign.jackson.JacksonEncoder | ||
import org.slf4j.LoggerFactory | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.http.HttpHeaders.AUTHORIZATION | ||
import org.springframework.http.HttpHeaders.CONTENT_TYPE | ||
import org.springframework.http.MediaType.APPLICATION_JSON_VALUE | ||
|
||
@Configuration | ||
@ConditionalOnProperty("clients.emby.enabled", havingValue = "true") | ||
class EmbyClientConfig { | ||
|
||
companion object { | ||
private val log = LoggerFactory.getLogger(this::class.java.enclosingClass) | ||
private val janitorrClientString = "Client=\"Janitorr\", Device=\"Spring Boot\", DeviceId=\"Janitorr-Device-Id\", Version=\"1.0\"" | ||
} | ||
|
||
@Bean | ||
fun embyClient(properties: EmbyProperties, mapper: ObjectMapper): EmbyClient { | ||
return Feign.builder() | ||
.decoder(JacksonDecoder(mapper)) | ||
.encoder(JacksonEncoder(mapper)) | ||
.requestInterceptor { | ||
it.header(AUTHORIZATION, "MediaBrowser Token=\"${properties.apiKey}\", ${janitorrClientString}") | ||
it.header(CONTENT_TYPE, APPLICATION_JSON_VALUE) | ||
} | ||
.target(EmbyClient::class.java, properties.url) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/com/github/schaka/janitorr/mediaserver/emby/EmbyProperties.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,11 @@ | ||
package com.github.schaka.janitorr.mediaserver.emby | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties | ||
|
||
@ConfigurationProperties(prefix = "clients.emby") | ||
data class EmbyProperties( | ||
val url: String, | ||
val apiKey: String, | ||
val username: String, | ||
val password: String | ||
) |
38 changes: 38 additions & 0 deletions
38
src/main/kotlin/com/github/schaka/janitorr/mediaserver/emby/EmbyRestService.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,38 @@ | ||
package com.github.schaka.janitorr.mediaserver.emby | ||
|
||
import com.github.schaka.janitorr.ApplicationProperties | ||
import com.github.schaka.janitorr.FileSystemProperties | ||
import com.github.schaka.janitorr.mediaserver.MediaServerService | ||
import com.github.schaka.janitorr.mediaserver.jellyfin.library.LibraryType | ||
import com.github.schaka.janitorr.servarr.LibraryItem | ||
import org.slf4j.LoggerFactory | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
@ConditionalOnProperty("clients.emby.enabled", havingValue = "true") | ||
class EmbyRestService( | ||
|
||
val jellyfinProperties: EmbyProperties, | ||
val applicationProperties: ApplicationProperties, | ||
val fileSystemProperties: FileSystemProperties | ||
|
||
) : MediaServerService { | ||
|
||
companion object { | ||
private val log = LoggerFactory.getLogger(this::class.java.enclosingClass) | ||
private val seasonPattern = Regex("Season (?<season>\\d+)") | ||
private val filePattern = Regex("^.*\\.(mkv|mp4|avi|webm|mts|m2ts|ts|wmv|mpg|mpeg|mp2|m2v|m4v)\$") | ||
private val numberPattern = Regex("[0-9]+") | ||
} | ||
|
||
override fun cleanupTvShows(items: List<LibraryItem>) { | ||
} | ||
|
||
override fun cleanupMovies(items: List<LibraryItem>) { | ||
} | ||
|
||
override fun updateGoneSoon(type: LibraryType, items: List<LibraryItem>, onlyAddLinks: Boolean) { | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...thub/schaka/janitorr/jellyfin/Jellyfin.kt → ...janitorr/mediaserver/jellyfin/Jellyfin.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
10 changes: 5 additions & 5 deletions
10
...chaka/janitorr/jellyfin/JellyfinClient.kt → ...rr/mediaserver/jellyfin/JellyfinClient.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
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.