Jump to content

New Plugin: My Own Api Provider - JSON Metadata


mickle026

Recommended Posts

mickle026

This is just a fully working version of the Person Provider. (I think - LOL :) , at least until I find some bugs!)

Requres latest stable 4.7.9

As Always with my plugins, I accept no resposibility for anything.....  its up to you if you try it.

Basically what it is, it lets you use your own json server to serve metadata for people directly into Emby as a metadata fetcher (with images)

People fetchers dont need turning on in library settings, they are already on by default.  So apart from the server string and mappings, there no more config.

*This plugin does not cover musicartists*

 

341381214_Screenshot2022-11-04at20-55-23Emby.png.67edc65725f3130c3cb25fac498810cb.png

Anyway anyone who wants to have a play can, let me know in the comment whether I should make this cover everything else so you can have your own Metadata servers
So far its only People

The config page lets you MAP your JSON to work with EMBY, so your JSON Element Names can be whatever you like,,you map them here.

The path to the image has 3 settings, it allows for a full url, a partial url and a base url path or a filename and a base url path
 

Edit Images (Magnifying glass search)

1331535044_Screenshot2022-11-04at20-58-59Emby.png.24a0324763f4d723927f12911adbe8cd.png

 

Identify (Looking for a Lee !)

1414534054_Screenshot2022-11-04at21-24-07Emby.thumb.png.fda17c179565bbd86c8ab0b927e1a126.png

136650517_Screenshot2022-11-04at21-24-26Emby.thumb.png.0a23b04e6720f45827944e17009eba0b.png

I have included the config file to my test server so you can at least try it.

My test server is all asian people (some do not have images as you will no doubt find) so if you look for anyone else you wont find them!

you can try the web view here
http://media-and-meta.ddns.net/metaserver/DBQueries/Find&Editperson.php

941069391_Screenshot2022-11-15at00-32-41Emby.thumb.png.7d6b0245cfd1ed1b23217974a2595b43.png

Any way if you try it let me know your findings - thanks

And Thanks to @TallBoiDezfor the inspiration to do this...

 

CreateMovieApi.zip MyPersonApiProvider.zip CreatePersonApi.zip

 

Added an Alpha version of MyMovieApiProvider.  You will have to test this and let me know if its fully working or not.  It seems to for me, leaving all the remap boxes blank because I used the CreateMovieApi.  Enable in your library settings

 

Included in the zip is some updated php files for the create movie api (adapted from another project)

 

 

Screenshot2024-03-21at05-44-27MediaServer.thumb.png.83acfe3e8f165990ece651abcbc3df32.png

Ignore the usb path - just testing identify with a movie name

Screenshot2024-03-21at05-58-30MediaServer.thumb.png.ee978601d79bc54757f5981629d4dcb4.png

 

Screenshot2024-03-21at05-58-45MediaServer.png.894eacfc21699cc7cb67ae3eedf6ce76.png

 

 

Screenshot2024-03-21at06-04-15MediaServer.thumb.png.3f0bc04abde74edbb68ea8f051940509.png

 

Screenshot2024-03-21at06-04-38MediaServer.thumb.png.47804c136558e7ac9d4fc13cadd37411.png

 

 

 

MyMovieApiProvider-Alpha(25-03-2024) - build 2.zip

Edited by mickle026
update server version required
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

mickle026

So what I have done is temporarily removed the plugins that were here whilst I fix what I know can be improved

 

 

 

 

 

 

 

 

 

 

Edited by mickle026
Link to comment
Share on other sites

Cheesegeezer

@mickle026

grats on the release chief! Great work, i been observing the dev posts you made and its quite a feat what you have achieved here.

👍👍

  • Thanks 1
Link to comment
Share on other sites

mickle026

I have the intention to cover all providers.

I already have a song cover provider of my own (for music), A lot of my tracks have their own covers different from the album itself, I'll probably make that available too as there are no others that I know of.

  • Like 1
