package com.yutou.nas.Controllers;

import com.yutou.nas.utils.AppTools;
import com.yutou.nas.utils.JellyfinAPIManager;
import com.yutou.nas.utils.QQBotManager;
import com.yutou.nas.utils.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class JellyfinController {
    @RequestMapping("/jellyfin/addItem")
    @ResponseBody
    public String addItem(String Name, String Date) {
        if (!StringUtils.isEmpty(Name) && !StringUtils.isEmpty(Date)) {
            QQBotManager.getInstance().sendMessage(734332887L, " 新增:" + Name);
            AppTools.exec("/home/yutou/public/servier/tinyMediaManager/tinyMediaManager tvshow -u --scrapeUnscraped", null, false, true);
            new JellyfinAPIManager().refresh();
        }
        return "ok";
    }

    @ResponseBody
    @RequestMapping("/jellyfin/updateMeta")
    public String updateMeta() {
        AppTools.exec("/home/yutou/public/servier/tinyMediaManager/tinyMediaManager tvshow -u --scrapeUnscraped", null, false, true);
        new JellyfinAPIManager().refresh();
        return "ok";
    }
}
