fix(mediadownloader): new media sources

This commit is contained in:
rhunk
2023-05-27 18:34:01 +02:00
parent 33c8e79557
commit 3dafa28f31
3 changed files with 13 additions and 8 deletions

View File

@@ -60,6 +60,7 @@ class ModContext {
runCatching { runCatching {
runnable() runnable()
}.onFailure { }.onFailure {
longToast("Async task failed " + it.message)
Logger.xposedLog("Async task failed", it) Logger.xposedLog("Async task failed", it)
} }
} }

View File

@@ -15,7 +15,7 @@ class ParamMap(obj: Any?) : AbstractWrapper(obj) {
)!! )!!
} }
private val concurrentHashMap: ConcurrentHashMap<Any, Any> val concurrentHashMap: ConcurrentHashMap<Any, Any>
get() = instanceNonNull().getObjectField(paramMapField.name) as ConcurrentHashMap<Any, Any> get() = instanceNonNull().getObjectField(paramMapField.name) as ConcurrentHashMap<Any, Any>
operator fun get(key: String): Any? { operator fun get(key: String): Any? {

View File

@@ -143,10 +143,7 @@ class MediaDownloader : Feature("MediaDownloader", loadParams = FeatureLoadParam
fun downloadLastOperaMediaAsync() { fun downloadLastOperaMediaAsync() {
if (lastSeenMapParams == null || lastSeenMediaInfoMap == null) return if (lastSeenMapParams == null || lastSeenMediaInfoMap == null) return
context.executeAsync { context.executeAsync {
handleOperaMedia( handleOperaMedia(lastSeenMapParams!!, lastSeenMediaInfoMap!!, true)
lastSeenMapParams!!,
lastSeenMediaInfoMap!!, true
)
} }
} }
@@ -224,14 +221,15 @@ class MediaDownloader : Feature("MediaDownloader", loadParams = FeatureLoadParam
) { ) {
val storyIdStartIndex = playlistV2Group.indexOf("storyUserId=") + 12 val storyIdStartIndex = playlistV2Group.indexOf("storyUserId=") + 12
val storyUserId = playlistV2Group.substring(storyIdStartIndex, playlistV2Group.indexOf(",", storyIdStartIndex)) val storyUserId = playlistV2Group.substring(storyIdStartIndex, playlistV2Group.indexOf(",", storyIdStartIndex))
val author = context.database.getFriendInfo(storyUserId) val author = context.database.getFriendInfo(if (storyUserId == "null") context.database.getMyUserId()!! else storyUserId)
downloadOperaMedia(mediaInfoMap, author!!.usernameForSorting!!) downloadOperaMedia(mediaInfoMap, author!!.usernameForSorting!!)
return return
} }
val snapSource = paramMap["SNAP_SOURCE"].toString() val snapSource = paramMap["SNAP_SOURCE"].toString()
//public stories //public stories
if (snapSource == "PUBLIC_USER" && (forceDownload || context.config.bool(ConfigProperty.AUTO_DOWNLOAD_PUBLIC_STORIES))) { if ((snapSource == "PUBLIC_USER" || snapSource == "SAVED_STORY") &&
(forceDownload || context.config.bool(ConfigProperty.AUTO_DOWNLOAD_PUBLIC_STORIES))) {
val userDisplayName = (if (paramMap.containsKey("USER_DISPLAY_NAME")) paramMap["USER_DISPLAY_NAME"].toString() else "").replace( val userDisplayName = (if (paramMap.containsKey("USER_DISPLAY_NAME")) paramMap["USER_DISPLAY_NAME"].toString() else "").replace(
"[^\\x00-\\x7F]".toRegex(), "[^\\x00-\\x7F]".toRegex(),
"") "")
@@ -247,7 +245,7 @@ class MediaDownloader : Feature("MediaDownloader", loadParams = FeatureLoadParam
//stories with mpeg dash media //stories with mpeg dash media
//TODO: option to download multiple chapters //TODO: option to download multiple chapters
if (paramMap.containsKey("SNAP_PLAYLIST_ITEM") && forceDownload) { if (paramMap.containsKey("LONGFORM_VIDEO_PLAYLIST_ITEM") && forceDownload) {
if (!isFFmpegPresent) { if (!isFFmpegPresent) {
context.shortToast("Can't download media. ffmpeg was not found") context.shortToast("Can't download media. ffmpeg was not found")
return return
@@ -293,6 +291,12 @@ class MediaDownloader : Feature("MediaDownloader", loadParams = FeatureLoadParam
} }
return return
} }
context.longToast("Download not implemented. Please report this issue!")
xposedLog("download not implemented issue:")
xposedLog("paramMap: ${paramMap.concurrentHashMap}")
xposedLog("mediaInfoMap: $mediaInfoMap")
xposedLog("forceDownload: $forceDownload")
} }
private fun canAutoDownload(): Boolean { private fun canAutoDownload(): Boolean {