Kodi Community Forum
Images name in Slideshow screenserver - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Look and feel (https://forum.kodi.tv/forumdisplay.php?fid=178)
+---- Thread: Images name in Slideshow screenserver (/showthread.php?tid=149852)

Pages: 1 2


Images name in Slideshow screenserver - tomer953 - 2012-12-28

Hi.

I want to edit the Addon "Slideshow", make him show the Img Name for every image in the screensaver.
I don't know python, or skinning, but I Tried to Edit some stuff.

Image

I edited the file: screensaver.xbmc.slideshow\resources\skins\default\720p\script-python-slideshow.xml
I Added a control "label", works fine.
The Only problem now is what to put in it? How to make it works.

Also tried to mess with the python code, but without success. (the Top window in the image)
any help?



RE: Images name in Slideshow screenserver - ronie - 2012-12-29

i think you need to move your python code inside the 'for img in items' loop
'img' contains the full path (including filename) of the image.

if you want to spit the path and filename, give this a shot (untested):

PATH, FILENAME = os.path.split(img)


RE: Images name in Slideshow screenserver - tomer953 - 2012-12-29

Ok Thanks, Works! (Only in Custom Dir slideshow, because Fanart view, make the filename empty and the path something like: http://....jpg)

I Used Artwork Manager Addon to create folder with my Movies Fanarts, and then Show the title and the year of the Movie.
So far, so good.
Now When Using the "FILENAME" var, I get: "The Matrix (1999).jpg"
almost perfect, just how to remove the .jpg? can't find xml tag that "replace" or "remove" thing (wierd?)
(what is the easy way to replace the ".jpg" with ".bmp" lets say? there is no command like: Replace("test.jpg",.jpg,.bmp) or something like that?)

and one little thing, any Idea how to screenshot my screensaver? CTRL+S doent quick enough, I want to show you the final result Smile



RE: Images name in Slideshow screenserver - Daniel Malmgren - 2012-12-29

(2012-12-29, 14:27)tomer953 Wrote: Now When Using the "FILENAME" var, I get: "The Matrix (1999).jpg"
almost perfect, just how to remove the .jpg? can't find xml tag that "replace" or "remove" thing (wierd?)
(what is the easy way to replace the ".jpg" with ".bmp" lets say? there is no command like: Replace("test.jpg",.jpg,.bmp) or something like that?)

Without knowing anything about Python, my guess would be os.path.basename(path). See http://docs.python.org/2/library/os.path.html.

/Daniel


RE: Images name in Slideshow screenserver - tomer953 - 2012-12-29

I Already did it with:
Code:
PATH, FILENAME = os.path.split(img)
                        FILENAME = FILENAME.replace(".jpg","")
I looked in google and got it

but thanks, I Edit it to:
Code:
FILENAME = os.path.basename(img)
                        FILENAME = FILENAME.replace(".jpg","")



RE: Images name in Slideshow screenserver - Daniel Malmgren - 2012-12-29

(2012-12-29, 14:42)tomer953 Wrote:
Code:
PATH, FILENAME = os.path.split(img)
                        FILENAME = FILENAME.replace(".jpg","")

...which will only work for .jpg, not for .jpeg, .png, .gif etc. I'd still vote for os.path.basename Cool

/Daniel

edit: Hahaha... We're obviously editing posts at the same time here. Funny :-)

edit2: Hmmm... I think I've misunderstood basename, I thought it'd return the filename without ending. I think the function you should use to remove the extension would be os.path.splitext(path)...


RE: Images name in Slideshow screenserver - tomer953 - 2012-12-29

(2012-12-29, 14:50)Daniel Malmgren Wrote:
(2012-12-29, 14:42)tomer953 Wrote:
Code:
PATH, FILENAME = os.path.split(img)
                        FILENAME = FILENAME.replace(".jpg","")

...which will only work for .jpg, not for .jpeg, .png, .gif etc. I'd still vote for os.path.basename Cool

/Daniel

edit: Hahaha... We're obviously editing posts at the same time here. Funny :-)

edit2: Hmmm... I think I've misunderstood basename, I thought it'd return the filename without ending. I think the function you should use to remove the extension would be os.path.splitext(path)...

Ok:
basename return = The Matrix (1998).jpg
and with:
Code:
FILENAME = os.path.basename(img)
                        FILENAME = FILENAME.replace(".jpg","")
its ok. "The Matrix (1998) only.

Tried to use:
FILENAME = os.path.splitext(img)
no success. nothing is showing now, but I think I know why, maybe I need to do whats ronie did, Put two vars, Like in "PATH, FILENAME = os.path.split(img)"
I will try it in a moment and ill edit.

Edit:
Almost, used:
PATH, FILENAME = os.path.splitext(img)
and now PATH = D:\Artwork\FanartMovies\
and FILENAME = .jpg
filename are gone.. so, wrong function.

Edit2:
as You said, the replace is not a great idea because .png and .bmp won't work.
So the best idea I see that can work, is to find the python command that search for "." (dot) from right side (from the end of the name), and then return the left side of it. = make the ext gone.
lets find it.


RE: Images name in Slideshow screenserver - Daniel Malmgren - 2012-12-29

I had to try around a bit myself. So now I've written my first Python script!

Anyway, I ended up with the following, seems to work:

BASE, EXT = os.path.splitext(os.path.basename(img))

After that BASE have the filename without ending and EXT have the ending.

/Daniel


RE: Images name in Slideshow screenserver - tomer953 - 2012-12-29

Genius.

http://i50.tinypic.com/34zmutj.jpg
Mission Accomplished

for users who wants it:

script-python-slideshow.xml : http://pastebin.com/1msS5bJR (Added The Control id="4" in the end.)
gui.py : http://pastebin.com/kyfp5Q3M


RE: Images name in Slideshow screenserver - Daniel Malmgren - 2012-12-29

(2012-12-29, 16:06)tomer953 Wrote: Mission Accomplished

Great!

In my opinion the text on your screenie is way to big though. But I've now put your code into my own xbmc and here it looks exactly as I want it (a little text in the upper left corner).

Any chance of this making it into the official repository now, Ronie?

/Daniel


RE: Images name in Slideshow screenserver - ronie - 2012-12-29

sure, i'll add it as an option.
good to see the two of you figured it out how to do this btw.

as you've aready noticed, it's not possible for the addon to define to font size.
this depends on whichever skin you are using, and there's sadly no work around possible.




RE: Images name in Slideshow screenserver - tomer953 - 2012-12-29

I think it because I Use T! skin, And used <font>font-45</font> (whice is a T! custom font), so thats the reason you see it small. edit it to your size.

I Am now trying to do another thing that could be nice, same idea.
Lets say that you have a main folder with your family pictures. but the File-Names are: DSC_001.jpg DSC_002.jpg so its not intersting to show them on the Screen, but,
It would be nice to show the DIR name, but without all the path, so D:\Pictures\Tomer's Birthday\DSC_001.jpg will Show on the Screen "Tomer's Birthday"
I found that: os.path.dirname(path) show only the path without the file, but how to show only the "last" dir?

Thanks


RE: Images name in Slideshow screenserver - ronie - 2012-12-29

maybe something like this:

PATH, DIR = os.path.split( os.path.dirname( img ) )

if it doesn't work, i'm sure you'll find the correct answer here:
http://docs.python.org/2/library/os.path.html


RE: Images name in Slideshow screenserver - tomer953 - 2012-12-29

Great. 10x


RE: Images name in Slideshow screenserver - ronie - 2012-12-29

hmm, maybe you need to strip the slash at the end first:

PATH, DIR = os.path.split( os.path.dirname( img )[:-1] )

...not sure, just test and see ;-)