Example #1
0
        public AnimeEntry SelectAnimeFromFile(int fid)
        {
            AnimeEntry anime = null;

            using (SQLiteCommand cmd = new SQLiteCommand(SQLConn))
            {
                cmd.CommandText = @"SELECT a.aid, a.type, a.romaji, a.nihongo, a.english, a.eps_total, a.year, IFNULL(SUM(f.length), 0) AS length, IFNULL(SUM(f.size), 0) AS size,
					                       COUNT(e.spl_epno) AS spl_have, (SELECT COUNT(spl_epno) FROM episodes WHERE aid = a.aid AND watched = 1) AS spl_watched,
					                       (SELECT COUNT(*) FROM episodes WHERE aid = a.aid AND spl_epno IS NULL) AS eps_have,
					                       (SELECT COUNT(*) FROM episodes WHERE aid = a.aid AND spl_epno IS NULL AND watched = 1) AS eps_watched
                                     FROM anime AS a
                                     JOIN episodes AS e ON e.aid = a.aid
                                     JOIN files AS f ON f.eid = e.eid
                                    WHERE f.fid = @fid
		                            LIMIT 1;"        ;
                cmd.Parameters.AddWithValue("@fid", fid);

                using (SQLiteDataReader reader = cmd.ExecuteReader())
                    if (reader.Read())
                    {
                        anime = new AnimeEntry(reader);
                    }
            }

            return(anime);
        }
Example #2
0
        private void CheckAnimeEntry(AnimeEntry entry, string title, AnimeEntryStatus status, int episodesWatched, int rewatched, int score,
                                     int priority, bool isPrivate, bool hiddenDefault, string notes, int[] advancedRatingScores, int[] customeLists,
                                     DateTime?startedOn, DateTime?endedOn)
        {
            Assert.NotNull(entry);
            Assert.AreEqual(title, entry.Anime.TitleEnglish);
            Assert.AreEqual(status, entry.ListStatus);
            Assert.AreEqual(episodesWatched, entry.EpisodesWatched);
            Assert.AreEqual(rewatched, entry.Rewatched);
            Assert.AreEqual(score, entry.Score);
            Assert.AreEqual(priority, entry.Priority); // NOTE: Don't know what this is actually used for, but it seems to always be 0
            Assert.AreEqual(isPrivate, entry.Private);
            Assert.AreEqual(hiddenDefault, entry.HiddenDefault);
            Assert.AreEqual(notes, entry.Notes);

            Assert.AreEqual(advancedRatingScores.Length, entry.AdvancedRatingScores.Length);
            for (var i = 0; i < advancedRatingScores.Length; i++)
            {
                Assert.AreEqual(advancedRatingScores[i], entry.AdvancedRatingScores[i]);
            }

            // TODO: Gotta figure out how the custom list system actually works
            //Assert.AreEqual(customeLists.Length, entry.CustomLists.Length);
            //foreach (var list in customeLists)
            //    Assert.True(entry.CustomLists.Contains(list));

            Assert.AreEqual(startedOn, entry.StartedOn);
            Assert.AreEqual(endedOn, entry.FinishedOn);
        }
Example #3
0
        /// <summary>
        /// Adds found anime search entry to specific user's list asynchronously.
        /// </summary>
        /// <param name="searchEntry">The search entry you found.</param>
        /// <param name="status">The status of the anime Watching, Completed, Onhold, Dropped...</param>
        /// <returns>A string represnting the state of adding "Created" or detailed error message.</returns>
        public async Task <string> AddAnimeAsync(AnimeSearchEntry searchEntry, AnimeListStatus status)
        {
            m_api.CheckAuthAsync();
            AnimeEntry addedAnime = new AnimeEntry()
            {
                Status = status,
            };

            return(await m_api.PostSerializedObjectAsync(addedAnime, string.Format(MAL.url_addAnime, searchEntry.Id)));
        }
Example #4
0
        /// <summary>
        /// Adds found anime search entry to specific user's list.
        /// </summary>
        /// <param name="searchEntry">The search entry you found.</param>
        /// <param name="status">The status of the anime Watching, Completed, Onhold, Dropped...</param>
        /// <returns>A string represnting the state of adding "Created" or detailed error message.</returns>
        public string AddAnime(AnimeSearchEntry searchEntry, AnimeListStatus status)
        {
            m_api.CheckAuth();

            AnimeEntry addedAnime = new AnimeEntry()
            {
                Status = status,
            };

            return(m_api.PostSerializedObject(addedAnime, string.Format(MAL.url_addAnime, searchEntry.Id)));
        }
