Jump to content

How to add an external url?


mickle026

Recommended Posts

mickle026

I undertand how to add the url if there is only 1 element in the url string to replace with the providerid Burt Reynolds: "357160"

https://www.citwf.com/persons_detailes_page.aspx?RequestedPid=357160

    public class ExternalCITWF : IExternalId
    {
        public string Name => "CITWF";
        public string ProviderName => "CITWF";
        public string Key => "CITWF";

        public string UrlFormatString
        {
            get { return "https://www.citwf.com/persons_detailes_page.aspx?RequestedPid={0}"; }
        }

        public bool Supports(IHasProviderIds item) => item is Person;
    }

But what if I want to use a little more complicated url and need to replace 2 elements when its called?

Like this:  Where {0} would be replaced by the provider id and  Where {1} would be replace with a formatted item.name ... like "Burt Reynolds" => "burt-reynolds"

https://www.dvdempire.com/1670/cast/burt-reynolds.html

    public class ExternalDVDEmpire : IExternalId
    {
        public string Name => "DVDEmpire";
        public string ProviderName => "DVE";
        public string Key => "DVE";

        public string UrlFormatString
        {
           get { return "https://www.dvdempire.com/{0}/cast/{1}.html"; }
        }

        public bool Supports(IHasProviderIds item) => item is Person;
    }

https://www.dvdempire.com/{0}/cast/{1}.html

1496021103_Screenshot2022-12-17at04-52-20Emby.png.5c4be1594afcc3c383e1b6c83405215a.png

 

I can only get this to add a link if I leave off part of the url, and of course the link doesnt work as part of the address is missing.

Is it possible to do this? - My current attempt (as above) kill the person item metadata page, and causes the server issues.

Edited by mickle026
Link to comment
Share on other sites

16 hours ago, mickle026 said:

But what if I want to use a little more complicated url and need to replace 2 elements when its called?

Like this:  Where {0} would be replaced by the provider id and  Where {1} would be replace with a formatted item.name ... like "Burt Reynolds" => "burt-reynolds"

How should this work with two replacements?

What I mean is - where should the other replacement part come from? A provider ID is a unique identifier - as single value that uniquely identifies an entity within a certain realm - which is spanned by the provider id. 

I have seen on their website that you can get to a movie by just appending the id to the base url, but I could find (guess) an url pattern that allows to access a person's page by providing the number only. Maybe there is one - you can try a little hard to find out or you could ask them.

But when that's not possible, then it means that 1670 is not a valid unique identifier for a person on their website, because it doesn't allow us (as 'the public') to get to that information (even though the number alone is probably a sufficiently valid identifier for them internally).

So - for us - knowing the 1670 is not sufficient, we also need the 'burt-reynolds' part and as an ID needs to be a single value, the ID for that actor will have to be:

  • "1670/cast/burt-reynolds"
    and the url pattern
  • "https://www.dvdempire.com/{0}.html"

 

Link to comment
Share on other sites

mickle026
1 hour ago, softworkz said:

How should this work with two replacements?

What I mean is - where should the other replacement part come from? A provider ID is a unique identifier - as single value that uniquely identifies an entity within a certain realm - which is spanned by the provider id. 

I have seen on their website that you can get to a movie by just appending the id to the base url, but I could find (guess) an url pattern that allows to access a person's page by providing the number only. Maybe there is one - you can try a little hard to find out or you could ask them.

But when that's not possible, then it means that 1670 is not a valid unique identifier for a person on their website, because it doesn't allow us (as 'the public') to get to that information (even though the number alone is probably a sufficiently valid identifier for them internally).

So - for us - knowing the 1670 is not sufficient, we also need the 'burt-reynolds' part and as an ID needs to be a single value, the ID for that actor will have to be:

  • "1670/cast/burt-reynolds"
    and the url pattern
  • "https://www.dvdempire.com/{0}.html"

 

