From 27cd0cee6dcc36e0b6c44207a0168768648c223c Mon Sep 17 00:00:00 2001 From: Harold Date: Mon, 22 Apr 2024 13:19:14 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alist_tvbox/service/BiliBiliService.java | 8 +++++ .../alist_tvbox/service/DoubanService.java | 20 +++++++---- .../alist_tvbox/service/SettingService.java | 16 +++++++++ .../service/SubscriptionService.java | 5 +++ .../alist_tvbox/service/TvBoxService.java | 33 +++++++++++++++---- .../alist_tvbox/youtube/YoutubeService.java | 10 +++++- web-ui/src/views/ConfigView.vue | 14 ++++++++ 7 files changed, 93 insertions(+), 13 deletions(-) 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..70e6b66653 100644 --- a/src/main/java/cn/har01d/alist_tvbox/service/BiliBiliService.java +++ b/src/main/java/cn/har01d/alist_tvbox/service/BiliBiliService.java @@ -2087,6 +2087,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 +2100,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 +330,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 +386,12 @@ const updateTmdbApiKey = () => { }) } +const updateAppBaseUrl = () => { + axios.post('/api/settings', {name: 'app_base_url', value: appBaseUrl.value}).then(() => { + ElMessage.success('更新成功') + }) +} + const updateDeleteDelayTime = () => { axios.post('/api/settings', {name: 'delete_delay_time', value: deleteDelayTime.value}).then(() => { ElMessage.success('更新成功') @@ -476,6 +489,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' From a7645647f06b9f8f23aef2191637929cfb53638d Mon Sep 17 00:00:00 2001 From: Harold Date: Mon, 22 Apr 2024 13:36:39 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web-ui/src/views/ConfigView.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web-ui/src/views/ConfigView.vue b/web-ui/src/views/ConfigView.vue index 7fdf52733a..dd054ef2e7 100644 --- a/web-ui/src/views/ConfigView.vue +++ b/web-ui/src/views/ConfigView.vue @@ -199,7 +199,7 @@ @change="updateReplaceAliToken" /> - + { } const updateAppBaseUrl = () => { - axios.post('/api/settings', {name: 'app_base_url', value: appBaseUrl.value}).then(() => { + axios.post('/api/settings', {name: 'app_base_url', value: appBaseUrl.value}).then(({data}) => { ElMessage.success('更新成功') + appBaseUrl.value = data.value }) } From e195e59d1221bbef5d502b65e635613f59131f23 Mon Sep 17 00:00:00 2001 From: Harold Date: Mon, 22 Apr 2024 13:43:05 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web-ui/src/views/ConfigView.vue | 74 +++++++++++++++++---------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/web-ui/src/views/ConfigView.vue b/web-ui/src/views/ConfigView.vue index dd054ef2e7..4d1a84511f 100644 --- a/web-ui/src/views/ConfigView.vue +++ b/web-ui/src/views/ConfigView.vue @@ -190,42 +190,44 @@ {{ currentUrl + '/ali/token/' + aliSecret }} - - - - - - - - - - - - + + + + + + + + + + + + + + From 7745654efa29d2e01a0f85788f2ccb754a2e743e Mon Sep 17 00:00:00 2001 From: Harold Date: Mon, 22 Apr 2024 13:53:15 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/README_zh.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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`开关。 ### 索引 对于阿里云盘资源,建议使用文件数量少的路径,并限速,防止被封号。 From 3ed90c595f86f1849afe204595eb22692fe18989 Mon Sep 17 00:00:00 2001 From: Harold Date: Mon, 22 Apr 2024 17:44:06 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alist_tvbox/service/BiliBiliService.java | 16 ---------------- 1 file changed, 16 deletions(-) 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 70e6b66653..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 ""; }