Example #5
0
        private void LoadPage_DoWork(object sender, DoWorkEventArgs e)
        {
            BeginInvoke(new MethodInvoker(delegate
            {
                progressBar.Visible   = true;
                progressBar.Value     = 0;
                label1.Text           = (pageIndex + 1) + "/" + pages;
                panelPage.Visible     = true;
                button1.Enabled       = false;
                button2.Enabled       = false;
                button_search.Enabled = false;
            }));

            var animes = animeEntries.Skip(pageIndex * entriesPerPage).Take(entriesPerPage);

            LoadPage.ReportProgress(10);

            BeginInvoke(new MethodInvoker(delegate
            {
                panelEntry.Controls.Clear();
            }));

            float progress = 10;
            float step     = 90f / animes.Count();

            foreach (var a in animes)
            {
                AnimeEntry entry = new AnimeEntry(a);
                entry.Dock = DockStyle.Top;

                BeginInvoke(new MethodInvoker(delegate
                {
                    entry.Visible = false;
                    panelEntry.Controls.Add(entry);
                    entry.BringToFront();  // entry.BringToFront(); - to add controls in correct order
                    entry.Visible = true;
                }));
                System.Threading.Thread.Sleep(100);

                progress += step;
                LoadPage.ReportProgress((int)progress);
            }

            BeginInvoke(new MethodInvoker(delegate
            {
                progressBar.Visible   = false;
                button1.Enabled       = true;
                button2.Enabled       = true;
                button_search.Enabled = true;
            }));
        }
Example #6
0
        private void UpdateAnime(AnimeEntry entry)
        {
            using (SQLiteCommand cmd = new SQLiteCommand(SQLConn))
            {
                cmd.CommandText = @"INSERT OR REPLACE INTO anime VALUES (@aid, @type, @title, @nihongo, @english, @year, @eps_total);";

                SQLiteParameter[] aParams = { new SQLiteParameter("@aid",       entry.aid),
                                              new SQLiteParameter("@type",      entry.type),
                                              new SQLiteParameter("@title",     entry.title),
                                              new SQLiteParameter("@nihongo",   entry.nihongo),
                                              new SQLiteParameter("@english",   entry.english),
                                              new SQLiteParameter("@year",      entry.year),
                                              new SQLiteParameter("@eps_total", entry.eps_total) };

                aParams[3].IsNullable = aParams[4].IsNullable = true;

                cmd.Parameters.AddRange(aParams);
                cmd.ExecuteNonQuery();
            }
        }
Example #7
0
        public static MylistEntry FromAnime(AnimeEntry entry)
        {
            MylistEntry m_entry = new MylistEntry();
            TimeSpan length = TimeSpan.FromSeconds(entry.length);

            m_entry.OriginalEntry = entry;
            m_entry.ID = entry.aid;
            m_entry.HasChildren = entry.eps_have > 0;

            m_entry.Col0 = entry.title;
            m_entry.Col1 = String.Format("{0}/{1}{2}", entry.eps_have,
                                                       (entry.eps_total == 0) ? "TBC" : entry.eps_total.ToString(),
                                                       (entry.spl_have > 0) ? String.Format("+{0}", entry.spl_have) : null);
            m_entry.Col2 = String.Format("{0}/{1}{2}", entry.eps_watched,
                                                       entry.eps_have,
                                                       (entry.spl_watched > 0) ? String.Format("+{0}", entry.spl_watched) : null);
            m_entry.Col3 = entry.year;
            m_entry.Col4 = length.ToFormattedLength();
            m_entry.Col5 = entry.size.ToFormattedBytes();

            return m_entry;
        }
Example #8
0
        public CharacterInfo(Characters character)
        {
            InitializeComponent();
            this.character = character;

            CharacterPreview preview = new CharacterPreview(character);

            preview.Dock = DockStyle.Left;
            panel1.Controls.Add(preview);

            seyus = Program.db.CharacterAnime
                    .Where(a => a.CharacterId == character.CharacterId)
                    .Select(a => a.Person)
                    .ToList();

            seyus = seyus.Distinct().ToList();

            foreach (var seyu in seyus)
            {
                var person = new PersonPreview(seyu);
                panel2.Controls.Add(person);
                person.Dock = DockStyle.Top;
                person.BringToFront();
            }

            animes = Program.db.CharacterAnime
                     .Where(a => a.CharacterId == character.CharacterId)
                     .Select(a => a.Anime)
                     .ToList();
            animes = animes.Distinct().ToList();

            foreach (var anime in animes)
            {
                var a = new AnimeEntry(anime);
                a.Dock = DockStyle.Top;
                panel3.Controls.Add(a);
                a.BringToFront();
            }
        }
