Skip to content

Commit

Permalink
[Emby] Small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Schaka committed Mar 6, 2024
1 parent 32d76b2 commit 18caa5f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class EmbyRestService(
Files.createDirectories(path)
}

// TODO: This entire block should probably go to the super class
// It's not dependent on any client

items.forEach {
try {

Expand All @@ -83,7 +86,7 @@ class EmbyRestService(
log.trace("Season folder - Source: {}, Target: {}", sourceSeasonFolder, targetSeasonFolder)

if (sourceSeasonFolder.exists()) {
log.trace("Creating season folder", targetSeasonFolder)
log.trace("Creating season folder {}", targetSeasonFolder)
Files.createDirectories(targetSeasonFolder)

val files = sourceSeasonFolder.listDirectoryEntries().filter { f -> isMediaFile(f.toString()) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ class JellyfinRestService(
var goneSoonCollection = result.firstOrNull { it.CollectionType == collectionFilter && it.Name == "${type.collectionName} (Deleted Soon)" }
if (goneSoonCollection == null) {
Files.createDirectories(path)
jellyfinClient.createLibrary("${type.collectionName} (Deleted Soon)", type.collectionType, AddLibraryRequest(), listOf(path.toUri().path))
val pathString = path.toUri().path
// Windows paths may have a trailing trash - Windows Jellyfin can't deal with that
val pathforJellyfin = if (pathString.startsWith("/")) pathString.replaceFirst("/", "") else pathString
jellyfinClient.createLibrary("${type.collectionName} (Deleted Soon)", type.collectionType, AddLibraryRequest(), listOf(pathforJellyfin))
goneSoonCollection = jellyfinClient.listLibraries().firstOrNull { it.CollectionType == collectionFilter && it.Name == "${type.collectionName} (Deleted Soon)" }
}

Expand All @@ -149,7 +152,7 @@ class JellyfinRestService(
log.trace("Season folder - Source: {}, Target: {}", sourceSeasonFolder, targetSeasonFolder)

if (sourceSeasonFolder.exists()) {
log.trace("Creating season folder", targetSeasonFolder)
log.trace("Creating season folder {}", targetSeasonFolder)
Files.createDirectories(targetSeasonFolder)

val files = sourceSeasonFolder.listDirectoryEntries().filter { f -> isMediaFile(f.toString()) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data class MediaFolderItem(
val IndexNumberEnd: Int,
val IsFolder: Boolean,
val IsoType: String?,
val LocationType: String,
val LocationType: String?,
val MediaSourceCount: Int,
val MediaSources: List<Any>?,
val MediaStreams: List<Any>?,
Expand Down

0 comments on commit 18caa5f

Please sign in to comment.