Skip to content

Commit

Permalink
文件名过长无法下载;关注页未获取到基本信息
Browse files Browse the repository at this point in the history
文件名过长无法下载;
关注页未获取到基本信息
  • Loading branch information
GangJust committed Mar 13, 2023
1 parent 4ee93bb commit 7840f2a
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId "com.freegang.fplus"
minSdk 21
targetSdk 33
versionCode 1
versionName "1.0.0"
versionCode 2
versionName "1.0.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/assets/update.log
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
v1.0.0
适配抖音24.4.0、24.5.0
适配抖音24.4.0、24.5.0

v1.0.1
文件名过长无法下载;
关注页未获取到基本信息
9 changes: 8 additions & 1 deletion core/src/main/java/com/freegang/douyin/HAbsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,14 @@ class HAbsActivity(
if (absActivity is DetailActivity || absActivity is MainActivity) {
val methods = absActivity.findMethodsByReturnType(Aweme::class.java)
if (methods.isNotEmpty()) {
val aweme = methods.first().call(absActivity)
var aweme = methods.first().call(absActivity)
if (aweme == null) {
val curFragment = absActivity.findMethod("getCurFragment", *arrayOf<Any>())?.call(absActivity)
val curFragmentMethods = curFragment?.findMethodsByReturnType(Aweme::class.java) ?: listOf()
if (curFragmentMethods.isNotEmpty()) {
aweme = curFragmentMethods.first().call(curFragment!!)
}
}
DownloadLogic(this@HAbsActivity, absActivity, aweme, config.isOwnerDir)
}
}
Expand Down
7 changes: 4 additions & 3 deletions core/src/main/java/com/freegang/douyin/logic/DownloadLogic.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.freegang.xpler.utils.app.KAlbumUtils
import com.freegang.xpler.utils.io.KFileUtils.child
import com.freegang.xpler.utils.io.KFileUtils.need
import com.freegang.xpler.utils.io.KFileUtils.pureFileName
import com.freegang.xpler.utils.io.KFileUtils.subMax
import com.freegang.xpler.utils.net.KHttpUtils
import com.freegang.xpler.xp.getObjectField
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -117,7 +118,7 @@ class DownloadLogic(
val pureFileName = if (deAweme.desc.isBlank()) {
"${deAweme.nickname.pureFileName}_${deAweme.shortId}_${System.currentTimeMillis() / 1000}"
} else {
"${deAweme.nickname.pureFileName}_${deAweme.shortId}_${deAweme.desc.pureFileName}"
"${deAweme.nickname.pureFileName}_${deAweme.shortId}_${deAweme.desc.pureFileName.subMax()}"
}.plus(".mp4")

//默认下载路径: `/外置存储器/DCIM/Freedom/video`
Expand Down Expand Up @@ -164,7 +165,7 @@ class DownloadLogic(
val pureFileName = if (deAweme.desc.isBlank()) {
"${deAweme.nickname.pureFileName}_${deAweme.shortId}_${System.currentTimeMillis() / 1000}"
} else {
"${deAweme.nickname.pureFileName}_${deAweme.shortId}_${deAweme.desc.pureFileName}"
"${deAweme.nickname.pureFileName}_${deAweme.shortId}_${deAweme.desc.pureFileName.subMax()}"
}

//默认下载路径: `/外置存储器/DCIM/Freedom/picture`
Expand Down Expand Up @@ -222,7 +223,7 @@ class DownloadLogic(
val pureFileName = if (deAweme.desc.isBlank()) {
"${deAweme.nickname.pureFileName}_${deAweme.shortId}_${System.currentTimeMillis() / 1000}"
} else {
"${deAweme.nickname.pureFileName}_${deAweme.shortId}_${deAweme.desc.pureFileName}"
"${deAweme.nickname.pureFileName}_${deAweme.shortId}_${deAweme.desc.pureFileName.subMax()}"
}.plus(".mp3")

//默认下载路径: `/外置存储器/DCIM/Freedom/music`
Expand Down
14 changes: 14 additions & 0 deletions core/src/main/java/com/freegang/xpler/utils/io/KFileUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ object KFileUtils {

/**
* 必要的路径地址, 如果该路径不存在, 则为其创建
* @param isFile 该路径最右侧的子项是否为文件
*/
fun File.need(isFile: Boolean = false): File {
if (isFile) {
Expand All @@ -54,6 +55,19 @@ object KFileUtils {
*/
fun String.toFile() = File(this)

/**
* 按给定最大长度截取某个字符串, 成功返回截取后的文本, 失败返回原文本
* 该字符串最大长度不能超过[max],
* 并以[ellipsis]结尾
* @param max 最大长度
* @param ellipsis 省略占位文本
* @return String
*/
fun String.subMax(max: Int = 10, ellipsis: String = ""): String {
if (this.length <= max) return this
return this.substring(0, max).plus(ellipsis)
}

//获取纯净的文件名, 替换掉部分特殊符号
val File.pureName: String
get() = name.pureFileName
Expand Down
31 changes: 31 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# FreedomPlus

[![](https://img.shields.io/github/v/release/GangJust/FreedomPlus)](https://github.com/GangJust/FreedomPlus/releases/tag/v1.0.0) [![](https://img.shields.io/github/downloads/GangJust/FreedomPlus/total?color=g)]()

依赖于抖音运行的开源Xposed模块

----



## 功能介绍

- 视频无水印下载
- 评论区静态图保存
- 表情包保存
- 顶部Tab栏自定义隐藏



## 支持版本

- 24.4.0、24.5.0



## 重要说明

- 本项目作为一个工具,代码开源,供开发者学习参考使用;
- 开发人员可能会在任何时间**停止更新****删除项目**源码,同时也欢迎issues、pull requests;
- **请、并且:禁止用于非法用途,否则将立即停止本项目的更新**

0 comments on commit 7840f2a

Please sign in to comment.