private void AddSeason(SeasonData season, ref int episodes)
        {
            var firstEpisode = Math.Max(1, episodes - 1);
            var seasonNumber = _seasonSeries.Count / 2 + 1;

            double ratingAverage = 0;
            var    ratedEpisodes = 0;

            foreach (var episode in season.Episodes)
            {
                if (double.IsNaN(episode.Rating))
                {
                    break;
                }

                _episodeSeries.Add(episodes, episode.Rating, GetEpisodeLabel(episode, seasonNumber));
                ratingAverage += episode.Rating;

                episodes++;
                ratedEpisodes++;
            }
            ratingAverage /= ratedEpisodes;

            _seasonSeries.Add(firstEpisode, ratingAverage);
            _seasonSeries.Add(episodes - 1, ratingAverage);

            episodes += season.Episodes.Count - ratedEpisodes;

            var label = Chart.Axes.Top.Labels.Items.Add(episodes - 1, $"Season {seasonNumber}");

            label.Font.Color = Color.FromRgb(0xFF, 0xFF, 0xFF);
            //TODO: Center season labeling

            SeasonSelector.Items.Add($"Season {seasonNumber}");
        }
    // Create New
    public PlayerProgress(string username)
    {
        // cache
        string[] directory       = new string[] { username, directoryName };
        int      maxSeasonLength = 4;

        seasons = new SeasonData[maxSeasonLength];

        for (int i = 0; i < maxSeasonLength; i++)
        {
            var type = (Season)i;

            seasons[i] = new SeasonData(type);
            seasons[i].Save(username);
        }

        // For Wrapper Data
        lastLevelLoaded  = new LevelIdentification((Season)0, (Difficulty)0);
        maxLevelAchieved = new LevelIdentification((Season)0, (Difficulty)0);

        var newDataWrapper = new PlayerProgressWrapper(this);

        SaveManager.Save(directory, dataFileName, newDataWrapper);

        // QUESTION:
        // What is PlayerProgressWrapper use for?
        // It is a PlayerProgress data without "SeasonData" in it, the purpose is to shorten the save and organize it in different files.
    }
Exemple #3
0
        private List <int> GetSeason()
        {
            var ReturnList = new List <int>();

            if (SeasonData.GetSplit(DateTime.Now.Month - 1).SplitCount(",") == 1)
            {
                try
                {
                    ReturnList.Add(SeasonData.GetSplit(DateTime.Now.Month - 1).ToInt());
                }
                catch (Exception)
                {
                    ReturnList.Add(-2);
                }
            }
            else
            {
                try
                {
                    foreach (string Season in SeasonData.GetSplit(DateTime.Now.Month - 1).Split(",".ToCharArray()))
                    {
                        ReturnList.Add(Season.ToInt());
                    }
                }
                catch (Exception)
                {
                    ReturnList.Add(-2);
                }
            }
            return(ReturnList);
        }
Exemple #4
0
        public static void GetOneShlSeason(int seasonNumber, string url, string leagueAcronym)
        {
            SeasonData season;

            bool isPlayoffs = url.Contains("-PLF-");

            var extractedSeason = SeasonStatsExtractor.ExtractSeason(url, seasonNumber, isPlayoffs, leagueAcronym);

            if (extractedSeason != null && extractedSeason.Teams.Count > 0)
            {
                season = new SeasonData(extractedSeason);
                Console.Write(" [DONE]");
                Console.WriteLine();
                Console.WriteLine("----");
                Console.WriteLine("Uploading Data to DB");
                Console.Write(" - Season " + season.SourceSeason.Number);
                season.SaveDataToDB();
                Console.Write(" [DONE]");
                Console.WriteLine();
            }
            else
            {
                Console.Write(" [Not Found]");
            }
            Console.WriteLine("----");
            Console.WriteLine("Extraction Complete");
            Console.WriteLine();
            Console.ReadKey();
        }
Exemple #5
0
 public List <Season> GetSeasons()
 {
     using (var data = new SeasonData())
     {
         return(data.GetSeasons());
     }
 }