Example #9
0
        /// <summary>
        /// Parses the return message of a FILE command,
        /// and then triggers the OnFileInfoFetched event.
        /// </summary>
        private void ParseFileData(object item, string data)
        {
            string[] info = Regex.Split(data, "\n")[1].Split('|');

            AnimeEntry anime = new AnimeEntry();
            EpisodeEntry episode = new EpisodeEntry();
            FileEntry file = (item is HashItem) ?
                new FileEntry((HashItem)item) : (FileEntry)item;

            file.fid = int.Parse(info[0]);
            anime.aid = episode.aid = int.Parse(info[1]);
            episode.eid = file.eid = int.Parse(info[2]);
            file.lid = int.Parse(info[4]);

            file.source = info[5].FormatNullable();
            file.acodec = info[6].Contains("'") ? info[6].Split('\'')[0] : info[6].FormatNullable();
            file.acodec = ExtensionMethods.FormatAudioCodec(file.acodec);
            file.vcodec = ExtensionMethods.FormatVideoCodec(info[7].FormatNullable());
            file.vres = info[8].FormatNullable();

            file.length = double.Parse(info[9]);

            if (!string.IsNullOrEmpty(info[10]) && int.Parse(info[10]) != 0) episode.airdate = double.Parse(info[10]);

            file.state = int.Parse(info[11]);
            episode.watched = file.watched = Convert.ToBoolean(int.Parse(info[12]));
            if (!string.IsNullOrEmpty(info[13]) && int.Parse(info[13]) != 0) file.watcheddate = double.Parse(info[13]);

            anime.eps_total = !string.IsNullOrEmpty(info[14]) ?
                (int.Parse(info[14]) > int.Parse(info[15]) ? int.Parse(info[14]) : int.Parse(info[15])) : int.Parse(info[15]);
            anime.year = info[16].Contains('-') ?
                        (info[16].Split('-')[0] != info[16].Split('-')[1] ? info[16] : info[16].Split('-')[0]) : info[16];
            anime.type = info[17];

            anime.romaji = info[18];
            anime.nihongo = info[19].FormatNullable();
            anime.english = info[20].FormatNullable();

            if (Regex.IsMatch(info[21].Substring(0, 1), @"\D"))
                episode.spl_epno = info[21];
            else
                episode.epno = info[21].Contains('-') ? int.Parse(info[21].Split('-')[0]) : int.Parse(info[21]);

            episode.english = info[22];
            episode.romaji = info[23].FormatNullable();
            episode.nihongo = info[24].FormatNullable();

            if (int.Parse(info[3]) != 0)
                file.Group = new GroupEntry
                {
                    gid = int.Parse(info[3]),
                    group_name = info[25],
                    group_abbr = info[26]
                };

            OnFileInfoFetched(new FileInfoFetchedArgs(anime, episode, file));
        }
Example #10
0
 public FileInfoFetchedArgs(AnimeEntry anime, EpisodeEntry episode, FileEntry file)
 {
     Anime = anime;
     Episode = episode;
     File = file;
 }
