Ejemplo n.º 1
0
        public void DoNzb(string nzbFullPath)
        {
            var contents    = File.ReadAllBytes(nzbFullPath);
            var nzbDocument = NzbPut.GetNzbDocument(contents);
            var key         = NzbPut.GetKeyName(nzbFullPath, nzbDocument);

            var xDocument = new NzbDocumentWrapper(key, nzbFullPath, contents, nzbDocument);

            this.DoNzb(xDocument);
        }
Ejemplo n.º 2
0
        public void DoZip(string nzbFullPath)
        {
            bool erreur      = false;
            var  erreurFiles = new List <string>();

            using (var zip = ZipFile.OpenRead(nzbFullPath))
            {
                foreach (var fil1 in zip.Entries)
                {
                    var extension = this.GetManagedFile(fil1.FullName);
                    if (extension == ManagedFile.Other)
                    {
                        var fileName = Path.Combine(KnownFolders.GetPath(KnownFolder.Downloads), Path.GetFileName(fil1.FullName));
                        fil1.ExtractToFile(fileName, true);
                        erreurFiles.Add(fileName);
                        erreur = true;
                    }
                    else
                    {
                        var fileName = Path.GetTempFileName();
                        fil1.ExtractToFile(fileName, true);
                        var contents    = File.ReadAllBytes(fileName);
                        var nzbDocument = NzbPut.GetNzbDocument(contents);
                        var key         = NzbPut.GetKeyName(nzbFullPath, nzbDocument);

                        var xDocument = new NzbDocumentWrapper(key, nzbFullPath, contents, nzbDocument);
                        this.DoNzb(xDocument);
                        File.Delete(fileName);
                    }
                }
            }

            if (erreur)
            {
                throw new NzbZipException($"copy bad file ({String.Join(", ", erreurFiles)} in {KnownFolders.GetPath(KnownFolder.Downloads)}");
            }
        }
Ejemplo n.º 3
0
        private void FireNzbEvent(string message)
        {
            var msg = new NzbEventArgs($"{NzbPut.GetValChrono()}ms - {message}");

            this.NzbEventHander?.Invoke(this, msg);
        }