Exemple #6
0
 public Season(SeasonData data)
 {
     Id       = data.Id;
     LeagueId = data.LeagueId;
     TeamId   = data.TeamId;
     Name     = data.Name;
     Order    = data.Order;
 }
Exemple #7
0
 public void TimeSet(TimeForSave t)
 {
     year      = t.year;
     day       = t.day;
     hour      = t.hour;
     minit     = t.minit;
     preHour   = t.preHour;
     preMinit  = t.preMinit;
     nowSeason = t.nowSeason;
 }
Exemple #8
0
 public TimeData()
 {
     year      = 1;
     day       = 1;
     hour      = 7;
     minit     = 0;
     preHour   = hour;
     preMinit  = minit;
     nowSeason = SeasonData.Spring;
 }
Exemple #9
0
 public TimeForSave(TimeData t)
 {
     year      = t.year;
     day       = t.day;
     hour      = t.hour;
     minit     = t.minit;
     preHour   = t.preHour;
     preMinit  = t.preMinit;
     nowSeason = t.nowSeason;
 }
    //TEMPORADA
    public static void SaveSeason(Manager m)
    {
        BinaryFormatter bf     = new BinaryFormatter();
        FileStream      stream = new FileStream(Application.persistentDataPath
                                                + "/season.sav", FileMode.Create);

        SeasonData data = new SeasonData(m);

        bf.Serialize(stream, data);
        stream.Close();
    }
Exemple #11
0
        private List <ISeasonData> ConvertApiToSeasonData(SeasonApiDTO[] dtos)
        {
            var ls = new List <ISeasonData>();

            for (var i = 0; i < dtos.Length; i++)
            {
                var season = new SeasonData
                {
                    Id                  = Guid.NewGuid(),
                    MovieDbId           = dtos[i].Id,
                    MetadataDescription = dtos[i].Overview,
                    EpisodeCount        = dtos[i].Episodes.Length
                }; // TODO: need a GetEpisode endpoint on the api client
            }

            return(ls);
        }
Exemple #12
0
        private async Task LoadSeasonCatalogueAsync()
        {
            try
            {
                IsSeasonCatalogue = true;
                //remove EndDate, essa informação não existe nos animes da temporada
                FilterData.Orders.RemoveAt(FilterData.Orders.Count - 1);

                await App.DelayRequest();

                var results = await App.Jikan.GetSeason();

                results.RequestCached = true;

                var favoritedEntries = await results.SeasonEntries.ConvertCatalogueAnimesToFavoritedAsync(_settingsPreferences.ShowNSFW);

                _originalCollection = favoritedEntries.OrderByDescending(p => p.Anime.Score).ToList();
                Animes.AddRange(_originalCollection);

                await App.DelayRequest();

                var seasonArchive = await App.Jikan.GetSeasonArchive();

                int minYear = seasonArchive.Archives.Min(p => p.Year);
                int maxYear = seasonArchive.Archives.Max(p => p.Year);

                Lazy <ResourceManager> ResMgr = new Lazy <ResourceManager>(
                    () => new ResourceManager(typeof(Lang.Lang)));

                string selectedSeason = ResMgr.Value.GetString(results.SeasonName);

                Seasons name = (JikanDotNet.Seasons)Enum.Parse(typeof(JikanDotNet.Seasons), results.SeasonName);
                SeasonData = new SeasonData(results.SeasonYear, selectedSeason, minYear, maxYear);
            }
            catch (JikanRequestException ex)
            {
                ex.SaveExceptionData();
            }
            catch (OperationCanceledException ex)
            {
            }
            catch (Exception ex)
            {
                ex.SaveExceptionData();
            }
        }
