Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion doc/README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,11 @@ channel@UCp1nO1bgVwks9b5EhKQGVag:幻海航行
- https://api.xhofe.top/alist/ali_open/token
- https://api.nn.ci/alist/ali_open/token

如果nginx配置了SSL,需要在高级设置中打开`订阅域名支持HTTPS`开关。
如果配置了nginx代理,可以在高级设置中配置`管理应用地址`。
默认为空,后台会根据当前访问地址组装URL。
配置了nginx代理后,组装的URL可能不正确,就需要手动填写管理应用地址。

如果nginx配置了SSL并且没有配置管理应用地址,需要在高级设置中打开`订阅域名支持HTTPS`开关。

### 索引
对于阿里云盘资源,建议使用文件数量少的路径,并限速,防止被封号。
Expand Down
24 changes: 8 additions & 16 deletions src/main/java/cn/har01d/alist_tvbox/service/BiliBiliService.java
Original file line number Diff line number Diff line change
Expand Up @@ -1430,22 +1430,6 @@ private static String secondsToTime(String text) {
private String getCookie(String token) {
if ("666".equals(token)) {
return BiliBiliUtils.getCookie();
} else {
try {
String cookie = BiliBiliUtils.getDefaultCookie();
if (cookie != null) {
return cookie;
}

cookie = restTemplate1.getForObject("https://agit.ai/30215429/TVBox/raw/branch/master/bilibili/cookie.txt", String.class);
// Map map = objectMapper.readValue(json, Map.class);
// cookie = (String) map.getOrDefault("cookie", "");
log.info("{}", cookie);
BiliBiliUtils.setDefaultCookie(cookie);
return cookie;
} catch (Exception e) {
log.warn("", e);
}
}
return "";
}
Expand Down Expand Up @@ -2087,6 +2071,10 @@ private static String fixCover(String cover) {
}

private String fixSubtitleUrl(String url) {
String baseUrl = settingRepository.findById("app_base_url").map(Setting::getValue).orElse("");
if (StringUtils.isNotBlank(baseUrl)) {
return baseUrl + "/subtitles?url=" + fixUrl(url);
}
return ServletUriComponentsBuilder.fromCurrentRequest()
.scheme(appProperties.isEnableHttps() && !Utils.isLocalAddress() ? "https" : "http") // nginx https
.replacePath("/subtitles")
Expand All @@ -2096,6 +2084,10 @@ private String fixSubtitleUrl(String url) {
}

private String getListPic() {
String baseUrl = settingRepository.findById("app_base_url").map(Setting::getValue).orElse("");
if (StringUtils.isNotBlank(baseUrl)) {
return baseUrl + "/list.png";
}
return ServletUriComponentsBuilder.fromCurrentRequest()
.scheme(appProperties.isEnableHttps() && !Utils.isLocalAddress() ? "https" : "http") // nginx https
.replacePath("/list.png")
Expand Down
20 changes: 14 additions & 6 deletions src/main/java/cn/har01d/alist_tvbox/service/DoubanService.java
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,7 @@ private void setDoubanInfo(MovieDetail detail) {
Movie movie = getByName(detail.getVod_name());
if (movie != null) {
if (movie.getCover() != null && !movie.getCover().isEmpty()) {
String cover = ServletUriComponentsBuilder.fromCurrentRequest()
.scheme(appProperties.isEnableHttps() && !Utils.isLocalAddress() ? "https" : "http") // nginx https
.replacePath("/images")
.query("url=" + movie.getCover())
.build()
.toUriString();
String cover = getCoverUrl(movie);
log.debug("cover url: {}", cover);
movie.setCover(cover);
}
Expand All @@ -372,6 +367,19 @@ private void setDoubanInfo(MovieDetail detail) {
}
}

private String getCoverUrl(Movie movie) {
String baseUrl = settingRepository.findById("app_base_url").map(Setting::getValue).orElse("");
if (StringUtils.isNotBlank(baseUrl)) {
return baseUrl + "/images?url=" + movie.getCover();
}
return ServletUriComponentsBuilder.fromCurrentRequest()
.scheme(appProperties.isEnableHttps() && !Utils.isLocalAddress() ? "https" : "http") // nginx https
.replacePath("/images")
.query("url=" + movie.getCover())
.build()
.toUriString();
}

public Movie getByName(String name) {
try {
Alias alias = aliasRepository.findById(name).orElse(null);
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/cn/har01d/alist_tvbox/service/SettingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import cn.har01d.alist_tvbox.config.AppProperties;
import cn.har01d.alist_tvbox.entity.Setting;
import cn.har01d.alist_tvbox.entity.SettingRepository;
import cn.har01d.alist_tvbox.exception.BadRequestException;
import cn.har01d.alist_tvbox.util.Utils;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import org.springframework.core.io.FileSystemResource;
Expand All @@ -18,6 +20,7 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.time.LocalDate;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -138,6 +141,19 @@ public Setting update(Setting setting) {
if ("tmdb_api_key".equals(setting.getName())) {
tmdbService.setApiKey(setting.getValue());
}
if ("app_base_url".equals(setting.getName())) {
String url = setting.getValue();
if (StringUtils.isNotBlank(url)) {
try {
new URL(url);
} catch (Exception e) {
throw new BadRequestException("错误的URL地址:" + e.getMessage(), e);
}
if (url.endsWith("/")) {
setting.setValue(url.substring(0, url.length() - 1));
}
}
}
if ("debug_log".equals(setting.getName())) {
setLogLevel(setting);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,10 @@ private String readHostAddress() {
}

private String readHostAddress(String path) {
String baseUrl = settingRepository.findById("app_base_url").map(Setting::getValue).orElse("");
if (StringUtils.isNotBlank(baseUrl)) {
return baseUrl + path;
}
UriComponents uriComponents = ServletUriComponentsBuilder.fromCurrentRequest()
.scheme(appProperties.isEnableHttps() && !Utils.isLocalAddress() ? "https" : "http") // nginx https
.replacePath(path)
Expand Down Expand Up @@ -1102,6 +1106,7 @@ public String repository(String token, String id) {
file = new File("/www/tvbox/juhe.json");
if (file.exists()) {
String json = FileUtils.readFileToString(file, StandardCharsets.UTF_8);
json = json.replace("https://tvbox.cainisi.cf", "https://tv.菜妮丝.top");
json = json.replace("DOCKER_ADDRESS/tvbox/my.json", baseUrl + id);
return json;
}
Expand Down
33 changes: 27 additions & 6 deletions src/main/java/cn/har01d/alist_tvbox/service/TvBoxService.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import cn.har01d.alist_tvbox.entity.Meta;
import cn.har01d.alist_tvbox.entity.MetaRepository;
import cn.har01d.alist_tvbox.entity.Movie;
import cn.har01d.alist_tvbox.entity.Setting;
import cn.har01d.alist_tvbox.entity.SettingRepository;
import cn.har01d.alist_tvbox.entity.ShareRepository;
import cn.har01d.alist_tvbox.entity.Site;
import cn.har01d.alist_tvbox.entity.Tmdb;
Expand Down Expand Up @@ -89,6 +91,7 @@ public class TvBoxService {
private final AListAliasRepository aliasRepository;
private final ShareRepository shareRepository;
private final MetaRepository metaRepository;
private final SettingRepository settingRepository;

private final AListService aListService;
private final IndexService indexService;
Expand Down Expand Up @@ -140,6 +143,7 @@ public TvBoxService(AccountRepository accountRepository,
AListAliasRepository aliasRepository,
ShareRepository shareRepository,
MetaRepository metaRepository,
SettingRepository settingRepository,
AListService aListService,
IndexService indexService,
SiteService siteService,
Expand All @@ -154,6 +158,7 @@ public TvBoxService(AccountRepository accountRepository,
this.aliasRepository = aliasRepository;
this.shareRepository = shareRepository;
this.metaRepository = metaRepository;
this.settingRepository = settingRepository;
this.aListService = aListService;
this.indexService = indexService;
this.siteService = siteService;
Expand Down Expand Up @@ -1071,6 +1076,10 @@ private List<MovieDetail> generatePlaylist(String path, int total, List<MovieDet
}

private String getListPic() {
String baseUrl = settingRepository.findById("app_base_url").map(Setting::getValue).orElse("");
if (StringUtils.isNotBlank(baseUrl)) {
return baseUrl + "/list.png";
}
return ServletUriComponentsBuilder.fromCurrentRequest()
.scheme(appProperties.isEnableHttps() && !Utils.isLocalAddress() ? "https" : "http") // nginx https
.replacePath("/list.png")
Expand Down Expand Up @@ -1732,12 +1741,7 @@ private void setTmdbInfo(MovieDetail movieDetail, Tmdb movie, boolean details) {
private void fixCover(MovieDetail movie) {
try {
if (movie.getVod_pic() != null && !movie.getVod_pic().isEmpty()) {
String cover = ServletUriComponentsBuilder.fromCurrentRequest()
.scheme(appProperties.isEnableHttps() && !Utils.isLocalAddress() ? "https" : "http") // nginx https
.replacePath("/images")
.replaceQuery("url=" + movie.getVod_pic())
.build()
.toUriString();
String cover = getCoverUrl(movie);
log.debug("cover url: {}", cover);
movie.setVod_pic(cover);
}
Expand All @@ -1746,9 +1750,26 @@ private void fixCover(MovieDetail movie) {
}
}

private String getCoverUrl(MovieDetail movie) {
String baseUrl = settingRepository.findById("app_base_url").map(Setting::getValue).orElse("");
if (StringUtils.isNotBlank(baseUrl)) {
return baseUrl + "/images?url=" + movie.getVod_pic();
}
return ServletUriComponentsBuilder.fromCurrentRequest()
.scheme(appProperties.isEnableHttps() && !Utils.isLocalAddress() ? "https" : "http") // nginx https
.replacePath("/images")
.query("url=" + movie.getVod_pic())
.build()
.toUriString();
}

private String getCover(String thumb, int type) {
String pic = thumb;
if (pic.isEmpty() && type == 1) {
String baseUrl = settingRepository.findById("app_base_url").map(Setting::getValue).orElse("");
if (StringUtils.isNotBlank(baseUrl)) {
return baseUrl + "/folder.png";
}
pic = ServletUriComponentsBuilder.fromCurrentRequest()
.scheme(appProperties.isEnableHttps() && !Utils.isLocalAddress() ? "https" : "http") // nginx https
.replacePath("/folder.png")
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/cn/har01d/alist_tvbox/youtube/YoutubeService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cn.har01d.alist_tvbox.youtube;

import cn.har01d.alist_tvbox.config.AppProperties;
import cn.har01d.alist_tvbox.entity.Setting;
import cn.har01d.alist_tvbox.entity.SettingRepository;
import cn.har01d.alist_tvbox.model.Filter;
import cn.har01d.alist_tvbox.model.FilterValue;
import cn.har01d.alist_tvbox.tvbox.Category;
Expand Down Expand Up @@ -84,9 +86,11 @@ public class YoutubeService {
.build(this::getVideoInfo);

private final AppProperties appProperties;
private final SettingRepository settingRepository;

public YoutubeService(AppProperties appProperties) {
public YoutubeService(AppProperties appProperties, SettingRepository settingRepository) {
this.appProperties = appProperties;
this.settingRepository = settingRepository;
Config config = new Config.Builder().header("User-Agent", Constants.USER_AGENT).build();

try {
Expand Down Expand Up @@ -222,6 +226,10 @@ private MovieDetail buildMovieDetail(PlaylistVideoDetails item) {
}

private String getListPic() {
String baseUrl = settingRepository.findById("app_base_url").map(Setting::getValue).orElse("");
if (StringUtils.isNotBlank(baseUrl)) {
return baseUrl + "/list.png";
}
return ServletUriComponentsBuilder.fromCurrentRequest()
.scheme(appProperties.isEnableHttps() && !Utils.isLocalAddress() ? "https" : "http") // nginx https
.replacePath("/list.png")
Expand Down
89 changes: 53 additions & 36 deletions web-ui/src/views/ConfigView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -179,47 +179,55 @@
<el-form-item>
<el-button type="primary" @click="updateTmdbApiKey">更新</el-button>
</el-form-item>
<el-form-item label="管理应用地址">
<el-input v-model="appBaseUrl" type="url"/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="updateAppBaseUrl">更新</el-button>
</el-form-item>
<el-form-item label="阿里Token地址">
<a :href="currentUrl + '/ali/token/' + aliSecret" target="_blank">
{{ currentUrl + '/ali/token/' + aliSecret }}
</a>
</el-form-item>
<el-form-item label="订阅替换阿里token地址">
<el-switch
v-model="replaceAliToken"
inline-prompt
active-text="开启"
inactive-text="关闭"
@change="updateReplaceAliToken"
/>
</el-form-item>
<el-form-item label="订阅域名支持HTTPS">
<el-switch
v-model="enableHttps"
inline-prompt
active-text="开启"
inactive-text="关闭"
@change="updateEnableHttps"
/>
</el-form-item>
<el-form-item label="开启调试日志">
<el-switch
v-model="debugLog"
inline-prompt
active-text="开启"
inactive-text="关闭"
@change="updateDebugLog"
/>
</el-form-item>
<el-form-item label="开启AList调试模式">
<el-switch
v-model="aListDebug"
inline-prompt
active-text="开启"
inactive-text="关闭"
@change="updateAListDebug"
/>
</el-form-item>
<el-form inline label-width="180px">
<el-form-item label="订阅替换阿里token地址">
<el-switch
v-model="replaceAliToken"
inline-prompt
active-text="开启"
inactive-text="关闭"
@change="updateReplaceAliToken"
/>
</el-form-item>
<el-form-item label="订阅域名支持HTTPS" v-if="!appBaseUrl">
<el-switch
v-model="enableHttps"
inline-prompt
active-text="开启"
inactive-text="关闭"
@change="updateEnableHttps"
/>
</el-form-item>
<el-form-item label="开启调试日志">
<el-switch
v-model="debugLog"
inline-prompt
active-text="开启"
inactive-text="关闭"
@change="updateDebugLog"
/>
</el-form-item>
<el-form-item label="开启AList调试模式">
<el-switch
v-model="aListDebug"
inline-prompt
active-text="开启"
inactive-text="关闭"
@change="updateAListDebug"
/>
</el-form-item>
</el-form>
<!-- <el-form-item label="开启阿里延迟加载">-->
<!-- <el-switch-->
<!-- v-model="aliLazyLoad"-->
Expand Down Expand Up @@ -324,6 +332,7 @@ const openTokenUrl = ref('')
const dockerAddress = ref('')
const aliSecret = ref('')
const tmdbApiKey = ref('')
const appBaseUrl = ref('')
const atvPass = ref('')
const apiClientId = ref('')
const apiClientSecret = ref('')
Expand Down Expand Up @@ -379,6 +388,13 @@ const updateTmdbApiKey = () => {
})
}

const updateAppBaseUrl = () => {
axios.post('/api/settings', {name: 'app_base_url', value: appBaseUrl.value}).then(({data}) => {
ElMessage.success('更新成功')
appBaseUrl.value = data.value
})
}

const updateDeleteDelayTime = () => {
axios.post('/api/settings', {name: 'delete_delay_time', value: deleteDelayTime.value}).then(() => {
ElMessage.success('更新成功')
Expand Down Expand Up @@ -476,6 +492,7 @@ onMounted(() => {
dockerAddress.value = data.docker_address
aliSecret.value = data.ali_secret
tmdbApiKey.value = data.tmdb_api_key
appBaseUrl.value = data.app_base_url
autoCheckin.value = data.auto_checkin === 'true'
aListRestart.value = data.alist_restart_required === 'true'
replaceAliToken.value = data.replace_ali_token === 'true'
Expand Down