Exemplo n.º 1
0
        private string CreateNewPlaylist(SmartPlaylistDto dto, User user)
        {
            var req = new PlaylistCreationRequest
            {
                Name   = dto.Name,
                UserId = user.Id,
            };
            var foo = _playlistManager.CreatePlaylist(req);

            return(foo.Result.Id);
        }
Exemplo n.º 2
0
        public async Task <object> Post(CreatePlaylist request)
        {
            var result = await _playlistManager.CreatePlaylist(new PlaylistCreationRequest
            {
                Name       = request.Name,
                ItemIdList = SplitValue(request.Ids, ','),
                UserId     = request.UserId,
                MediaType  = request.MediaType
            }).ConfigureAwait(false);

            return(ToOptimizedResult(result));
        }
Exemplo n.º 3
0
        public async Task <object> Post(CreatePlaylist request)
        {
            var result = await _playlistManager.CreatePlaylist(new PlaylistCreationRequest
            {
                Name       = request.Name,
                ItemIdList = (request.Ids ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToList(),
                UserId     = request.UserId,
                MediaType  = request.MediaType
            }).ConfigureAwait(false);

            return(ToOptimizedResult(result));
        }
Exemplo n.º 4
0
        public async Task <ActionResult <PlaylistCreationResult> > CreatePlaylist(
            [FromBody, Required] CreatePlaylistDto createPlaylistRequest)
        {
            var result = await _playlistManager.CreatePlaylist(new PlaylistCreationRequest
            {
                Name       = createPlaylistRequest.Name,
                ItemIdList = createPlaylistRequest.Ids,
                UserId     = createPlaylistRequest.UserId,
                MediaType  = createPlaylistRequest.MediaType
            }).ConfigureAwait(false);

            return(result);
        }
        private void NewPlaylist(object sender, RoutedEventArgs e)
        {
            var dialog = new AddPlaylist();

            dialog.ShowDialog();

            if (dialog.DialogResult == true)
            {
                var playlist = new Playlist
                {
                    Name  = dialog.TextBox.Text,
                    Songs = new List <string>()
                };
                _playlistManager.CreatePlaylist(playlist);
            }
            ShowPlaylists(sender, e);
        }
Exemplo n.º 6
0
        public object Post(CreatePlaylist request)
        {
            var task = _playlistManager.CreatePlaylist(new PlaylistCreationOptions
            {
                Name       = request.Name,
                ItemIdList = (request.Ids ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToList(),
                UserId     = request.UserId
            });

            var item = task.Result;

            var dto = _dtoService.GetBaseItemDto(item, new List <ItemFields>());

            return(ToOptimizedResult(new PlaylistCreationResult
            {
                Id = dto.Id
            }));
        }
        public async Task UpdateAsync(UserPlaylist playlist, BaseItem[] newItems)
        {
            var playlistItems = playlist.GetItems();

            if (playlist is LibraryUserPlaylist libraryUserPlaylist)
            {
                RemoveFromPlaylist(libraryUserPlaylist, playlistItems);
                AddToPlaylist(libraryUserPlaylist, newItems);
            }
            else if (newItems.Any())
            {
                await _playlistManager.CreatePlaylist(new PlaylistCreationRequest
                {
                    ItemIdList = newItems.Select(x => x.InternalId).ToArray(),
                    Name       = playlist.Name,
                    UserId     = playlist.User.InternalId
                }).ConfigureAwait(false);
            }
        }
Exemplo n.º 8
0
        public async Task <IActionResult> PostPlaylist(PlaylistCreateRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(StatusCode(400));
            }

            var dto = _mapper.Map <PlaylistCreateDTO>(request);

            dto.DateCreated = DateTime.Now;
            dto.OwnerId     = GetUser();

            if (await _manager.CreatePlaylist(dto))
            {
                return(StatusCode(201));
            }

            throw new Exception();
        }
Exemplo n.º 9
0
        public async System.Threading.Tasks.Task Execute(CancellationToken cancellationToken, IProgress <double> progress)
        {
            if (VersionCheck.IsVersionValid(_appHost.ApplicationVersion, _appHost.SystemUpdateLevel) == false)
            {
                _logger.Info("ERROR : Plugin not compatible with this server version");
                return;
            }

            // query the user playback info for the most active movies
            ActivityRepository    repository = new ActivityRepository(_logger, _config.ApplicationPaths, _fileSystem);
            ReportPlaybackOptions config     = _config.GetReportPlaybackOptions();

            foreach (var activity_playlist in config.ActivityPlaylists)
            {
                string list_name = activity_playlist.Name;
                string list_type = activity_playlist.Type;
                int    list_days = activity_playlist.Days;
                int    list_size = activity_playlist.Size;

                _logger.Info("Activity Playlist - Name:" + list_name + " Type:" + list_type + " Days:" + list_days);

                string sql = "";
                sql += "SELECT ItemId, ";
                sql += "COUNT(DISTINCT(UserId)) as count, ";
                sql += "AVG(CAST(strftime('%Y%m%d%H%M', 'now', 'localtime') AS int) - CAST(strftime('%Y%m%d%H%M', DateCreated) AS int)) as av_age ";
                sql += "FROM PlaybackActivity ";
                sql += "WHERE ItemType = '" + list_type + "' ";
                sql += "AND DateCreated > datetime('now', '-" + list_days + " day', 'localtime') ";
                sql += "GROUP BY ItemId ";
                sql += "ORDER BY count DESC, av_age ASC ";
                sql += "LIMIT " + list_size;

                List <string>         cols          = new List <string>();
                List <List <Object> > query_results = new List <List <object> >();
                repository.RunCustomQuery(sql, cols, query_results);

                List <long> items = new List <long>();
                foreach (List <Object> row in query_results)
                {
                    long item_id = long.Parse((string)row[0]);
                    items.Add(item_id);
                }

                // create a playlist with the most active movies
                string             playlist_name = list_name;
                InternalItemsQuery query         = new InternalItemsQuery();
                query.IncludeItemTypes = new string[] { "Playlist" };
                query.Name             = playlist_name;

                BaseItem[] results = _libraryManager.GetItemList(query, false);
                foreach (BaseItem item in results)
                {
                    _logger.Info("Deleting Existing Movie Playlist : " + item.InternalId);
                    DeleteOptions delete_options = new DeleteOptions();
                    delete_options.DeleteFileLocation = true;
                    _libraryManager.DeleteItem(item, delete_options);
                }

                _logger.Info("Creating Movie Playlist");
                PlaylistCreationRequest create_options = new PlaylistCreationRequest();
                create_options.Name = playlist_name;

                if (list_type == "Movie")
                {
                    create_options.MediaType = "Movie";
                }
                else
                {
                    create_options.MediaType = "Episode";
                }

                create_options.ItemIdList = items.ToArray();
                await _playlistman.CreatePlaylist(create_options).ConfigureAwait(false);
            }
        }
Exemplo n.º 10
0
            public void CreatePlaylist()
            {
                _playlistManager.CreatePlaylist(playlist2);

                Assert.Contains(playlist2, _playlistManager.GetAllPlaylists().ToList());
            }