mike99mac 6 Posted July 21, 2022 Posted July 21, 2022 Hi, I'm trying to learn the Emby RESTful API. I tried this call, but got an error: curl -k "http://192.168.1.229:8096/Artists/Adele?Recursive=true&format=json&api_key=$myKey" Object reference not set to an instance of an object. Saw this in the log file: 2022-07-21 13:05:01.816 Error Server: Error processing request *** Error Report *** Version: 4.7.5.0 Command line: /opt/emby-server/system/EmbyServer.dll -programdata /var/lib/emby -ffdetect /opt/emby-server/bin/ffdetect -ffmpeg /opt/emby-server/bin/ffmpeg -ffprobe /opt/emby-server/bin/ffprobe -restartexitcode 3 -updatepackage emby-server-deb_{version}_arm64.deb Operating system: Linux version 5.15.0-1005-raspi (buildd@bos02-arm64-056) (gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #5-Ubuntu SMP P Framework: .NET 6.0.2 OS/Process: arm64/arm64 Runtime: opt/emby-server/system/System.Private.CoreLib.dll Processor count: 4 Data path: /var/lib/emby Application path: /opt/emby-server/system System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object. at Emby.Server.Implementations.Dto.DtoService.AttachPeople(BaseItemDto dto, BaseItem item, DtoOptions options) at Emby.Server.Implementations.Dto.DtoService.GetBaseItemDtoInternal(BaseItem item, DtoOptions options, User user) at Emby.Server.Implementations.Dto.DtoService.GetBaseItemDto(BaseItem item, DtoOptions options, User user) at Emby.Api.UserLibrary.ArtistsService.GetItem(GetArtist request) at Emby.Server.Implementations.Services.ServiceController.Execute(HttpListenerHost appHost, Object requestDto, IRequest req) at Emby.Server.Implementations.Services.ServiceHandler.ProcessRequestAsync(HttpListenerHost appHost, IRequest httpReq, IResponse httpRes, RestPath restPath, String responseContentType, CancellationToken cancellationToken) at Emby.Server.Implementations.HttpServer.HttpListenerHost.RequestHandler(IRequest httpReq, ReadOnlyMemory`1 urlString, ReadOnlyMemory`1 localPath, CancellationToken cancellationToken) Source: Emby.Server.Implementations TargetSite: Void AttachPeople(MediaBrowser.Model.Dto.BaseItemDto, MediaBrowser.Controller.Entities.BaseItem, MediaBrowser.Controller.Dto.DtoOptions) I thought somebody might be interested. Let me back up and introduce myself. I'm working on a project called "Smart Boomboxes" that's trying to put Emby and Mycroft, etc onto Ubuntu 22.04 on a Raspberry Pi inside of a boombox. So it's either a real smart boombox, or a general purpose computer with great sound. The goal is to play music by voice. The problem is that Mycroft's Emby skill is not that great. I can say "Hey Mycroft ... play {artist}" and that usually works, but I can't say "Hey Mycroft ... play track {track} by artist {artist}". I'm trying to fix that (I don't believe the issue is in the emby.rickyphewitt skill, but the in mycroft-playback-control.mycroftai). I have looked at the Swagger API docs, but there aren't a lot of examples. If Mycroft were to call an API asking for "track {track} by artist {artist}", what might a URI look like? Thanks in advance. -Mike Mac
Luke 42078 Posted July 21, 2022 Posted July 21, 2022 HI, you can query tracks by artist id. If all you have is artist name, then the first thing to do is to use the search api to try and locate the correct artist.
mike99mac 6 Posted July 21, 2022 Author Posted July 21, 2022 Thanks for the quick reply. I'll try that. -Mike Mac
Luke 42078 Posted July 21, 2022 Posted July 21, 2022 Let us know how you get on. The name based api that you were trying to use is legacy at this point. It was only being used by Emby for Windows Media Center. When all you have is a name, it's best to start with search and then once you have the Id you can do any operation from that.
mike99mac 6 Posted July 21, 2022 Author Posted July 21, 2022 Hmm, this is not working either: @chef http://192.168.1.229:8096/Items/RemoteSearch/MusicArtist/Adele?Recursive=true&format=json&api_key=2cb36c16427b46659856d40029250e79 Unable to find the specified file. Is this "the search api" you referred to? Thanks. -Mike Mac
mike99mac 6 Posted July 21, 2022 Author Posted July 21, 2022 Never mind, found a "Try it out" button in swagger and got it working with the search term in added JSON: curl -X POST "http://localhost:8096/emby/Items/RemoteSearch/MusicArtist?api_key=42fce6daac1d4c7f867927cf9b932eef" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"SearchInfo\":{\"Name\":\"Adele\"}" Wow, that's a lot of data coming back to get just one ID. Thanks for your help. -Mike Mac
Luke 42078 Posted July 21, 2022 Posted July 21, 2022 No that's going to search the internet metadata providers. That's not what you want. To search the Emby server library you'd just do a normal item query and use the SearchTerm param.
chef 3810 Posted July 22, 2022 Posted July 22, 2022 Hi! I think the best way to try and figure out the Rest API is with the swagger. Open the dashboard Scroll down to where it says "api" at the bottom of the screen Then just start taking a look at the different endpoints available for you query. Let us know how you make out with the swagger. Unfortunately, I'm on my phone and I can't get the proper url to help at the moment, but the swagger will give you exactly what you are looking for.
chef 3810 Posted July 22, 2022 Posted July 22, 2022 (edited) Here in the swagger is what you are looking for. It is the "Items" endpoint. Use the "SearchTerm" to locate the artist name. Get the ID of the artist, then you can do another request using the ID, and use "feilds" to request specific information. Hope this helps Edited July 22, 2022 by chef
mike99mac 6 Posted July 22, 2022 Author Posted July 22, 2022 Thanks for all the replies, but I still can't get an artist's ID from my local library (I can play Adele songs). This URI: http://localhost:8096/emby/items/Artists?searchterm=Adele&recursive=true returns "Unable to find the specified file". I've tried a lot of other variations. -Mike Mac
Luke 42078 Posted July 22, 2022 Posted July 22, 2022 Try just /artists instead of /items/artists. This should all be in swagger so that you can try it.
mike99mac 6 Posted July 22, 2022 Author Posted July 22, 2022 Yes this URI worked!! http://localhost:8096/emby/Artists?searchterm=Adele&recursive=true&api_key=2cb36c16427b46659856d40029250e79 Thanks @luke -Mike Mac 1 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now