Link to comment
Share on other sites

mickle026

*UPDATED 9th Nov 2022 @ 5.30am GMT

1. Handle DirectoryNames with Invalid Characters (if persons name has a character in it that cannot be used to build the directory name)
These are changed to _ (previously crashed the plugin)  If it still fails on a person it will now continue after logging the failure.
2. Fix Correct Php generation for SearchById and add
3. Change searchNames in php as in fix 1, replace invalid characters with _
4. Changed the php Names To PersonSearch.php etc to allow future export files without clasing. (updated this post examples)

 

It might need some tweeks, but here is an Emby Exporter for your People (Not MusicArtist) to A local Backup Path to create a structured API

Remember this is just a tool, you can create your own if you do not like the way this tool does it.

The Plugin Exports an XML file and the Primary image (Only the primary image at the moment) into a folder named with the Person name, Year of birth and Provider keys

like this:

Capture.JPG.45805869cc8b657ade1b9cda2d1f3b0a.JPG

It also writes 3 PHP files for use on a php enabled webpage

You can then use an api string with Search.php

If no format is supplied, json will be automatically returned

any of the elements can be supplied:

Name
Year
Id

http://<YourServer>/PersonSearch.php?Name=<Name>&Year=<Year>&Id=<Id>&Format=json

examples:
http://<YourServer>/PersonSearch.php?Name=Tom Cruise
http://<YourServer>/PersonSearch.php?Name=Tom
http://<YourServer>/PersonSearch.php?Name=Tom Cruise&Year=1962
http://<YourServer>/PersonSearch.php?Name=Tom Cruise&Year=1962&Id=nm0000129

The Api server will respond with a json result if it exists (XML is converted to json on the fly)

The php is very basic, it gets a file list of this directory , searches the directory names for the Name, Year or Id provided and replies with the Person.xml inside the folder, building a json array if there is more than one result

Currently only php is available, if someone can convert the php to javascript for me that would be awesome!! - as then it would work on the very basic websites.

 

9894623_Screenshot2022-11-08at16-17-32Emby.png.f04b6dd7fd21c03f789e6a48167f6d79.png

One thing to note is that I need to update the API Providers to allow and prioitise ID searches - this is a still to do!

 

Download currently removed whilst I fix another bug! (wont be too long)

 

Edited by mickle026
  • Like 1
Link to comment
Share on other sites

mickle026

OK so now improved an mostly tested up to the point of primary images. (I havent tested backdrops and logos)

Please note that there is still an issue with identify removing images, or not fetching them. (if it has a json reply with no image in it)

*Fixed an error in SearchById.php
*Completely changed the server config  string  and added server string mapping, see the plugin and images in this post

So for the Api server it must have these elements in the query string: Name={Name}&Year={Year}&Id={Id}

http://media-and-meta.ddns.net/metaserver/TIBML/PersonSearch.php?Name={Name}&Year={Year}&Id={Id}

^^ this is my test server - I moved it from the original post ^^

So now auto lookup by emby uses Ids if they are available, you can now search for any id in the MyPersonApi field of the Emby identify feature

If the api can search it by id it will return the json

For Example the CreatePersonApi tool below creates seperate folders for each person like this:
Park So-dam(1991)[Tmdb-1442583][Imdb-nm6524394][Tvdb-515330]

So in identify CreatePersonApi  Id: I have made it a general search as in Name with the supplied php

You can search any of that text, Park So-dam,1442583,nm6524394 etc

The CreatePersonApi now writes the <PrimaryImage> Tag with <PrimaryImage>/PersonsName+Ids/Image.jpg</PrimaryImage>

So to Use the Provider you should map the path+ the primary image string with the drop down selection

My Config is included to my server so you can see how it works

Once you are happy with it up and running turn logging off as it slows it down.

My Api server is not at all quick so if you use it expect its to slow down loading pages.