Exemple #13
0
        private static void UploadSeason(SeasonPack season)
        {
            string urlTemplate = "http://simulationhockey.com/games/{leagueLow}/S{seasonNumber}/{seasonType}/{leagueUp}-{playoffAcro}ProTeamScoring.html";

            Console.WriteLine("");
            Console.WriteLine(season.leagueAcro + ": " + season.number + ": " + (season.isPlayoffs ? "PLF" : "") + ": " + (season.isLegacy ? "LEG" : ""));
            SeasonData seasonData = new SeasonData(season.number, season.leagueAcro, season.isPlayoffs);

            try
            {
                if (season.isLegacy)
                {
                    Console.Write("Loading - ");
                    var loader   = new LegacyFileLoader(seasonData);
                    var document = loader.LoadFile();

                    Console.Write("Extracting - ");
                    var extractor = new LegacyExtractor(seasonData);
                    seasonData = extractor.Extract(document);
                }
                else
                {
                    Console.Write("Downloading - ");
                    var loader = new FileLoader(seasonData);

                    var document = loader.LoadFile();
                    if (document == null)
                    {
                        document = loader.DownloadFile(urlTemplate, false);
                    }

                    Console.Write("Extracting - ");
                    var extractor = new Extractor(seasonData);
                    seasonData = extractor.Extract(document);
                }

                Console.Write("Uploading - ");
                var uploader = new SeasonUploader(seasonData);
                uploader.Upload();
            }
            catch (Exception e)
            {
                Console.Write("Error: " + e.Message);
            }
        }
    void Start()
    {
        for(int idx = 0; idx < Timer.Instance._seasonData.Length; ++idx)
        {
            if(_targetSeason == Timer.Instance._seasonData[idx]._seasonType)
            {
                _seasonData = Timer.Instance._seasonData[idx];
                break;
            }
        }

        if(_particle != null)
        {
            _emissionRate = _particle.emissionRate;
        }

        StartCoroutine("CoUpdate");
    }
    public static int[,] LoadSeason()
    {
        if (File.Exists(Application.persistentDataPath + "/season.sav"))
        {
            BinaryFormatter bf     = new BinaryFormatter();
            FileStream      stream = new FileStream(Application.persistentDataPath
                                                    + "/season.sav", FileMode.Open);
            SeasonData data = bf.Deserialize(stream) as SeasonData;

            stream.Close();
            return(data.balance);
        }
        else
        {
            Debug.LogError("NOP");
            return(null);
        }
    }
Exemple #16
0
    //public Plant(Item i)
    //{
    //    Regex reg = new Regex("の種");
    //    name = reg.Replace(i.itemName, "");
    //    icon = i.icon;
    //    nowGrowth = 0;
    //    growthSpeed = i.growthSpeed;
    //    soilState = Soil.Dry;
    //    quality = i.quality;
    //    upQuality = i.upQuality;
    //    downQuality = i.downQuality;
    //    plantState = PlantState.Growth;
    //    info = i.info;
    //    defValue = i.sellPrice;
    //    getValue = i.getValue;
    //    plantType = i.plantType;
    //    soilWaterValue = 0;
    //    jastSeason = i.vestSeason;
    //    fertilizers = new List<FertilizerData>();
    //}
    public void PlantDataSet(Item i)
    {
        Regex reg = new Regex("の種");

        name        = reg.Replace(i.itemName, "");
        icon        = i.icon;
        nowGrowth   = 0;
        growthSpeed = i.growthSpeed;
        quality     = 50;
        upQuality   = i.upQuality;
        downQuality = i.downQuality;
        plantState  = PlantState.Growth;
        info        = i.info;
        defValue    = i.sellPrice;
        getValue    = i.getValue;
        plantType   = i.plantType;
        //soilWaterValue = 0;
        jastSeason = i.vestSeason;
    }
Exemple #17
0
        /// <summary>
        /// Retrieve information about shows in a specific season
        /// </summary>
        /// <param name="year">Year for which season data should be retrieved</param>
        /// <param name="season">Season for which data should be retrieved</param>
        /// <returns>Collection of show for the selected season</returns>
        public async Task <RetrievalWrapper <SeasonShowCollection> > GetSeasonData(int year, Seasons season)
        {
            var collectionWrapper = new SeasonShowCollection();

            try
            {
                var doc = await _pageRetriever.RetrieveHtmlPageAsync(MalRouteBuilder.SeasonUrl(year, season));

                if (doc.ResponseStatusCode == null)
                {
                    throw doc.Exception;
                }

                var links = doc.Document.DocumentNode
                            .SelectNodes("//a[@class='link-title']");

                foreach (var link in links)
                {
                    var url      = link.Attributes["href"].Value;
                    var idString = url.Split('/')[4];
                    int id;
                    int.TryParse(idString, out id);

                    var title = link.InnerHtml;

                    var tmpData = new SeasonData
                    {
                        Id    = id,
                        Title = title
                    };
                    collectionWrapper.SeasonShows.Add(tmpData);
                }
                return(new RetrievalWrapper <SeasonShowCollection>(doc.ResponseStatusCode.Value, doc.Success,
                                                                   collectionWrapper));
            }
            catch (Exception exception)
            {
                return(new RetrievalWrapper <SeasonShowCollection>(exception, collectionWrapper));
            }
        }
