package com.yutou.nas.Controllers;

import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.Services.IBangumiService;
import com.yutou.nas.utils.AnimRssManager;
import com.yutou.nas.utils.BTDownloadManager;
import com.yutou.nas.utils.DmhyRssDownloadManager;
import com.yutou.nas.utils.Log;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class BTDownloadController {
    @Resource
    IBangumiService bangumiService;

    @ResponseBody
    @RequestMapping("/bt/down.do")
    public String bt(){
        DmhyRssDownloadManager.getInstance().start();
        AnimRssManager.scan();
        return "ok";
    }
    @ResponseBody
    @RequestMapping("/bt/done.do")
    public String done(String path,String filename,String hash1,String hash2,String tid){
        Log.i("BTDownloadController.done","path = " + path + ", filename = " + filename + ", hash1 = " + hash1 + ", hash2 = " + hash2 + ", tid = " + tid);
        BTDownloadManager.done(path, filename, hash1, hash2, tid);
        return "ok";
    }
    @ResponseBody
    @RequestMapping("/bt/download.do")
    public String download(int id,boolean isDownloadNext,String url){
        Log.i("跳过下载","手动下载 id = " + id + ", isDownloadNext = " + isDownloadNext + ", url = " + url);
        bangumiService.download(id,isDownloadNext,url);
        return "1";
    }
}
