public async Task<ObservableCollection<Anime>> GetAnimeListAsync()
        {
            try
            {
                string userName = UserManager.GetCredentialFromLocker().UserName;

                Task<string> getStringTask = _client.GetStringAsync("http://myanimelist.net/malappinfo.php?status=all&u=" + userName + "&nocache=" + DateTime.UtcNow.ToString("r"));
                XDocument xDoc = XDocument.Parse(await getStringTask.ConfigureAwait(false));

                ObservableCollection<Anime> animeList = new ObservableCollection<Anime>(); ;

                Anime a;
                foreach (XElement e in xDoc.Root.Elements("anime"))
                {
                    a = new Anime();
                    a.Id = Int32.Parse(e.Element("series_animedb_id").Value);
                    a.Name = e.Element("series_title").Value;
                    a.Episodes = Int32.Parse(e.Element("series_episodes").Value);
                    a.Status = Int32.Parse(e.Element("my_status").Value);
                    a.Type = Int32.Parse(e.Element("series_type").Value);
                    //string filename = a.Id + System.Text.RegularExpressions.Regex.Replace(a.Name, @"[^a-z]", String.Empty);
                    //a.Image = ApplicationData.Current.LocalFolder.Path + "\\images\\" + filename + ".jpg";
                    //client.GetStreamAsync(e.Element("series_image").Value);
                    a.WatchedEpisodes = Int32.Parse(e.Element("my_watched_episodes").Value);
                    a.Episodes = Int32.Parse(e.Element("series_episodes").Value);
                    a.Score = Int32.Parse(e.Element("my_score").Value);
                    a.ImageUrl = e.Element("series_image").Value;
                    a.Version = UInt64.Parse(e.Element("my_last_updated").Value);
                    animeList.Add(a);
                }

                return animeList;
            }
            catch { return null; }
        }
Beispiel #2
0
		public void SetUp()
		{
			_response = new AniDBResponse(Encoding.UTF8.GetBytes(ResponseString));

			//I think I'm probably overengineering this; why not just store the amask as 
			// a const string instead of the entire request? It's the only part (of the request)
			// that's relevant to testing the Anime class
			_aMask =
				new Anime.AMask(
					(Anime.AMask.AMaskValues)
					ulong.Parse(new Regex(@"(?<=amask\=)\w+((?=\&.+)|$)").Match(Request).Value, NumberStyles.HexNumber));

			_anime = new Anime(_response, _aMask);

			for (int i = 0; i < _response.DataFields[0].Length; i++)
				Console.WriteLine(String.Format("{0,3}", "[" + i) + "] " + _response.DataFields[0][i]);

			Console.WriteLine();

			Console.WriteLine(_aMask.MaskString);

			for (int i = 55; i >= 0; i--)
			{
				Anime.AMask.AMaskValues flag = (Anime.AMask.AMaskValues)(ulong)Math.Pow(2, i);
				if (_aMask.Mask.HasFlag(flag))
					Console.WriteLine(flag);
			}
		}
Beispiel #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="anime">The anime object detected</param>
 /// <param name="input">The input file path</param>
 /// <param name="output">The output directory</param>
 public SortingNode(Anime anime, string input, string output)
 {
     anime_ = anime;
     input_ = input;
     output_ = Path.Combine(output, anime.AnimeTitle());
     progress_ = 0;
     task_ = null;
 }
Beispiel #4
0
 public static int CompareAnimeByName(Anime p_anime1, Anime p_anime2)
 {
     return p_anime1.Name.CompareTo(p_anime2.Name);
 }
Beispiel #5
0
 public override void Exit()
 {
     Agent.enabled = false;
     Anime.SetBool("Falling", false);
 }
 public async Task<int> DeleteAnimeAsync(Anime anime)
 {
     throw new NotImplementedException();
 }
Beispiel #7
0
 private void Sample3()
 {
     Anime.Play(new Vector3(-5f, 0f, 0f), new Vector3(5f, 0f, 0f), Easing.OutQuad(TimeSpan.FromSeconds(2f)))
     .StopRecording()
     .SubscribeToPosition(cube);
 }
