feat(app/tasks): merge videos

This commit is contained in:
rhunk
2023-12-30 16:30:05 +01:00
parent a7f4f1cdaf
commit 04b70431c7
11 changed files with 407 additions and 95 deletions

View File

@ -38,8 +38,8 @@
"export_logs_button": "Export Logs"
}
},
"downloads": {
"empty_download_list": "(empty)"
"tasks": {
"no_tasks": "No tasks"
},
"features": {
"disabled": "Disabled"
@ -899,6 +899,18 @@
"STATUS_COUNTDOWN": "Countdown"
},
"media_download_source": {
"none": "None",
"pending": "Pending",
"chat_media": "Chat Media",
"story": "Story",
"public_story": "Public Story",
"spotlight": "Spotlight",
"profile_picture": "Profile Picture",
"story_logger": "Story Logger",
"merged": "Merged"
},
"chat_action_menu": {
"preview_button": "Preview",
"download_button": "Download",

View File

@ -13,6 +13,8 @@ enum class FileType(
GIF("gif", "image/gif", false, false, false),
PNG("png", "image/png", false, true, false),
MP4("mp4", "video/mp4", true, false, false),
MKV("mkv", "video/mkv", true, false, false),
AVI("avi", "video/avi", true, false, false),
MP3("mp3", "audio/mp3",false, false, true),
OPUS("opus", "audio/opus", false, false, true),
AAC("aac", "audio/aac", false, false, true),
@ -34,6 +36,9 @@ enum class FileType(
"4f676753" to OPUS,
"fff15" to AAC,
"ffd8ff" to JPG,
"47494638" to GIF,
"1a45dfa3" to MKV,
"52494646" to AVI,
)
fun fromString(string: String?): FileType {

View File

@ -40,12 +40,12 @@ fun createNewFilePath(
config: RootConfig,
hexHash: String,
downloadSource: MediaDownloadSource,
mediaAuthor: String,
mediaAuthor: String?,
creationTimestamp: Long?
): String {
val pathFormat by config.downloader.pathFormat
val customPathFormat by config.downloader.customPathFormat
val sanitizedMediaAuthor = mediaAuthor.sanitizeForPath().ifEmpty { hexHash }
val sanitizedMediaAuthor = mediaAuthor?.sanitizeForPath() ?: hexHash
val currentDateTime = SimpleDateFormat("yyyy-MM-dd_HH-mm-ss", Locale.ENGLISH).format(creationTimestamp ?: System.currentTimeMillis())
val finalPath = StringBuilder()

View File

@ -1,25 +1,31 @@
package me.rhunk.snapenhance.common.data.download
import me.rhunk.snapenhance.common.bridge.wrapper.LocaleWrapper
enum class MediaDownloadSource(
val key: String,
val displayName: String = key,
val pathName: String = key,
val ignoreFilter: Boolean = false
) {
NONE("none", "None", ignoreFilter = true),
PENDING("pending", "Pending", ignoreFilter = true),
CHAT_MEDIA("chat_media", "Chat Media", "chat_media"),
STORY("story", "Story", "story"),
PUBLIC_STORY("public_story", "Public Story", "public_story"),
SPOTLIGHT("spotlight", "Spotlight", "spotlight"),
PROFILE_PICTURE("profile_picture", "Profile Picture", "profile_picture"),
STORY_LOGGER("story_logger", "Story Logger", "story_logger");
NONE("none", ignoreFilter = true),
PENDING("pending", ignoreFilter = true),
CHAT_MEDIA("chat_media", "chat_media"),
STORY("story", "story"),
PUBLIC_STORY("public_story", "public_story"),
SPOTLIGHT("spotlight", "spotlight"),
PROFILE_PICTURE("profile_picture", "profile_picture"),
STORY_LOGGER("story_logger", "story_logger"),
MERGED("merged", "merged");
fun matches(source: String?): Boolean {
if (source == null) return false
return source.contains(key, ignoreCase = true)
}
fun translate(translation: LocaleWrapper): String {
return translation["media_download_source.$key"]
}
companion object {
fun fromKey(key: String?): MediaDownloadSource {
if (key == null) return NONE