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 05-23-2006, 07:37 AM
dflachbart dflachbart is offline
SageTVaholic
 
Join Date: Jan 2006
Location: Brookfield, CT
Posts: 2,743
Test if MediaFile exists

Supposed I have a reference to a MediaFile object, and this file gets delete by DeleteFile().

Is there any simple method which can tell me if the reference I have is still in the database, pointing to an existing file ? I tried a few methods of the MediaFile API, but all worked as if the file still existed. I am currently calling GetMediaFiles() again and do a lookup, but I am wondering if there is a less expensive approach ...

Thanks,

Dirk
Reply With Quote
  #2  
Old 05-23-2006, 08:59 AM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
You said you tried a few calls... what have you tried? GetSize()? GetSegmentsFiles()? I think the default STV just does a refresh after deleting a file.

- 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 05-23-2006, 09:01 AM
nielm's Avatar
nielm nielm is offline
SageTVaholic
 
Join Date: Oct 2003
Location: Belgium
Posts: 4,496
How about:
GetMediaFileForID(GetMediaFileID(DeletedMediaFile))
(returns null if the ID of the DeletedMediaFile is not in the DB)

Alternatively
GetMediaFileSize(DeletedMediaFile)==0
(but I dont know what this does if the file still exists, but is on an offline drive)
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki
Reply With Quote
  #4  
Old 05-23-2006, 09:07 AM
BobPhoenix BobPhoenix is offline
SageTVaholic
 
Join Date: Oct 2004
Posts: 3,152
Couldn't you use IsFilePath in the Utility class?

BobP.

Edit: Think I mis-understood the problem - sorry.

Last edited by BobPhoenix; 05-23-2006 at 09:12 AM.
Reply With Quote
  #5  
Old 05-23-2006, 09:13 AM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
Quote:
Originally Posted by BobPhoenix
Couldn't you use IsFilePath in the Utility class?
You could do that after a call to GetFileForSegment(MediaFile,0)... and if that returns nothing, there is no need to check the file path. If the file is deleted outside SageTV, this combo might work decently.

- 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
  #6  
Old 05-23-2006, 09:22 AM
dflachbart dflachbart is offline
SageTVaholic
 
Join Date: Jan 2006
Location: Brookfield, CT
Posts: 2,743
Quote:
Originally Posted by nielm
How about:
GetMediaFileForID(GetMediaFileID(DeletedMediaFile))
(returns null if the ID of the DeletedMediaFile is not in the DB)
I actually got up to GetMediaFileID(DeletedMediaFile), but when this returned a valid ID I didn't take this a step further ...

I'll also try the other suggestions posted here, thanks again to everyone !


Dirk
Reply With Quote
  #7  
Old 05-23-2006, 11:18 AM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
I'm told that a lot of the MediaFile info is cached, but GetSize() checks the file size at the moment it is called. As Niel mentioned, you probably won't get a good response on offline files.

You can also do the check on the file segments, but offline files won't exist there either, so GetSize may be all that is needed.

Due to the possibility of files being offline, I would make sure to only remove the item from your list as opposed to trying to get SageTV to remove actually it via any further deletion.

- 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
  #8  
Old 05-23-2006, 11:40 AM
dflachbart dflachbart is offline
SageTVaholic
 
Join Date: Jan 2006
Location: Brookfield, CT
Posts: 2,743
Quote:
Originally Posted by Opus4
I'm told that a lot of the MediaFile info is cached, but GetSize() checks the file size at the moment it is called.
Thanks Andy for the inquiry, this is good to know ...


Quote:
Originally Posted by Opus4
Due to the possibility of files being offline, I would make sure to only remove the item from your list as opposed to trying to get SageTV to remove actually it via any further deletion.
Actually it's the other way around, after a deletion action initiated by the user on a played mediafile the file has to be removed from a list (which is the base for a display table) so that it wont show up any more. So yes, I would only remove it from the list, and it is guaranteed not to be an offline file, so the GetSize() solution seems perfect ...

Thanks again,

Dirk
Reply With Quote
  #9  
Old 05-23-2006, 01:02 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Maybe I'm missing something, but if you just want to know whether the file still exists on disk, it seems like the most authoritative test would be

Code:
java_io_File_exists(GetFileForSegment(MediaFile, 0))
On the other hand, if you're trying to detect whether the MediaFile object has been removed from wiz.bin, then Niel's GetMediaFileForID test seems like the obvious way to go.
__________________
-- Greg
Reply With Quote
  #10  
Old 05-23-2006, 01:24 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
Quote:
Originally Posted by GKusnick
Maybe I'm missing something, but if you just want to know whether the file still exists on disk, it seems like the most authoritative test would be

Code:
java_io_File_exists(GetFileForSegment(MediaFile, 0))
Yes and no... that will check for the file, but if you are doing this on the client, it will check for the file as if the path is relative to the client, i.e.: local.

To access any files that the server manages, such as recordings, you have to use the API file access calls to make sure a client will be able to 'see' it correctly. I added a blurb about this to the last couple pages of the v5 Studio manual... since I had to do a whole bunch of fixes for the default STV, I figured it would be good for others to know about.

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


All times are GMT -6. The time now is 06:07 PM.


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