コード例 #1
0
        public void FileNameShouldParse(string fileName, int year, int month, int day, string title)
        {
            var expected = new FileNameParser.Metadata(fileName, new DateTime(year, month, day), title);

            FileNameParser.Metadata actual = FileNameParser.Parse(fileName);
            Assert.Equal(expected, actual);
        }
コード例 #2
0
        public void ShouldReadDateFromFileName(string fileName, int y, int m, int d)
        {
            var parser = new FileNameParser();

            var date = parser.Parse(fileName);

            date.Year.Should().Be(y);
            date.Month.Should().Be(m);
            date.Day.Should().Be(d);
        }
コード例 #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="series"></param>
        /// <param name="episode"></param>
        /// <param name="quality"></param>
        /// <returns></returns>
        public override SearchResult FindTorrent(Series series, 
                                                 Episode episode, 
                                                 Global.EpisodeQuality quality)
        {
            string tempQuality = string.Empty;
            switch (quality)
            {
                case Global.EpisodeQuality.FullBluRay:
                    tempQuality = "1024";
                    break;
                case Global.EpisodeQuality.HdTv:
                    tempQuality = "HD";
                    break;
                case Global.EpisodeQuality.HdBluRay:
                case Global.EpisodeQuality.HdWebDl:
                case Global.EpisodeQuality.SdDvd:
                case Global.EpisodeQuality.SdTv:
                    tempQuality = "720";
                    break;
            }

            DailyTvTorrents api = new DailyTvTorrents();
            Torrent torrent = api.TorrentGetInfo(series.Name.Replace(" ", "-").ToLower(),
                                                 string.Format("S{0}E{1}", ((int)episode.SeasonNumber).ToString("D2"), ((int)episode.EpisodeNumber).ToString("D2")),
                                                 tempQuality);
            if (torrent.torrentFile == null)
            {
                return null;
            }

            FileNameParser fileNameParser = new FileNameParser();
            fileNameParser.Parse(torrent.torrentFile);
            if (fileNameParser.Matched() == false)
            {
                return null;
            }

            SearchResult searchResult = new SearchResult();
            searchResult.Url = torrent.torrentFile;

            return searchResult;
        }
