Ejemplo n.º 1
0
        public async Task <PhosResponse> PostWebhook()
        {
            if (!ModelState.IsValid)
            {
                return(new PhosResponse {
                    MalResult = false, AniListResult = false
                });
            }

            var content = await this.Request.Content.ReadAsStringAsync();

            PlexRequest plexRequest = new PlexRequest();

            try
            {
                plexRequest = JsonConvert.DeserializeObject <PlexRequest>(PlexManager.ParseJsonFromWebhook(content));
            }
            catch (JsonSerializationException jse)
            {
                Logger.CreateLogEntry(Enumerations.LogType.Error, jse, DateTime.Now);
                return(new PhosResponse {
                    MalResult = false, AniListResult = false
                });
            }

            Logger.CreateLogEntry(Enumerations.LogType.Info, $"Incoming event ({plexRequest.Event}) from {plexRequest.Account.Title} for episode {plexRequest.Metadata.Index} of {plexRequest.Metadata.GrandparentTitle}", DateTime.Now);

            values = RegisterValues.GetRegisteredValues();

            bool malResult = false, aniListResult = false;

            if (plexRequest.Event.Equals("media.scrobble"))
            {
                // MAL
                malResult = MyAnimeListManager.UpdateList(values, plexRequest);

                // AniList
                aniListResult = await AniListManager.UpdateListAsync(values, plexRequest);

                Logger.CreateLogEntry(Enumerations.LogType.Scrobble, $"Finished watching episode {plexRequest.Metadata.Index} of {plexRequest.Metadata.GrandparentTitle}", DateTime.Now);
            }

            return(new PhosResponse {
                MalResult = malResult, AniListResult = aniListResult
            });
        }
Ejemplo n.º 2
0
 public async Task <bool> GetAniListToken()
 {
     values = RegisterValues.GetRegisteredValues();
     return(await AniListManager.UpdateListAsync(values, new PlexRequest()));
 }