Jump to content

Assign Poster from Refresh metadata with Plugin


mickle026

Recommended Posts

mickle026

Hi @@chef,

 

Im still messing about trying to learn how to do plugins :P, im still trying to learn c# too.   So excuse me as I am trying.

 

So far I have managed to mod one of those on git hub as a poster image downloader from my own server.

 

I have it working so far like this:

Images > Find image magnifying glass.  This works like a charm, clicking download , it downloads and assigns.

 

 5e8529cb16068_Untitled_1.png

 

But I want it to add the image automatically when doing a refresh metadata > replace images.

 

This is what is not working properly.

Refresh metadata and replace images is using it to look up the image, but thats it.  How do I set emby up to download it and assign it?

 

5e8529fdae6d8_Untitled_2.png

 

5e8530f59468e_Untitled_3.png

 

 

When running refresh metadta with replace thumbs I log that I am finding it

 

// get poster

2020-04-02 01:24:15.108 Info PosterClient_CSharp: GetUrl: http://NASSERVER2/PosterServer/Throw.Momma.From.The.Train.1987/poster.jpg2020-04-02 01:24:15.108 Info PosterClient_CSharp: Matched:Throw.Momma.From.The.Train.1987//get thumbs 2020-04-02 01:24:15.113 Info PosterClient_CSharp: GetUrl: http://NASSERVER2/PosterServer/Throw.Momma.From.The.Train.1987/thumb.jpg2020-04-02 01:24:15.113 Info PosterClient_CSharp: Matched:Throw.Momma.From.The.Train.1987

I have managed to add it here and it is using it according to my logs its finding the poster but how do I automatically download and assign it?




			
				


	Edited  by Luke
	
	

			
		
Link to comment
Share on other sites

 

 

I have managed to add it here and it is using it according to my logs its finding the poster but how do I automatically download and assign it?

Hi, great job getting this far.

 

To answer the question, you don't do this in your plugin. The emby server core will handle this for you.

Link to comment
Share on other sites

chef

I was just going to say, if you replace the image, you could kick off the refresh task and the server will take care of it. :)

Link to comment
Share on other sites

mickle026

For some strange reason, it is doing now.  When I posted my question I was trying and trying and it wasn't.

 

Lol.  Thanks guys!

Link to comment
Share on other sites

mickle026

OK, got this working fine now, but how do I handle no image

 

Currently if the image is there it works fine, but if there is no image, i get a crash.