Exemple #18
0
 public PlantDataForSave(Plant p)
 {
     name           = p.name;
     icon           = p.icon;
     nowGrowth      = p.nowGrowth;
     growthSpeed    = p.growthSpeed;
     soilState      = p.soilState;
     quality        = p.quality;
     upQuality      = p.upQuality;
     downQuality    = p.downQuality;
     plantState     = p.plantState;
     info           = p.info;
     defValue       = p.defValue;
     getValue       = p.getValue;
     plantType      = p.plantType;
     soilWaterValue = p.soilWaterValue;
     jastSeason     = p.jastSeason;
     fertilizers    = new List <FertilizerSaveData>();
     foreach (FertilizerData f in p.fertilizers)
     {
         fertilizers.Add(new FertilizerSaveData(f));
     }
 }
Exemple #19
0
        public Season AddSeason(Season season)
        {
            using (var entities = Database.GetEntities())
            {
                var order = entities.SeasonDatas.Count(x => x.TeamId == season.TeamId);

                var seasonData = new SeasonData
                {
                    TeamId   = season.TeamId,
                    LeagueId = season.LeagueId,
                    Name     = season.Name,
                    Order    = (short)order
                };

                entities.SeasonDatas.AddObject(seasonData);
                entities.SaveChanges();

                season.Id    = seasonData.Id;
                season.Games = new List <Game>();
                season.Order = seasonData.Order;
                return(season);
            }
        }
Exemple #20
0
 public IEnumerable <ProRel> DoSeasonEnd()
 {
     return(SeasonData.GetEndOfSeasonData());
 }