You can increase your api server simply by adding files and folders to it, but please remember that the create api tool will overwrite so backup somewhere else and then move what you want to your api site.

It can also be turned on/off in the config page near the save settings button

 

 

The api string should now also be able to be in this format too (I havent tested this)

http://[host address]/people/{Name}

http://[host address]/people/{Name}+{Year}+{Id}

http://[host address]/people/{Name}&{Year}&{Id}

and leave all the server string mappings blank

 

 

Im thinking of adding a timeout to the server query, what do you think?

 

 

 

 

Edited by mickle026
Link to comment
Share on other sites

mickle026

It turns out I had introduced 2 seperate bugs,

I found and fixed one of them easily because it was in the new code, the other I dont even know how I introduced it and was much harder to find.

Anyway its done!  Completely fixed, please update to this one, and sorry for the inconvenience 😉

One thing to note is date of birth / death in your json has to be in dd/mm/yyyy format with those slashes.  I can add support for other type if requested.
Other is there is now a testpage, for testing the server but that is NOT functional yet.  I was doing that whilst getting Peeved by having a hard time finding the bugs! So its a still to do.

I reposted the dll in the 1st post and updated the screenshot

I have a week off work coming up soon, so I hope to finish it properly then get on to the other media types.

Edited by mickle026
  • Like 1
Link to comment
Share on other sites

mickle026

CreatePersonApi is now fully functional, it now outputs Banners,Backdrops etc and adds them to the source xml that creates the lookup json.

MyPersonApi is now fully functional.  It will now import Backdrops (only 1 is fetched automatically, that must be an internal emby thing) but the rest can be fetched from the Edit Images option.  The server testing page is also now working.
1578315345_Screenshot2022-11-18at03-48-51Emby.thumb.png.ed41a593030ddff8824fd9047bc06799.png

504263839_Screenshot2022-11-18at03-48-32Emby.png.a9fd7ce183770efad6a2d3c0586da07d.png

I have also started on CreateMovieApi, I have included it here as it seems fully functional (although its for testing).  This will create a backup of your Emby movie library complete with the php files for the Api, I will now start on the MyMovieApi for fetching back into Emby.

 

  • Like 1
Link to comment
Share on other sites

mickle026

MyPersonApi, updated.

A Few fixes.

Handle Array'ed Json in Images , now wont crash, but if an array of json is returned on single person (ie in my own api server jo Lin, ad Jo Linwood can be returned fo just Jo Lin).  I still have to impliment the result of an array, so that the correct result is used.  For now its just error handled.

Handle Identify Metadata better, there was a crash when Overview or Primary Image in the Json was empty or was not present.  Now it is handled.  The crash caused the plugin to exit, and therefore metadata was not updated.

Edited by mickle026
Link to comment
Share on other sites

mickle026

MyPersonApi, updated. (this is now all working) - hopefully no more bugs!
Nearly Everything is imported!  Overviews, Date of birth , Place of Birth, Date of Death , Images etc (only 1 backdrop, Emby limitation) However using Edit Images you can import more!  (at the moment the last thing to fix is import provider ids)
GetImages array json now handled
To search just MyPersonApi with Identify (and ignore default TMDB), leave the Name field blank and enter either the name or id (not both) in MyPersonApi id: field.  This might produce an error in the logs for tmdb, as nothin is passed to it (but you can safely ignore that)

CreatePersonApi Updated
UTF8 now supported when exporting
Updated PHP
Included a HowTo.txt when the plugin is run and php is selected as output, it includes How To install & Create a truenas server
Exports to folders with provider keys, an xml file in the folder with the images.
Added a date

 

Update 2 dec 2022

Added Provider Id support to import.

Edited by mickle026
  • Like 1
Link to comment
Share on other sites

  • 9 months later...
  • 5 months later...
mickle026

omg , totally forgot about this!

I'll look to see what needed to be done.

  • Haha 1
Link to comment
Share on other sites