2020-04-02 21:00:53.342 Info HttpServer: HTTP Response 204 to ::1. Time: 20ms. http://localhost:8096/emby/Items/38/Refresh?Recursive=true&ImageRefreshMode=FullRefresh&MetadataRefreshMode=FullRefresh&ReplaceAllImages=true&ReplaceAllMetadata=true
2020-04-02 21:00:53.487 Info MediaProbeManager: ProcessRun 'ffprobe' Execute: C:\Users\mike\AppData\Roaming\Emby-Server\system\ffprobe.exe -i file:"\\NASSERVER2\PosterServer\Movies\Throw Momma From The Train (1987).mp4" -threads 0 -v info -print_format json -show_streams -show_chapters -show_format -show_data
2020-04-02 21:00:53.873 Info MediaProbeManager: ProcessRun 'ffprobe' Process exited with code 0
2020-04-02 21:00:53.964 Info PosterClient_CSharp: #################################################################
2020-04-02 21:00:53.964 Info PosterClient_CSharp: ##                     LOCAL POSTER SERVER                    ###
2020-04-02 21:00:53.964 Info PosterClient_CSharp: #################################################################
2020-04-02 21:00:53.964 Info PosterClient_CSharp: We are in Task<IEnumerable<RemoteImageInfo>> GetImages: (step 1) 
2020-04-02 21:00:53.970 Info PosterClient_CSharp: #################################################################
2020-04-02 21:00:53.970 Info PosterClient_CSharp: ##                     LOOK FOR POSTERS                       ###
2020-04-02 21:00:53.970 Info PosterClient_CSharp: #################################################################
2020-04-02 21:00:53.970 Info PosterClient_CSharp: PosterUrl: http://NASSERVER2/PosterServer/MoviePosters.txt (Step 2)
2020-04-02 21:00:53.974 Info PosterClient_CSharp: GetListUrl: http://NASSERVER2/PosterServer/MoviePosters.txt (Step 3)
2020-04-02 21:00:53.974 Info HttpClient: GET http://NASSERVER2/PosterServer/MoviePosters.txt
2020-04-02 21:00:53.984 Info PosterClient_CSharp: ## GetAvailableImages ## (Step 5)
2020-04-02 21:00:53.985 Info PosterClient_CSharp: Filenames on the server: Throw Momma From The Train (1987) (Step 6)
2020-04-02 21:00:53.985 Info PosterClient_CSharp: Filenames on the server: Throw.Momma.From.The.Train.(1987) (Step 6)
2020-04-02 21:00:53.986 Info PosterClient_CSharp: ## Find the Match ## (Step 7)
2020-04-02 21:00:53.986 Info PosterClient_CSharp: Titles to SEARCH in the SERVER List: Throw Momma From The Train (1987) (Step 8)
2020-04-02 21:00:53.986 Info PosterClient_CSharp: Titles to SEARCH in the SERVER List: Throw.Momma.From.The.Train.(1987) (Step 8)
2020-04-02 21:00:53.986 Info PosterClient_CSharp: OurSEARCH: Original Name: Throw Momma From The Train (Step 9)
2020-04-02 21:00:53.986 Info PosterClient_CSharp: OurSEARCH: Adding Production Year: Throw Momma From The Train (1987) (Step 9a)
2020-04-02 21:00:53.986 Info PosterClient_CSharp: Possible Match: Throw Momma From The Train (1987)
2020-04-02 21:00:53.986 Info PosterClient_CSharp: ### ITEM EXISTS ###
2020-04-02 21:00:53.986 Info PosterClient_CSharp: Found a Match: Throw Momma From The Train (1987) (Step 10):
2020-04-02 21:00:53.986 Info PosterClient_CSharp: Image Type: poster
2020-04-02 21:00:53.986 Info PosterClient_CSharp: Get Image From Url: http://NASSERVER2/PosterServer/Throw Momma From The Train (1987)/poster.jpg
2020-04-02 21:00:53.986 Info PosterClient_CSharp: Adding Image: http://NASSERVER2/PosterServer/Throw Momma From The Train (1987)/poster.jpg
2020-04-02 21:00:53.986 Info PosterClient_CSharp: #################################################################
2020-04-02 21:00:53.986 Info PosterClient_CSharp: ##                     LOOK FOR THUMBS                        ###
2020-04-02 21:00:53.986 Info PosterClient_CSharp: #################################################################
2020-04-02 21:00:53.986 Info PosterClient_CSharp: ThumbsUrl: http://NASSERVER2/PosterServer/MovieThumbs.txt
2020-04-02 21:00:53.986 Info PosterClient_CSharp: GetListUrl: http://NASSERVER2/PosterServer/MovieThumbs.txt (Step 3)
2020-04-02 21:00:53.986 Info HttpClient: GET http://NASSERVER2/PosterServer/MovieThumbs.txt
2020-04-02 21:00:54.093 Info PosterClient_CSharp: ## GetAvailableImages ## (Step 5)
2020-04-02 21:00:54.093 Info PosterClient_CSharp: Filenames on the server: Throw Momma From The Train (1987) (Step 6)
2020-04-02 21:00:54.093 Info PosterClient_CSharp: Filenames on the server: Throw.Momma.From.The.Train.(1987) (Step 6)
2020-04-02 21:00:54.093 Info PosterClient_CSharp: ## Find the Match ## (Step 7)
2020-04-02 21:00:54.093 Info PosterClient_CSharp: Titles to SEARCH in the SERVER List: Throw Momma From The Train (1987) (Step 8)
2020-04-02 21:00:54.093 Info PosterClient_CSharp: Titles to SEARCH in the SERVER List: Throw.Momma.From.The.Train.(1987) (Step 8)
2020-04-02 21:00:54.093 Info PosterClient_CSharp: OurSEARCH: Original Name: Throw Momma From The Train (Step 9)
2020-04-02 21:00:54.093 Info PosterClient_CSharp: OurSEARCH: Adding Production Year: Throw Momma From The Train (1987) (Step 9a)
2020-04-02 21:00:54.093 Info PosterClient_CSharp: Possible Match: Throw Momma From The Train (1987)
2020-04-02 21:00:54.093 Info PosterClient_CSharp: ### ITEM EXISTS ###
2020-04-02 21:00:54.093 Info PosterClient_CSharp: Found a Match: Throw Momma From The Train (1987) (Step 10):
2020-04-02 21:00:54.093 Info PosterClient_CSharp: Image Type: thumb
2020-04-02 21:00:54.093 Info PosterClient_CSharp: Get Image From Url: http://NASSERVER2/PosterServer/Throw Momma From The Train (1987)/thumb.jpg
2020-04-02 21:00:54.093 Info PosterClient_CSharp: Adding Image: http://NASSERVER2/PosterServer/Throw Momma From The Train (1987)/thumb.jpg
2020-04-02 21:00:54.102 Info PosterClient_CSharp: GetImageResponseUrl: http://NASSERVER2/PosterServer/Throw Momma From The Train (1987)/poster.jpg
2020-04-02 21:00:54.103 Info HttpClient: GET http://NASSERVER2/PosterServer/Throw Momma From The Train (1987)/poster.jpg
2020-04-02 21:00:54.171 Info PosterClient_CSharp: GetImageResponseUrl: http://NASSERVER2/PosterServer/Throw Momma From The Train (1987)/thumb.jpg
2020-04-02 21:00:54.171 Info HttpClient: GET http://NASSERVER2/PosterServer/Throw Momma From The Train (1987)/thumb.jpg