Beispiel #8
0
 private void BugCheck()
 {
     Anime.Play(new Vector3(-5f, 0f, 0f), new Vector3(5f, 0f, 0f), Motion.Uniform(4f))
     .PlayRelative(new Vector3(0f, 3f, 0f), Motion.Uniform(4f))
     .SubscribeToPosition(cube);
 }
Beispiel #9
0
 public void Sample22()
 {
     Anime.Play(7.5f, 3f, Easing.OutElastic(TimeSpan.FromSeconds(1f)))
     .SubscribeToPositionY(sphere2);
 }
Beispiel #10
0
 private void Sample11()
 {
     Anime.Play(new Vector3(-5f, 0f, 0f), new Vector3(5f, 0f, 0f), Motion.From(curve, TimeSpan.FromSeconds(3f)))
     .StopRecording()
     .SubscribeToPosition(cube);
 }
Beispiel #11
0
 public AnimeFile LastEpisode(Anime anime)
 {
     return(LastEpisode(GetEpisodes(anime, EpisodeStatus.All)));
 }
 public CharactersListView(Anime anime)
 {
     InitializeComponent();
     animeDetail.BindingContext     = anime;
     charactersListView.ItemsSource = anime.Characters;
 }
Beispiel #13
0
        public async Task GetAnime([Remainder] string animetitle)
        {
            using var Database = new SkuldDbContextFactory().CreateDbContext();

            var usr = await Database
                      .InsertOrGetUserAsync(Context.User)
                      .ConfigureAwait(false);

            var loc = Locale.GetLocale(
                usr.Language ?? Locale.DefaultLocale
                );

            var raw = await Anime
                      .GetAnimeAsync(animetitle)
                      .ConfigureAwait(false);

            var data = raw.Data;

            if (data.Count > 1) // do pagination
            {
                var pages = data.PaginateList(25);

                IUserMessage sentmessage = await ReplyAsync(null, false,
                                                            EmbedExtensions
                                                            .FromMessage(
                                                                loc.GetString("SKULD_SEARCH_MKSLCTN") + " 30s",
                                                                pages[0],
                                                                Context
                                                                )
                                                            .WithColor(Color.Purple)
                                                            .Build()
                                                            ).ConfigureAwait(false);

                var response = await NextMessageAsync(
                    true,
                    true,
                    TimeSpan.FromSeconds(30)
                    ).ConfigureAwait(false);

                if (response == null)
                {
                    await sentmessage.DeleteAsync().ConfigureAwait(false);
                }

                var selection = Convert.ToInt32(response.Content);

                var anime = data[selection - 1];

                await anime
                .ToEmbed(loc)
                .QueueMessageAsync(Context)
                .ConfigureAwait(false);
            }
            else
            {
                var anime = data[0];

                await anime
                .ToEmbed(loc)
                .QueueMessageAsync(Context)
                .ConfigureAwait(false);
            }
        }
 public abstract Task <IEnumerable <RemoteMedia> > FindAllMedia(Anime anime, string name, int episode);
 public async Task <IEnumerable <RemoteMedia> > FindAllMedia(Anime anime, int episode)
 {
     return(await GetMedia(anime, episode));
 }
Beispiel #16
0
 public void DeleteAnimeCatalog(Anime anime)
 {
     context.Animes.Remove(anime);
     context.SaveChanges();
 }
Beispiel #17
0
        public async Task<bool> GetSubscriptionList()
        {
            try
            {
                HttpEngine httpRequest = new HttpEngine();
                string result = await httpRequest.GetAsync("http://api2.ricter.info/get_subscription_list?key=" + key + "&sb=Ricter&hash=" + new Random().Next());
                ErrorProcessor(result);

                subscriptionList.Clear();
                updateNumber = 0;
                string[] list = result.Split('\n');
                for (int i = 0; i < list.Length; ++i)
                {
                    string[] item = list[i].Split('|');
                    if (item.Length < 6)
                        continue;
                    Anime anime     = new Anime();
                    anime.aid       = item[0];
                    anime.name      = item[1];
                    anime.status    = item[2];
                    anime.epi       = item[3];
                    anime.read      = item[4];
                    anime.highlight = item[5];
                    subscriptionList.Add(anime);

                    if (anime.highlight != "0")
                        updateNumber++;
                }
/*
                subscriptionList.Sort((Anime x, Anime y) => 
                {
                    if (x.highlight != "0" && y.highlight == "0")
                        return -1;
                    if (x.highlight == "0" && y.highlight != "0")
                        return 0;
                    if (x.highlight != "0" && y.highlight != "0")
                    {
                        if (x.highlight == "1" && y.highlight == "2")
                            return -1;
                        if (x.highlight == "2" && y.highlight == "1")
                            return 0;
                    }
                    return -1;
                });
*/
                for (int i = 0; i < subscriptionList.Count; ++i)
                    subscriptionList[i].num = i + 1;

                return true;
            }
            catch
            {
                throw;
            }
        }
