absolute thumbnail path: correct method to retrieve?

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
wastl Offline
Junior Member
Posts: 14
Joined: Apr 2012
Reputation: 0
Post: #1
hi

following problem: i need the absolute path for the thumbnail of the currently played video.

i am using xbmc.getCacheThumbName() but this only returns a filename which cannot be used directly, eg: 8765432.tbn'.
the 'real' file would be (on linux): /home/someuser/.xbmc/userdata/Thumbnails/Video/8/auto-8765432.tbn

i couln't find a 'clean' / 'beautiful' way for this and i am now using this code:

thumbnail_rel = xbmc.getCacheThumbName( xbmc.getInfoLabel("Player.Filenameandpath") )
thumbnail_abs = xbmc.translatePath( "special://profile/Thumbnails/Video/" ) + thumbnail_rel[0] + "/auto-" + thumbnail_rel

it works. but is there a better way for this?
find quote
blittan Offline
Team-XBMC Handyman
Posts: 1,724
Joined: Jun 2004
Reputation: 11
Location: Sweden
Post: #2
use os.path.basename would be cleaner / better

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
If you don't have the time to read them, please don't take the time to post in this forum!
For troubleshooting and bug reporting please make sure you read this first.
find quote
wastl Offline
Junior Member
Posts: 14
Joined: Apr 2012
Reputation: 0
Post: #3
what does os.path.basename improve / do better here?

what i want to improve is: avoiding concatination of path to the video cache + first char. of xbmc.getCacheThumbName() + "auto-" + xbmc.getCacheThumbName().
find quote
vdrfan Offline
Team-XBMC Developer
Posts: 2,793
Joined: Jan 2008
Reputation: 7
Location: Germany
Post: #4
You could still try to get it directly from the player.

Example: icon = "file://%s" % xbmc.translatePath(xbmc.getInfoImage("VideoPlayer.Cover"))

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules
For troubleshooting and bug reporting please make sure you read this first.
find quote
wastl Offline
Junior Member
Posts: 14
Joined: Apr 2012
Reputation: 0
Post: #5
yep, getInfoImage() does the trick. thanks!

i've tried xbmc.getInfoLabel("VideoPlayer.Cover") before but this one returned an empty string ...

but xbmc.getInfoImage() returns exactly what i want.
find quote
vdrfan Offline
Team-XBMC Developer
Posts: 2,793
Joined: Jan 2008
Reputation: 7
Location: Germany
Post: #6
Glad to hear Wink

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules
For troubleshooting and bug reporting please make sure you read this first.
find quote
wastl Offline
Junior Member
Posts: 14
Joined: Apr 2012
Reputation: 0
Post: #7
here i'm again with another thumbnail problem:

this time i'd need the cached thumbnail of a youtube item:

xbmc.getInfoLabel("VideoPlayer.Cover") returns the 'youtube'-URL of the thumbnail, eg: http://i.ytimg.com/vi/blahblabla/0.jpg, but the image has already been cached by youtube-plugin (i can find it in the userdata-directory) so it would be fine to use the thumbnail that has already been cached and not to re-fetch it.
find quote
jmarshall Offline
Team-XBMC Developer
Posts: 24,564
Joined: Oct 2003
Reputation: 138
Post: #8
You won't be refetching it, just set the thumbnail to that URL and XBMC will take care of the rest.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


[Image: badge.gif]
find quote
wastl Offline
Junior Member
Posts: 14
Joined: Apr 2012
Reputation: 0
Post: #9
the python service processes the information for a daemon that is not a part of XBMC (thus i'd need the absolute file name of the cached image).
find quote
wastl Offline
Junior Member
Posts: 14
Joined: Apr 2012
Reputation: 0
Post: #10
i've found a rather ugly, but working 'workaround':

Code:
currentitem['Thumbnail'] = xbmc.translatePath(xbmc.getInfoImage("VideoPlayer.Cover"))
if currentitem['Thumbnail'][0:7] == "http://" or currentitem['Thumbnail'][0:8] == "https://":
  thumbnail_rel = get_crc32(currentitem['Thumbnail'])
  pos = currentitem['Thumbnail'].rfind(".")
  if (pos > 0):
    currentitem['Thumbnail'] = xbmc.translatePath( "special://profile/Thumbnails/" ) + thumbnail_rel[0] + "/" + thumbnail_rel + currentitem['Thumbnail'][pos:]

but maybe there's a more beautiful way for this ...

(get_crc32() is the method that i've found somewhere in the xbmc-wiki)
find quote
Post Reply