commit 7924d5a445180d2786cfc8ef9b6b1c6fc203b701 parent 2cf172e597efbadbff2c41f2434a7be4b86cfbca Author: rhunk <101876869+rhunk@users.noreply.github.com> Date: Wed, 6 Sep 2023 23:02:11 +0200 fix(media_downloader): two images overlay merge Diffstat:
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/download/DownloadProcessor.kt b/app/src/main/kotlin/me/rhunk/snapenhance/download/DownloadProcessor.kt @@ -380,14 +380,15 @@ class DownloadProcessor ( if (shouldMergeOverlay) { assert(downloadedMedias.size == 2) - val media = downloadedMedias.values.first { it.fileType.isVideo } - val overlayMedia = downloadedMedias.values.first { it.fileType.isImage } + //TODO: convert "mp4 images" into real images + val media = downloadedMedias.entries.first { !it.key.isOverlay }.value + val overlayMedia = downloadedMedias.entries.first { it.key.isOverlay }.value val renamedMedia = renameFromFileType(media.file, media.fileType) val renamedOverlayMedia = renameFromFileType(overlayMedia.file, overlayMedia.fileType) - val mergedOverlay: File = File.createTempFile("merged", "." + media.fileType.fileExtension) + val mergedOverlay: File = File.createTempFile("merged", ".mp4") runCatching { - callbackOnProgress(translation.format("download_toast", "path" to media.file.nameWithoutExtension)) + callbackOnProgress(translation.format("processing_toast", "path" to media.file.nameWithoutExtension)) downloadObjectObject.downloadStage = DownloadStage.MERGING ffmpegProcessor.execute(FFMpegProcessor.Request( diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/download/data/DownloadRequest.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/download/data/DownloadRequest.kt @@ -7,6 +7,7 @@ data class InputMedia( val type: DownloadMediaType, val encryption: MediaEncryptionKeyPair? = null, val messageContentType: String? = null, + val isOverlay: Boolean = false, ) class DownloadRequest( diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/features/impl/downloader/MediaDownloader.kt b/core/src/main/kotlin/me/rhunk/snapenhance/features/impl/downloader/MediaDownloader.kt @@ -199,7 +199,8 @@ class MediaDownloader : MessagingRuleFeature("MediaDownloader", MessagingRuleTyp overlay = InputMedia( overlayReference, DownloadMediaType.fromUri(Uri.parse(overlayReference)), - overlay.encryption?.toKeyPair() + overlay.encryption?.toKeyPair(), + isOverlay = true ) ) return @@ -372,7 +373,7 @@ class MediaDownloader : MessagingRuleFeature("MediaDownloader", MessagingRuleTyp mediaAuthor = storyName ).downloadDashMedia(playlistUrl, 0, null) } - setPositiveButton("Download") { dialog, which -> + setPositiveButton("Download") { _, _ -> val groups = mutableListOf<MutableList<SnapChapterInfo>>() var currentGroup = mutableListOf<SnapChapterInfo>() var lastChapterIndex = -1