Exemple #21
0
        private static List <DownloadData> ParseSite(ShowData showData, string url, out string nextpageurl, out string firstcover, UploadCache uploadCache)
        {
            nextpageurl = "";
            firstcover  = "";

            WebResponse resp = null;

            for (int i = 0; i <= 7; i++)
            {
                try
                {
                    HttpWebRequest req = WebRequest.CreateHttp(url);
                    req.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
                    req.KeepAlive = false;
                    resp          = req.GetResponse();
                    break;
                }
                catch (WebException ex)
                {
                    if (ex.Status != WebExceptionStatus.Timeout)
                    {
                        throw;
                    }
                }
            }
            if (resp == null)
            {
                throw new TimeoutException();
            }


            HtmlDocument doc = new HtmlDocument();

            doc.OptionDefaultStreamEncoding = Encoding.UTF8;
            doc.Load(resp.GetResponseStream());
            resp.Dispose();
            List <DownloadData> list = new List <DownloadData>();

            HtmlNode content = doc.GetElementbyId("content");

            HtmlNode nextLink = content.SelectSingleNode("//div[@class='navigation']//a[@href][@class='next']");

            if (nextLink != null)
            {
                nextpageurl = nextLink.GetAttributeValue("href", null);
            }

            var posts = content.SelectNodes("div[@class='post']");

            if (posts == null)
            {
                return(list);
            }
            foreach (var post in posts)
            {
                //--------------Season Title-----------------------------------
                var title = post.SelectSingleNode("h2/a[@href]");
                if (title == null)
                {
                    Console.WriteLine("SjInfo Parser: No Title");
                    continue;
                }
                var seasonData = new SeasonData();
                seasonData.Show  = showData;
                seasonData.Url   = title.GetAttributeValue("href", null);
                seasonData.Title = WebUtility.HtmlDecode(title.InnerText);


                var postContent = post.SelectSingleNode("div[@class='post-content']");
                if (postContent == null)
                {
                    Console.WriteLine("SjInfo Parser: No Post content");
                    continue;
                }

                //----------------Season Cover------------------------------------------------
                var cover = postContent.SelectSingleNode(".//p/img[@src]");
                if (cover != null)
                {
                    seasonData.CoverUrl = cover.GetAttributeValue("src", null);
                    if (String.IsNullOrEmpty(firstcover))
                    {
                        firstcover = seasonData.CoverUrl;
                    }
                }

                //----------------Season description-----------------------------------------
                var desc = postContent.SelectSingleNode(".//p[count(node())=1][not(@class='post-info-co')]/text()");
                if (desc != null)
                {
                    seasonData.Description = WebUtility.HtmlDecode(desc.InnerText);
                }

                UploadData uploadData = null;

                var ps = postContent.SelectNodes(".//node()[self::p|self::div][count(strong)>=2]");
                if (ps == null)
                {
                    Console.WriteLine("SjInfo Parser: no uploads/headers");
                    continue;
                }

                foreach (var p in ps)
                {
                    //--------------- Upload Header ------------------------------
                    if (p.SelectSingleNode("self::node()[not(./a[@target])]") != null)
                    {
                        uploadData        = new UploadData();
                        uploadData.Season = seasonData;

                        String          c  = WebUtility.HtmlDecode(p.InnerHtml);
                        MatchCollection mc = new Regex("<strong>\\s*(.+?)\\s*</strong>\\s*(.+?)\\s*(?:\\||$)").Matches(c);
                        foreach (Match match in mc)
                        {
                            String key   = match.Groups[1].Value.ToLower();
                            String value = match.Groups[2].Value;
                            if (key.Contains("dauer") || key.Contains("runtime") || key.Contains("duration"))
                            {
                                uploadData.Runtime = value;
                            }
                            else if (key.Contains("grösse") || key.Contains("größe") || key.Contains("size"))
                            {
                                uploadData.Size = value;
                            }
                            else if (key.Contains("uploader"))
                            {
                                uploadData.Uploader = value;
                            }
                            else if (key.Contains("format"))
                            {
                                uploadData.Format = value;
                            }
                            else if (key.Contains("sprache") || key.Contains("language"))
                            {
                                value = value.ToLower();
                                if (value.Contains("deutsch") || value.Contains("german"))
                                {
                                    uploadData.Language |= UploadLanguage.German;
                                }
                                if (value.Contains("englisch") || value.Contains("english"))
                                {
                                    uploadData.Language |= UploadLanguage.English;
                                }
                                if (value.Contains("subbed"))
                                {
                                    uploadData.Subbed = true;
                                }
                            }
                        }
                    }
                    else if (uploadData != null)
                    {
                        // ------------------ Links -------------------------
                        var ulTitle = p.SelectSingleNode("strong[position()=1][count(node())=1]/text()");
                        if (ulTitle == null)
                        {
                            Console.WriteLine("SjInfo Parser: No title for link? " + p.InnerHtml);
                            continue;
                        }
                        string titleStr = WebUtility.HtmlDecode(ulTitle.InnerText).Trim();

                        var links = p.SelectNodes("a[@href][following-sibling::text()]");
                        if (links == null)
                        {
                            continue;
                        }
                        var downloads = new Dictionary <string, string>();
                        foreach (var link in links)
                        {
                            string ur     = link.GetAttributeValue("href", null);
                            string keyOrg = WebUtility.HtmlDecode(link.NextSibling.InnerText.Trim());
                            if (keyOrg.StartsWith("|"))
                            {
                                keyOrg = keyOrg.Substring(1).Trim();
                            }

                            String key = keyOrg;
                            int    i   = 1;
                            while (downloads.ContainsKey(key))
                            {
                                key = keyOrg + "(" + i++ + ")";
                            }
                            downloads.Add(key, ur);
                        }

                        if (titleStr.Contains("720p"))
                        {
                            uploadData.Format = "720p";
                        }
                        else if (titleStr.Contains("1080p"))
                        {
                            uploadData.Format = "1080p";
                        }
                        else if (titleStr.Contains("720i"))
                        {
                            uploadData.Format = "720i";
                        }
                        else if (titleStr.Contains("1080i"))
                        {
                            uploadData.Format = "1080i";
                        }

                        DownloadData dd = new DownloadData();
                        dd.Upload = uploadCache == null ? uploadData : uploadCache.GetUniqueUploadData(uploadData);
                        dd.Title  = titleStr;

                        if (titleStr.ToLower().Contains("subbed"))
                        {
                            dd.Upload.Subbed = true;
                        }

                        foreach (var download in downloads)
                        {
                            dd.Links.Add(download.Key, download.Value);
                        }

                        list.Add(dd);
                    }
                    else
                    {
                        Console.WriteLine("SjInfo Parser: UploadData was null");
                    }
                }
            }
            return(list);
        }