Beispiel #18
0
        private void AnimeInfo_RemarkChanged(object sender, EventArgs e)
        {
            Anime a = this.olvAnime.SelectedObject as Anime;

            this.richtxtNote.Text = (a == null ? String.Empty : a.Remark);
        }
Beispiel #19
0
 public async Task <IEnumerable <AnimeFile> > GetEpisodesAsync(Anime anime, EpisodeStatus episodeStatus)
 {
     return(await Task.Run(() => GetEpisodes(anime, episodeStatus)));
 }
Beispiel #20
0
 private void Sample19()
 {
     Anime.Play(new Vector3(0f, 0f, 0f), new Vector3(3f, 0f, 0f), new Sample19Animator())
     .PlayRelative(new Vector3(0f, 3f, 0f), Easing.Linear(TimeSpan.FromSeconds(1.0f)))
     .SubscribeToPosition(cube);
 }
 public AnimeComparisonSubEntryBuilder WithAnime(Anime anime)
 {
     _anime = anime;
     return(this);
 }
Beispiel #22
0
 public void Sample26()
 {
     Anime.PlayInOut(-5f, -2f, 2f, 5f, Easing.InCubic(TimeSpan.FromSeconds(1.0)), Easing.OutCubic(TimeSpan.FromSeconds(5.0)))
     .StopRecording()
     .SubscribeToPositionX(cube);
 }
