Beispiel #1
0
        public void Run(string[] args)
        {
            Sonarr sonarr           = new Sonarr();
            IWebResponseFactory wrf = new WebResponseFactory(sonarr.QueuedItems());
            string                    responseBody     = wrf.GetResponseBody(wrf.ExecuteRequest());
            IJsonManager              jm               = new JsonManager();
            JArray                    jsonArray        = jm.DeserializeArray(responseBody);
            List <string>             downloadFolders  = sonarr.GetDownloadFolders(jsonArray);
            Qbittorrent               qbt              = new Qbittorrent();
            Dictionary <string, bool> downloadFinished = qbt.CheckDownloadStatus(downloadFolders);

            qbt.Logout();
            FileSysOps fso = new FileSysOps();

            fso.ExtractFile(downloadFinished);
            sonarr.PushExtracted(downloadFinished);
        }
Beispiel #2
0
        public Dictionary <string, bool> CheckDownloadStatus(List <string> folders)
        {
            Dictionary <string, bool> downloadFinished = new Dictionary <string, bool>();
            string          urlParams = "/torrents/info";
            string          method    = "POST";
            List <string[]> headers   = new List <string[]>();

            headers.Add(new string[] { "Cookie", cookie });
            string contentType = "application/json";

            webRespFac = new WebResponseFactory(webReqFac.BuildRequest(urlParams, method, contentType, headers, ""));
            string       responseBody = webRespFac.GetResponseBody(webRespFac.ExecuteRequest());
            IJsonManager jManager     = new JsonManager();
            JArray       jsonArray    = jManager.DeserializeArray(responseBody);

            foreach (JObject jsonObject in jsonArray)
            {
                string name = jManager.SelectStringTokensInTopLevelJObject(jsonObject, "name");
                foreach (string s in folders)
                {
                    if (String.Equals(name, s))
                    {
                        int amount_left = jManager.SelectIntTokensInTopLevelJObject(jsonObject, "amount_left");
                        if (amount_left == 0)
                        {
                            downloadFinished.Add(name, true);
                        }
                        else
                        {
                            downloadFinished.Add(name, false);
                        }
                        break;
                    }
                }
            }
            return(downloadFinished);
        }
Beispiel #3
0
        public List <string> GetDownloadFolders(JArray ja)
        {
            IJsonManager jm = new JsonManager();

            return(jm.SelectTokensInTopLevelJArray(ja, "title"));
        }