With Crash

2020-04-02 21:26:50.488 Info MediaProbeManager: ProcessRun 'ffprobe' Process exited with code 0
2020-04-02 21:26:50.574 Info PosterClient_CSharp: #################################################################
2020-04-02 21:26:50.574 Info PosterClient_CSharp: ##                     LOCAL POSTER SERVER                    ###
2020-04-02 21:26:50.574 Info PosterClient_CSharp: #################################################################
2020-04-02 21:26:50.574 Info PosterClient_CSharp: We are in Task<IEnumerable<RemoteImageInfo>> GetImages: (step 1) 
2020-04-02 21:26:50.579 Info PosterClient_CSharp: #################################################################
2020-04-02 21:26:50.579 Info PosterClient_CSharp: ##                     LOOK FOR POSTERS                       ###
2020-04-02 21:26:50.579 Info PosterClient_CSharp: #################################################################
2020-04-02 21:26:50.579 Info PosterClient_CSharp: PosterUrl: http://NASSERVER2/PosterServer/MoviePosters.txt (Step 2)
2020-04-02 21:26:50.579 Info PosterClient_CSharp: GetListUrl: http://NASSERVER2/PosterServer/MoviePosters.txt (Step 3)
2020-04-02 21:26:50.580 Info HttpClient: GET http://NASSERVER2/PosterServer/MoviePosters.txt
2020-04-02 21:26:50.684 Info PosterClient_CSharp: ## GetAvailableImages ## (Step 5)
2020-04-02 21:26:50.684 Info PosterClient_CSharp: Filenames on the server: Throw Momma From The Train (1987) (Step 6)
2020-04-02 21:26:50.684 Info PosterClient_CSharp: Filenames on the server: Throw.Momma.From.The.Train.(1987) (Step 6)
2020-04-02 21:26:50.685 Info PosterClient_CSharp: ## Find the Match ## (Step 7)
2020-04-02 21:26:50.685 Info PosterClient_CSharp: Titles to SEARCH in the SERVER List: Throw Momma From The Train (1987) (Step 8)
2020-04-02 21:26:50.685 Info PosterClient_CSharp: Titles to SEARCH in the SERVER List: Throw.Momma.From.The.Train.(1987) (Step 8)
2020-04-02 21:26:50.685 Info PosterClient_CSharp: OurSEARCH: Original Name: Throw Momma From The Train (Step 9)
2020-04-02 21:26:50.685 Info PosterClient_CSharp: OurSEARCH: Adding Production Year: Throw Momma From The Train (1987) (Step 9a)
2020-04-02 21:26:50.685 Info PosterClient_CSharp: Possible Match: Throw Momma From The Train (1987)
2020-04-02 21:26:50.685 Info PosterClient_CSharp: ### ITEM EXISTS ###
2020-04-02 21:26:50.685 Info PosterClient_CSharp: Found a Match: Throw Momma From The Train (1987) (Step 10):
2020-04-02 21:26:50.685 Info PosterClient_CSharp: Image Type: poster
2020-04-02 21:26:50.686 Info PosterClient_CSharp: Get Image From Url: http://NASSERVER2/PosterServer/Throw Momma From The Train (1987)/poster.jpg
2020-04-02 21:26:50.686 Info PosterClient_CSharp: Adding Image: http://NASSERVER2/PosterServer/Throw Momma From The Train (1987)/poster.jpg
2020-04-02 21:26:50.686 Info PosterClient_CSharp: #################################################################
2020-04-02 21:26:50.686 Info PosterClient_CSharp: ##                     LOOK FOR THUMBS                        ###
2020-04-02 21:26:50.686 Info PosterClient_CSharp: #################################################################
2020-04-02 21:26:50.686 Info PosterClient_CSharp: ThumbsUrl: http://NASSERVER2/PosterServer/MovieThumbs.txt
2020-04-02 21:26:50.686 Info PosterClient_CSharp: GetListUrl: http://NASSERVER2/PosterServer/MovieThumbs.txt (Step 3)
2020-04-02 21:26:50.686 Info HttpClient: GET http://NASSERVER2/PosterServer/MovieThumbs.txt
2020-04-02 21:26:50.695 Info PosterClient_CSharp: ## GetAvailableImages ## (Step 5)
2020-04-02 21:26:50.695 Info PosterClient_CSharp: Filenames on the server: Throw Momma From The Train (1987) (Step 6)
2020-04-02 21:26:50.695 Info PosterClient_CSharp: Filenames on the server: Throw.Momma.From.The.Train.(1987) (Step 6)
2020-04-02 21:26:50.695 Info PosterClient_CSharp: ## Find the Match ## (Step 7)
2020-04-02 21:26:50.695 Info PosterClient_CSharp: Titles to SEARCH in the SERVER List: Throw Momma From The Train (1987) (Step 8)
2020-04-02 21:26:50.695 Info PosterClient_CSharp: Titles to SEARCH in the SERVER List: Throw.Momma.From.The.Train.(1987) (Step 8)
2020-04-02 21:26:50.695 Info PosterClient_CSharp: OurSEARCH: Original Name: Throw Momma From The Train (Step 9)
2020-04-02 21:26:50.695 Info PosterClient_CSharp: OurSEARCH: Adding Production Year: Throw Momma From The Train (1987) (Step 9a)
2020-04-02 21:26:50.695 Info PosterClient_CSharp: Possible Match: Throw Momma From The Train (1987)
2020-04-02 21:26:50.695 Info PosterClient_CSharp: ### ITEM EXISTS ###
2020-04-02 21:26:50.695 Info PosterClient_CSharp: Found a Match: Throw Momma From The Train (1987) (Step 10):
2020-04-02 21:26:50.695 Info PosterClient_CSharp: Image Type: thumb
2020-04-02 21:26:50.695 Info PosterClient_CSharp: Get Image From Url: http://NASSERVER2/PosterServer/Throw Momma From The Train (1987)/thumb.jpg
2020-04-02 21:26:50.695 Info PosterClient_CSharp: Adding Image: http://NASSERVER2/PosterServer/Throw Momma From The Train (1987)/thumb.jpg
2020-04-02 21:26:50.695 Info PosterClient_CSharp: #################################################################
2020-04-02 21:26:50.695 Info PosterClient_CSharp: ##                     LOOK FOR BACKDROPS                     ###
2020-04-02 21:26:50.695 Info PosterClient_CSharp: #################################################################
2020-04-02 21:26:50.695 Info PosterClient_CSharp: ThumbsUrl: http://NASSERVER2/PosterServer/MovieBackdrops.txt
2020-04-02 21:26:50.695 Info PosterClient_CSharp: GetListUrl: http://NASSERVER2/PosterServer/MovieBackdrops.txt (Step 3)
2020-04-02 21:26:50.695 Info HttpClient: GET http://NASSERVER2/PosterServer/MovieBackdrops.txt
2020-04-02 21:26:50.702 Info PosterClient_CSharp: ## GetAvailableImages ## (Step 5)
2020-04-02 21:26:50.702 Info PosterClient_CSharp: Filenames on the server: Throw Momma From The Train (1987) (Step 6)
2020-04-02 21:26:50.702 Info PosterClient_CSharp: ## Find the Match ## (Step 7)
2020-04-02 21:26:50.702 Info PosterClient_CSharp: Titles to SEARCH in the SERVER List: Throw Momma From The Train (1987) (Step 8)
2020-04-02 21:26:50.702 Info PosterClient_CSharp: OurSEARCH: Original Name: Throw Momma From The Train (Step 9)
2020-04-02 21:26:50.702 Info PosterClient_CSharp: OurSEARCH: Adding Production Year: Throw Momma From The Train (1987) (Step 9a)
2020-04-02 21:26:50.702 Info PosterClient_CSharp: Possible Match: Throw Momma From The Train (1987)
2020-04-02 21:26:50.702 Info PosterClient_CSharp: ### ITEM EXISTS ###
2020-04-02 21:26:50.702 Info PosterClient_CSharp: Found a Match: Throw Momma From The Train (1987) (Step 10):
2020-04-02 21:26:50.702 Info PosterClient_CSharp: Image Type: backdrop
2020-04-02 21:26:50.702 Info PosterClient_CSharp: Get Image From Url: http://NASSERVER2/PosterServer/Throw Momma From The Train (1987)/backdrop.jpg
2020-04-02 21:26:50.702 Info PosterClient_CSharp: Adding Image: http://NASSERVER2/PosterServer/Throw Momma From The Train (1987)/backdrop.jpg
2020-04-02 21:26:50.702 Info PosterClient_CSharp: #################################################################
2020-04-02 21:26:50.702 Info PosterClient_CSharp: ##                      LOOK FOR BANNER                       ###
2020-04-02 21:26:50.702 Info PosterClient_CSharp: #################################################################
2020-04-02 21:26:50.702 Info PosterClient_CSharp: ThumbsUrl: http://NASSERVER2/PosterServer/MovieBanner.txt
2020-04-02 21:26:50.702 Info PosterClient_CSharp: GetListUrl: http://NASSERVER2/PosterServer/MovieBanner.txt (Step 3)
2020-04-02 21:26:50.703 Info HttpClient: GET http://NASSERVER2/PosterServer/MovieBanner.txt
2020-04-02 21:26:50.712 Info PosterClient_CSharp: ## GetAvailableImages ## (Step 5)
2020-04-02 21:26:50.712 Info PosterClient_CSharp: Filenames on the server: Nothing Here (Step 6)
2020-04-02 21:26:50.712 Info PosterClient_CSharp: ## Find the Match ## (Step 7)
2020-04-02 21:26:50.712 Info PosterClient_CSharp: Titles to SEARCH in the SERVER List: Nothing Here (Step 8)
2020-04-02 21:26:50.712 Info PosterClient_CSharp: OurSEARCH: Original Name: Throw Momma From The Train (Step 9)
2020-04-02 21:26:50.712 Info PosterClient_CSharp: OurSEARCH: Adding Production Year: Throw Momma From The Train (1987) (Step 9a)
2020-04-02 21:26:50.712 Info PosterClient_CSharp: No Match on Server: 
2020-04-02 21:26:50.712 Info PosterClient_CSharp: ### ITEM DOESN'T EXIST! ###
2020-04-02 21:26:50.712 Info PosterClient_CSharp: No Images Returned By Server!
2020-04-02 21:26:50.712 Info PosterClient_CSharp: !! Emby will report an Exception Now !!
2020-04-02 21:26:50.718 Error ProviderManager: PosterProvider failed in GetImageInfos for type Movie
	*** Error Report ***
	Version: 4.4.0.40
	Command line: C:\Users\mike\AppData\Roaming\Emby-Server\system\EmbyServer.dll -noautorunwebapp
	Operating system: Microsoft Windows NT 6.2.9200.0
	64-Bit OS: True
	64-Bit Process: True
	User Interactive: True
	Runtime: file:///C:/Users/mike/AppData/Roaming/Emby-Server/system/System.Private.CoreLib.dll
	System.Environment.Version: 3.1.2
	Processor count: 4
	Program data path: C:\Users\mike\AppData\Roaming\Emby-Server\programdata
	Application directory: C:\Users\mike\AppData\Roaming\Emby-Server\system
	System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.
	   at PosterClient_CSharp.PosterProvider.GetImages(BaseItem item, Boolean posters, Boolean thumbs, Boolean backdrops, Boolean banner, CancellationToken cancellationToken)
	   at MediaBrowser.Providers.Manager.ProviderManager.GetImages(BaseItem item, LibraryOptions libraryOptions, CancellationToken cancellationToken, IRemoteImageProvider provider, Int32 providerIndex)
	Source: PosterClient-CSharp
	TargetSite: Void MoveNext()