Example #11
0
        /// <summary>
        /// Parses the return message of a FILE command,
        /// and then triggers the OnFileInfoFetched event.
        /// </summary>
        private void ParseFileData(object item, string data)
        {
            string[] info = Regex.Split(data, "\n")[1].Split('|');

            AnimeEntry   anime   = new AnimeEntry();
            EpisodeEntry episode = new EpisodeEntry();
            FileEntry    file    = (item is HashItem) ?
                                   new FileEntry((HashItem)item) : (FileEntry)item;

            file.fid    = int.Parse(info[0]);
            anime.aid   = episode.aid = int.Parse(info[1]);
            episode.eid = file.eid = int.Parse(info[2]);
            file.lid    = int.Parse(info[4]);

            file.source = info[5].FormatNullable();
            file.acodec = info[6].Contains("'") ? info[6].Split('\'')[0] : info[6].FormatNullable();
            file.acodec = ExtensionMethods.FormatAudioCodec(file.acodec);
            file.vcodec = ExtensionMethods.FormatVideoCodec(info[7].FormatNullable());
            file.vres   = info[8].FormatNullable();

            file.length = double.Parse(info[9]);

            if (!string.IsNullOrEmpty(info[10]) && int.Parse(info[10]) != 0)
            {
                episode.airdate = double.Parse(info[10]);
            }

            file.state      = int.Parse(info[11]);
            episode.watched = file.watched = Convert.ToBoolean(int.Parse(info[12]));
            if (!string.IsNullOrEmpty(info[13]) && int.Parse(info[13]) != 0)
            {
                file.watcheddate = double.Parse(info[13]);
            }

            anime.eps_total = !string.IsNullOrEmpty(info[14]) ?
                              (int.Parse(info[14]) > int.Parse(info[15]) ? int.Parse(info[14]) : int.Parse(info[15])) : int.Parse(info[15]);
            anime.year = info[16].Contains('-') ?
                         (info[16].Split('-')[0] != info[16].Split('-')[1] ? info[16] : info[16].Split('-')[0]) : info[16];
            anime.type = info[17];

            anime.romaji  = info[18];
            anime.nihongo = info[19].FormatNullable();
            anime.english = info[20].FormatNullable();

            if (Regex.IsMatch(info[21].Substring(0, 1), @"\D"))
            {
                episode.spl_epno = info[21];
            }
            else
            {
                episode.epno = info[21].Contains('-') ? int.Parse(info[21].Split('-')[0]) : int.Parse(info[21]);
            }

            episode.english = info[22];
            episode.romaji  = info[23].FormatNullable();
            episode.nihongo = info[24].FormatNullable();

            if (int.Parse(info[3]) != 0)
            {
                file.Group = new GroupEntry
                {
                    gid        = int.Parse(info[3]),
                    group_name = info[25],
                    group_abbr = info[26]
                }
            }
            ;

            OnFileInfoFetched(new FileInfoFetchedArgs(anime, episode, file));
        }
