Ejemplo n.º 1
0
        private void UserManager_UserDataSaved(object sender, UserDataSaveEventArgs e)
        {
            if (e.SaveReason != UserDataSaveReason.UpdateUserRating)
            {
                return;
            }
            if (!e.Item.IsFavoriteOrLiked(e.User))
            {
                return;
            }

            var config = Plugin.Instance.Configuration;

            if (!config.UserPostsOptIn.Contains(e.User.Id))
            {
                return;
            }

            var type    = e.Item.GetType();
            var item    = type.Name == "Episode" ? LibraryManager.GetItemById(e.Item.Parent.Parent.InternalId) : e.Item;
            var message = $"{e.User.Name} likes the {type.Name}: {e.Item.Name} ";

            message += type.Name == "Episode" ? $" from the series {item.Name}" : "";

            var data = new Payload
            {
                message  = message,
                url      = $"{WanAddress}/emby/Items/{item.InternalId}/Images/Primary?maxHeight=1108&maxWidth=800&quality=90",
                endpoint = "me/photos"
            };

            FacebookClient.PostToPage(data, Logger, HttpClient, config);
        }
Ejemplo n.º 2
0
        private void SessionManager_PlaybackStart(object sender, PlaybackProgressEventArgs e)
        {
            // ReSharper disable once ComplexConditionExpression
            if (e.MediaInfo.RunTimeTicks != null && (e.Item.MediaType == MediaType.Video && e.MediaInfo.RunTimeTicks.Value < IntroOrVideoBackDrop))
            {
                return;
            }

            var config = Plugin.Instance.Configuration;

            if (!config.UserPostsOptIn.Exists(id => id.ToString().Replace("-", string.Empty) == e.Session.UserId))
            {
                return;                                                                                                   //Somethings wrong here!!
            }
            var type    = e.Item.GetType();
            var item    = type.Name == "Episode" ? LibraryManager.GetItemById(e.Item.Parent.ParentId) : e.Item;
            var message = $"{e.Session.UserName} is watching the {e.MediaInfo.Type}:  {e.Item.Name} ";

            message += e.MediaInfo.Type == "Episode" ? $" from the series {item.Name}" : "";

            var data = new Payload
            {
                message  = message,
                url      = $"{WanAddress}/emby/Items/{item.InternalId}/Images/Primary?maxHeight=1108&amp;maxWidth=800&amp;quality=90",
                endpoint = "me/photos"
            };

            FacebookClient.PostToPage(data, Logger, HttpClient, config);
        }
        public async Task Execute(CancellationToken cancellationToken, IProgress <double> progress)
        {
            //var systemInfo = await Host.GetPublicSystemInfo(CancellationToken.None);
            //WanAddress = systemInfo.WanAddress;

            var ids = LibraryManager.GetInternalItemIds(new InternalItemsQuery()
            {
                IncludeItemTypes = new[] { "Movie", "Episode" },
                MinDateCreated   = DateTime.Now.AddDays(-7),
                Limit            = 8
            });

            if (ids.Any())
            {
                var data = new Payload();

                foreach (var id in ids)
                {
                    var item = LibraryManager.GetItemById(id);

                    if (item.GetType().Name == "Episode")
                    {
                        data.message += $"• {item.Name} from the series {item.Parent.Parent.Name}\n";
                        continue;
                    }
                    data.message += $"• {item.Name}\n";
                    //data.url = "https://images.unsplash.com/photo-1564923867983-41d586b10e54?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80";
                }

                data.url      = "https://images.unsplash.com/photo-1564923867983-41d586b10e54?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80";
                data.endpoint = "me/photos";

                FacebookClient.PostToPage(data, Logger, HttpClient, Plugin.Instance.Configuration);
            }
            progress.Report(100.0);
        }