mickle026
Posted (edited)

Updated first post with the MyMovieApi for re-importing the CreateMovieApi exports.  Hopefully you'll be able to figure it out using my screenshot.

If you dont have the full url to the poster image in the json reply then you will need to add the baseurl. If its not correct the thumbnails wont show in the identify dialog.

Edited by mickle026
Link to comment
Share on other sites

hrohh

Hello, thank you for your work! I would like to create php api for website www.csfd.cz. So if I add new film, it will fetch via imdb id movie overview in czech language and rating. Can you please add to json "rating"? It is possible add "trailer url" somehow?

Link to comment
Share on other sites

mickle026
5 hours ago, hrohh said:

Hello, thank you for your work! I would like to create php api for website www.csfd.cz. So if I add new film, it will fetch via imdb id movie overview in czech language and rating. Can you please add to json "rating"? It is possible add "trailer url" somehow?

Do you already have a response json file for this site ?  Or are you going to make your own site based on this site?

Link to comment
Share on other sites

hrohh

I have some code already with another plugin ScripterX, but it is so complicated.
In this plugin there is event "onMediaItemUpdated", which trigger my PowerShell script. In PS there is fetch to my php API to website csfd.cz, which will return some data (rating, overview). Next step in PS is call Emby fetch API and overwrite data in movie. Its working, but I want some better solution, which is your plugin.

CSFD in logged area has IMDB link on each movie. I have about 1 500 000 movies in SQL (some scrapping). So no problem get data from IMDB ID => CSFD movie page.

My JSON in PowerShell is like this

{"csfdid":"1175698","imdbid":"tt8347740","rating":"0","poster":"https:data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7","overview":"","origin":["Finsko","2010","58 min"],"year":"2010"}

and from video section 

