package com.yutou.nas.utils;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.nas.Controllers.UpdateIp;

public class AnimRssManager {
    public static void scan() {
        String tmp=HttpTools.https_get("https://tools.yutou233.cn/anim/rss/list.do?type=-1&token=zIrsh9TUZP2lfRW753PannG49E7VJvor",null);
        if(tmp==null){
            return;
        }
        JSONObject json= JSON.parseObject(tmp);
        if(json.getInteger("code")==0){
            JSONArray data=json.getJSONArray("data");
            for (Object datum : data) {
                String url= ((JSONObject) datum).getString("title");
                String title= ((JSONObject) datum).getString("titlekey");
                download(title,url);
            }
        }
    }

    private static void download(String title,String url) {
        JSONObject rss=RssXMLtoJson.toJSON(url);
        if (rss != null && "ok".equals(rss.getString("status"))) {
            BTDownloadManager.download(title, rss);
        }
    }

    public static void main(String[] args) {
        scan();
    }
}