Beispiel #23
0
        /// <summary>
        /// 运行计划任务的代理
        /// </summary>
        /// <param name="task">
        /// 调用的任务
        /// </param>
        /// <remarks>
        /// 调用定期或资源密集型任务时调用此方法
        /// </remarks>
        protected override async void OnInvoke(ScheduledTask task)
        {
            //TODO: 添加用于在后台执行任务的代码
            if (IsolatedStorageSettings.ApplicationSettings.Contains("UserKey"))
            {
                try
                {
                    DateTime TimeLast   = (DateTime)IsolatedStorageSettings.ApplicationSettings["LastUpdatedTime"];
                    DateTime TimeNow    = DateTime.Now;
                    TimeSpan TimeOffset = TimeNow - TimeLast;
                    int      TimeSet    = 0;
                    switch ((int)IsolatedStorageSettings.ApplicationSettings["UpdateInterval"])
                    {
                    case 0:
                        TimeSet = 2;
                        break;

                    case 1:
                        TimeSet = 4;
                        break;

                    case 2:
                        TimeSet = 8;
                        break;

                    case 3:
                        TimeSet = 12;
                        break;

                    case 4:
                        TimeSet = 24;
                        break;
                    }
                    if (Debugger.IsAttached || TimeOffset.TotalHours >= (double)TimeSet)
                    {
                        HttpEngine httpRequest = new HttpEngine();
                        string     result      = await httpRequest.GetAsync("http://api.anime.mmmoe.info/get_user_info?key=" + IsolatedStorageSettings.ApplicationSettings["UserKey"] + "&sb=Ricter&hash=" + new Random().Next());

                        JObject json = JObject.Parse(result);

                        List <Anime> subscriptionList = new List <Anime>();
                        int          pushNumber       = 0;
                        int          updatedNumber    = 0;
                        JArray       subscription     = json["data"]["subscription"] as JArray;
                        foreach (JObject item in subscription)
                        {
                            Anime anime = new Anime();
                            anime.name      = (string)item["name"];
                            anime.epi       = ((int)item["episode"]).ToString();
                            anime.highlight = ((int)item["isread"]).ToString();
                            subscriptionList.Add(anime);

                            if (anime.highlight != "0")
                            {
                                updatedNumber++;
                            }
                        }

                        subscriptionList.Sort((Anime x, Anime y) =>
                        {
                            if (x.highlight != "0" && y.highlight == "0")
                            {
                                return(-1);
                            }
                            if (x.highlight == "0" && y.highlight != "0")
                            {
                                return(0);
                            }
                            if (x.highlight != "0" && y.highlight != "0")
                            {
                                if (x.highlight == "1" && y.highlight == "2")
                                {
                                    return(-1);
                                }
                                if (x.highlight == "2" && y.highlight == "1")
                                {
                                    return(0);
                                }
                            }
                            return(-1);
                        });

                        if (Debugger.IsAttached)
                        {
                            for (int i = 0; i < subscriptionList.Count; ++i)
                            {
                                Debug.WriteLine(subscriptionList[i].name);
                                Debug.WriteLine(subscriptionList[i].epi);
                                Debug.WriteLine(subscriptionList[i].highlight);
                                Debug.WriteLine("----------------------------");
                            }
                        }

                        string[] TileContent = new string[3];
                        string   showName    = "";
                        if (subscriptionList.Count >= 1 && subscriptionList[0].highlight != "0")
                        {
                            TileContent[0] = "订阅更新";
                            TileContent[1] = subscriptionList[0].name + " 更新到第 " + subscriptionList[0].epi + " 集";
                            showName       = subscriptionList[0].name;
                        }
                        if (subscriptionList.Count >= 2 && subscriptionList[1].highlight != "0")
                        {
                            TileContent[2] = subscriptionList[1].name + " 更新到第 " + subscriptionList[1].epi + " 集";
                        }

                        ShellTile Tile = ShellTile.ActiveTiles.FirstOrDefault();
                        if (Tile != null)
                        {
                            var TileData = new IconicTileData()
                            {
                                Title           = "新番提醒",
                                Count           = updatedNumber,
                                BackgroundColor = System.Windows.Media.Colors.Transparent,
                                WideContent1    = TileContent[0],
                                WideContent2    = TileContent[1],
                                WideContent3    = TileContent[2]
                            };
                            Tile.Update(TileData);
                        }
                        if (pushNumber > 0)
                        {
                            ShellToast toast = new ShellToast();
                            toast.Title   = showName + " 等 " + pushNumber.ToString() + " 个订阅更新,点击查看";
                            toast.Content = "";
                            toast.Show();
                        }
                        IsolatedStorageSettings.ApplicationSettings["LastUpdatedTime"] = TimeNow;
                        IsolatedStorageSettings.ApplicationSettings.Save();
                    }
                }
                catch
                {
                }
            }
            NotifyComplete();
        }
Beispiel #24
0
 private void Sample1()
 {
     Anime.Play(new Vector3(-5f, 0f, 0f), new Vector3(5f, 0f, 0f), Motion.Uniform(4f))
     .StopRecording()
     .SubscribeToPosition(cube);
 }