[{"raw":{"description":"Trailer 3","language_id":3,"duration":205,"subtitles_language_id":null,"poster_path":"files\/images\/film\/video\/preview\/164\/460\/164460762_9ce646.jpg","poster_storage_id":"image-production","poster_width":2560,"poster_height":1440,"video_film_id":157760363,"film_video_type_id":1,"position":3,"video_id":157766731,"copyright":"Twentieth Century Fox","film_name":"Avatar","creators":null,"poster":{"width":2560,"height":1440,"path":"files\/images\/film\/video\/preview\/164\/460\/164460762_9ce646.jpg","storage_id":"image-production"},"external_description":"Avatar: Trailer 3","request_data":"rlW2nJEyo0yxVwbkAGp3AwL3ZmRfVaA1LaEcqTkyGTShM3IuM2IWMUZvByfkYQWqYPW0o2gyovV6VwSuLmywLJV2BQNkLmqyMGOuATWyAQpjATD2MJD4LwRjMJLlMzV0BQtvsD","request_final":"rlWmo3IlL2ImVwc7VwRjBQOjVwcorlW0rKOyVwbvqzyxMJ9pY21jAPVfVaAlLlV6VyjiKP92nJEyol5joJqmqTS0nJZhL29gKP9znJkyp1jiqzyxMJ9mKP8kAGqpYmp2AyjiZGH3AmL2AmZkKP8kAwD0AwN3AQqsLGZjAJZjYz1jAPW9KFjvZmLjpPV6J3fvqUyjMFV6VaMcMTIiKP9gpQDvYPWmpzZvBvWpY1jiqzyxMJ8hpT1ap3EuqTywYzAioIjiMzyfMKApY3McMTIip1jiZGH3KP83AwMpYmR1Amp2AwpmZIjiZGL0AQLjAmD5K2WxMJZ2MP5gpQDvsI0fVwplZUNvByg7VaE5pTHvBvW2nJEyo1jioKN0Vvjvp3WwVwbvKP9pY3McMTIiYaOgM3A0LKEcLl5wo21pY2McoTImKP92nJEyo3ApYmR1A1jiAmL2KP8kAGp3AwL3ZmSpYmR2AQD2ZQp1ZI83BTH2AmthoKN0Va1qsK0"},"sources":{"1080p":[{"type":"video\/mp4","src":"\/\/video.pmgstatic.com\/files\/videos\/157\/766\/157766731\/164460747_a305c0.mp4"}],"360p":[{"type":"video\/mp4","src":"\/\/video.pmgstatic.com\/files\/videos\/157\/766\/157766731\/164460749_bdec6d.mp4"}],"720p":[{"type":"video\/mp4","src":"\/\/video.pmgstatic.com\/files\/videos\/157\/766\/157766731\/164460751_78e678.mp4"}]}},{"raw":{"description":"Trailer 2","language_id":3,"duration":210,"subtitles_language_id":1,"poster_path":"files\/images\/film\/video\/preview\/021\/135\/21135852_2fcf78.jpg","poster_storage_id":"image-production","poster_width":700,"poster_height":300,"video_film_id":310480,"film_video_type_id":1,"position":2,"video_id":310480,"copyright":"Twentieth Century-Fox Film Corporation","film_name":"Avatar","creators":null,"poster":{"width":700,"height":300,"path":"files\/images\/film\/video\/preview\/021\/135\/21135852_2fcf78.jpg","storage_id":"image-production"},"external_description":"Avatar: Trailer 2","request_data":"rlW2nJEyo0yxVwbmZGN0BQNfVaA1LaEcqTkyGTShM3IuM2IWMUZvByfkYQWqYPW0o2gyovV6VwEyBJZ0AQLjMzL5ZJMxZJR3BJR0AGHkZGEvZwIwLGAzLwL4ZGtlAGNvsD","request_final":"rlWmo3IlL2ImVwc7VwZ2ZUNvByg7VaE5pTHvBvW2nJEyo1jioKN0Vvjvp3WwVwbvKP9pY3McMTIiYaOgM3A0LKEcLl5wo21pY2McoTImKP92nJEyo3ApYmNjZSjiZmRjKP8mZGN0BQOpYmR1AmpkZQD1ZS9wLzMvZGDhoKN0Va1qsFjvp3IvqTy0oTImVwc7VaAlL2kuozpvBvWwplVfVzkuLzIfVwbvKUHjZGOxMKAeKUHjZTMxVvjvp3WwVwbvKP9pY3McMTIiYaOgM3A0LKEcLl5wo21pY2McoTImKP9mqJW0nKEfMKApYmNjZSjiZmRlKP8mZGV2ZwAsAQR2LmSwYaM0qPVfVzEyMzS1oUDvBaElqJHfVzgcozDvBvWmqJW0nKEfMKZvsK0"},"sources":{"360p":[{"type":"video\/mp4","src":"\/\/video.pmgstatic.com\/files\/videos\/000\/310\/310480\/157710450_cbfb14.mp4"}]}},{"raw":{"description":"Trailer 1","language_id":3,"duration":129,"subtitles_language_id":1,"poster_path":"files\/images\/film\/video\/preview\/021\/135\/21135832_59439f.jpg","poster_storage_id":"image-production","poster_width":700,"poster_height":310,"video_film_id":310211,"film_video_type_id":1,"position":1,"video_id":310211,"copyright":"Twentieth Century-Fox Film Corporation","film_name":"Avatar","creators":null,"poster":{"width":700,"height":310,"path":"files\/images\/film\/video\/preview\/021\/135\/21135832_59439f.jpg","storage_id":"image-production"},"external_description":"Avatar: Trailer 1","request_data":"rlW2nJEyo0yxVwbmZGNlZGRfVaA1LaEcqTkyGTShM3IuM2IWMUZvByfkYQWqYPW0o2gyovV6Vwx4AwOzMzMuZGx5BGqyBQIuAwH5LGEvMTZ0ZmL0MTHlBJL0AwV0MJRvsD","request_final":"rlWmo3IlL2ImVwc7VwZ2ZUNvByg7VaE5pTHvBvW2nJEyo1jioKN0Vvjvp3WwVwbvKP9pY3McMTIiYaOgM3A0LKEcLl5wo21pY2McoTImKP92nJEyo3ApYmNjZSjiZmRjKP8mZGNlZGSpYmR1AmpjBGx2ZS81BJV0BQNhoKN0Va1qsFjvp3IvqTy0oTImVwc7VaAlL2kuozpvBvWwplVfVzkuLzIfVwbvKUHjZGOxMKAeKUHjZTMxVvjvp3WwVwbvKP9pY3McMTIiYaOgM3A0LKEcLl5wo21pY2McoTImKP9mqJW0nKEfMKApYmNjZSjiZmRlKP8mZGV1AQOsL2IxZmL2YaM0qPVfVzEyMzS1oUDvBaElqJHfVzgcozDvBvWmqJW0nKEfMKZvsK0"},"sources":{"360p":[{"type":"video\/mp4","src":"\/\/video.pmgstatic.com\/files\/videos\/000\/310\/310211\/157709960_59b480.mp4"}]}}]


