Jump to content

LibraryManager AddVirtualFolder


Recommended Posts

bakes82

Error:

Task AddVirtualFolder(
      string name,
      ReadOnlyMemory<char> collectionType,
      LibraryOptions options,
      bool refreshLibrary);

 

System.MissingMethodException: System.MissingMethodException: Method not found: 'System.Threading.Tasks.Task MediaBrowser.Controller.Library.ILibraryManager.AddVirtualFolder(System.String, System.ReadOnlyMemory`1<Char>, MediaBrowser.Model.Configuration.LibraryOptions, Boolean)'.

 

Is this method suppose to tie to the image below?  Whats the collectiontype?

image.thumb.png.d1749445b589cee46053ef6c08fb5032.png

Link to post
Share on other sites
Luke

Please attach the emby server log. But really I would just use the web interface to configure your libraries because this was endpoint was not meant to be used ad-hoc and therefore hasn't been tested that way.

Link to post
Share on other sites
bakes82

Whats the point of the API then?  How do I automate making a library/collection from a list?  I did attach the server log error, its the method not found.

 

Link to post
Share on other sites
Luke

Adding and removing libraries is a less frequently used function, so that's the only reason I said that. If you really want to do this then I would suggest monitoring what the web app does using the Chrome debugger and then mimic it.

Link to post
Share on other sites
Luke
7 minutes ago, bakes82 said:

I did attach the server log error, its the method not found.

 

  • You attached a snippet, and from how to report a problem, we ask that you: "Please supply the full and complete log file, and avoid attempting to extract relevant sections. Everything is relevant to us. When you attach the log, please also discuss what actions you took, and what the results were."

 

Link to post
Share on other sites
bakes82

Why would I monitor the chrome api?  Isnt the api layer suppose to do all this for me, why should I reinvent the rest calls in c#?  Whats the process to create a channel/collection from the c# plugin api?

 

var traktUser = UserHelper.GetTraktUser(user);

            /*var channel = _libraryManager.GetItemList(new InternalItemsQuery
            {
                Name = "Test"
            });*/
            
            try
            {
                var data = await _traktApi.GetTraktUserListItems(traktUser, "movistapp", "horror", cancellationToken);

                _logger.Info($"Count of items on list {data.Count}");
                //_logger.Info(_jsonSerializer.SerializeToString(data));

                var mediaItems =
                    _libraryManager.GetItemList(
                            new InternalItemsQuery(user)
                            {
                                IncludeItemTypes = new[] {nameof(Movie), nameof(Episode)},
                                IsVirtualItem = false,
                                OrderBy = new[]
                                {
                                    new ValueTuple<string, SortOrder>(ItemSortBy.SeriesSortName, SortOrder.Ascending),
                                    new ValueTuple<string, SortOrder>(ItemSortBy.SortName, SortOrder.Ascending)
                                }
                            })
                        .ToList();
                
                _logger.Info($"Count of items in emby {mediaItems.Count}");

                var newItems = new List<ChannelItemInfo>();
                var paths = new List<MediaPathInfo>();

                foreach (var movie in mediaItems.OfType<Movie>())
                {
                    _logger.Info($"Movie {movie.Name}");
                    cancellationToken.ThrowIfCancellationRequested();
                    var foundMovie = Match.FindMatch(movie, data);

                    if (foundMovie != null)
                    {
                        _logger.Info($"Movie {movie.Name} found");
                        
                        var embyMove = _libraryManager.GetItemById(movie.Id);
                        if (embyMove != null)
                        {
                            _logger.Info($"Emby Movie {embyMove.Name}");
                            var path = new MediaPathInfo()
                            {
                                Path = movie.Path
                            };
                            var newMovie = new ChannelItemInfo
                            {
                                Name = embyMove.Name,
                                ImageUrl = embyMove.PrimaryImagePath,
                                Id = embyMove.Id.ToString(),
                                Type = ChannelItemType.Media,
                                ContentType = ChannelMediaContentType.Movie,
                                MediaType = ChannelMediaType.Video,
                                IsLiveStream = false,
                                MediaSources = new List<MediaSourceInfo>
                                {
                                    new ChannelMediaInfo
                                        {Path = embyMove.Path, Protocol = MediaProtocol.File}.ToMediaSource()
                                },
                                OriginalTitle = embyMove.OriginalTitle
                            };
                            newItems.Add(newMovie);
                            paths.Add(path);
                        }
                    }
                    else
                    {
                        _logger.Info($"Movie {movie.Name} not found");
                    }
                }
                
                _logger.Info($"Count of items in List to add {newItems.Count}");
                var libOptions = new LibraryOptions
                {
                    ContentType = "channel",
                    PathInfos = paths.ToArray()
                };

                
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    _logger.Error(ex.Message + " " + ex.InnerException.Message);
                }
                else
                {
                    _logger.Error(ex.Message);
                }
            }

 

 