Beispiel #25
0
        public MainViewConsole(MainViewController controller)
        {
            mainController = controller;
            viewCommands   = new Dictionary <string, Func <MainViewArgs> >
            {
                #region animeCRUD
                {
                    "get_all_anime",
                    () => new MainViewArgs()
                },
                {
                    "get_anime",
                    () => new MainViewArgs {
                        AnimeId = GetId()
                    }
                },
                {
                    "delete_anime",
                    () => new MainViewArgs {
                        AnimeId = GetId()
                    }
                },
                {
                    "insert_anime",//
                    () =>
                    {
                        Anime anime = GetAnimeValues(null);
                        return(new MainViewArgs {
                            Anime = anime
                        });
                    }
                },
                {
                    "update_anime",
                    () =>
                    {
                        Anime anime = mainController.GetAnime(GetId());
                        if (anime == null)
                        {
                            throw new Exception();
                        }
                        Anime anime1 = GetAnimeValues(anime);
                        return(new MainViewArgs {
                            Anime = anime1
                        });
                    }
                },
                #endregion

                #region AnimeGirls
                {
                    "AddGirlToAnime",
                    () =>
                    {
                        return(new MainViewArgs {
                            AnimeId = GetId("anime"), GirlId = GetId("girl")
                        });
                    }
                },
                {
                    "DeleteGirlFromAnime",
                    () =>
                    {
                        return(new MainViewArgs {
                            AnimeId = GetId("anime"), GirlId = GetId("girl")
                        });
                    }
                },
                {
                    "GetGirlsOfAnime",
                    () => new MainViewArgs {
                        AnimeId = GetId("anime")
                    }
                },
                #endregion

                #region AnimeProducers
                {
                    "AddProducerToAnime",
                    () =>
                    {
                        return(new MainViewArgs {
                            AnimeId = GetId("anime"), ProducerId = GetId("producer")
                        });
                    }
                },
                {
                    "DeleteProducerFromAnime",
                    () =>
                    {
                        return(new MainViewArgs {
                            AnimeId = GetId("anime"), ProducerId = GetId("producer")
                        });
                    }
                },
                {
                    "GetProducersOfAnime",
                    () => new MainViewArgs {
                        AnimeId = GetId("anime")
                    }
                },
                #endregion

                #region GirlsCRUD
                {
                    "get_girls",
                    () => new MainViewArgs()
                },
                {
                    "get_girl",
                    () => new MainViewArgs {
                        GirlId = GetId()
                    }
                },
                {
                    "delete_girl",
                    () => new MainViewArgs {
                        GirlId = GetId()
                    }
                },
                {
                    "insert_girl",
                    () =>
                    {
                        Girl girl = GetGirlValues(null);
                        return(new MainViewArgs {
                            Girl = girl
                        });
                    }
                },
                {
                    "update_girl",
                    () =>
                    {
                        Girl girl = mainController.GetGirl(GetId());
                        if (girl == null)
                        {
                            throw new Exception();
                        }
                        Girl girl1 = GetGirlValues(girl);
                        return(new MainViewArgs {
                            Girl = girl1
                        });
                    }
                },
                {
                    "get_girls_anime",
                    () => new MainViewArgs {
                        GirlId = GetId()
                    }
                },
                #endregion

                #region ProducersCRUD
                {
                    "get_producers",
                    () => new MainViewArgs()
                },
                {
                    "get_producer",
                    () => new MainViewArgs {
                        ProducerId = GetId()
                    }
                },
                {
                    "delete_producer",
                    () => new MainViewArgs {
                        ProducerId = GetId()
                    }
                },
                {
                    "insert_producer",
                    () =>
                    {
                        Producer producer = GetProducerValues(null);
                        return(new MainViewArgs {
                            Producer = producer
                        });
                    }
                },
                {
                    "update_producer",
                    () =>
                    {
                        Producer producer = mainController.GetProducer(GetId());
                        if (producer == null)
                        {
                            throw new Exception();
                        }
                        Producer producer1 = GetProducerValues(producer);
                        return(new MainViewArgs {
                            Producer = producer1
                        });
                    }
                },
                {
                    "get_producers_anime",
                    () => new MainViewArgs {
                        ProducerId = GetId()
                    }
                },
                #endregion
                {
                    "add_random_anime",
                    () => new MainViewArgs {
                        RandomCount = GetCount()
                    }
                },
                {
                    "add_random_girls",
                    () => new MainViewArgs {
                        RandomCount = GetCount()
                    }
                },
                {
                    "add_random_producers",
                    () => new MainViewArgs {
                        RandomCount = GetCount()
                    }
                },
                {
                    "add_random_links_ga",
                    () => new MainViewArgs {
                        RandomCount = GetCount()
                    }
                },
                {
                    "add_random_links_ap",
                    () => new MainViewArgs {
                        RandomCount = GetCount()
                    }
                },
                {
                    "search1",
                    () => new MainViewArgs
                    {
                        SearchOneParameters = new SearchOneParameters
                        {
                            MinSeries = GetInt("Enter minimum series in title:"),
                            MinWorks  = GetInt("Enter minimum producer's works:"),
                            Name      = GetStr("Enter girl's name:")
                        }
                    }
                },
                {
                    "search2",
                    () => new MainViewArgs
                    {
                        SearchTwoParameters = new SearchTwoParameters
                        {
                            MinRating = GetDouble("Enter minimal title's rating(0.00 - 10.00):"),
                            MinAge    = GetInt("Enter minimum girl's age:"),
                            MaxAge    = GetInt("Enter maximum girl's age:"),
                        }
                    }
                },
                {
                    "search3",
                    () => new MainViewArgs
                    {
                        SearchThreeParameters = new SearchThreeParameters
                        {
                            Name    = GetStr("Enter producer's name:"),
                            MinYear = GetInt("Enter minimum anime year:"),
                            MaxYear = GetInt("Enter maximum anime year:"),
                        }
                    }
                },
                {
                    "MRA",
                    () => new MainViewArgs()
                },
                {
                    "RC",
                    () => new MainViewArgs {
                        AnimeId = GetId()
                    }
                },
                {
                    "BS",
                    () => new MainViewArgs()
                },
            };
        }