Exemple #22
0
 public SeasonUploader(SeasonData season)
 {
     this.season = season;
 }
    void SetSeasonInfo(string json)
    {
        SeasonResponseData responseData = JsonConvert.DeserializeObject <SeasonResponseData>(json);

        _seasonSyncData = responseData.season;
    }
Exemple #24
0
 public Season Get()
 {
     return(SeasonData.GetSeason());
 }
Exemple #25
0
 public LegacyFileLoader(SeasonData season)
 {
     this.season = season;
 }
Exemple #26
0
 public SeasonBusiness(String connString)
 {
     this.seasonData = new SeasonData(connString);
 }//Fin del constructor.
 public LegacyExtractor(SeasonData season)
 {
     this.season = season;
 }
Exemple #28
0
 public Extractor(SeasonData season)
 {
     this.season = season;
 }
Exemple #29
0
        private static List <DownloadData> ParseSite(ShowData showData, string url, out string nextpageurl, out string firstcover, UploadCache uploadCache)
        {
            nextpageurl = "";
            firstcover  = "";

            HttpWebRequest req = HttpWebRequest.CreateHttp(url);

            req.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
            var            resp       = req.GetResponse();
            BufferedStream buffStream = new BufferedStream(req.GetResponse().GetResponseStream());

            url = resp.ResponseUri.ToString();
            StreamReader reader = new StreamReader(buffStream);

            bool inContent           = false;
            bool inPost              = false;
            bool inPostContent       = false;
            List <DownloadData> list = new List <DownloadData>();
            Match      m;
            SeasonData seasonData = null;
            UploadData uploadData = null;

            while (!reader.EndOfStream)
            {
                String line = reader.ReadLine();
                if (line.Contains("line-height") && line.Contains("&nbsp;")) //detect: <div style="line-height:5px;height:5px;background-color:lightgrey;">&nbsp;</div>
                {
                    continue;                                                //I can only hope this will never occour in any other case..
                }
                if (inContent)
                {
                    if (inPost)
                    {
                        if (inPostContent)
                        {
                            //Debug.Assert(seasonData!=null);
                            if (seasonData == null)
                            {
                                Console.WriteLine("Warning: Invalid Html received while parsing " + showData.Name + ". Trying to continue");
                                continue;
                            }
                            if ((m = new Regex("<p>\\s*<strong>\\s*(.+?)\\s*</strong>\\s*[^/]*\\s*<br\\s?/>").Match(line)).Success)
                            {
                                //Debug.Assert(uploadData != null);
                                if (uploadData == null)
                                {
                                    Console.WriteLine("Warning: Invalid Html received while parsing " + showData.Name + ". Trying to continue");
                                    continue;
                                }
                                string title = WebUtility.HtmlDecode(m.Groups[1].Value);

                                var   downloads = new Dictionary <string, string>();
                                Regex r         = new Regex("<a\\s+href\\s*=\"([^\"]+)\".+\\s+(.+?)\\s*<");
                                while (true)
                                {
                                    line = reader.ReadLine();
                                    Match m2 = r.Match(line);
                                    if (m2.Success)
                                    {
                                        String keyOrg = WebUtility.HtmlDecode(m2.Groups[2].Value);
                                        String key    = keyOrg;
                                        while (downloads.ContainsKey(key))
                                        {
                                            Match mx  = new Regex("\\((\\d+)\\)$").Match(key);
                                            int   num = 1;
                                            if (mx.Success)
                                            {
                                                num = int.Parse(mx.Groups[1].Value);
                                            }

                                            key = keyOrg + "(" + ++num + ")";
                                        }
                                        String val = m2.Groups[1].Value;
                                        if (val != null && !String.IsNullOrWhiteSpace(val) && val.Trim().StartsWith("http://"))
                                        {
                                            downloads.Add(key, val);
                                        }
                                        else
                                        {
                                            Console.WriteLine("Warning: Invalid Download received while parsing " + showData.Name + ". Ignoring link");
                                            //ignoring invalid download
                                        }
                                    }
                                    if (line.Contains("</p>"))
                                    {
                                        break;
                                    }
                                }

                                if (title.Contains("720p"))
                                {
                                    uploadData.Format = "720p";
                                }
                                else if (title.Contains("1080p"))
                                {
                                    uploadData.Format = "1080p";
                                }
                                else if (title.Contains("720i"))
                                {
                                    uploadData.Format = "720i";
                                }
                                else if (title.Contains("1080i"))
                                {
                                    uploadData.Format = "1080i";
                                }

                                DownloadData dd = new DownloadData();
                                dd.Upload = uploadCache == null ? uploadData : uploadCache.GetUniqueUploadData(uploadData);
                                dd.Title  = title;

                                if (title.ToLower().Contains("subbed"))
                                {
                                    dd.Upload.Subbed = true;
                                }

                                foreach (var download in downloads)
                                {
                                    dd.Links.Add(download.Key, download.Value);
                                }

                                list.Add(dd);
                            }
                            else if ((m = new Regex("(?:(?:<p(?:\\s+style\\s*\\=\\s*\\\"[^\\\"]+\\\"\\s*)?>)|(?:<div\\s+class\\s*=\\s*\"info\">))\\s*(.*?(?:Dauer|Größe|Sprache|Format|Uploader).*?)\\s*(?:(?:</p>)|(?:</div>))").Match(line)).Success ||
                                     ((m = new Regex("<p\\s+style\\s*\\=\\s*\\\"[^\\\"]+\\\"\\s*>").Match(line)).Success && ((line = reader.ReadLine()) != "") && (m = new Regex("\\s*(.*?(?:Dauer|Größe|Sprache|Format|Uploader).*?)\\s*</p>").Match(line)).Success))
                            {
                                /*
                                 * Nice case:
                                 * <p><strong>Dauer:</strong> 20:00 | <strong>Größe:</strong> 175 MB | <strong>Sprache:</strong> Englisch &amp; deutsche Untertitel | <strong>Format:</strong> XviD | <strong>HQ-Cover:</strong> <a href="http://justpic.info/?s=cover&amp;id=&amp;name=&amp;keyword=VGhlIEJpZyBCYW5nIFRoZW9yeQ,,">Download</a> | <strong>Uploader:</strong> block06</p>
                                 *
                                 * Bad case: (note newline!!)
                                 * <p style="background-color: #f0f0f0;">
                                 *  <strong>Dauer:</strong> 20:00 | <strong>Größe:</strong> 175 MB | <strong>Sprache:</strong> Englisch | <strong>Format:</strong> XviD | <strong>HQ-Cover:</strong> <a href="http://justpic.info/?s=cover&#038;id=&#038;name=&#038;keyword=VGhlIEJpZyBCYW5nIFRoZW9yeQ,,">Download</a> | <strong>Uploader:</strong> block06</p>
                                 */

                                uploadData        = new UploadData();
                                uploadData.Season = seasonData;

                                String          c  = WebUtility.HtmlDecode(m.Groups[1].Value);
                                MatchCollection mc = new Regex("<strong>\\s*(.+?)\\s*</strong>\\s*(.+?)\\s*(?:\\||$)").Matches(c);
                                foreach (Match match in mc)
                                {
                                    String key   = match.Groups[1].Value.ToLower();
                                    String value = match.Groups[2].Value;
                                    if (key.Contains("dauer") || key.Contains("runtime") || key.Contains("duration"))
                                    {
                                        uploadData.Runtime = value;
                                    }
                                    else if (key.Contains("grösse") || key.Contains("größe") || key.Contains("size"))
                                    {
                                        uploadData.Size = value;
                                    }
                                    else if (key.Contains("uploader"))
                                    {
                                        uploadData.Uploader = value;
                                    }
                                    else if (key.Contains("format"))
                                    {
                                        uploadData.Format = value;
                                    }
                                    else if (key.Contains("sprache") || key.Contains("language"))
                                    {
                                        value = value.ToLower();
                                        if (value.Contains("deutsch") || value.Contains("german"))
                                        {
                                            uploadData.Language |= UploadLanguage.German;
                                        }
                                        if (value.Contains("englisch") || value.Contains("english"))
                                        {
                                            uploadData.Language |= UploadLanguage.English;
                                        }
                                        if (value.Contains("subbed"))
                                        {
                                            uploadData.Subbed = true;
                                        }
                                    }
                                }
                            }
                            else if ((m = new Regex("<p>\\s*([^<]+)\\s*</p>").Match(line)).Success)
                            {
                                if (seasonData.Description == "")
                                {
                                    seasonData.Description = WebUtility.HtmlDecode(m.Groups[1].Value);
                                }
                            }
                            else if ((m = new Regex("<p>\\s*<img\\s+src\\s*=\"([^\"]+)\".*?/>\\s*</p>").Match(line)).Success)
                            {
                                seasonData.CoverUrl = m.Groups[1].Value;
                                if (firstcover == "")
                                {
                                    firstcover = seasonData.CoverUrl;
                                }
                            }
                            else if (new Regex("</div>").Match(line).Success)
                            {
                                inPostContent = false;
                                seasonData    = null;
                                uploadData    = null;
                            }
                        }
                        else if ((m = new Regex("<h2>\\s*<a\\s+href\\s*=\"([^\"]+)\".*?>(.+?)</a>\\s*</h2>").Match(line)).Success)
                        {
                            seasonData      = new SeasonData();
                            seasonData.Show = showData;

                            seasonData.Url   = m.Groups[1].Value;
                            seasonData.Title = WebUtility.HtmlDecode(m.Groups[2].Value);
                        }
                        else if (new Regex("<div\\s+class\\s*=\\s*\"post-content\"\\s*>").Match(line).Success)
                        {
                            inPostContent = true;
                        }
                        else if (new Regex("</div>").Match(line).Success)
                        {
                            inPost = false;
                        }
                    }
                    else if (new Regex("<div\\s+class\\s*=\\s*\"post\"\\s*>").Match(line).Success)
                    {
                        inPost = true;
                    }
                    else
                    {
                        if ((m = new Regex("<span\\s+class\\s*=\\s*'page\\s+current'>\\s*(\\d+)\\s*</span>").Match(line)).Success)
                        {
                            int currentPage = int.Parse(m.Groups[1].Value);
                            int nextPage    = currentPage + 1;
                            if (new Regex("title\\s*='" + nextPage + "'").Match(line).Success)
                            {
                                if (new Regex("/page/" + currentPage + "/?$").Match(url).Success)
                                {
                                    nextpageurl = url.Replace("page/" + currentPage, "page/" + nextPage);
                                }
                                else
                                {
                                    nextpageurl = url;
                                    if (!nextpageurl.EndsWith("/"))
                                    {
                                        nextpageurl += "/";
                                    }
                                    nextpageurl += "page/" + nextPage + "/";
                                }
                            }
                        }
                        if (new Regex("</div>").Match(line).Success)
                        {
                            inContent = false;
                        }
                    }
                }
                else if (new Regex("<div\\s+id\\s*=\\s*\"content\"\\s*>").Match(line).Success)
                {
                    inContent = true;
                }
            }
            reader.Close();
            return(list);
        }
Exemple #30
0
 public Season Get(int id)
 {
     return(SeasonData.GetById(id));
 }