SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-17-2009, 02:31 PM
jaminben jaminben is offline
Sage Icon
 
Join Date: Sep 2007
Location: Norwich, UK
Posts: 1,754
Send a message via MSN to jaminben
Selecting an image by file name

I have another query, this time about images and selecting an image by file name. Basically I have my imported folder with various images and media files and these are named as:

background.jpg
folder.jpg
season_banner.jpg
season 1 - episode1.jpg
season 1 - episode2.jpg
season 1 - episode3.jpg
season 1 - episode4.jpg
season 1 - episode1.mkv
season 1 - episode2.mkv
season 1 - episode3.mkv
season 1 - episode4.mkv

Now I wanted to display each media file with its own image which is named the same. So for example if I select media file "season 1 - episode 1.mkv" it will display image "season 1 - episode 1.jpg".

I started off using:

Code:
GetThumbnail(Program) 
     Image
This worked great until I realised that if I had a missing "season 1 - episode 2.jpg" image it would then default to the folder.jpg image. Obviously this is no good as the aspect ratio's are all wrong among other things.

So I then looked at:

Code:
IsFilePath(ParentPath + java_io_File_separator + ".jpg") 
          LoadImage(ParentPath + java_io_File_separator + ".jpg") 
                 Image
That didn't work at all so I assumed it was because its not being told what the title of the media file is. Going on that assumption I started to add various
other commands into the code like:

Code:
     IsFilePath(ParentPath + java_io_File_separator + GetFileNameFromPath + ".jpg") 
          LoadImage(ParentPath + java_io_File_separator + GetFileNameFromPath + ".jpg") 
               true 
                   Image
Code:
IsFilePath(ParentPath + java_io_File_separator + GetFileNameFromPath(Program) + ".jpg") 
         LoadImage(ParentPath + java_io_File_separator + GetFileNameFromPath(program) + ".jpg") 
                 true 
                     Image

Code:
sFilePath = GetFileNameFromPath(GetFileForSegment(Airing, 0)) 
      iPos = StringLastIndexOf(sFilePath, ".") 
           sTitle = Substring(sFilePath, 0, iPos) 
                IsFilePath(ParentPath + java_io_File_separator + sFilePath + ".jpg") 
                      Image = LoadImage(ParentPath + java_io_File_separator + sFilePath + ".jpg") 
                              Image
Plus many, many other combinations of everything I can think of that would relate to a file name, nothing worked I'm also using various attribute widgets which as far as I know are the correct ones.

I've been looking around Studio and the forums but can't find a solution. I know one exists as fan art backgrounds prove it, but I've been unable to understand how that works.

Sorry for the long post.

Regards

Ben
__________________
Server - Win7 64bit, 2.4Ghz Intel Core 2 Duo, TBS 6284 PCI-E Quad DVB-T2 Tuner, 3 x HD200 & 1 x HD300 extenders

Last edited by jaminben; 02-17-2009 at 02:43 PM.
Reply With Quote
  #2  
Old 02-17-2009, 03:08 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
If it isn't loading anything, is the path even leading to the image file? If you haven't already done so, you could call DebugLog() to print the file path you are trying to use to the debug log.

Also: you can create file paths using CreateFilePath() to add dirs & filenames together.

- Andy
__________________
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.
Reply With Quote
  #3  
Old 02-17-2009, 03:13 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
My advice would be to break the problem down into smaller pieces, and debug each piece separately. For instance, try hard-coding a file path that you know exists and see if you can get that to display. (One simplification is to omit the call to LoadImage; you can pass a filename string or a java.io.File directly into an Image widget without calling LoadImage first.)

Once you've mastered that, try calculating the desired file path and displaying it as a Text widget instead of an Image widget, so you can see with your own eyes whether you're calculating it correctly.

Only after you have both pieces working should you try to put them together.

Your overall goal should be to learn how each function behaves in isolation (Evaluate Expression can be very useful for this) so that you can design a code sequence that uses them effectively, instead of just trying things at random and hoping to stumble on a combination that works.

Also, when posting code snippets like this, it would be helpful to the reader if you indicate the widget types as well as their contents. For larger chunks of code, Studio screenshots are usually the clearest way to present them.
__________________
-- Greg
Reply With Quote
  #4  
Old 02-17-2009, 03:37 PM
jaminben jaminben is offline
Sage Icon
 
Join Date: Sep 2007
Location: Norwich, UK
Posts: 1,754
Send a message via MSN to jaminben
Thankyou for the swift replys

It does however seem that I've just made a complete arse of myself and my original code was working how I expected it to and it was the images I was pulling in that were incorrect. Its not a complete waste of six hours work as you've both given me some handy tips which will no doubt come in usefull in the near future I'm tempted to delete my post's to save on the embarrassment but I guess that's my punishment.