Beispiel #26
0
 public FavoritedAnime(Anime anime)
 {
     Anime  = anime;
     IsNSFW = UTIL.AnimeExtension.HasAnySpecifiedGenresAsync(this, UTIL.AnimeExtension.FillNSFWGenres().Select(p => p.Genre).ToArray()).Result;
 }
 public void addAnimeToList(Anime anime)
 {
     animeList.Add(anime.getTitle(), anime);
 }
        public Anime Get(int id)
        {
            Anime anime = new Anime();

            return(anime.Index().Where(x => x.id == id).FirstOrDefault());
        }
Beispiel #29
0
 public override void Enter()
 {
     Agent.enabled = true;
     Anime.SetBool("Falling", true);
     timer = 0;
 }
 public Task<int> UpdateAnimeAsync(Anime anime)
 {
     throw new NotImplementedException();
 }
 public Anime Post([FromBody] Anime anime)
 {
     return(anime.Store(anime));
 }
        /// <summary>
        /// 运行计划任务的代理
        /// </summary>
        /// <param name="task">
        /// 调用的任务
        /// </param>
        /// <remarks>
        /// 调用定期或资源密集型任务时调用此方法
        /// </remarks>
        protected override async void OnInvoke(ScheduledTask task)
        {
            //TODO: 添加用于在后台执行任务的代码
            if (IsolatedStorageSettings.ApplicationSettings.Contains("UserKey"))
            {
                try
                {
                    DateTime TimeLast = (DateTime)IsolatedStorageSettings.ApplicationSettings["LastUpdatedTime"];
                    DateTime TimeNow = DateTime.Now;
                    TimeSpan TimeOffset = TimeNow - TimeLast;
                    int TimeSet = 0;
                    switch ((int)IsolatedStorageSettings.ApplicationSettings["UpdateInterval"])
                    {
                        case 0:
                            TimeSet = 2;
                            break;
                        case 1:
                            TimeSet = 4;
                            break;
                        case 2:
                            TimeSet = 8;
                            break;
                        case 3:
                            TimeSet = 12;
                            break;
                        case 4:
                            TimeSet = 24;
                            break;
                    }
                    if (Debugger.IsAttached || TimeOffset.TotalHours >= (double)TimeSet)
                    {
                        HttpEngine httpRequest = new HttpEngine();
                        string result = await httpRequest.GetAsync("http://api2.ricter.info/get_subscription_list?key=" + IsolatedStorageSettings.ApplicationSettings["UserKey"] + "&hash=" + new Random().Next());
/*
                        string result = await httpRequest.GetAsync("http://apianime.ricter.info/get_subscription_list?key=" + IsolatedStorageSettings.ApplicationSettings["UserKey"] + "&hash=" + new Random().Next());
                        if (result.Contains("ERROR_"))
                        {
                            throw new Exception(result);
                        }
                        string[] list = result.Split('\n');
                        int updatedNumber = 0;
                        string[] TileContent = new string[3] { "", "", "" };
                        string ShowName = "";
                        for (int i = 0; i < list.Length; ++i)
                        {
                            string[] item = list[i].Split('|');
                            if (item.Length < 5)
                                continue;
                            string isUpdate = item[0];
                            string name     = item[2];
                            string epi      = item[3];
                            if (isUpdate == "1")
                            {
                                updatedNumber++;
                                if (updatedNumber == 1)
                                {
                                    TileContent[0] = "订阅更新";
                                    TileContent[1] = name + " 更新到第 " + epi + " 集";
                                    ShowName = name;
                                }
                                else if (updatedNumber == 2)
                                {
                                    TileContent[2] = name + " 更新到第 " + epi + " 集";
                                }
                            }
                        }
*/
                        List<Anime> subscriptionList = new List<Anime>();
                        int pushNumber = 0;
                        int updatedNumber = 0;
                        string[] list = result.Split('\n');
                        for (int i = 0; i < list.Length; ++i)
                        {
                            string[] item = list[i].Split('|');
                            if (item.Length < 6)
                                continue;
                            Anime anime     = new Anime();
                            anime.name      = item[1];
                            anime.epi       = item[3];
                            anime.highlight = item[5];
                            subscriptionList.Add(anime);

                            if (anime.highlight == "1")
                                pushNumber++;
                            if (anime.highlight != "0")
                                updatedNumber++;
                        }

                        subscriptionList.Sort((Anime x, Anime y) =>
                        {
                            if (x.highlight != "0" && y.highlight == "0")
                                return -1;
                            if (x.highlight == "0" && y.highlight != "0")
                                return 0;
                            if (x.highlight != "0" && y.highlight != "0")
                            {
                                if (x.highlight == "1" && y.highlight == "2")
                                    return -1;
                                if (x.highlight == "2" && y.highlight == "1")
                                    return 0;
                            }
                            return -1;
                        });

                        if (Debugger.IsAttached)
                        {
                            for (int i = 0; i < subscriptionList.Count; ++i)
                            {
                                Debug.WriteLine(subscriptionList[i].name);
                                Debug.WriteLine(subscriptionList[i].epi);
                                Debug.WriteLine(subscriptionList[i].highlight);
                                Debug.WriteLine("----------------------------");
                            }
                        }

                        string[] TileContent = new string[3];
                        string showName = "";
                        if (subscriptionList.Count >= 1 && subscriptionList[0].highlight != "0")
                        {
                            TileContent[0] = "订阅更新";
                            TileContent[1] = subscriptionList[0].name + " 更新到第 " + subscriptionList[0].epi + " 集";
                            showName = subscriptionList[0].name;
                        }
                        if (subscriptionList.Count >= 2 && subscriptionList[1].highlight != "0")
                        {
                            TileContent[2] = subscriptionList[1].name + " 更新到第 " + subscriptionList[1].epi + " 集";
                        }

                        ShellTile Tile = ShellTile.ActiveTiles.FirstOrDefault();
                        if (Tile != null)
                        {
                            var TileData = new IconicTileData()
                            {
                                Title = "新番提醒",
                                Count = updatedNumber,
                                BackgroundColor = System.Windows.Media.Colors.Transparent,
                                WideContent1 = TileContent[0],
                                WideContent2 = TileContent[1],
                                WideContent3 = TileContent[2]
                            };
                            Tile.Update(TileData);
                        }
                        if (pushNumber > 0)
                        {
                            ShellToast toast = new ShellToast();
                            toast.Title = showName + " 等 " + pushNumber.ToString() + " 个订阅更新,点击查看";
                            toast.Content = "";
                            toast.Show();
                        }
                        IsolatedStorageSettings.ApplicationSettings["LastUpdatedTime"] = TimeNow;
                        IsolatedStorageSettings.ApplicationSettings.Save();
                    }
                }
                catch
                {

                }
            }
            NotifyComplete();
        }
 public Anime Put(int id, [FromBody] Anime anime)
 {
     return(anime.Update(id, anime));
 }
        public bool Delete(int id)
        {
            Anime _anime = new Anime();

            return(_anime.Destroy(id));
        }
 public JikanServiceBuilder WithAnimeReturned(Anime anime)
 {
     JikanClient.Setup(x => x.GetAnime(It.IsAny <long>()))
     .ReturnsAsync(anime);
     return(this);
 }
