From c1daea0ec7c07675b8a4c3f038be69d94a36a794 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Wed, 1 May 2019 07:47:22 +0200 Subject: [PATCH 1/8] Change owner and parent id of extras to the main media item --- MediaBrowser.Controller/Entities/BaseItem.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index e20641c99a..b05e97868f 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1481,7 +1481,10 @@ namespace MediaBrowser.Controller.Entities private async Task RefreshExtras(BaseItem item, MetadataRefreshOptions options, List fileSystemChildren, CancellationToken cancellationToken) { - var newExtras = LoadExtras(fileSystemChildren, options.DirectoryService).Concat(LoadThemeVideos(fileSystemChildren, options.DirectoryService)).Concat(LoadThemeSongs(fileSystemChildren, options.DirectoryService)); + var newExtras = LoadExtras(fileSystemChildren, options.DirectoryService) + .Concat(LoadThemeVideos(fileSystemChildren, options.DirectoryService)) + .Concat(LoadThemeSongs(fileSystemChildren, options.DirectoryService)) + .ToArray(); var newExtraIds = newExtras.Select(i => i.Id).ToArray(); @@ -1493,7 +1496,17 @@ namespace MediaBrowser.Controller.Entities var tasks = newExtras.Select(i => { - return RefreshMetadataForOwnedItem(i, true, new MetadataRefreshOptions(options), cancellationToken); + var subOptions = new MetadataRefreshOptions(options); + if (!i.ExtraType.HasValue || + i.OwnerId != ownerId || + !i.ParentId.Equals(Guid.Empty)) + { + i.OwnerId = ownerId; + i.ParentId = Guid.Empty; + subOptions.ForceSave = true; + } + + return RefreshMetadataForOwnedItem(i, true, subOptions, cancellationToken); }); await Task.WhenAll(tasks).ConfigureAwait(false); From 3634d367c1809a2ff53b0583bd19b87e860d966e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Thu, 25 Apr 2019 05:33:17 +0200 Subject: [PATCH 2/8] Move artifact chown inside docker to avoid sudo --- deployment/centos-package-x64/docker-build.sh | 1 + deployment/centos-package-x64/package.sh | 3 --- deployment/debian-package-arm64/docker-build.sh | 1 + deployment/debian-package-arm64/package.sh | 5 ++--- deployment/debian-package-armhf/docker-build.sh | 1 + deployment/debian-package-armhf/package.sh | 5 ++--- deployment/debian-package-x64/docker-build.sh | 1 + deployment/debian-package-x64/package.sh | 5 ++--- deployment/fedora-package-x64/docker-build.sh | 1 + deployment/fedora-package-x64/package.sh | 5 ++--- deployment/ubuntu-package-arm64/docker-build.sh | 1 + deployment/ubuntu-package-arm64/package.sh | 5 ++--- deployment/ubuntu-package-armhf/docker-build.sh | 1 + deployment/ubuntu-package-armhf/package.sh | 5 ++--- deployment/ubuntu-package-x64/docker-build.sh | 1 + deployment/ubuntu-package-x64/package.sh | 5 ++--- 16 files changed, 22 insertions(+), 24 deletions(-) diff --git a/deployment/centos-package-x64/docker-build.sh b/deployment/centos-package-x64/docker-build.sh index 3acf1ec0df..cefb1652e9 100755 --- a/deployment/centos-package-x64/docker-build.sh +++ b/deployment/centos-package-x64/docker-build.sh @@ -18,3 +18,4 @@ rpmbuild -bb SPECS/jellyfin.spec --define "_sourcedir ${SOURCE_DIR}/SOURCES/pkg- # Move the artifacts out mkdir -p ${ARTIFACT_DIR}/rpm mv /root/rpmbuild/RPMS/x86_64/jellyfin-*.rpm /root/rpmbuild/SRPMS/jellyfin-*.src.rpm ${ARTIFACT_DIR}/rpm/ +chown -Rc $(stat -c %u:%g ${ARTIFACT_DIR}) ${ARTIFACT_DIR} diff --git a/deployment/centos-package-x64/package.sh b/deployment/centos-package-x64/package.sh index 27d686e46f..df5a665808 100755 --- a/deployment/centos-package-x64/package.sh +++ b/deployment/centos-package-x64/package.sh @@ -72,9 +72,6 @@ fi ${docker_sudo} docker build ../.. -t "${image_name}" -f ./Dockerfile # Build the RPMs and copy out to ${package_temporary_dir} ${docker_sudo} docker run --rm -v "${package_temporary_dir}:/dist" "${image_name}" -# Correct ownership on the RPMs (as current user, then as root if that fails) -chown -R "${current_user}" "${package_temporary_dir}" \ - || sudo chown -R "${current_user}" "${package_temporary_dir}" # Move the RPMs to the output directory mkdir -p "${output_dir}" mv "${package_temporary_dir}"/rpm/* "${output_dir}" diff --git a/deployment/debian-package-arm64/docker-build.sh b/deployment/debian-package-arm64/docker-build.sh index 308f3df15b..cee96e1369 100755 --- a/deployment/debian-package-arm64/docker-build.sh +++ b/deployment/debian-package-arm64/docker-build.sh @@ -18,3 +18,4 @@ dpkg-buildpackage -us -uc -aarm64 # Move the artifacts out mkdir -p ${ARTIFACT_DIR}/deb mv /jellyfin_* ${ARTIFACT_DIR}/deb/ +chown -Rc $(stat -c %u:%g ${ARTIFACT_DIR}) ${ARTIFACT_DIR} diff --git a/deployment/debian-package-arm64/package.sh b/deployment/debian-package-arm64/package.sh index 19f70d7f68..ce02b1af53 100755 --- a/deployment/debian-package-arm64/package.sh +++ b/deployment/debian-package-arm64/package.sh @@ -30,13 +30,12 @@ case $ARCH in ;; esac +# Prepare temporary package dir +mkdir -p "${package_temporary_dir}" # Set up the build environment Docker image ${docker_sudo} docker build ../.. -t "${image_name}" -f ./${DOCKERFILE} # Build the DEBs and copy out to ${package_temporary_dir} ${docker_sudo} docker run --rm -v "${package_temporary_dir}:/dist" "${image_name}" -# Correct ownership on the DEBs (as current user, then as root if that fails) -chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null \ - || sudo chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null # Move the DEBs to the output directory mkdir -p "${output_dir}" mv "${package_temporary_dir}"/deb/* "${output_dir}" diff --git a/deployment/debian-package-armhf/docker-build.sh b/deployment/debian-package-armhf/docker-build.sh index 45e68f0c6b..56227b5880 100755 --- a/deployment/debian-package-armhf/docker-build.sh +++ b/deployment/debian-package-armhf/docker-build.sh @@ -18,3 +18,4 @@ dpkg-buildpackage -us -uc -aarmhf # Move the artifacts out mkdir -p ${ARTIFACT_DIR}/deb mv /jellyfin_* ${ARTIFACT_DIR}/deb/ +chown -Rc $(stat -c %u:%g ${ARTIFACT_DIR}) ${ARTIFACT_DIR} diff --git a/deployment/debian-package-armhf/package.sh b/deployment/debian-package-armhf/package.sh index 0ec0dc95cf..4393fb8340 100755 --- a/deployment/debian-package-armhf/package.sh +++ b/deployment/debian-package-armhf/package.sh @@ -30,13 +30,12 @@ case $ARCH in ;; esac +# Prepare temporary package dir +mkdir -p "${package_temporary_dir}" # Set up the build environment Docker image ${docker_sudo} docker build ../.. -t "${image_name}" -f ./${DOCKERFILE} # Build the DEBs and copy out to ${package_temporary_dir} ${docker_sudo} docker run --rm -v "${package_temporary_dir}:/dist" "${image_name}" -# Correct ownership on the DEBs (as current user, then as root if that fails) -chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null \ - || sudo chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null # Move the DEBs to the output directory mkdir -p "${output_dir}" mv "${package_temporary_dir}"/deb/* "${output_dir}" diff --git a/deployment/debian-package-x64/docker-build.sh b/deployment/debian-package-x64/docker-build.sh index 0590be0972..07f726dcc8 100755 --- a/deployment/debian-package-x64/docker-build.sh +++ b/deployment/debian-package-x64/docker-build.sh @@ -17,3 +17,4 @@ dpkg-buildpackage -us -uc # Move the artifacts out mkdir -p ${ARTIFACT_DIR}/deb mv /jellyfin_* ${ARTIFACT_DIR}/deb/ +chown -Rc $(stat -c %u:%g ${ARTIFACT_DIR}) ${ARTIFACT_DIR} diff --git a/deployment/debian-package-x64/package.sh b/deployment/debian-package-x64/package.sh index d7c3f5809c..2530e253bd 100755 --- a/deployment/debian-package-x64/package.sh +++ b/deployment/debian-package-x64/package.sh @@ -19,13 +19,12 @@ else docker_sudo="" fi +# Prepare temporary package dir +mkdir -p "${package_temporary_dir}" # Set up the build environment Docker image ${docker_sudo} docker build ../.. -t "${image_name}" -f ./Dockerfile # Build the DEBs and copy out to ${package_temporary_dir} ${docker_sudo} docker run --rm -v "${package_temporary_dir}:/dist" "${image_name}" -# Correct ownership on the DEBs (as current user, then as root if that fails) -chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null \ - || sudo chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null # Move the DEBs to the output directory mkdir -p "${output_dir}" mv "${package_temporary_dir}"/deb/* "${output_dir}" diff --git a/deployment/fedora-package-x64/docker-build.sh b/deployment/fedora-package-x64/docker-build.sh index 3acf1ec0df..cefb1652e9 100755 --- a/deployment/fedora-package-x64/docker-build.sh +++ b/deployment/fedora-package-x64/docker-build.sh @@ -18,3 +18,4 @@ rpmbuild -bb SPECS/jellyfin.spec --define "_sourcedir ${SOURCE_DIR}/SOURCES/pkg- # Move the artifacts out mkdir -p ${ARTIFACT_DIR}/rpm mv /root/rpmbuild/RPMS/x86_64/jellyfin-*.rpm /root/rpmbuild/SRPMS/jellyfin-*.src.rpm ${ARTIFACT_DIR}/rpm/ +chown -Rc $(stat -c %u:%g ${ARTIFACT_DIR}) ${ARTIFACT_DIR} diff --git a/deployment/fedora-package-x64/package.sh b/deployment/fedora-package-x64/package.sh index eed29aef3c..e659ee5e9e 100755 --- a/deployment/fedora-package-x64/package.sh +++ b/deployment/fedora-package-x64/package.sh @@ -23,13 +23,12 @@ fi ./create_tarball.sh +# Prepare temporary package dir +mkdir -p "${package_temporary_dir}" # Set up the build environment Docker image ${docker_sudo} docker build ../.. -t "${image_name}" -f ./Dockerfile # Build the RPMs and copy out to ${package_temporary_dir} ${docker_sudo} docker run --rm -v "${package_temporary_dir}:/dist" "${image_name}" -# Correct ownership on the RPMs (as current user, then as root if that fails) -chown -R "${current_user}" "${package_temporary_dir}" \ - || sudo chown -R "${current_user}" "${package_temporary_dir}" # Move the RPMs to the output directory mkdir -p "${output_dir}" mv "${package_temporary_dir}"/rpm/* "${output_dir}" diff --git a/deployment/ubuntu-package-arm64/docker-build.sh b/deployment/ubuntu-package-arm64/docker-build.sh index 308f3df15b..cee96e1369 100755 --- a/deployment/ubuntu-package-arm64/docker-build.sh +++ b/deployment/ubuntu-package-arm64/docker-build.sh @@ -18,3 +18,4 @@ dpkg-buildpackage -us -uc -aarm64 # Move the artifacts out mkdir -p ${ARTIFACT_DIR}/deb mv /jellyfin_* ${ARTIFACT_DIR}/deb/ +chown -Rc $(stat -c %u:%g ${ARTIFACT_DIR}) ${ARTIFACT_DIR} diff --git a/deployment/ubuntu-package-arm64/package.sh b/deployment/ubuntu-package-arm64/package.sh index 54fc387509..5a2bf61c86 100755 --- a/deployment/ubuntu-package-arm64/package.sh +++ b/deployment/ubuntu-package-arm64/package.sh @@ -30,13 +30,12 @@ case $ARCH in ;; esac +# Prepare temporary package dir +mkdir -p "${package_temporary_dir}" # Set up the build environment Docker image ${docker_sudo} docker build ../.. -t "${image_name}" -f ./${DOCKERFILE} # Build the DEBs and copy out to ${package_temporary_dir} ${docker_sudo} docker run --rm -v "${package_temporary_dir}:/dist" "${image_name}" -# Correct ownership on the DEBs (as current user, then as root if that fails) -chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null \ - || sudo chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null # Move the DEBs to the output directory mkdir -p "${output_dir}" mv "${package_temporary_dir}"/deb/* "${output_dir}" diff --git a/deployment/ubuntu-package-armhf/docker-build.sh b/deployment/ubuntu-package-armhf/docker-build.sh index 45e68f0c6b..56227b5880 100755 --- a/deployment/ubuntu-package-armhf/docker-build.sh +++ b/deployment/ubuntu-package-armhf/docker-build.sh @@ -18,3 +18,4 @@ dpkg-buildpackage -us -uc -aarmhf # Move the artifacts out mkdir -p ${ARTIFACT_DIR}/deb mv /jellyfin_* ${ARTIFACT_DIR}/deb/ +chown -Rc $(stat -c %u:%g ${ARTIFACT_DIR}) ${ARTIFACT_DIR} diff --git a/deployment/ubuntu-package-armhf/package.sh b/deployment/ubuntu-package-armhf/package.sh index fb03652cd5..15f55bff20 100755 --- a/deployment/ubuntu-package-armhf/package.sh +++ b/deployment/ubuntu-package-armhf/package.sh @@ -30,13 +30,12 @@ case $ARCH in ;; esac +# Prepare temporary package dir +mkdir -p "${package_temporary_dir}" # Set up the build environment Docker image ${docker_sudo} docker build ../.. -t "${image_name}" -f ./${DOCKERFILE} # Build the DEBs and copy out to ${package_temporary_dir} ${docker_sudo} docker run --rm -v "${package_temporary_dir}:/dist" "${image_name}" -# Correct ownership on the DEBs (as current user, then as root if that fails) -chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null \ - || sudo chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null # Move the DEBs to the output directory mkdir -p "${output_dir}" mv "${package_temporary_dir}"/deb/* "${output_dir}" diff --git a/deployment/ubuntu-package-x64/docker-build.sh b/deployment/ubuntu-package-x64/docker-build.sh index 0590be0972..07f726dcc8 100755 --- a/deployment/ubuntu-package-x64/docker-build.sh +++ b/deployment/ubuntu-package-x64/docker-build.sh @@ -17,3 +17,4 @@ dpkg-buildpackage -us -uc # Move the artifacts out mkdir -p ${ARTIFACT_DIR}/deb mv /jellyfin_* ${ARTIFACT_DIR}/deb/ +chown -Rc $(stat -c %u:%g ${ARTIFACT_DIR}) ${ARTIFACT_DIR} diff --git a/deployment/ubuntu-package-x64/package.sh b/deployment/ubuntu-package-x64/package.sh index 6d4625a197..32e6d4fd65 100755 --- a/deployment/ubuntu-package-x64/package.sh +++ b/deployment/ubuntu-package-x64/package.sh @@ -19,13 +19,12 @@ else docker_sudo="" fi +# Prepare temporary package dir +mkdir -p "${package_temporary_dir}" # Set up the build environment Docker image ${docker_sudo} docker build ../.. -t "${image_name}" -f ./Dockerfile # Build the DEBs and copy out to ${package_temporary_dir} ${docker_sudo} docker run --rm -v "${package_temporary_dir}:/dist" "${image_name}" -# Correct ownership on the DEBs (as current user, then as root if that fails) -chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null \ - || sudo chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null # Move the DEBs to the output directory mkdir -p "${output_dir}" mv "${package_temporary_dir}"/deb/* "${output_dir}" From b8a09339cd7c14ce4806463c4d62b80f760d93aa Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Thu, 2 May 2019 08:14:00 +0200 Subject: [PATCH 3/8] Enforce extras folder structure according to Emby's wiki --- MediaBrowser.Controller/Entities/BaseItem.cs | 67 ++++++++++++-------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index b05e97868f..1c6902b73f 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -82,6 +82,21 @@ namespace MediaBrowser.Controller.Entities public static string ThemeSongsFolderName = "theme-music"; public static string ThemeSongFilename = "theme"; public static string ThemeVideosFolderName = "backdrops"; + public static string ExtrasFolderName = "extras"; + public static string BehindTheScenesFolderName = "behind the scenes"; + public static string DeletedScenesFolderName = "deleted scenes"; + public static string InterviewFolderName = "interviews"; + public static string SceneFolderName = "scenes"; + public static string SampleFolderName = "samples"; + + public static string[] AllExtrasTypesFolderNames = { + ExtrasFolderName, + BehindTheScenesFolderName, + DeletedScenesFolderName, + InterviewFolderName, + SceneFolderName, + SampleFolderName + }; [IgnoreDataMember] public Guid[] ThemeSongIds { get; set; } @@ -1276,16 +1291,15 @@ namespace MediaBrowser.Controller.Entities .Select(item => { // Try to retrieve it from the db. If we don't find it, use the resolved version - var dbItem = LibraryManager.GetItemById(item.Id) as Video; - if (dbItem != null) + if (LibraryManager.GetItemById(item.Id) is Video dbItem) { item = dbItem; } else { // item is new - item.ExtraType = MediaBrowser.Model.Entities.ExtraType.ThemeVideo; + item.ExtraType = Model.Entities.ExtraType.ThemeVideo; } return item; @@ -1296,33 +1310,37 @@ namespace MediaBrowser.Controller.Entities protected virtual BaseItem[] LoadExtras(List fileSystemChildren, IDirectoryService directoryService) { - var files = fileSystemChildren.Where(i => i.IsDirectory) - .SelectMany(i => FileSystem.GetFiles(i.FullName)); + var extras = new List