Example #12
0
        private void DoWork(object sender, DoWorkEventArgs e)
        {
            List <AnimeEntry> m_aList = new List <AnimeEntry>();

            double totalProcessedFiles = 0;
            double totalFiles          = int.Parse(new XPathDocument(xmlPath).CreateNavigator().Evaluate("count(//file)").ToString()) * 2;

            using (XmlReader reader = XmlReader.Create(xmlPath))
            {
                reader.ReadToFollowing("mylist");
                if (reader["template"] != "mini")
                {
                    Dispatcher.Invoke(new Action(delegate
                    {
                        MessageBox.Show("Please ensure you selected a mylist export file that used the xml-mini template.",
                                        "Invalid xml template!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }));

                    xmlWorker.CancelAsync();
                    return;
                }


                // <anime>
                while (reader.ReadToFollowing("anime"))
                {
                    while (closePending)
                    {
                        Thread.Sleep(500);
                    }

                    AnimeEntry entry = new AnimeEntry();

                    entry.aid  = int.Parse(reader["aid"]);
                    entry.type = reader["type"];
                    entry.year = reader["year"];

                    // <titles>
                    reader.ReadToFollowing("default");
                    entry.romaji = reader.ReadElementContentAsString();
                    Dispatcher.BeginInvoke(new Action(delegate { importFilePath.Text = String.Format("Reading: {0}", entry.title); }));

                    reader.ReadToFollowing("nihongo");
                    entry.nihongo = reader.ReadElementContentAsString().FormatNullable();

                    reader.ReadToFollowing("english");
                    entry.english = reader.ReadElementContentAsString().FormatNullable();
                    // </titles>

                    // <episodes>
                    if (!reader.ReadToFollowing("episodes"))
                    {
                        goto Finish;
                    }

                    entry.eps_total = int.Parse(reader["total"]);

                    XmlReader episodesReader = reader.ReadSubtree();
                    // <episode>
                    while (episodesReader.ReadToFollowing("episode"))
                    {
                        while (closePending)
                        {
                            Thread.Sleep(500);
                        }

                        EpisodeEntry episode = new EpisodeEntry();

                        episode.eid = int.Parse(episodesReader["eid"]);

                        episode.airdate = episodesReader["aired"] == "-" ? null :
                                          UnixTimestamp.FromDateTime(DateTime.Parse(episodesReader["aired"],
                                                                                    System.Globalization.CultureInfo.CreateSpecificCulture("en-GB")));
                        episode.watched = Convert.ToBoolean(int.Parse(episodesReader["watched"]));

                        if (Regex.IsMatch(episodesReader["epno"].Substring(0, 1), @"\D"))
                        {
                            episode.spl_epno = episodesReader["epno"];
                        }
                        else
                        {
                            episode.epno = int.Parse(episodesReader["epno"]);
                        }

                        // <titles>
                        episodesReader.ReadToDescendant("english");
                        episode.english = episodesReader.ReadElementContentAsString();

                        episodesReader.ReadToFollowing("nihongo");
                        episode.nihongo = episodesReader.ReadElementContentAsString().FormatNullable();

                        episodesReader.ReadToFollowing("romaji");
                        episode.romaji = episodesReader.ReadElementContentAsString().FormatNullable();
                        // </titles>

                        // <files>
                        if (!episodesReader.ReadToFollowing("files"))
                        {
                            goto Finish;
                        }

                        XmlReader filesReader = episodesReader.ReadSubtree();
                        // <file>
                        while (filesReader.ReadToFollowing("file"))
                        {
                            while (closePending)
                            {
                                Thread.Sleep(500);
                            }

                            FileEntry file = new FileEntry();

                            file.fid         = int.Parse(filesReader["fid"]);
                            file.lid         = int.Parse(filesReader["lid"]);
                            file.watcheddate = filesReader["watched"] == "-" ? null :
                                               UnixTimestamp.FromDateTime(DateTime.Parse(episodesReader["watched"],
                                                                                         System.Globalization.CultureInfo.CreateSpecificCulture("en-GB")));
                            file.watched = file.watcheddate != null;
                            file.generic = episodesReader["generic"] != null;

                            if (!file.generic) // generic entries do not have this information
                            {
                                int gid = 0;

                                if (filesReader["gid"] != null)
                                {
                                    gid = int.Parse(filesReader["gid"]);
                                }

                                file.ed2k   = filesReader["ed2k"];
                                file.length = double.Parse(filesReader["length"]);
                                file.size   = double.Parse(filesReader["size"]);
                                file.source = filesReader["source"].FormatNullable();
                                file.acodec = ExtensionMethods.FormatAudioCodec(filesReader["acodec"].FormatNullable());
                                file.vcodec = ExtensionMethods.FormatVideoCodec(filesReader["vcodec"].FormatNullable());
                                file.vres   = filesReader["vres"].FormatNullable();

                                if (gid != 0)
                                {
                                    // <group_name>
                                    filesReader.ReadToFollowing("group_name");
                                    string group_name = filesReader.ReadElementContentAsString();
                                    // </group_name>

                                    // <group_abbr>
                                    filesReader.ReadToFollowing("group_abbr");
                                    string group_abbr = filesReader.ReadElementContentAsString();
                                    // </group_abbr>


                                    file.Group = new GroupEntry
                                    {
                                        gid        = gid,
                                        group_name = group_name,
                                        group_abbr = group_abbr
                                    };
                                }
                            }

                            episode.Files.Add(file);
                            importProgressBar.Dispatcher.BeginInvoke(new Action <double, double>((total, processed) =>
                            {
                                importProgressBar.Value = Math.Ceiling(processed / total * 100);
                            }), totalFiles, ++totalProcessedFiles);
                            // </file>
                        }
                        // </files>
                        filesReader.Close();
                        entry.Episodes.Add(episode);
                        // </episode>
                    }
                    // </episodes>
                    episodesReader.Close();

Finish:
                    m_aList.Add(entry);

                    // </anime>
                }
                // </mylist>
            }

            m_myList.OnEntryInserted += (aTitle) =>
            {
                importProgressBar.Dispatcher.BeginInvoke(new Action(delegate
                {
                    importFilePath.Text     = String.Format("Writing: {0}", aTitle);
                    importProgressBar.Value = Math.Ceiling(++totalProcessedFiles / totalFiles * 100);
                }));
            };

            m_myList.InsertFromImport(m_aList);
        }
Example #13
0
        /// <summary>
        /// Adds anime entry to specific user's list.
        /// </summary>
        /// <param name="addedAnime">The anime entry you want to add to the list.</param>
        /// <param name="animeId">The ID of the new added anime.</param>
        /// <returns>A string represnting the state of adding "Created" or detailed error message.</returns>
        public string AddAnime(AnimeEntry addedAnime, int animeId)
        {
            m_api.CheckAuth();

            return(m_api.PostSerializedObject(addedAnime, string.Format(MAL.url_addAnime, animeId)));
        }
Example #14
0
        /// <summary>
        /// Updates existing anime in user's list.
        /// </summary>
        /// <param name="newAnimeInfo">The updated anime entry.</param>
        /// <param name="animeId">the ID of the anime entry you want to update.</param>
        /// <returns>A string represnting the state of updating "Updated" or detailed error message.</returns>
        public string UpdateAnime(AnimeEntry newAnimeInfo, int animeId)
        {
            m_api.CheckAuth();

            return(m_api.PostSerializedObject(newAnimeInfo, string.Format(MAL.url_updateAnime, animeId)));
        }
Example #15
0
 public void Show(AnimeEntry[] entries)
 {
     this.entries = entries;
     this.Show();
 }
Example #16
0
        private void DoWork(object sender, DoWorkEventArgs e)
        {
            List<AnimeEntry> m_aList = new List<AnimeEntry>();

            double totalProcessedFiles = 0;
            double totalFiles = int.Parse(new XPathDocument(xmlPath).CreateNavigator().Evaluate("count(//file)").ToString()) * 2;

            using (XmlReader reader = XmlReader.Create(xmlPath))
            {
                reader.ReadToFollowing("mylist");
                if (reader["template"] != "mini")
                {
                    Dispatcher.Invoke(new Action(delegate
                    {
                        MessageBox.Show("Please ensure you selected a mylist export file that used the xml-mini template.",
                            "Invalid xml template!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }));

                    xmlWorker.CancelAsync();
                    return;
                }

                // <anime>
                while (reader.ReadToFollowing("anime"))
                {
                    while (closePending) Thread.Sleep(500);

                    AnimeEntry entry = new AnimeEntry();

                    entry.aid = int.Parse(reader["aid"]);
                    entry.type = reader["type"];
                    entry.year = reader["year"];

                    // <titles>
                    reader.ReadToFollowing("default");
                    entry.romaji = reader.ReadElementContentAsString();
                    Dispatcher.BeginInvoke(new Action(delegate { importFilePath.Text = String.Format("Reading: {0}", entry.title); }));

                    reader.ReadToFollowing("nihongo");
                    entry.nihongo = reader.ReadElementContentAsString().FormatNullable();

                    reader.ReadToFollowing("english");
                    entry.english = reader.ReadElementContentAsString().FormatNullable();
                    // </titles>

                    // <episodes>
                    if (!reader.ReadToFollowing("episodes"))
                        goto Finish;

                    entry.eps_total = int.Parse(reader["total"]);

                    XmlReader episodesReader = reader.ReadSubtree();
                    // <episode>
                    while (episodesReader.ReadToFollowing("episode"))
                    {
                        while (closePending) Thread.Sleep(500);

                        EpisodeEntry episode = new EpisodeEntry();

                        episode.eid = int.Parse(episodesReader["eid"]);

                        episode.airdate = episodesReader["aired"] == "-" ? null :
                                          UnixTimestamp.FromDateTime(DateTime.Parse(episodesReader["aired"],
                                          System.Globalization.CultureInfo.CreateSpecificCulture("en-GB")));
                        episode.watched = Convert.ToBoolean(int.Parse(episodesReader["watched"]));

                        if (Regex.IsMatch(episodesReader["epno"].Substring(0, 1), @"\D"))
                            episode.spl_epno = episodesReader["epno"];
                        else
                            episode.epno = int.Parse(episodesReader["epno"]);

                        // <titles>
                        episodesReader.ReadToDescendant("english");
                        episode.english = episodesReader.ReadElementContentAsString();

                        episodesReader.ReadToFollowing("nihongo");
                        episode.nihongo = episodesReader.ReadElementContentAsString().FormatNullable();

                        episodesReader.ReadToFollowing("romaji");
                        episode.romaji = episodesReader.ReadElementContentAsString().FormatNullable();
                        // </titles>

                        // <files>
                        if (!episodesReader.ReadToFollowing("files"))
                            goto Finish;

                        XmlReader filesReader = episodesReader.ReadSubtree();
                        // <file>
                        while (filesReader.ReadToFollowing("file"))
                        {
                            while (closePending) Thread.Sleep(500);

                            FileEntry file = new FileEntry();

                            file.fid = int.Parse(filesReader["fid"]);
                            file.lid = int.Parse(filesReader["lid"]);
                            file.watcheddate = filesReader["watched"] == "-" ? null :
                                               UnixTimestamp.FromDateTime(DateTime.Parse(episodesReader["watched"],
                                               System.Globalization.CultureInfo.CreateSpecificCulture("en-GB")));
                            file.watched = file.watcheddate != null;
                            file.generic = episodesReader["generic"] != null;

                            if (!file.generic) // generic entries do not have this information
                            {
                                int gid = 0;

                                if (filesReader["gid"] != null)
                                    gid = int.Parse(filesReader["gid"]);

                                file.ed2k = filesReader["ed2k"];
                                file.length = double.Parse(filesReader["length"]);
                                file.size = double.Parse(filesReader["size"]);
                                file.source = filesReader["source"].FormatNullable();
                                file.acodec = ExtensionMethods.FormatAudioCodec(filesReader["acodec"].FormatNullable());
                                file.vcodec = ExtensionMethods.FormatVideoCodec(filesReader["vcodec"].FormatNullable());
                                file.vres = filesReader["vres"].FormatNullable();

                                if (gid != 0)
                                {
                                    // <group_name>
                                    filesReader.ReadToFollowing("group_name");
                                    string group_name = filesReader.ReadElementContentAsString();
                                    // </group_name>

                                    // <group_abbr>
                                    filesReader.ReadToFollowing("group_abbr");
                                    string group_abbr = filesReader.ReadElementContentAsString();
                                    // </group_abbr>

                                    file.Group = new GroupEntry
                                    {
                                        gid = gid,
                                        group_name = group_name,
                                        group_abbr = group_abbr
                                    };
                                }
                            }

                            episode.Files.Add(file);
                            importProgressBar.Dispatcher.BeginInvoke(new Action<double, double>((total, processed) =>
                            {
                                importProgressBar.Value = Math.Ceiling(processed / total * 100);
                            }), totalFiles, ++totalProcessedFiles);
                        // </file>
                        }
                        // </files>
                        filesReader.Close();
                        entry.Episodes.Add(episode);
                    // </episode>
                    }
                    // </episodes>
                    episodesReader.Close();

                Finish:
                    m_aList.Add(entry);

                // </anime>
                }
             // </mylist>
            }

            m_myList.OnEntryInserted += (aTitle) =>
            {
                importProgressBar.Dispatcher.BeginInvoke(new Action(delegate
                {
                    importFilePath.Text = String.Format("Writing: {0}", aTitle);
                    importProgressBar.Value = Math.Ceiling(++totalProcessedFiles / totalFiles * 100);
                }));
            };

            m_myList.InsertFromImport(m_aList);
        }
Example #17
0
        /// <summary>
        ///Adds anime entry to specific user's list asynchronously.
        /// </summary>
        /// <param name="addedAnime">The new added anime to the list.</param>
        /// <param name="animeId">The ID of the new added anime.</param>
        /// <returns>A string represnting the state of adding "Created" or detailed error message.</returns>
        public async Task <string> AddAnimeAsync(AnimeEntry addedAnime, int animeId)
        {
            m_api.CheckAuthAsync();

            return(await m_api.PostSerializedObjectAsync(addedAnime, string.Format(MAL.url_addAnime, animeId)));
        }
Example #18
0
 public FileInfoFetchedArgs(AnimeEntry anime, EpisodeEntry episode, FileEntry file)
 {
     Anime   = anime;
     Episode = episode;
     File    = file;
 }
Example #19
0
 /// <summary>
 /// Updates existing anime in user's list asynchronously.
 /// </summary>
 /// <param name="newAnimeInfo">The updated anime object.</param>
 /// <param name="animeId">the ID of the anime you want to update.</param>
 /// <returns>A string represnting the state of updating "Updated" or detailed error message.</returns>
 public async Task <string> UpdateAnimeAsync(AnimeEntry newAnimeInfo, int animeId)
 {
     m_api.CheckAuthAsync();
     return(await m_api.PostSerializedObjectAsync(newAnimeInfo, string.Format(MAL.url_updateAnime, animeId)));
 }