Ejemplo n.º 1
0
        private static List <LibraryEntry> BuildLibraryEntries(dynamic entries)
        {
            List <LibraryEntry> new_entries = new List <LibraryEntry>();

            foreach (dynamic entry in entries)
            {
                dynamic      attributes = entry.attributes;
                LibraryEntry new_entry  = new LibraryEntry()
                {
                    Id          = entry.id,
                    Rating      = attributes.rating,
                    Status      = attributes.status,
                    Progress    = attributes.progress,
                    Started     = attributes.createdAt,
                    LastUpdated = attributes.updatedAt,
                    AnimeUrl    = entry.relationships.anime.links.related
                };

                new_entries.Add(new_entry);
            }

            return(new_entries);
        }
Ejemplo n.º 2
0
        private static async Task FetchAnimeAttributes(LibraryEntry entry)
        {
            string content = await client.GetStringAsync(entry.AnimeUrl);

            dynamic response = JObject.Parse(content);
            Dictionary <string, string> titles = JsonConvert.DeserializeObject <Dictionary <string, string> >(response.data.attributes.titles.ToString());

            string title = "";

            if (titles.ContainsKey("en"))
            {
                title = titles["en"];
            }
            else if (titles.ContainsKey("en_us"))
            {
                title = titles["en_us"];
            }
            else if (titles.ContainsKey("en_jp"))
            {
                title = titles["en_jp"];
            }
            else if (titles.ContainsKey("ja_jp"))
            {
                title = titles["ja_jp"];
            }
            else
            {
                title = response.data.attributes.canonicalTitle;
            }

            entry.Title = title;
            entry.Total = 0;
            if (response.data.attributes.episodeCount != null)
            {
                entry.Total = response.data.attributes.episodeCount;
            }
        }