public clsDataPoint(double OldValue, double NewValue, clsDataPointField DataField, string VideoID)
 {
     this.Old = OldValue;
     this.New = NewValue;
     this.Field = DataField;
     this.Time = DateTime.Now;
     this.VideoID = VideoID;
 }
Example #2
0
        private void button5_Click(object sender, EventArgs e)
        {
            List<clsVideoEntry> init = new List<clsVideoEntry>();

            string log = textBox3.Text;
            Regex r = new Regex("V=(.*),Views=(.*),Comments=(.*),Favorites=(.*),Ratings=(.*),ARating=(.*)");
            MatchCollection matches = r.Matches(textBox3.Text);
            foreach (Match m in matches)
            {
                Google.GData.YouTube.YouTubeEntry entry = new Google.GData.YouTube.YouTubeEntry();
                entry.VideoId = m.Groups[1].Value;
                Google.GData.Extensions.FeedLink feedlink = new Google.GData.Extensions.FeedLink();
                feedlink.CountHint = int.Parse(m.Groups[3].Value);
                entry.Comments = new Google.GData.Extensions.Comments();
                entry.Comments.FeedLink = feedlink;
                entry.Statistics = new Google.GData.YouTube.Statistics();
                entry.Statistics.ViewCount = m.Groups[2].Value;
                entry.Statistics.FavoriteCount = m.Groups[4].Value;
                entry.Rating = new Google.GData.Extensions.Rating();
                entry.Rating.NumRaters = int.Parse(m.Groups[5].Value);
                entry.Rating.Average = double.Parse(m.Groups[6].Value);
                init.Add(new clsVideoEntry(entry));
            }

            Dictionary<string, List<clsDataPoint>> hist = new Dictionary<string, List<clsDataPoint>>();
            r = new Regex("DT=.*V=(.*),field=(.*),init_v=(.*),new_v=(.*)");
            matches = r.Matches(textBox3.Text);
            foreach (Match m in matches)
            {
                string v = m.Groups[1].Value;
                string f = m.Groups[2].Value;
                double Iv = double.Parse(m.Groups[3].Value);
                double Nv = double.Parse(m.Groups[4].Value);
                if (!hist.ContainsKey(v))
                    hist.Add(v, new List<clsDataPoint>());

                clsDataPointField field = new clsDataPointField();
                switch (f)
                {
                    case "E_VIEWS":
                        field.Field = clsDataPointField.VideoDataFields.VIEWS;
                        break;
                    case "E_RATINGS":
                        field.Field = clsDataPointField.VideoDataFields.RATERS;
                        break;
                    case "E_AVERAGE_RATING":
                        field.Field = clsDataPointField.VideoDataFields.AVERAGE_RATING;
                        break;
                    case "E_COMMENTS":
                        field.Field = clsDataPointField.VideoDataFields.COMMENT_COUNT;
                        break;
                    case "E_FAVORITES":
                        field.Field = clsDataPointField.VideoDataFields.FAVORITED_COUNT;
                        break;
                }
                hist[v].Add(new clsDataPoint(Iv, Nv, field, v));
            }

            lb.Items.Clear();
            lb3.Items.Clear();

            mash = new clsStatMasher(init, hist);

            foreach (clsVideoEntry en in init)
            {
                lb.Items.Add(en.VideoID);
                lb3.Items.Add(mash.AverageNewRatingByID(en.VideoID, 10));
            }
        }
        public void LoadDataFile(string LogFileContents)
        {
            List<clsVideoEntry> init = new List<clsVideoEntry>();
            Dictionary<string, List<clsDataPoint>> hist = new Dictionary<string, List<clsDataPoint>>();

            string log = LogFileContents;
            Regex r = new Regex("init : .+?{(.+?)}.+?{(.+?)}.+?{(.+?)}.+?{(.+?)}.+?{(.+?)}.+?{(.+?)}.+?{(.+?)}.+?{(.+?)}.+?{(.+?)}");
            MatchCollection matches = r.Matches(log);
            foreach (Match m in matches)
            {
                Google.GData.YouTube.YouTubeEntry entry = new Google.GData.YouTube.YouTubeEntry();
                entry.VideoId = m.Groups[3].Value;
                Google.GData.Extensions.FeedLink feedlink = new Google.GData.Extensions.FeedLink();
                feedlink.CountHint = int.Parse(m.Groups[8].Value);
                entry.Comments = new Google.GData.Extensions.Comments();
                entry.Comments.FeedLink = feedlink;
                entry.Statistics = new Google.GData.YouTube.Statistics();
                entry.Statistics.ViewCount = m.Groups[7].Value;
                entry.Statistics.FavoriteCount = m.Groups[9].Value;
                entry.Rating = new Google.GData.Extensions.Rating();
                entry.Rating.NumRaters = int.Parse(m.Groups[5].Value);
                entry.Rating.Average = double.Parse(m.Groups[6].Value);
                entry.Title = new Google.GData.Client.AtomTextConstruct(Google.GData.Client.AtomTextConstructElementType.Title, m.Groups[4].Value);
                clsVideoEntry new_e = new clsVideoEntry(entry);
                new_e.Time = DateTime.Parse(m.Groups[1].Value + " " + m.Groups[2].Value);
                clsVideoEntry old_entry = _GetEntryByIdFromList(init, new_e.VideoID);
                if ( old_entry == null)
                    init.Add(new_e);
                else
                {
                    List<clsDataPoint> new_dps = _compare_entities(new_e, old_entry);
                    if (new_e.Time < old_entry.Time)
                        old_entry = new_e;
                    foreach (clsDataPoint dp in new_dps)
                    {
                        if (!hist.ContainsKey(new_e.VideoID))
                            hist.Add(new_e.VideoID, new List<clsDataPoint>());
                        hist[new_e.VideoID].Add(dp);
                    }
                }

            }

            r = new Regex("upd : d{(.*)},t{(.*)},vId{(.*),(.*)},old{(.*)},new{(.*)}");
            matches = r.Matches(log);
            foreach (Match m in matches)
            {
                string v = m.Groups[3].Value;
                string f = m.Groups[4].Value;
                double Iv = double.Parse(m.Groups[5].Value);
                double Nv = double.Parse(m.Groups[6].Value);
                if (!hist.ContainsKey(v))
                    hist.Add(v, new List<clsDataPoint>());

                clsDataPointField field = new clsDataPointField();
                switch (f)
                {
                    case "VIEWS":
                        field.Field = clsDataPointField.VideoDataFields.VIEWS;
                        break;
                    case "RATERS":
                        field.Field = clsDataPointField.VideoDataFields.RATERS;
                        break;
                    case "AVERAGE_RATING":
                        field.Field = clsDataPointField.VideoDataFields.AVERAGE_RATING;
                        break;
                    case "COMMENT_COUNT":
                        field.Field = clsDataPointField.VideoDataFields.COMMENT_COUNT;
                        break;
                    case "FAVORITED_COUNT":
                        field.Field = clsDataPointField.VideoDataFields.FAVORITED_COUNT;
                        break;
                }
                clsDataPoint new_dp = new clsDataPoint(Iv, Nv, field, v);
                new_dp.Time = DateTime.Parse(m.Groups[1].Value + " " + m.Groups[2].Value);
                hist[v].Add(new_dp);
            }

            _initial_dataset = init;
            _historical_data = hist;
            _sort_historical_data();
        }
 private void _compare_stat(double Old, double New, clsDataPointField.VideoDataFields Field, clsVideoEntry Entry)
 {
     if (Old == New)
         return;
     else
     {
         clsDataPoint new_datapoint = new clsDataPoint(Old, New, new clsDataPointField(Field), Entry.VideoID);
         if (_historical_data.ContainsKey(Entry.VideoID))
             _historical_data[Entry.VideoID].Add(new_datapoint);
         else
         {
             List<clsDataPoint> new_dp_list = new List<clsDataPoint>();
             new_dp_list.Add(new_datapoint);
             _historical_data.Add(Entry.VideoID, new_dp_list);
         }
         _entry_updated(new_datapoint, Entry);
     }
 }
        public double GetMovedStatByField(string VideoID, clsDataPointField.VideoDataFields field)
        {
            clsVideoEntry InitialData = GetInitialDataByID(VideoID);
            List<clsDataPoint> HistoricalData = GetDataPointsByID(VideoID);

            if (InitialData == null || HistoricalData == null || HistoricalData.Count == 0)
                return 0;

            double ret = 0;
            int num = 0;
            foreach (clsDataPoint d in HistoricalData)
            {
                if (d.Field.Field == field)
                {
                    if (d.Field.Field == clsDataPointField.VideoDataFields.AVERAGE_RATING)
                        num++;
                    else
                        ret += d.Delta;
                }
            }
            if (field == clsDataPointField.VideoDataFields.AVERAGE_RATING)
                return num;
            else
                return ret;
        }