With the Error (No items in the file), Emby just stops and doesn't download what it found for the other image types.

 

 

This is confusing me

 

 

System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.
     at PosterClient_CSharp.PosterProvider.GetImages(BaseItem item, Boolean posters, Boolean thumbs, Boolean backdrops, Boolean banner, CancellationToken cancellationToken)

I get that it means something is empty or null, and it works if I put a name into the list that it can find.  So its return of no information (not found) thats causing this.

        private async Task<RemoteImageInfo> GetImage(BaseItem item, Stream stream, ImageType type, string remoteFilename)
        {

            var list = await GetAvailableImages(stream, _fileSystem).ConfigureAwait(false);

            var match = FindMatch(item, list);
            // list contains the available images on the server
            try
            {
                if (!string.IsNullOrEmpty(match))

                {
                    logger.Info("### ITEM EXISTS ###", null);
                    logger.Info("Found a Match: " + match + " (Step 10):", null);
                    logger.Info("Image Type: " + remoteFilename, null);
                    var url = GetUrl(match, remoteFilename);
                    //logger.Info("Matched: " + match, null);

                    if (!string.IsNullOrEmpty(url))
                    {
                        return new RemoteImageInfo
                        {
                            ProviderName = Name,
                            Type = type,
                            Url = url

                        };
                    }
                }
                else
                {
                    logger.Info("### ITEM DOESN'T EXIST! ###", null);
                    logger.Info("No Images Returned By Server!", null);
                    logger.Info("!! Emby will report an Exception Now !!", null);
                }
            }
            catch (InvalidCastException e)
            {
                logger.Info("Exception e in GetImage: " + e.Message, null);
            }
            return null;
        }

