diff --git a/doc/README_zh.md b/doc/README_zh.md index 5fedbf7163..6a2737e6bd 100644 --- a/doc/README_zh.md +++ b/doc/README_zh.md @@ -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`开关。 ### 索引 对于阿里云盘资源,建议使用文件数量少的路径,并限速,防止被封号。 diff --git a/src/main/java/cn/har01d/alist_tvbox/service/BiliBiliService.java b/src/main/java/cn/har01d/alist_tvbox/service/BiliBiliService.java index dbd280624f..6f971125b1 100644 --- a/src/main/java/cn/har01d/alist_tvbox/service/BiliBiliService.java +++ b/src/main/java/cn/har01d/alist_tvbox/service/BiliBiliService.java @@ -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 ""; } @@ -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") @@ -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") diff --git a/src/main/java/cn/har01d/alist_tvbox/service/DoubanService.java b/src/main/java/cn/har01d/alist_tvbox/service/DoubanService.java index bc90cdf33e..f0709f58ec 100644 --- a/src/main/java/cn/har01d/alist_tvbox/service/DoubanService.java +++ b/src/main/java/cn/har01d/alist_tvbox/service/DoubanService.java @@ -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); } @@ -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); diff --git a/src/main/java/cn/har01d/alist_tvbox/service/SettingService.java b/src/main/java/cn/har01d/alist_tvbox/service/SettingService.java index 88fc5ba6c5..7e0d1960e8 100644 --- a/src/main/java/cn/har01d/alist_tvbox/service/SettingService.java +++ b/src/main/java/cn/har01d/alist_tvbox/service/SettingService.java @@ -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; @@ -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; @@ -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); } diff --git a/src/main/java/cn/har01d/alist_tvbox/service/SubscriptionService.java b/src/main/java/cn/har01d/alist_tvbox/service/SubscriptionService.java index 9f3564e7af..a0ce4f7a8f 100644 --- a/src/main/java/cn/har01d/alist_tvbox/service/SubscriptionService.java +++ b/src/main/java/cn/har01d/alist_tvbox/service/SubscriptionService.java @@ -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) @@ -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; } diff --git a/src/main/java/cn/har01d/alist_tvbox/service/TvBoxService.java b/src/main/java/cn/har01d/alist_tvbox/service/TvBoxService.java index 681e698f52..a36d68e108 100644 --- a/src/main/java/cn/har01d/alist_tvbox/service/TvBoxService.java +++ b/src/main/java/cn/har01d/alist_tvbox/service/TvBoxService.java @@ -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; @@ -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; @@ -140,6 +143,7 @@ public TvBoxService(AccountRepository accountRepository, AListAliasRepository aliasRepository, ShareRepository shareRepository, MetaRepository metaRepository, + SettingRepository settingRepository, AListService aListService, IndexService indexService, SiteService siteService, @@ -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; @@ -1071,6 +1076,10 @@ private List generatePlaylist(String path, int total, List 更新 + + + + + 更新 + {{ currentUrl + '/ali/token/' + aliSecret }} - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -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('') @@ -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('更新成功') @@ -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'