If you can add "rating" field please - for me is most important.

Edited by hrohh
Link to comment
Share on other sites

mickle026

I have updated th MyMovieApi to incorporate TrailerURL and Rating (They are strings)

I havent tested it, though  it should work fine. *eek*

Link to comment
Share on other sites

hrohh

Thank you so much. So now I reworked php API, but I have issues with settings. API demo is on, required is Id field. Name/Year/JSON are only for debug and do nothing.

https://refreshpixel.com/csfd2/?Name=Chudáčci&Year=2023&Id=tt14230458&Format=json

I have match only, if your plugin sends ID. With Name= I cannot match for 100% on csfd.cz. So my idea is, If I can set MyMovieApi to lower order position in Library metadata section? So at first Emby will fetch TheMovieDb, The Open Movie Database and last run MyMovieApi with Id=XXX, which match 100% movie in my API?

Thanks 

Link to comment
Share on other sites

mickle026
Posted (edited)
4 hours ago, hrohh said:

Thank you so much. So now I reworked php API, but I have issues with settings. API demo is on, required is Id field. Name/Year/JSON are only for debug and do nothing.

https://refreshpixel.com/csfd2/?Name=Chudáčci&Year=2023&Id=tt14230458&Format=json

I have match only, if your plugin sends ID. With Name= I cannot match for 100% on csfd.cz. So my idea is, If I can set MyMovieApi to lower order position in Library metadata section? So at first Emby will fetch TheMovieDb, The Open Movie Database and last run MyMovieApi with Id=XXX, which match 100% movie in my API?

Thanks 

This plugin will should send in the ID if it exists in the emby db for that file

When Emby requests this data via a GetMetadata Task, the Base item is sent.  It Contains Name, Year, and Provider ids amongst a few others,  what this plugin does is build a string based on what it can detect from embys BaseItem object. 

1. It will add the Name (It will alsways do this as its a fallback)

2. It extracts the year from the baseitem then adds that

3.  It tries to extract the provider ids.  IMDB, TMDB , TVDB (tvdb has movies aswell) in this order.  It will add the id if it exists.  (it will add the first one it finds)

 

Next Question, I added Rating as OfficialRating, but in your JSON that seems to be a viewer/critic rating so would you need that to be CritcRating?,

Maybe Official Rating is a Parental Rating - Not Sure ???

A screen shot of what emby supports (community, critic , custom & Official)

rating.jpg.7f11d6b0a6df0320873ac85f620d5769.jpg

 

Please note that emby does NOT supply the IMDB / TMDB ids within identify unless they a specifically typed in to the search fields -  Identify is a blank seach!

 

I put this in first post too!

MyMovieApiProvider-Alpha(25-03-2024) - build 2.zip

Edited by mickle026
Link to comment
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...