return null;

 

 

What should I return ?

 

Help will be very much appreciated.  Thanks
 

Link to comment
Share on other sites

chef

Maybe return an empty 'RemoteImageInfo' object instead of null...

return new RemoteImageInfo();

but leave it empty.

 

Then you could  check after the Task is complete to see if a result parameter (example: Url)  is not null.

RemoteImageInfo result = await GetImage();

if(Equals(result.Url, null)) return;

//Do something with result because it has Url data.

Does that help at all?

 

I know it's not a great idea to 'new-up' an object for the sake of not returning null... so I understand if you were to choose another way.

Edited by chef
Link to comment
Share on other sites

mickle026

WOW Thanks !!!

 

Just by adding the return empty RemoteImageInfo item to the else clause fixed this

else
                {
                    logger.Info("### ITEM DOESN'T EXIST! ###", null);
                    logger.Info("No Images Returned By Server!", null);
                    return new RemoteImageInfo
                    {
                    };
                }

THANK YOU !
 

:D :D :D :D :D :D

  • Like 1
Link to comment
Share on other sites

mickle026

Nice! Let me know if I can help again.

 

 

You will wish you never offered!! LOL

 

Thats all working now, thanks.  As below, all obtained from My Own Server.

 

5e866a768c501_Untitled.png

 

