Jump to content

How to add an external url?


mickle026

Recommended Posts

9 hours ago, Haikner said:
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.

 

You are experiencing the exact same issues that I had come across last year. The problem is that there are (rare) cases where a provider ID can have multiple values (i.e. there are multiple IDs of the same type for an item). Unfortunately, these are saved in the database as a single string, delimited with a slash ('/'). The result of this design flaw is that IDs which are containing slashes are considered as being multiple separate IDs. This is not only unfortunate with regards to URL generation

I had proposed a solution which would have solved that in a compatible way, but it has been declined with the argument that we could switch to a different delimiter to solve this - which would have been a DB-breaking change and of course it never happened.

Link to comment
Share on other sites

mickle026
1 hour ago, softworkz said:

 

You are experiencing the exact same issues that I had come across last year. The problem is that there are (rare) cases where a provider ID can have multiple values (i.e. there are multiple IDs of the same type for an item). Unfortunately, these are saved in the database as a single string, delimited with a slash ('/'). The result of this design flaw is that IDs which are containing slashes are considered as being multiple separate IDs. This is not only unfortunate with regards to URL generation

I had proposed a solution which would have solved that in a compatible way, but it has been declined with the argument that we could switch to a different delimiter to solve this - which would have been a DB-breaking change and of course it never happened.

I dont mind the slash / being treated as a delimeter if we could pull the id's (seperate) outs as {0} {1} etc then the url would just be rebuilt by the custom provider id. 

so:    mypage/1234

could be built:  "http://linking.to/{0}/{1}.htm"  - http://linking.to/mypage/1234.htm

its no so dissimilar - essentially the same as...

 

anyway more importantly because this can wait a little.  Has the forum been hacked / infiltrated, like the post above, im getting crap like this in email from here too (as if someone replied to to this conversation but the post is not there) - its nothing to do with this thread?

email from emby username FrancesaCed, and now the post above by SamuellaDes

Edited by mickle026
Link to comment
Share on other sites

37 minutes ago, mickle026 said:

Has the forum been hacked / infiltrated, like the post above, im getting crap like this in email from here too (as if someone replied to to this conversation but the post is not there) - its nothing to do with this thread?

I flagged the poster as spammer. He's banned now.

Anybody can register an account and post something. But these forums are well-moderated, such posts never last for long here.

Edited by softworkz
Link to comment
Share on other sites

38 minutes ago, mickle026 said:

I dont mind the slash / being treated as a delimeter if we could pull the id's (seperate) outs as {0} {1} etc then the url would just be rebuilt by the custom provider id. 

so:    mypage/1234

could be built:  "http://linking.to/{0}/{1}.htm"  - http://linking.to/mypage/1234.htm

This would be a breaking change, incompatible with everything we have. An ID is an identifier, which means a single value which is uniquely identifying an entity, and as such it cannot be two or multi-part. Also it would not solve the underlying issue that sometimes, multiple IDs are stored with slash delimiters - which is something totally different, because each one is itself uniquely identifying something - opposed to the case above where a single ID is comprised of multiple parts and only the combination of all parts is unique.

To handle this properly, it needs to be known/declared, which of those two cases a certain ProviderId is adhering to. 

Link to comment
Share on other sites

Haikner
4 hours ago, softworkz said:

 

You are experiencing the exact same issues that I had come across last year. The problem is that there are (rare) cases where a provider ID can have multiple values (i.e. there are multiple IDs of the same type for an item). Unfortunately, these are saved in the database as a single string, delimited with a slash ('/'). The result of this design flaw is that IDs which are containing slashes are considered as being multiple separate IDs. This is not only unfortunate with regards to URL generation

I had proposed a solution which would have solved that in a compatible way, but it has been declined with the argument that we could switch to a different delimiter to solve this - which would have been a DB-breaking change and of course it never happened.

Okay, thanks for the answer... Still, I have to ask, how is it possible that the link works without any problem in the metadata editor? Do you store the IDs for the links separately/in a different way than the ones used in metadata management?

Link to comment
Share on other sites

Haikner
7 hours ago, mickle026 said:

 

@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
            }); ;
        }

 

Thanks for the advice, since it seems I will have no other option, I will try it.

Edited by Haikner
Link to comment
Share on other sites

4 minutes ago, Haikner said:

Okay, thanks for the answer... Still, I have to ask, how is it possible that the link works without any problem in the metadata editor? Do you store the IDs for the links separately/in a different way than the ones used in metadata management?

The IDs are always coming from the the same place in the database. When items are viewed normally in the app, the server builds the URLs (splitting the ID by '/') and transmits them to the client as part of the Emby SDK Reference: BaseItemDto model. Without having it looked up, I suppose that the URL generation is just done differently in case of the Metadata Editor (maybe even at the client-side).

Link to comment
Share on other sites

Haikner

Okay. I really can't say I'm happy about this bug (and yes, I'll call it a bug), but I'm grateful that it was at least explained to me, thanks.

On a different note. It would be nice if Emby would add AVIF image support. I've managed to get the image provider working in the plugin, but only for JPG images, which the Akichan database only has for backwards compatibility and will soon remove them completely.

  • Like 1
Link to comment
Share on other sites

1 minute ago, Haikner said:

Okay. I really can't say I'm happy about this bug (and yes, I'll call it a bug), but I'm grateful that it was at least explained to me, thanks.

I've been quite unhappy about it myself when I did the TvMaze metadata provider last year. 🙂 

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