|
@@ -1,6 +1,12 @@
|
|
|
package v1
|
|
package v1
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
|
+ "fmt"
|
|
|
|
|
+ "github.com/Tnze/go.num/v2/zh"
|
|
|
|
|
+ "github.com/allanpk716/ChineseSubFinder/pkg/mix_media_info"
|
|
|
|
|
+ "github.com/allanpk716/ChineseSubFinder/pkg/settings"
|
|
|
|
|
+ "github.com/jinzhu/now"
|
|
|
|
|
+ PTN "github.com/middelink/go-parse-torrent-name"
|
|
|
"net/http"
|
|
"net/http"
|
|
|
"strconv"
|
|
"strconv"
|
|
|
|
|
|
|
@@ -149,3 +155,96 @@ func (cb *ControllerBase) PreviewCleanUp(c *gin.Context) {
|
|
|
c.JSON(http.StatusOK, backend2.ReplyCommon{Message: "true"})
|
|
c.JSON(http.StatusOK, backend2.ReplyCommon{Message: "true"})
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+func (cb *ControllerBase) PreviewSearchOtherWeb(c *gin.Context) {
|
|
|
|
|
+ var err error
|
|
|
|
|
+ defer func() {
|
|
|
|
|
+ // 统一的异常处理
|
|
|
|
|
+ cb.ErrorProcess(c, "PreviewSearchOtherWeb", err)
|
|
|
|
|
+ }()
|
|
|
|
|
+
|
|
|
|
|
+ searchOtherWeb := SearchOtherWebReq{}
|
|
|
|
|
+ err = c.ShouldBindJSON(&searchOtherWeb)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if pkg.IsFile(searchOtherWeb.VideoFPath) == false {
|
|
|
|
|
+ c.JSON(http.StatusOK, backend2.ReplyCommon{Message: "video file not found"})
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ mixMediaInfo, err := mix_media_info.GetMixMediaInfo(cb.cronHelper.FileDownloader.MediaInfoDealers,
|
|
|
|
|
+ searchOtherWeb.VideoFPath, searchOtherWeb.IsMovie)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ // 搜索网站的地址
|
|
|
|
|
+ searchOtherWebReply := SearchOtherWebReply{}
|
|
|
|
|
+ searchOtherWebReply.SearchUrls = make([]string, 0)
|
|
|
|
|
+ searchOtherWebReply.SearchUrls = append(searchOtherWebReply.SearchUrls, settings.Get().AdvancedSettings.SuppliersSettings.Zimuku.GetSearchUrl())
|
|
|
|
|
+ searchOtherWebReply.SearchUrls = append(searchOtherWebReply.SearchUrls, settings.Get().AdvancedSettings.SuppliersSettings.SubHD.GetSearchUrl())
|
|
|
|
|
+ searchOtherWebReply.SearchUrls = append(searchOtherWebReply.SearchUrls, settings.Get().AdvancedSettings.SuppliersSettings.A4k.GetSearchUrl())
|
|
|
|
|
+
|
|
|
|
|
+ year, err := now.Parse(mixMediaInfo.Year)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ strYear := fmt.Sprintf("%d", year.Year())
|
|
|
|
|
+ // 返回多种关键词
|
|
|
|
|
+ searchOtherWebReply.KeyWords = make([]string, 0)
|
|
|
|
|
+ // imdb id
|
|
|
|
|
+ searchOtherWebReply.KeyWords = append(searchOtherWebReply.KeyWords, mixMediaInfo.ImdbId)
|
|
|
|
|
+
|
|
|
|
|
+ if searchOtherWeb.IsMovie == true {
|
|
|
|
|
+ // 电影
|
|
|
|
|
+ searchOtherWebReply.KeyWords = append(searchOtherWebReply.KeyWords, mixMediaInfo.TitleCn)
|
|
|
|
|
+ searchOtherWebReply.KeyWords = append(searchOtherWebReply.KeyWords, mixMediaInfo.TitleCn+" "+strYear)
|
|
|
|
|
+ if mixMediaInfo.TitleCn != mixMediaInfo.TitleEn {
|
|
|
|
|
+ searchOtherWebReply.KeyWords = append(searchOtherWebReply.KeyWords, mixMediaInfo.TitleEn)
|
|
|
|
|
+ searchOtherWebReply.KeyWords = append(searchOtherWebReply.KeyWords, mixMediaInfo.TitleEn+" "+strYear)
|
|
|
|
|
+ }
|
|
|
|
|
+ if mixMediaInfo.TitleCn != mixMediaInfo.OriginalTitle && mixMediaInfo.OriginalTitle != mixMediaInfo.TitleEn {
|
|
|
|
|
+ searchOtherWebReply.KeyWords = append(searchOtherWebReply.KeyWords, mixMediaInfo.OriginalTitle)
|
|
|
|
|
+ searchOtherWebReply.KeyWords = append(searchOtherWebReply.KeyWords, mixMediaInfo.OriginalTitle+" "+strYear)
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 电视剧
|
|
|
|
|
+ var ptn *PTN.TorrentInfo
|
|
|
|
|
+ ptn, err = decode.GetVideoInfoFromFileName(searchOtherWeb.VideoFPath)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ seasonKeyWord0 := " 第" + zh.Uint64(ptn.Season).String() + "季"
|
|
|
|
|
+ seasonKeyWord1 := fmt.Sprintf(" S%02d", ptn.Season)
|
|
|
|
|
+ seasonKeyWord2 := " " + pkg.GetEpisodeKeyName(ptn.Season, ptn.Episode, true)
|
|
|
|
|
+ searchOtherWebReply.KeyWords = append(searchOtherWebReply.KeyWords, mixMediaInfo.TitleCn)
|
|
|
|
|
+ searchOtherWebReply.KeyWords = append(searchOtherWebReply.KeyWords, mixMediaInfo.TitleCn+seasonKeyWord0)
|
|
|
|
|
+ searchOtherWebReply.KeyWords = append(searchOtherWebReply.KeyWords, mixMediaInfo.TitleCn+seasonKeyWord1)
|
|
|
|
|
+ searchOtherWebReply.KeyWords = append(searchOtherWebReply.KeyWords, mixMediaInfo.TitleCn+seasonKeyWord2)
|
|
|
|
|
+ if mixMediaInfo.TitleCn != mixMediaInfo.TitleEn {
|
|
|
|
|
+ searchOtherWebReply.KeyWords = append(searchOtherWebReply.KeyWords, mixMediaInfo.TitleEn)
|
|
|
|
|
+ searchOtherWebReply.KeyWords = append(searchOtherWebReply.KeyWords, mixMediaInfo.TitleEn+seasonKeyWord0)
|
|
|
|
|
+ searchOtherWebReply.KeyWords = append(searchOtherWebReply.KeyWords, mixMediaInfo.TitleEn+seasonKeyWord1)
|
|
|
|
|
+ searchOtherWebReply.KeyWords = append(searchOtherWebReply.KeyWords, mixMediaInfo.TitleEn+seasonKeyWord2)
|
|
|
|
|
+ }
|
|
|
|
|
+ if mixMediaInfo.TitleCn != mixMediaInfo.OriginalTitle && mixMediaInfo.OriginalTitle != mixMediaInfo.TitleEn {
|
|
|
|
|
+ searchOtherWebReply.KeyWords = append(searchOtherWebReply.KeyWords, mixMediaInfo.OriginalTitle)
|
|
|
|
|
+ searchOtherWebReply.KeyWords = append(searchOtherWebReply.KeyWords, mixMediaInfo.OriginalTitle+seasonKeyWord0)
|
|
|
|
|
+ searchOtherWebReply.KeyWords = append(searchOtherWebReply.KeyWords, mixMediaInfo.OriginalTitle+seasonKeyWord1)
|
|
|
|
|
+ searchOtherWebReply.KeyWords = append(searchOtherWebReply.KeyWords, mixMediaInfo.OriginalTitle+seasonKeyWord2)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ c.JSON(http.StatusOK, searchOtherWebReply)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+type SearchOtherWebReq struct {
|
|
|
|
|
+ VideoFPath string `json:"video_f_path"`
|
|
|
|
|
+ IsMovie bool `json:"is_movie"`
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+type SearchOtherWebReply struct {
|
|
|
|
|
+ KeyWords []string `json:"key_words"`
|
|
|
|
|
+ SearchUrls []string `json:"search_url"`
|
|
|
|
|
+}
|