I was hoping for it to come from the item.Name that was loading / gererating the link, and allow formatting, ie lowercase, uppercase or drop caps as well as repace spaces with hyphen, underscore etc,  ie definable in the IExternal class and how to do it.  I guess thats not he case :( and would probably need more server side manipulation or need extra written into the core to do this....

ie ,  if it were a person

 "https://www.dvdempire.com/{0}/cast/{1}.html"; 

then {1} could come from

item.Name.ToLower().Replace(" ","-");
        

and that would also work for movie links https://www.dvdempire.com/3797695/top-gun-maverick-dvd-movie.html

 "https://www.dvdempire.com/{0}/{1}-dvd-movie.html"; 

then {1} could come from

item.Name.ToLower().Replace(" ","-");

So the only way to do this right now is add another IExternal Class where the User set Provider Id key has the value is stored as 3797695/top-gun-maverick-dvd-movie.html

and use https://www.dvdempire.com/{0}

I can do this but really would rather not fill up the database Luke is trying to compact and also this would become visible in not just the metadata editor but the identify dialogue.

 

Link to comment
Share on other sites

13 minutes ago, mickle026 said:

I was hoping for it to come from the item.Name that was loading / gererating the link, and allow formatting, ie lowercase, uppercase or drop caps as well as repace spaces with hyphen, underscore etc,  ie definable in the IExternal class and how to do it.  I guess thats not he case :( and would probably need more server side manipulation or need extra written into the core to do this....

I had an idea for allowing to put some more logic into external id implementations (like an interface IExternalId2), but that wouldn't allow you to do this either.

13 minutes ago, mickle026 said:
 "https://www.dvdempire.com/{0}/cast/{1}.html"; 

then {1} could come from

item.Name.ToLower().Replace(" ","-");
        

and that would also work for movie links https://www.dvdempire.com/3797695/top-gun-maverick-dvd-movie.html

 "https://www.dvdempire.com/{0}/{1}-dvd-movie.html"; 

then {1} could come from

item.Name.ToLower().Replace(" ","-");

> but that wouldn't allow you to do this either

because (I'm repeating myself) a provider ID must be a unique identifier and it must be sufficient to identify the item.
It may not depend on anything else (like the name). The name can be changed by users or it can come from a different provider which uses a slightly different variation of the name. All these things would render the link invalid.

24 minutes ago, mickle026 said:

So the only way to do this right now is add another IExternal Class where the User set Provider Id key has the value is stored as 3797695/top-gun-maverick-dvd-movie.html

and use https://www.dvdempire.com/{0}

You don't need to include the .html part. See my example above.

24 minutes ago, mickle026 said:

I can do this but really would rather not fill up the database

Those few letters really aren't of concern. There are other provider IDs where the id is a full url and the pattern is '{0}'. Also - unfortunately - your plugin wouldn't qualify for the catalog anyway.

24 minutes ago, mickle026 said:

this would become visible in not just the metadata editor but the identify dialogue.

No, it wouldn't be shown in the identify dialogue, because the provider id fields are empty there.

But there will be an empty field for your provider where a user can enter an ID. And your provider wouldn't even be able to find the person by ID when it wouldn't include the name:

When the ID would be 1670 only, your plugin couldn't return the data. That's why it's got to be 1670/cast/burt-reynolds

Link to comment
Share on other sites

4 minutes ago, softworkz said:

Also - unfortunately - your plugin wouldn't qualify for the catalog anyway.

PS: Not for the partially adult content but because data is acquired by scraping rather than from a public API.

Link to comment
Share on other sites

mickle026
53 minutes ago, softworkz said:

PS: Not for the partially adult content but because data is acquired by scraping rather than from a public API.

This plugin uses a private api, and doesn't scrape anything - just returns json converted on the fly from xml located on my server.

The config file is also in the archive to access my server (so its kinda public).

Example:

http://media-and-meta.com/TIMBL/PersonSearch.php?Name=Jason%20Statham&Year=1967&Format=json

My Person Provider Plugin pulls this infomation directly from my own server, this is not the adult plugin discussed privately ...

I was hoping to add more providers to the json, so that external links would work with people for these sites.

 

As you already noticed they work fine for the movie itself on this particular site

Resident Evil Afterlife:

1397922126_Screenshot2022-12-18at01-54-08Emby.png.e0308af4c8d8633c2879d14435be781e.png

Untitled.jpg.d2e418f4faca1479ee1e9bd9dcd9683d.jpg

 

I have about a dozen private plugins, that are solely used in my own server.  I completely understand what can and cannot go in the catalogue, some cannot, but this one should be completely fine.

The Person Api does not have the code within it to do this at the moment.  Its inside a different plugin I am using to test atm.

 

 

As for this I understand why this isnt implimented, I just wondered if it were possible or could be - it would only enhance if it could be.

 

 

 

Link to comment
Share on other sites

3 minutes ago, mickle026 said:

This plugin uses a private api, and doesn't scrape anything - just returns json converted on the fly from xml located on my server.

Okay, but the data from dvdempire must come from somewhere. Do you mean dvdempire has a private api to which you have access?

5 minutes ago, mickle026 said:

My Person Provider Plugin pulls this infomation directly from my own server, this is not the adult plugin discussed privately ...

I wasn't referring to what we talked privately, I was referring to the other ...empire.com sites.

8 minutes ago, mickle026 said:

As for this I understand why this isnt implimented, I just wondered if it were possible or could be - it would only enhance if it could be.

I have explained why it isn't logically possible to have external IDs that rely on additional information besides the id string itself.

Link to comment
Share on other sites

mickle026
3 minutes ago, softworkz said:

Okay, but the data from dvdempire must come from somewhere. Do you mean dvdempire has a private api to which you have access?

No, I was wanting to put links in  my own json so external links would work (copy and paste from the browser) - thats all , nothing sinister! - no link scrapers, I do not have a hidden agenda here ......

But overall it wasnt about the empire.com sites, that is just what i used as an example (my bad :( ).  It was about adding a link to whatever site I wished to on whatever item i wished to.
Could be a book, music, person or tvshow to show possibly other information or trivia.

Anyway, I get it, i cannot unless the format just uses the id.

Thanks

Link to comment
Share on other sites

8 minutes ago, mickle026 said:

No, I was wanting to put links in  my own json so external links would work (copy and paste from the browser) - thats all , nothing sinister! - no link scrapers, I do not have a hidden agenda here ......

LOL, no big thing. Personally I don't even mind, it's just the Emby policy for the plugin catalog.

10 minutes ago, mickle026 said:

It was about adding a link to whatever site I wished to on whatever item i wished to.
Anyway, I get it, i cannot unless the format just uses the id.

Oh no - you can. That's a different story. Your provider can also return multiple IDs for such links. You can either create your own IDs for this, or use one of the new built-in ProviderIds that we have added recently (will be in beta .22):

Key Format

Facebook

https://www.facebook.com/{0}

Instagram

https://www.instagram.com/{0}

Twitter

https://twitter.com/{0}

Official Website

{0}

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

mickle026
7 minutes ago, softworkz said:

You can either create your own IDs for this, or use one of the new built-in ProviderIds that we have added recently (will be in beta .22):

This is where I was going, sorry if we were on different paths/understandings/cross purposes .....

I tried to format like return "{0}"; so the whole url would be used and currently it gets truncated - so it will be great if that doesn't happen any more :) - it'll be just what i wanted!
currntly beta .21

This is just an example from above:
https://www.dvdempire.com/3797695/top-gun-maverick-dvd-movie.html
becomes
https://www.dvdempire.com/3797695


Will the urls still be under ExternalIds as they are now?

Link to comment
Share on other sites

Note that all of the above still qualify for being a provider id as they fulfill the constraint of being unique:

Each movie, series, artist, actor, album, etc. is supposed to have just one official website, just one Twitter, Instagram of Facebook page, which means that those ids - even when it's a complete url - will still allow to uniquely identify them. Or to disambiguate multiple having the same name, for example.

What would not qualify for being a ProviderId would be things like:

  • Link to recent related news article
  • Link to a fanclub
  • Link to my friend's emby server
  • Google search link
  • etc.
Link to comment
Share on other sites

8 minutes ago, mickle026 said:

I tried to format like return "{0}"; so the whole url would be used and currently it gets truncated - so it will be great if that doesn't happen any more :) - it'll be just what i wanted!
currntly beta .21

This is just an example from above:
https://www.dvdempire.com/3797695/top-gun-maverick-dvd-movie.html
becomes
https://www.dvdempire.com/3797695

Yes, there was an issue which is fixed now.

  • Like 1
Link to comment
Share on other sites

mickle026
10 minutes ago, softworkz said:

image.png.e28ac9724e5f8b3632a2f3a9ce5b2193.png

Exactly what I wanted :)

This leads me on to further expansion.

The only thing that is missing now in my opinion in the server, is the ability to expand on roles in people.  This would probably be a feature request and might not have great uptake without a public provider but i would also like to add a page like a person page but for the persons role.  So sort of like another database of actors, but actor roles/characters.

1289755958_Screenshot2022-12-18at03-35-59Emby.png.7a5cf19a392ebae3792c98c3bc488091.png

So clicking Rocky Johnson would take you to a pagelike an actors page but tell you about the character and show a photo of the character played.

I dont know of any metadata providers for this, so the demand for this would just be people like me - i think who would actually take the time to curate my own library.

 

But in the meantime the description you gave would allow me to create my own webpages of roles and trivia for each person :) and have that on a link.

 

thanks :)

 

 

Link to comment
Share on other sites

TvMaze does have character information, same as TheTVDB.

TMDB and OMDB don't.

I'm not sure whether there would be enough general interest in such a feature.
@Luke ?

Link to comment
Share on other sites

  • 1 year later...
Haikner
On 12/18/2022 at 4:25 AM, softworkz said:

Yes, there was an issue which is fixed now.

Hi, I've been working on a metadata plugin for Emby and found that even now there is still a problem. The unique ID I'm using consists of two parts separated by a slash, so for example "anime/21658". When I try to click on the link in the metadata editor, it works as expected without any problem (I am redirected to  https://akichan.moe/anime/21658 ).

obrazek.png.f941d8ed78ab0da5a7417ba9acfe025d.png

But when I click on the link in the normal info, the link gets truncated and instead of "anime/21658" only "anime" remains in the URL, so the link doesn't (logically) lead where it should. The images come from the Beta version of Emby, the problem is apparently in both the normal and Beta version.

obrazek.png.48aa2febf32647039ca9cc249fd76f22.png

Link to comment
Share on other sites

mickle026
3 hours ago, Haikner said:

Hi, I've been working on a metadata plugin for Emby and found that even now there is still a problem. The unique ID I'm using consists of two parts separated by a slash, so for example "anime/21658". When I try to click on the link in the metadata editor, it works as expected without any problem (I am redirected to  https://akichan.moe/anime/21658 ).

obrazek.png.f941d8ed78ab0da5a7417ba9acfe025d.png

But when I click on the link in the normal info, the link gets truncated and instead of "anime/21658" only "anime" remains in the URL, so the link doesn't (logically) lead where it should. The images come from the Beta version of Emby, the problem is apparently in both the normal and Beta version.

obrazek.png.48aa2febf32647039ca9cc249fd76f22.png

The workaround is to use a backslash \ rather than a forward slash /, webrowsers will follow it anyway.  Its not perfect but it works.

or

have   https://akichan.moe/anime/ as your provider url https://akichan.moe/anime/{0} so that you only need  21658 storing

Emby has removed forward slashes here as far back as I remember.

Edited by mickle026
Link to comment
Share on other sites

Haikner

I must admit that using \ would probably never have occurred to me. I'd have to redo some of the code to do it, but the bigger problem is that it would break previously saved IDs (I'm making this plugin for a friend and since this is the only thing that doesn't work for me, I sent him the DLL file and he's already started using the plugin). I don't know if Emby supports something like a migration when updating a plugin...

The second option is unfortunately not usable for me at all, because the "anime" part is dynamic, not static, that's why it's part of the ID.

Link to comment
Share on other sites

mickle026
1 minute ago, Haikner said:

I must admit that using \ would probably never have occurred to me. I'd have to redo some of the code to do it, but the bigger problem is that it would break previously saved IDs (I'm making this plugin for a friend and since this is the only thing that doesn't work for me, I sent him the DLL file and he's already started using the plugin). I don't know if Emby supports something like a migration when updating a plugin...

The second option is unfortunately not usable for me at all, because the "anime" part is dynamic, not static, that's why it's part of the ID.

You could use a redirect URL.

I do this with one of mine so that they all point to the same place and the website then does a redirect when it looks up the id.

Link to comment
Share on other sites

Haikner

I'm not sure I follow, but if I understand correctly, there's been some misunderstanding. Both parts are a necessary part of the ID, the number alone is not enough. For example:
https://akichan.moe/anime/14000
https://akichan.moe/dorama/14000
are two completely different things and both can be found by my Emby plugin. The number 14000 can theoretically refer to 9 different things on Akichan, 3 of which are of type "movie/tv series".

Link to comment
Share on other sites

roaku

What happens if the encoded value for the slash, '%2F' is used?

  • Like 1
Link to comment
Share on other sites

Haikner

I have no idea, to try this I would (just like with suggested "\") have to modify the plugin code and invalidate already saved IDs. Honestly, I'd probably rather remove the link completely than invalidate the saved IDs. 🙁

Link to comment
Share on other sites

mickle026
1 hour ago, Haikner said:

I'm not sure I follow, but if I understand correctly, there's been some misunderstanding. Both parts are a necessary part of the ID, the number alone is not enough. For example:
https://akichan.moe/anime/14000
https://akichan.moe/dorama/14000
are two completely different things and both can be found by my Emby plugin. The number 14000 can theoretically refer to 9 different things on Akichan, 3 of which are of type "movie/tv series".

 

@roakusuggestion %2F instead of / works just fine.  I like this :)

You could bulk replace them with a repair button in your plugin?

Here is what I do to copy from tmdb to my custom provider id (radarr), you can modify it by changing th provider ids to you provider id, read yours modifify it with a replace("/","%2F") and write it back.

Remove the logging because I use a custom built logger not emby internal one.

public string Get(CopyTmdbKeys2CustomMovieId1 result)
        {

            config = Plugin.Instance.Configuration;
            Current = this;

            string LogPath = Current.configurationManager.ApplicationPaths.LogDirectoryPath;
            string MyLog = Path.Combine(LogPath, $"PID_Extender_CopyTmdbKeys2CustomMovieId1_" + DateTime.Now.ToString("dd.MMM.yyy-HH'.'mm'.'ss") + ".txt");
            var log = new PIDExt_FileLogging();

            var xMovies = libraryManager.GetInternalItemIds(new InternalItemsQuery
            {
                IncludeItemTypes = new[] { "Movie" },
            });
            var MovieCount = xMovies.Length;
            var ProcessingCount = 0;
            var ProcessedCount = 0;

            log.PIDExt_ioLogging(MyLog, DateTime.Now.ToString("dd.MMM.yyy - HH':'mm':'ss") + $" CustomMovieId1 Ids Items to Process: {MovieCount}");
            log.PIDExt_ioLogging(MyLog, DateTime.Now.ToString("dd.MMM.yyy - HH':'mm':'ss") + $" Log: {MyLog}");
            log.PIDExt_ioLogging(MyLog, DateTime.Now.ToString("dd.MMM.yyy - HH':'mm':'ss") + $" ==========================================");

            foreach (var SingleMovie in xMovies)
            {
                ProcessingCount++;

                try
                {
                    BaseItem IndividualMovie = libraryManager.GetItemById(SingleMovie);
                    string radarrid = IndividualMovie.GetProviderId("Tmdb");

                    if (!string.IsNullOrEmpty(radarrid))
                    {
                        ProcessedCount++;
                        log.PIDExt_ioLogging(MyLog, DateTime.Now.ToString("dd.MMM.yyy - HH':'mm':'ss") + $" Copy Item ({ProcessingCount}) : {IndividualMovie.Name} , Imdb={radarrid}");
                        IndividualMovie.ProviderIds.Add(config.CustomMovieIdName, radarrid);
                        IndividualMovie.SetProviderId(config.CustomMovieIdName, radarrid);
                        IndividualMovie.UpdateToRepository(ItemUpdateType.MetadataEdit);
                    }
                    else if (radarrid == string.Empty)
                    {
                        try
                        {
                            IndividualMovie.ProviderIds.Remove(config.CustomMovieIdName);
                            log.PIDExt_ioLogging(MyLog, DateTime.Now.ToString("dd.MMM.yyy - HH':'mm':'ss") + $" Removed Empty Key from DB ({ProcessingCount}) : {IndividualMovie.Name}");
                        }
                        catch { }
                    }
                }
                catch { }
            }

            log.PIDExt_ioLogging(MyLog, DateTime.Now.ToString("dd.MMM.yyy - HH':'mm':'ss") + $" ==========================================");
            log.PIDExt_ioLogging(MyLog, DateTime.Now.ToString("dd.MMM.yyy - HH':'mm':'ss") + $" Finished, {ProcessedCount} ids changed/updated or added.");

            string ReturnText = string.Empty;

            if (ProcessedCount > 0)
            {
                ReturnText = $"All Copied - found {ProcessedCount} ids!\nLogged to: {MyLog}";
            }
            else
            {
                ReturnText = $"Nothing Copied, 0 Imdb ids found!\nLogged to: {MyLog}";
            }

            return JsonSerializer.SerializeToString(new CopyTmdbKeys2CustomMovieId1()
            {
                Text = ReturnText
            }); ;
        }

 

Edited by mickle026
Link to comment
Share on other sites

mickle026
On 18/12/2022 at 03:00, softworkz said:

LOL, no big thing. Personally I don't even mind, it's just the Emby policy for the plugin catalog.

Oh no - you can. That's a different story. Your provider can also return multiple IDs for such links. You can either create your own IDs for this, or use one of the new built-in ProviderIds that we have added recently (will be in beta .22):

Key Format

Facebook

https://www.facebook.com/{0}

Instagram

https://www.instagram.com/{0}

Twitter

https://twitter.com/{0}

Official Website

{0}

 

 

 

 

 

I still don't see this in 4.8 stable. Not in MetadataProviders at least.  Everything I have tried still results in emby truncating the at the forward slash / .

Link to comment
Share on other sites

1 hour ago, mickle026 said:
On 12/18/2022 at 4:00 AM, softworkz said:

Oh no - you can. That's a different story. Your provider can also return multiple IDs for such links. You can either create your own IDs for this, or use one of the new built-in ProviderIds that we have added recently (will be in beta .22):

Key Format

Facebook

https://www.facebook.com/{0}

Instagram

https://www.instagram.com/{0}

Twitter

https://twitter.com/{0}

Official Website

{0}

 

 

 

 

 

I still don't see this in 4.8 stable. Not in MetadataProviders at least.  Everything I have tried still results in emby truncating the at the forward slash / .

They have been there but @Lukehas deleted them shortly after.

IIRC the argument was that a provider could define such ID on its own. I disagreed to the removal, because I think that a provider should only define such IDs for URL spaces that it handles exclusively. For example, a TvMaze provider should define a "tvmaze" ProviderId, for which it takes the sole responsibilitiy. But social network URLs like Facebook, Instagram and Twitter can be provided by multiple different metadata providers and if each one would define for example a "facebook" provider ID, it would lead to a collision of IDs. That's why I had added them to the common code for being available to be used by multiple providers.

 

My recommendation is still that these should be added.

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...