How do I get a thumbnail via HTTP API?
#1
Question 
This probably super easy, I just can't get my head round it.

I am able to get the thumbnail from XBMC using:

http://10.0.0.2/xbmcCmds/xbmcHttp?comman...6a6.tbn%20)

but all I get from that is a load of text, how do I covert it to a JPEG?
Reply
#2
it's mime64 encoded
Reply
#3
I've been attempting the same thing. I believe you can use the FileDownload command in the API or use the CopyFile command which would allow you to copy the thumb to a folder that is exposed to the web server.

Hopefully, someone can confirm or set me straight.
Reply
#4
do the getthumb. mime64-decode the data. you have your thumb.
or use the CopyFile/FileDownload stuff but that will surely be much slower if you plan to grab many thumbs..

http://en.wikipedia.org/wiki/Base64
Reply
#5
I may be being really dim but I can't seem to decode any thumbnails should the below code work?

$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'http://10.0.0.2/xbmcCmds/xbmcHttp?command=GetThumb(C:\Documents%20and%20Settings\jenkins\Application%20Data\XBMC\userdata\Thumbnails\Video\9\99caa6a6.tbn)');
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$test = curl_exec($curl_handle);
curl_close($curl_handle);


$ifp = fopen( "image.jpg", "wb" );
fwrite( $ifp, base64_decode( $test) );
fclose( $ifp );

It creates the image but the image doesn't open. Can anyone help.
Reply
#6
Can anyone help me with this? I am wanting to create a new web interface to control XBMC but am coming across this stumbling block and can't get round it.
Reply
#7
is there anyone who can give me a clue on this?

the above code was in PHP.
Reply
#8
I've tried GetThumb and couldn't get it to work either (C#).
I'm using FileDownload to get the now playing cover art...

Code:
public bool FileExists(string filePath)
        {
            string[] response =    parent.Request("FileExists", filePath);
            return parent.CreateBoolRespose(response);
        }
        
        public MemoryStream FileDownload(string filePath)
        {
            MemoryStream msFile;
            string[] aDownloadData;
            byte[] aFileBytes;
            
            if (this.FileExists(filePath))
            {
                try
                {
                    aDownloadData = parent.Request("FileDownload(" +filePath+ ";[bare])");
                    
                    if (aDownloadData != null)
                    {
                        aFileBytes     = Convert.FromBase64String(aDownloadData[0]);
                        msFile        = new MemoryStream(aFileBytes, 0, aFileBytes.Length);
                        //msFile.Write(aFileBytes, 0, aFileBytes.Length);
                    }
                    else
                        msFile = null;
                }
                catch (Exception e)
                {
                    parent.WriteToLog(DateTime.Now.ToString("dd.MM.yyyy hh:mm:ss") + " - DEBUG: " + e.Message + " || " + filePath);
                    msFile = null;
                }
            }
            else
            {
                MessageBox.Show("File does not exist");
                msFile = null;
            }
            
            return msFile;
        }
This returns a MemoryStream which you won't be using in PHP.
Image

Please add to my reputation if you find my posts usefull (+/- button below posts)
Ubuntu 12.10 minimal XBMC auto-install script :: XBMControl :: Xbmc XBOX Skins :: XBMControl for Android :: Owner of Sudo Systems
Reply
#9
I'm an idiot, I just didn't have the bare parameter set!
Reply
#10
I'm trying to do that with

Code:
GetCurrentlyPlaying([thumbFilename],[nothingPlayingFilename],[onlyIfChanged])

but I've not been succesful.
Reply
#11
Have a look at the .Net source code here http://code.google.com/p/xbmc-http-api-a...loads/list

If you are wanting to display a thumb from within a browser the easiest approach is the CopyFile approach that bufferbuilder mentioned.

Nad

Reply

Logout Mark Read Team Forum Stats Members Help
How do I get a thumbnail via HTTP API?0