コード例 #4
0
        // Token: 0x06000020 RID: 32 RVA: 0x00002E1C File Offset: 0x0000101C
        public static string Parse(string ruleString, AssemblyInstance assemblyInstance, CNCProjectData projectData, bool allowsSpaces = true)
        {
            bool   flag = projectData.isNull();
            string result;

            if (flag)
            {
                result = string.Empty;
            }
            else
            {
                string text;
                if (assemblyInstance == null)
                {
                    text = null;
                }
                else
                {
                    Document document = assemblyInstance.Document;
                    text = ((document != null) ? document.PathName : null);
                }
                string   path  = text;
                string   text2 = projectData.DrawingData.Date;
                DateTime dateTime;
                bool     flag2 = DateTime.TryParseExact(text2, "dd.MM.yyyy", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out dateTime);
                if (flag2)
                {
                    text2 = dateTime.ToString("yyyyMMdd");
                }
                Dictionary <string, string> valuesDict = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase)
                {
                    {
                        CNCFilenameTokens.FileName.ToString(),
                                            Path.GetFileNameWithoutExtension(path)
                    },
                    {
                        CNCFilenameTokens.Date.ToString(),
                                            DateTime.Now.ToString("yyyyMMdd")
                    },
                    {
                        CNCFilenameTokens.Time.ToString(),
                                            DateTime.Now.ToString("hhmmss")
                    },
                    {
                        CNCFilenameTokens.ProdNo.ToString(),
                                            assemblyInstance.prodNo().ToString()
                    },
                    {
                        CNCFilenameTokens.OrderNumber.ToString(),
                                            projectData.General.OrderNumber
                    },
                    {
                        CNCFilenameTokens.Component.ToString(),
                                            projectData.General.Component
                    },
                    {
                        CNCFilenameTokens.Storey.ToString(),
                                            projectData.General.Storey
                    },
                    {
                        CNCFilenameTokens.DrawingNumber.ToString(),
                                            projectData.General.DrawingNumber
                    },
                    {
                        CNCFilenameTokens.ProjectDescriptionLine1.ToString(),
                                            projectData.ProjectDescription.Line1
                    },
                    {
                        CNCFilenameTokens.ProjectDescriptionLine2.ToString(),
                                            projectData.ProjectDescription.Line2
                    },
                    {
                        CNCFilenameTokens.ProjectDescriptionLine3.ToString(),
                                            projectData.ProjectDescription.Line3
                    },
                    {
                        CNCFilenameTokens.ProjectDescriptionLine4.ToString(),
                                            projectData.ProjectDescription.Line4
                    },
                    {
                        CNCFilenameTokens.BuildingSiteName.ToString(),
                                            projectData.BuildingSite.Name
                    },
                    {
                        CNCFilenameTokens.BuildingSiteStreet.ToString(),
                                            projectData.BuildingSite.Street
                    },
                    {
                        CNCFilenameTokens.BuildingSitePostCode.ToString(),
                                            projectData.BuildingSite.ZipCode
                    },
                    {
                        CNCFilenameTokens.BuildingSitePlace.ToString(),
                                            projectData.BuildingSite.Place
                    },
                    {
                        CNCFilenameTokens.BuildingOwnerName.ToString(),
                                            projectData.BuildingOwner.Name
                    },
                    {
                        CNCFilenameTokens.BuildingOwnerStreet.ToString(),
                                            projectData.BuildingOwner.Street
                    },
                    {
                        CNCFilenameTokens.BuildingOwnerPostCode.ToString(),
                                            projectData.BuildingOwner.ZipCode
                    },
                    {
                        CNCFilenameTokens.BuildingOwnerPlace.ToString(),
                                            projectData.BuildingOwner.Place
                    },
                    {
                        CNCFilenameTokens.DrawingDate.ToString(),
                                            text2
                    },
                    {
                        CNCFilenameTokens.DrawingRevision.ToString(),
                                            projectData.DrawingData.Revision
                    },
                    {
                        CNCFilenameTokens.DrawingAuthor.ToString(),
                                            projectData.DrawingData.Author
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo01.ToString(),
                                            projectData.ProjectDescription.Line1
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo02.ToString(),
                                            projectData.ProjectDescription.Line2
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo03.ToString(),
                                            projectData.ProjectDescription.Line3
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo04.ToString(),
                                            projectData.ProjectDescription.Line4
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo05.ToString(),
                                            projectData.BuildingSite.Name
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo06.ToString(),
                                            projectData.BuildingSite.Street
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo07.ToString(),
                                            projectData.BuildingSite.ZipCode
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo08.ToString(),
                                            projectData.BuildingSite.Place
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo09.ToString(),
                                            projectData.BuildingOwner.Name
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo10.ToString(),
                                            projectData.BuildingOwner.Street
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo11.ToString(),
                                            projectData.BuildingOwner.ZipCode
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo12.ToString(),
                                            projectData.BuildingOwner.Place
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo13.ToString(),
                                            projectData.GenericOrderInfo.Line13
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo14.ToString(),
                                            projectData.GenericOrderInfo.Line14
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo15.ToString(),
                                            projectData.GenericOrderInfo.Line15
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo16.ToString(),
                                            projectData.GenericOrderInfo.Line16
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo17.ToString(),
                                            projectData.GenericOrderInfo.Line17
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo18.ToString(),
                                            projectData.GenericOrderInfo.Line18
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo19.ToString(),
                                            projectData.GenericOrderInfo.Line19
                    },
                    {
                        CNCFilenameTokens.GenericOrderInfo20.ToString(),
                                            projectData.GenericOrderInfo.Line20
                    }
                };
                string text3 = FileNameParser.Parse(ruleString, valuesDict, true);
                result = text3;
            }
            return(result);
        }
コード例 #5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="series"></param>
        /// <param name="minAge"></param>
        /// <returns></returns>
        public override List<RssResult> UpdateRss(List<Series> series, int minAge)
        {
            FileNameParser fileNameParser = new FileNameParser();
            List<RssResult> rssResults = new List<RssResult>();

            foreach (Series serie in series)
            {
                WebClient wc = new WebClient();
                byte[] temp = wc.DownloadData(string.Format("http://www.dailytvtorrents.org/rss/show/{0}?items=all&minage={1}",
                                              serie.Name.Replace(" ", "-").ToLower(),
                                              minAge));
                string rss = Encoding.ASCII.GetString(temp);

                XDocument xDoc = XDocument.Parse(rss);

                foreach (var item in xDoc.Descendants("item"))
                {
                    RssResult rssResult = new RssResult();
                    rssResult.SeriesId = serie.Id;
                    rssResult.Title = Misc.GetElementValueAsString(item, "title");

                    var enclosure = from e in item.Elements("enclosure") select e;
                    if (enclosure.Any() == false)
                    {
                        continue;
                    }

                    rssResult.Url = Misc.GetAttributeValueAsString(enclosure.First(), "url");

                    fileNameParser.Parse(rssResult.Title);
                    if (fileNameParser.Matched() == true)
                    {
                        rssResult.SeasonNumber = fileNameParser.SeasonNumber;
                        rssResult.EpisodeNumber = fileNameParser.EpisodeNumber;
                        rssResult.Quality = fileNameParser.Quality;

                        rssResults.Add(rssResult);
                    }
                }
            }

            return rssResults;
        }