Beispiel #36
0
        public async Task<bool> GetUpdateSchedule()
        {
            try
            {
                HttpEngine httpRequest = new HttpEngine();
                string result = await httpRequest.GetAsync("http://api2.ricter.info/get_update_schedule?hash=" + new Random().Next());

                scheduleList.Clear();
                string[] list = result.Split('\n');
                for (int i = 0; i < list.Length; ++i)
                {
                    string[] item = list[i].Split('|');
                    if (item.Length < 4)
                        continue;
                    Anime anime = new Anime();
                    anime.date  = item[0];
                    anime.aid   = item[1];
                    anime.name  = item[2];
                    anime.time  = item[3];
                    scheduleList.Add(anime);
                }

                for (int i = 0; i < scheduleList.Count; ++i)
                    scheduleList[i].num = i + 1;

                return true;
            }
            catch
            {
                throw;
            }
        }
Beispiel #37
0
        public async Task <Anime> GetAnime(string slug)
        {
            var encodedSlug = WebUtility.UrlEncode(slug);
            var json        = await HttpGet($"https://kitsu.io/api/edge/anime?filter[slug]={encodedSlug}&include=genres,productions.company,animeProductions.producer,episodes,streamingLinks,characters.character");

            var attributes = json["data"][0]["attributes"];
            var included   = json["included"] as JArray;

            var animeEpisodes = included.Where(o => o.Value <string>("type") == "episodes")
                                .Select(o => o["attributes"])
                                .Select(e => new Episode
            {
                Title         = e.ValueOrDefault <string>("canonicalTitle"),
                Synopsis      = e.ValueOrDefault <string>("synopsis"),
                SeasonNumber  = e.ValueOrDefault <int>("seasonNumber"),
                EpisodeNumber = e.ValueOrDefault <int>("relativeNumber"),
                Length        = e.ValueOrDefault <int>("length"),
                ThumbnailUrl  = e["thumbnail"].ValueOrDefault <string>("original"),
                AirDate       = e.ValueOrDefault <DateTime>("airdate")
            }).ToList();

            var animeCharacters = included.Where(o => o.Value <string>("type") == "characters")
                                  .Select(o => o["attributes"])
                                  .Select(c => new Character
            {
                Name        = c.ValueOrDefault <string>("name"),
                Slug        = c.ValueOrDefault <string>("slug"),
                Description = c.ValueOrDefault <string>("description").StripHtml(),
                ImageUrl    = c["image"].ValueOrDefault <string>("original")
            }).ToList();

            var animeStreamingLinks = included.Where(o => o.Value <string>("type") == "streamingLinks")
                                      .Select(o => o["attributes"])
                                      .Select(l => new StreamingLink
            {
                Url             = l.ValueOrDefault <string>("url"),
                SubbedLanguages = (l["subs"] as JArray)?.Select(c => c.Value <string>()).ToList(),
                DubbedLanguages = (l["dubs"] as JArray)?.Select(c => c.Value <string>()).ToList()
            }).ToList();

            var animeGenres = included.Where(o => o.Value <string>("type") == "genres")
                              .Select(o => o["attributes"])
                              .Select(g => new Genre
            {
                Name = g.ValueOrDefault <string>("name"),
                Slug = g.ValueOrDefault <string>("slug")
            }).ToList();

            var animeStudios = included.Where(o => o.Value <string>("type") == "producers")
                               .Select(o => o["attributes"])
                               .Select(s => new Studio
            {
                Name = s.ValueOrDefault <string>("name"),
                Slug = s.ValueOrDefault <string>("slug")
            }).ToList();

            var anime = new Anime
            {
                Episodes       = animeEpisodes,
                Characters     = animeCharacters,
                StreamingLinks = animeStreamingLinks,
                Genres         = animeGenres,
                Studios        = animeStudios
            };

            ReadCoreAnimeInfo(anime, attributes);

            if (anime.EpisodeCount == 0)
            {
                anime.EpisodeCount = anime.Episodes.Count();
            }

            if (anime.TotalLength == 0)
            {
                anime.TotalLength = anime.EpisodeCount * anime.EpisodeLength;
            }

            return(anime);
        }