Link to post
Share on other sites
Luke

Because swagger can tell you the params, but over time newer endpoints or params might be added that are intended to be used instead, or sometimes there are different combinations of params depending on circumstances.

Anyway you don't use the web api from a plugin, you use the internal plugin api's. 

If you'd like to create a Channel, these are all examples you can look at:

https://github.com/MediaBrowser/TuneIn

https://github.com/MediaBrowser/Tou.tv

https://github.com/MediaBrowser/IPTV

Link to post
Share on other sites
bakes82

I dont know what a channel is, or a collection or a playlist.  What makes a channel unique?  Can I have 1 method that makes 40 channels?  How is it dynamic.   I looked at the one by Chef for new requests but everything seems static,  If on the UI I want them to make N channels is that possible?   Or is a collection better?   Basically I want something that shows on the main screen like "Movies"

I can see that my code is working for retreiving the list data from trakt and the matching works, I just  need the "right" way to make a new grouping so I can make it appear.

 

2020-10-20 14:41:59.054 Info HttpClient: POST https://api.trakt.tv/oauth/token
2020-10-20 14:41:59.294 Info HttpClient: GET https://api.trakt.tv/users/movistapp/lists/horror/items/
2020-10-20 14:41:59.384 Info Trakt: Count of items on list 200
2020-10-20 14:41:59.649 Info Trakt: Count of items in emby 2456
2020-10-20 14:41:59.649 Info Trakt: Movie #cats_the_mewvie
2020-10-20 14:41:59.651 Info Trakt: Movie #cats_the_mewvie not found
2020-10-20 14:41:59.651 Info Trakt: Movie 2 Guns
2020-10-20 14:41:59.651 Info Trakt: Movie 2 Guns not found
2020-10-20 14:41:59.651 Info Trakt: Movie 3 Days to Kill
2020-10-20 14:41:59.651 Info Trakt: Movie 3 Days to Kill not found
2020-10-20 14:41:59.651 Info Trakt: Movie 3 Days with Dad
2020-10-20 14:41:59.652 Info Trakt: Movie 3 Days with Dad not found
2020-10-20 14:41:59.652 Info Trakt: Movie 3 from Hell
2020-10-20 14:41:59.652 Info Trakt: Movie 3 from Hell not found
2020-10-20 14:41:59.660 Info Trakt: Movie Alice Through the Looking Glass
2020-10-20 14:41:59.660 Info Trakt: Movie Alice Through the Looking Glass not found
2020-10-20 14:41:59.660 Info Trakt: Movie Alien
2020-10-20 14:41:59.660 Info Trakt: Movie Alien found
2020-10-20 14:41:59.661 Info Trakt: Emby Movie Alien
2020-10-20 14:41:59.664 Info Trakt: Movie Alien Outbreak
2020-10-20 14:41:59.664 Info Trakt: Movie Alien Outbreak found
2020-10-20 14:41:59.664 Info Trakt: Emby Movie Alien Outbreak
2020-10-20 14:41:59.664 Info Trakt: Movie Alien: Covenant
2020-10-20 14:41:59.664 Info Trakt: Movie Alien: Covenant found
2020-10-20 14:41:59.665 Info Trakt: Emby Movie Alien: Covenant
2020-10-20 14:41:59.665 Info Trakt: Movie Alita: Battle Angel
2020-10-20 14:41:59.665 Info Trakt: Movie Alita: Battle Angel not found
2020-10-20 14:41:59.665 Info Trakt: Movie All Creatures Here Below
2020-10-20 14:41:59.665 Info Trakt: Movie All Creatures Here Below not found
2020-10-20 14:41:59.665 Info Trakt: Movie All Eyez on Me
2020-10-20 14:41:59.665 Info Trakt: Movie All Eyez on Me not found
2020-10-20 14:41:59.665 Info Trakt: Movie All in My Family
2020-10-20 14:41:59.665 Info Trakt: Movie All in My Family not found
2020-10-20 14:41:59.665 Info Trakt: Movie All Is Bright
2020-10-20 14:41:59.665 Info Trakt: Movie All Is Bright not found
2020-10-20 14:41:59.665 Info Trakt: Movie All Is True
2020-10-20 14:41:59.665 Info Trakt: Movie All Is True not found
2020-10-20 14:41:59.665 Info Trakt: Movie All the Devil's Men
2020-10-20 14:41:59.665 Info Trakt: Movie All the Devil's Men not found
2020-10-20 14:41:59.935 Info Trakt: Count of items in List to add 45
Link to post
Share on other sites
bakes82
Just now, Luke said:

Is the content also in your emby library?

Yes, I want the 45 matched items to now appear in a group called "Horror Movies".

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...