Esempio n. 1
0
        private void ButtonSets_Click(object sender, EventArgs e)
        {
            var flickr = new Flickr(Program.ApiKey, Program.SharedSecret, Program.AuthToken);
            // Liste des albums
            var sets = flickr.PhotosetsGetList();
            string setlist = "";
            foreach (Photoset pset in sets) setlist += pset.Title + "\n";
            MessageBox.Show("Liste des albums\n" + setlist, "Liste des albums",
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            // Statistiques
            var statfile = new System.IO.StreamWriter("albums_stats.csv");
            var reffile = new System.IO.StreamWriter("albums_referrers.csv");
            DateTime day = DateTime.Today;
            statfile.WriteLine("Date;Album;Vues;Favoris;Commentaires");
            reffile.WriteLine("Date;Album;Domain;Views");
            while (day > Program.LastUpdate)
            {
                foreach (Photoset pset in sets)
                {
                    StatusLabel.Text = "Stats de l'album " +
                        pset.Title + " pour le " + day.ToShortDateString();
                    Application.DoEvents();
                    try
                    {
                        var s = flickr.StatsGetPhotosetStats(day, pset.PhotosetId);
                        statfile.WriteLine(day.ToShortDateString() + ";" +
                            pset.Title + ";" + Utility.toCSV(s));
                        var r = flickr.StatsGetPhotosetDomains(day, pset.PhotosetId, 1, 100);
                        reffile.WriteLine(Utility.toCSV(r, day.ToShortDateString() + ";" + pset.Title));
                    }
                    catch(FlickrApiException ex)
                    { }
                }

                day -= TimeSpan.FromDays(1);
            }
            statfile.Close(); reffile.Close();
        }