示例#1
0
        /// <summary>
        /// tries to get the password from nzb file
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static string GetNzbPassword(string filePath)
        {
            string ret = null;

            try
            {
                using (System.IO.FileStream fsNzb = File.OpenRead(filePath))
                {
                    Task <NzbDocument> tDoc = NzbDocument.Load(fsNzb);
                    tDoc.Wait();
                    NzbDocument nDoc = tDoc.Result;

                    if (nDoc.Metadata.Any(a => a.Key.Equals("password", StringComparison.OrdinalIgnoreCase)))
                    {
                        ret = nDoc.Metadata.First(f => f.Key.Equals("password", StringComparison.OrdinalIgnoreCase)).Value;
                    }
                }
            }
            catch { }

            if (!string.IsNullOrWhiteSpace(ret))
            {
                return(ret);
            }

            return(null);
        }
示例#2
0
        private static NzbDocument GetNzbDocument(byte[] contents)
        {
            NzbDocument retour = null;

            using (var file = new BufferedStream(new MemoryStream(contents)))
            {
                retour = NzbDocument.Load(file).Result;
            }

            return(retour);
        }