Sorry for wasting your time.

Regards

Ben
__________________
Server - Win7 64bit, 2.4Ghz Intel Core 2 Duo, TBS 6284 PCI-E Quad DVB-T2 Tuner, 3 x HD200 & 1 x HD300 extenders

Last edited by jaminben; 02-17-2009 at 03:57 PM.
Reply With Quote
  #5  
Old 02-19-2009, 10:55 AM
jaminben jaminben is offline
Sage Icon
 
Join Date: Sep 2007
Location: Norwich, UK
Posts: 1,754
Send a message via MSN to jaminben
Time for some more punishment...

Even though I have some working code which does allow me to do what I wanted I thought it would be a good idea to learn how to do it via the file name route. So since my last post I've been trying to do this but I cannot get it to work the way I would have liked it too.

I've attached an image showing my code and what it displays.

No.3 This code works great and I can pull in images via show title or show episode if the images are named the same as the title or episode. However my images have both the show title and episode included within the image name. An example of a show image is:

Everybody Hates Chris S04E12 - Everybody Hates Varsity Jackets.jpg

So rather than mess around with show title and episode I tried to take the information I wanted directly from the media file title (Which is named the same as the image).

No.1 & No.2 Show attempts at getting the media title directly but they have the file extension included (.mkv) so I figured these wouldn't work.

I also tried GetFileNameFromPath(Program) which I added to No.1 to make it EpisodeImage = GetFileNameFromPath(Program) and replaced EpisodeImage = GetShowEpisode(Program). When I use GetFileNameFromPath(Program) it returns a title of \\SAGEWHS\TV Shows\Knight Rider\ 18234156.000]].jpg which obviously doesn't pull the image in as the image isn't named like that.

So how can I get the actual media file title if it differs from the show episode or title?

I think I'm over cooking this and theirs proberly an easier way to make this work so I'm asking for a little bit of guidance, please.

Many Thanks

Ben
Attached Images
File Type: jpg image1.jpg (270.6 KB, 159 views)
__________________
Server - Win7 64bit, 2.4Ghz Intel Core 2 Duo, TBS 6284 PCI-E Quad DVB-T2 Tuner, 3 x HD200 & 1 x HD300 extenders
Reply With Quote
  #6  
Old 02-19-2009, 12:17 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
I don't want to go all RTFM on you, but you'll spend a lot less time spinning your wheels if you know what the API functions are designed to do and what data types they operate on before you start coding.

According to the Java API docs, java.io.File.getName() returns (in String form) everything after the last slash, including the extension.

According to the SageTV API docs, GetFileNameFromPath() does basically the same thing as java.io.File.getName(), i.e. takes a java.io.File and returns (in String form) everything after the last slash. I don't see where your Program variable gets assigned but I'm betting it's not a File but is probably an Airing or a Show. So expect the unexpected if you pass that in to either java.io.File.getName() or GetFileNameFromPath() without first getting a File from it.

The last code snippet in your first post looks to be on the right track in calculating sTitle by getting the File for an Airing, extracting just the last segment of the path, and then stripping away the extension.
__________________
-- Greg
Reply With Quote
  #7  
Old 02-19-2009, 03:08 PM
jaminben jaminben is offline
Sage Icon
 
Join Date: Sep 2007
Location: Norwich, UK
Posts: 1,754
Send a message via MSN to jaminben
Thanks for the reply Greg

Yes you are correct in that I should RTFM but being a hobbyist I could really use another manual to understand the other If you have any suggestions for someone like me who doesn't really have a clue as where to start and which manual would be beneficial to the Sage way of coding then I would be very grateful.

Anyway on a more positive note, I got it to work using your cryptic clues from above Its properly not the best way to make it work but it does at least work now.

Many Thanks

Ben

P.s I've attached an image of the working code just in case you wanted a giggle
Attached Images
File Type: jpg Image2.jpg (126.4 KB, 158 views)
__________________
Server - Win7 64bit, 2.4Ghz Intel Core 2 Duo, TBS 6284 PCI-E Quad DVB-T2 Tuner, 3 x HD200 & 1 x HD300 extenders
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Selecting New CPU toricred Hardware Support 1 12-19-2007 09:12 AM
Selecting an HDTV Humanzee General Discussion 22 12-14-2005 11:16 AM
Passing image name from action to image widget jbuszkie SageTV Studio 5 12-09-2005 07:40 PM
Selecting appropriate tuner enclade SageTV Software 1 10-02-2004 08:21 AM
How can I post a screen image from a MPG file? carlgar The SageTV Community 3 12-29-2003 08:44 PM


All times are GMT -6. The time now is 02:17 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.