Get artwork using API

Post Reply
lindsayward
Junior
Posts: 55
Joined: Sat May 31, 2014 4:58 am
Australia

Get artwork using API

Post by lindsayward »

Hi.
Is there a way to get the program artwork using the Frontend Service API?

I would like to be able to get a (local) URL to an image for the currently playing recording.
User avatar
bill6502
Developer
Posts: 2307
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Get artwork using API

Post by bill6502 »

Hi,

Short answer, no, not from the frontend.

Try Dvr/GetRecordedList and or Video/GetVideoList from you browser and then look for lines like:

Code: Select all

<Artwork>
<ArtworkInfos>
<ArtworkInfo>
<URL>
/Content/GetImageFile?StorageGroup=Coverart&FileName=/tmdb3.py_10201_coverart.jpg
</URL>
<FileName>myth://Coverart@mc0/tmdb3.py_10201_coverart.jpg</FileName>
<StorageGroup>Coverart</StorageGroup>
<Type>coverart</Type>
</ArtworkInfo>
<ArtworkInfo>
Note that you're getting this from the backend so set the port to 6544 when
calling api.send(), which you know will return JSON.
User avatar
bill6502
Developer
Posts: 2307
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Get artwork using API

Post by bill6502 »

Also, for recordings there's GetTitleInfoList which returns much less information,
but it includes the inetref and as you can see from the above, the URL can be
developed from that.
lindsayward
Junior
Posts: 55
Joined: Sat May 31, 2014 4:58 am
Australia

Re: Get artwork using API

Post by lindsayward »

Thanks!
Are you Bill Meek from: https://github.com/billmeek/MythTVServicesAPI
I'm working on a Home Assistant platform (https://github.com/calmor15014/HA-Compo ... v-frontend) using this Python API, so thanks if you are!

So, looks like I can use this Python wrapper for any MythTV API (listed at https://www.mythtv.org/wiki/Services_API)?
Then I can get the recording ID from the frontend and use it to look up "Dvr/GetRecorded" to get the artwork (and other) data from the backend...
I'll test that soon.
User avatar
bill6502
Developer
Posts: 2307
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Get artwork using API

Post by bill6502 »

As long as it's working, yes that's me. And you right about send(). Originally, I'd considered
one module per service (Dvr/Frontend/Video etc.) but saw that they're all doing the same
thing, so abandon the idea and tried to make a single tool that any endpoint could be
plugged into. Really, a subset of send() could live in the work you and Jim are doing.

For this specific case, I assume you're trying to get art for the recording that's playing.
So could use the title that you've already got from Frontend/GetStatus and then call
endpoint=Dvr/GetRecordedList, rest=TitleRegEx=Elementary (for example.) The
response will have the URL you need to get the art. But send() will fire an error
'cause the response isn't JSON, rather, it's an icon. I hadn't tried this, looks like a
bug to me. Maybe a new opt like 'rawdata'.
User avatar
bill6502
Developer
Posts: 2307
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Get artwork using API

Post by bill6502 »

Try mythtv_services_api-0.0.4 (you must delete the temporary file
in the calling code.) Not sure I like it, but it's a start.
lindsayward
Junior
Posts: 55
Joined: Sat May 31, 2014 4:58 am
Australia

Re: Get artwork using API

Post by lindsayward »

I just noticed I didn't reply to say thank you... Thank you!
I think I was waiting until I'd tried out what you'd suggested...

I have been following your API updates (v 0.0.8 currently), and will keep trying with your suggestions as well.
lindsayward
Junior
Posts: 55
Joined: Sat May 31, 2014 4:58 am
Australia

Re: Get artwork using API

Post by lindsayward »

Is there any way to get a unique identifier from the frontend to look up the recorded program details?

I would like to use the info on what's currently playing (Frontend/GetStatus) to look up the metadata on that program (Dvr/GetRecorded), but I don't see anything unique.
Do I just have to use the title and subtitle of the current item to go looking for the program in the GetRecordedList details? Or is there a better way?
Thanks!
lindsayward
Junior
Posts: 55
Joined: Sat May 31, 2014 4:58 am
Australia

Re: Get artwork using API

Post by lindsayward »

I have got what I want working - thanks for your help Bill!
But I would still like to know if there's a better way to get the program data from the backend for the current program playing on the frontend. It would be great if MythTV would provide a unique identifier to link them together.

Currently I'm getting all programs with the matching "Title", then if there are multiples, I look for the one with matching "SubTitle". I hope there won't be duplicates of those, but I guess there could be.
daraden
Senior
Posts: 175
Joined: Tue Feb 23, 2016 7:33 am
United States of America

Re: Get artwork using API

Post by daraden »

The best way to get a unique recording entry would be using the chanid and starttime with Dvr/GetRecorded. For videos you would need to strip the path name to just the file name and use Video/GetVideoByFileName.

Bill any reason you suggested GetRecordedList TitleRegEx instead?
User avatar
bill6502
Developer
Posts: 2307
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Get artwork using API

Post by bill6502 »

Hi,

Been mostly off the grid for the last week, but suggest TitleRegEx
to get all (perhaps previously recorded) recordings of a single series.
If a recording is in progress and the metadata hasn't been retrieved,
getting a unique recording may not give the desired results.

daraden is correct for a unique recording, or with 0.28+ if the RecordedId
is available, then I'd prefer it.
lindsayward
Junior
Posts: 55
Joined: Sat May 31, 2014 4:58 am
Australia

Re: Get artwork using API

Post by lindsayward »

Thanks for the replies daraden and Bill!
The start time + channel id seem a bit odd, but I guess that uniquely identifies the playing video in the list so I don't need to get all and process them.
That sounds good and a quick test in the browser shows that it works.
Recordedid doesn't exist on most of my recorded media it seems, so I'll skip that.
I haven't looked at videos (as opposed to TV) since I very rarely use those, but I'll check that out.
lindsayward
Junior
Posts: 55
Joined: Sat May 31, 2014 4:58 am
Australia

Re: Get artwork using API

Post by lindsayward »

Thanks again for the input.
Using starttime and chanid works well. Done. https://github.com/calmor15014/HA-Compo ... 05eab63b93
I was also able to handle video artwork as well. https://github.com/calmor15014/HA-Compo ... ab8915715e
Post Reply