What I want to do now is use the config page to set custom urls.  I have my page setup, Thus:

 

5e8669dbef72d_Untitled2.png

<!DOCTYPE html>
<html>
<head>
    <title>My Poster Server</title>
</head>
<body>
    <div id="PosterClient_CSharpConfigurationPage" data-role="page" class="page type-interior pluginConfigurationPage PosterClient_CSharpConfigurationPage" data-require="emby-input,emby-button">
        <div data-role="content">
            <div class="content-primary">
                <div class="sectionTitleContainer flex align-items-center">
                    <h2 class="sectionTitle">My Poster Server Configuration</h2>
                </div>

                <form class="PosterClient_CSharpConfigurationPage">
                    <p style="margin:2em 0;">
                        Please set the urls that contain a list of images for each type on you Image Server</p>
                    <br />
                    <div class="inputContainer">
                      <label class="inputLabel inputLabelUnfocused" for="txtPosterList">PosterList:</label>
                        <input type="text" is="emby-input" id="txtPosterList" label="PosterList:" class="emby-input" />
                        <div class="fieldDescription">
                            Poster List File Url
                        </div>
                    </div>
                    <div class="inputContainer">
                      <label class="inputLabel inputLabelUnfocused" for="txtThumbList">ThumbList:</label>
                        <input type="text" is="emby-input" id="txtThumbList" label="ThumbList:" class="emby-input" />
                        <div class="fieldDescription">
                            Thumbnail List File Url
                        </div>
                    </div>
                   <div class="inputContainer">
                      <label class="inputLabel inputLabelUnfocused" for="txtBackdropList">BackdropList:</label>
                        <input type="text" is="emby-input" id="txtBackdropList" label="BackdropList:" class="emby-input" />
                        <div class="fieldDescription">
                            Backdrop List File Url
                        </div>
                    </div>
                    <div class="inputContainer">
                      <label class="inputLabel inputLabelUnfocused" for="txtBannerList">BannerList:</label>
                        <input type="text" is="emby-input" id="txtBannerList" label="BannerList:" class="emby-input" />
                        <div class="fieldDescription">
                            Banner List File Url
                        </div>
                    </div>

                    <button is="emby-button" type="submit" class="raised button-submit block"><span>Save</span></button>

                </form>
            </div>
        </div>
        <script type="text/javascript">
            var pluginId = "A65D56B1-6F1C-4EAC-8FB7-F191CDB61837";

            function loadConfig(page) {
                    Dashboard.showLoadingMsg();

                ApiClient.getPluginConfiguration(pluginId).then(function (config) {
                    if (config) {

                        $('#txtPosterList', page).val(config.PosterList || "");
                        $('#txtThumbList', page).val(config.ThumbList || "");
                        $('#txtBackdropList', page).val(config.BackdropList || "");
                        $('#txtBannerList', page).val(config.BannerList || "");

                    }
                    Dashboard.hideLoadingMsg();
                });
            }

             $(".PosterClient_CSharpConfigurationPage").on("pageinit", function () {
                    var page = this;

                    loadConfig(page);

                    $("#testConnection", page).on("click", function (event) {
                        Dashboard.showLoadingMsg();

                        var showError = function (msg) {
                            Dashboard.hideLoadingMsg();
                            require(["alert"], function (alert) {
                                alert(msg);
                            });
                        }

                        ApiClient.getPluginConfiguration(pluginId).then(function (config) {
                            if (!config) return showError("Please complete the plugin configuration form and save it.");

                        });
                    })
             .on("pageshow", function () {
                    var page = this;

                   loadConfig(page);
             });

            $('.PosterClient_CSharpConfigurationPage').on('submit', function (e) {

                Dashboard.showLoadingMsg();

                var form = this;

                ApiClient.getPluginConfiguration(PosterClient_CSharpConfigurationPage.pluginUniqueId).then(function (config) {
                    config = config;

                    if (!config) {
                        config = {}
                    }

                    config.PosterList = $('#txtAppID', form).val();
                    config.ThumbList = $('#txtAppKey', form).val();
					config.BackdropList = $('#txtBackdropList', form).val();
                    config.BannerList = $('#txtBannerList', form).val();

                    ApiClient.updatePluginConfiguration(pluginId, config).then(function () {
                                Dashboard.processPluginConfigurationUpdateResult();
                                loadConfig();
                            });

                });

                // Disable default form submission
                return false;
                Dashboard.hideLoadingMsg();
            });
        </script>
    </div>
</body>
</html>

I am trying to get the data in to my code like this , im currently only trying to read it and log it (Still using the const at the moment)

 private async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, bool posters, bool thumbs, bool backdrops, bool banner, CancellationToken cancellationToken)
        {
            var list = new List<RemoteImageInfo>();
            PluginConfiguration config = Plugin.Instance.Configuration;

            if (posters)
            {
                try
                {
                    const string url = "http://NASSERVER2/PosterServer/MoviePosters.txt";
                    
                    logger.Info("PosterUrl: " + url + " (Step 2)", null);

                    if (!string.IsNullOrEmpty(config.PosterList))
                    {
                        logger.Info("Read From Config PosterURL is Empty!", null);
                    }
                   else
                    {
                       logger.Info("Read From Config PosterURL: " + config.PosterList, null);
                    }
                    

However I am not getting any thing logged because it is again - erroring with the same null object reference

2020-04-02 23:34:28.692 Error ProviderManager: PosterProvider failed in GetImageInfos for type Movie
	*** Error Report ***
	Version: 4.4.0.40
	Command line: C:\Users\mike\AppData\Roaming\Emby-Server\system\EmbyServer.dll -noautorunwebapp
	Operating system: Microsoft Windows NT 6.2.9200.0
	64-Bit OS: True
	64-Bit Process: True
	User Interactive: True
	Runtime: file:///C:/Users/mike/AppData/Roaming/Emby-Server/system/System.Private.CoreLib.dll
	System.Environment.Version: 3.1.2
	Processor count: 4
	Program data path: C:\Users\mike\AppData\Roaming\Emby-Server\programdata
	Application directory: C:\Users\mike\AppData\Roaming\Emby-Server\system
	System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object.
	   at PosterClient_CSharp.FetchPoster.PosterProvider.GetImages(BaseItem item, Boolean posters, Boolean thumbs, Boolean backdrops, Boolean banner, CancellationToken cancellationToken)
	   at MediaBrowser.Providers.Manager.ProviderManager.GetImages(BaseItem item, LibraryOptions libraryOptions, CancellationToken cancellationToken, IRemoteImageProvider provider, Int32 providerIndex)
	Source: PosterClient-CSharp
	TargetSite: Void MoveNext()

with this bit of code

if (!string.IsNullOrEmpty(config.PosterList))
                    {
                        logger.Info("Read From Config PosterURL is Empty!", null);
                    }
                   else
                    {
                       logger.Info("Read From Config PosterURL: " + config.PosterList, null);
                    }

Im not sure that I have done the html java correct either because when I try to save, the screen goes black, reloads the server startup emby logo and goes back to the plugin with no entries so its not saving either .

 

I cannot check whether its null because nothing exists (which it probably is) by trying to save something.  I would have thought that the if (!string.IsNullOrEmpty(config.PosterList)) clause would have cought it though.

 

:unsure::wacko:

Edited by mickle026
Link to comment
Share on other sites

chef

This might help. I think your PluginConfiguration is null.

 

In your plugin class, add a public variable called 'Instance'

    public class Plugin : BasePlugin<PluginConfiguration>, IHasThumbImage, IHasWebPages
    {
        public static Plugin Instance { get; private set; }

        public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) : base(applicationPaths,
            xmlSerializer)
        {
            Instance = this;
        }

   }
This will allow us to access the PluginConfiguration object scoped throughout different classes of the Plugin.

 

 

I'm not sure if you are using a class which is handling the "IServerEntryPoint" interface or not.

 

If you are not, create a class called "ServerEntryPoint" which inherits "IServerEntryPoint"

 

Like this:

    public class ServerEntryPoint : IServerEntryPoint
    {
         public ServerEntryPoint()
         {
        
         }

         public void Run() //I run on plugin load
         {

         }

         Public void Dispose() //I dispose of persistent object or connections when the server restarts or exits
         {

         }
    }
The "Run" void function and the Dispose void function are both part of the IServerEntryPoint Interface and will add themselves to the class.

 

Inside the "Run()" function at the top, add this line of code which will run when the plugin loads:

    Plugin.Instance.UpdateConfiguration(Plugin.Instance.Configuration);
I have found that this will create the Plugin config files (configuration XML files) if they don't exist (which I think is your issue).

 

All it's doing is Updating itself.

         public void Run() //I run on plugin load
         {
             Plugin.Instance.UpdateConfiguration(Plugin.Instance.Configuration);

             //Any other code you want to handle on plugin load
         }
Also, you can do something like this:
public void Run() 
{
    var config = Plugin.Instance.Configuration;  //You config object 
    

    //Do some work with the config object here... change it... whatever you need
    // config.ListObject.Add(item);

    //Save the config again
    Plugin.Instance.UpdateConfiguration(config);

}
The good news is that by creating the public static Instance of the Configuration it becomes easily available in all your classes.

 

So, I believe it is because the configuration is not yet created that you get the null reference exception when you try to access it.

 

 

If I'm wrong please let me know, and I'll read your code more carefully LOL! ;)

 

P.S. there are a couple tricks I can show you to set up your plugin in a way that your javascript and html files are separate.

 

Are you familiar with Vanilla Javascript at all? I'm not sure how much longer emby's libraries will embrace jQuery (even though some of the http request schemes are still reliant on the ajax object).

It might be a good idea to consider writing Vanilla JS so you don;t have to refactor the solution later.

Edited by chef
Link to comment
Share on other sites

mickle026

I had tried doing this

    public class Plugin : BasePlugin<PluginConfiguration>, IHasThumbImage, IHasWebPages
    {
        public static Plugin Instance { get; private set; }

        public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) : base(applicationPaths,
            xmlSerializer)
        {
            Instance = this;
        }

   }

But was getting error about BasePlugin hiding configuration and Plugin being a higher class so was using:

 

class Plugin : BasePlugin, IHasThumbImage, IHasWebPages

 

Turns out that my Plugin configuration was not public.  Clue was in the "hiding", I just didn't see that :(, newbie error.

 

class PluginConfiguration : BasePluginConfiguration  -> public class PluginConfiguration : BasePluginConfiguration

    class Plugin : BasePlugin<PluginConfiguration>, IHasThumbImage, IHasWebPages
    {
        public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
            : base(applicationPaths, xmlSerializer)
        {
            Instance = this;
        }
        /// <summary>
        /// Gets the instance.
        /// </summary>
        public static Plugin Instance { get; private set; }

I have changed the javascript too, I was using examples from several plugins and had a few errors in it. As i have said in earlier posts these: { } are new to me and they really are annoying me!

 

Its saving and reloading now :) - thanks for the instance pointers - I kind of thought it was something to do with that but wasn't sure.  I certainly wasnt sure why i had a problem with BasePlugin<PluginConfiguration>.  "public class PluginConfiguration : BasePluginConfiguration" was there to be seen, I just didn't see it.

 

I just need to test the links I save in my config are valid

 

I have to say this is not easy is it?  - theres plenty of code but next to no pointers or explanations in it for newbies

 

My errors were in the java too, but once the xml wrote and even though javascript is pretty much new to me too i figured that out. 

 

 

Thank you again for you time.  Appreciated Muchly :D

 

:D :D :D :D
 

Link to comment
Share on other sites

mickle026

https://github.com/chefbennyj1

 

There are some more examples here

Thank You !!

 

I have added My Plugin to this message for anyone who wants to try it and let me know how it goes...

Its fully working as the list server but there is no checks yet for the = sign for the query server, so if you check the box and you are using a list type server then you url will have the moviename appended

 

5e87cb5c4ae6a_MyPosterServer1.png

 

5e87cb6a432e8_MyPosterServer2.png

 

 

I cannot figure out why these are blank now, clicking the card loads the images in another webpage tab just fine, so why there is no preview I cannot fathom.  It was working yesterday :huh:

Clicking the download works just fine, the image grabs and assigns.

 

Running a Refresh metadata with replace images works too if the images are on the server

 

5e87cb77f365e_MyPosterServer3.png

 

Server setup is seperate to the plugin, but is needed for it to work.

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