SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV v7 Customizations > Batch Metadata Tools
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

Batch Metadata Tools This forums is for discussing the user-created Batch Metadata Tools for SageTV.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-22-2011, 12:20 PM
les_bloom les_bloom is offline
Sage Advanced User
 
Join Date: Feb 2011
Location: Kirkland, WA, USA
Posts: 187
Using BMT to prevent recordings of specific episodes?

Hi there,

I don't know if this is the right place to post this question. If it isn't, then I apologize. I posted about this earlier in the main software thread (http://forums.sagetv.com/forums/showthread.php?t=54137), but the feedback I got makes me wonder if BMT can be used to solve my issue.

I have a bunch of episodes ripped from my various DVD collections. I want to also have scheduled recordings setup for these same shows. I am trying to get SageTV to record episodes that I don't already have ripped and then ignore the episodes that I do have ripped.

I know I could just let SageTV record the dupes, and then manually delete them myself. However this seems like it will be a pain.

I wonder, instead, if there is a way I can use BMT to add entries into my wiz.bin for all my ripped episodes. Maybe I can find some sort of 'airingID' online for a specific episode? Then I can add that to the wiz.bin somehow?

Any help would be appreciated
Les
Reply With Quote
  #2  
Old 02-22-2011, 12:38 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Unfortunately, this is not is possible today, with bmt. For that to happen, the imported TV shows would have to be associated with an Airing in the EPG, and then we'd have to set call SetWarched on it, so that sagetv doesn't try to record it. While BMT does import other media as recordings, it does not associate it with actual airings from the guide data. Sage has no idea that your imported shows are the same as those in the guide.
Reply With Quote
  #3  
Old 02-22-2011, 01:39 PM
les_bloom les_bloom is offline
Sage Advanced User
 
Join Date: Feb 2011
Location: Kirkland, WA, USA
Posts: 187
Quote:
Originally Posted by stuckless View Post
Unfortunately, this is not is possible today, with bmt. For that to happen, the imported TV shows would have to be associated with an Airing in the EPG, and then we'd have to set call SetWarched on it, so that sagetv doesn't try to record it. While BMT does import other media as recordings, it does not associate it with actual airings from the guide data. Sage has no idea that your imported shows are the same as those in the guide.
Hi Stuckless,

Thank you for that information. While BMT won't directly be able to help me with this, maybe your knowledge can help me a bit more ...

I have not done any plugin work for SageTV (yet), but I am a programmer by profession. I figured it was only a matter of time before get obsessed with SageTV enough to want to start working with SageStudio. Maybe that time is now

In theory, given a specific TV show and episode, I could find this 'airing info' online? What kind of airing info do I need to find? Is there some sort of unified ID system that all EPG systems utilize? I guess really what are the data types of the parameters for this SetWatched call?

Again, your knowledge on this matter would really be appreciated.

In the main time, I am gonna start reading the docs on SageStudio.

Thanks
Les
Reply With Quote
  #4  
Old 02-22-2011, 01:58 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by les_bloom View Post
Hi Stuckless,

Thank you for that information. While BMT won't directly be able to help me with this, maybe your knowledge can help me a bit more ...

I have not done any plugin work for SageTV (yet), but I am a programmer by profession. I figured it was only a matter of time before get obsessed with SageTV enough to want to start working with SageStudio. Maybe that time is now

In theory, given a specific TV show and episode, I could find this 'airing info' online? What kind of airing info do I need to find? Is there some sort of unified ID system that all EPG systems utilize? I guess really what are the data types of the parameters for this SetWatched call?

Again, your knowledge on this matter would really be appreciated.

In the main time, I am gonna start reading the docs on SageStudio.

Thanks
Les
This is probably more a java tweak, vs a studio tweak... but the basic premise would be...

For a given show, iterate through all the sage airings and find a match based on series title and the episode name. If you find a matching airing, then call SetMediaFileAiring(MediaFile, AIring) to set this Airing as the airing for the show. Doing this should prevent sagetv from recording it.

The larger issue arises in that the sage guide data has 14 days of airing info, and if the show that you are looking for is not in the guide, then you'll have to periodically check the guide to see if the airing get added to guide via a guide update, and if so, then update the mediafile now that that the airing has arrived.
Reply With Quote
  #5  
Old 02-22-2011, 02:07 PM
les_bloom les_bloom is offline
Sage Advanced User
 
Join Date: Feb 2011
Location: Kirkland, WA, USA
Posts: 187
Quote:
Originally Posted by stuckless View Post
This is probably more a java tweak, vs a studio tweak... but the basic premise would be...
I probably just need to dig deeper into the docs, but why do you mention java? From the little I have figured out so far, I thought all plugin work was done through the SageStudio interface? Speaking of which, do you have a suggestion for where to start my reading? I am looking through the manual (http://download.sage.tv/SageTVStudio_UserGuide.pdf) right now, but do you suggest a better/different spot to start?

Quote:
Originally Posted by stuckless View Post
For a given show, iterate through all the sage airings and find a match based on series title and the episode name. If you find a matching airing, then call SetMediaFileAiring(MediaFile, AIring) to set this Airing as the airing for the show. Doing this should prevent sagetv from recording it.

The larger issue arises in that the sage guide data has 14 days of airing info, and if the show that you are looking for is not in the guide, then you'll have to periodically check the guide to see if the airing get added to guide via a guide update, and if so, then update the mediafile now that that the airing has arrived.
I assume you suggested this implementation because we don't know how to generate the airing info ourselves? If we knew how to generate the airing info (based on the series title and episode name), then we would not need to query the guide at all. And we would therefore not care if the episode was going to be aired in the next 14 days or not.

Thank you again
Reply With Quote
  #6  
Old 02-22-2011, 02:21 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
I mention Java, because studio is primarily the UI language, which Java is the backend language. ie, if you are doing a UI mod, then Studio would be the right choice, but if you are going non-ui mod, then perhaps java would be the better choice. But, that being said, you can do some real programming using studio, and it does allow you to create/use java object, call methods, etc. (I'm not a studio developer)

For plugin development, I'd start with the studio sub forum and look at the links there, etc, and definately read the pdf you are currently reading

Creating an Airing that "looks" like the Airing that sagetv wants, unfortunately, isn't going to cut it. YOu'll need to ensure that the Airing that you create has the same showid and zaptoit id that sagetv would use, which is why I suggest finding it in the list of "known" airings. Every mediafile has an Airing associated with it, but not all Airings are in the EPG data. The best way to prevent sagetv from recording a show is to simply make it think that it has already recorded the show, but assigning a physical file, the Airing that it would have recorded from the guide.
Reply With Quote
  #7  
Old 02-22-2011, 05:26 PM
les_bloom les_bloom is offline
Sage Advanced User
 
Join Date: Feb 2011
Location: Kirkland, WA, USA
Posts: 187
Quote:
Originally Posted by stuckless View Post
I mention Java, because studio is primarily the UI language, which Java is the backend language. ie, if you are doing a UI mod, then Studio would be the right choice, but if you are going non-ui mod, then perhaps java would be the better choice. But, that being said, you can do some real programming using studio, and it does allow you to create/use java object, call methods, etc. (I'm not a studio developer)

For plugin development, I'd start with the studio sub forum and look at the links there, etc, and definately read the pdf you are currently reading

Creating an Airing that "looks" like the Airing that sagetv wants, unfortunately, isn't going to cut it. YOu'll need to ensure that the Airing that you create has the same showid and zaptoit id that sagetv would use, which is why I suggest finding it in the list of "known" airings. Every mediafile has an Airing associated with it, but not all Airings are in the EPG data. The best way to prevent sagetv from recording a show is to simply make it think that it has already recorded the show, but assigning a physical file, the Airing that it would have recorded from the guide.
Thanks again for your help, Stuckless. I am going to start digging more into this and hopefully I can get a solution in place
Reply With Quote
  #8  
Old 02-22-2011, 06:18 PM
les_bloom les_bloom is offline
Sage Advanced User
 
Join Date: Feb 2011
Location: Kirkland, WA, USA
Posts: 187
Quote:
Originally Posted by stuckless View Post
I mention Java, because studio is primarily the UI language, which Java is the backend language. ie, if you are doing a UI mod, then Studio would be the right choice, but if you are going non-ui mod, then perhaps java would be the better choice. But, that being said, you can do some real programming using studio, and it does allow you to create/use java object, call methods, etc. (I'm not a studio developer)

For plugin development, I'd start with the studio sub forum and look at the links there, etc, and definately read the pdf you are currently reading
Hello again stuckless,

I am a bit confused about your last post. It sounded like you were saying that you don't use SageStudio at all. That you instead create a completely separate stand alone java project (like in Eclipse or some other IDE).

Is that what you were saying? Or did I completely misunderstand?

If that is what you are doing, where did you get the Sage library to link with?

I found that java can be used in SageStudio (like you mentioned) and that there are some specific Sage hooks that be referenced (basically a method overload), but I didn't see anything that suggested the ability to create a project outside of SageStudio.

Thank you again for your time
Reply With Quote
  #9  
Old 02-22-2011, 06:32 PM
Slugger Slugger is offline
SageTVaholic
 
Join Date: Mar 2007
Location: Kingston, ON
Posts: 4,008
Quote:
Originally Posted by les_bloom View Post
Hello again stuckless,

I am a bit confused about your last post. It sounded like you were saying that you don't use SageStudio at all. That you instead create a completely separate stand alone java project (like in Eclipse or some other IDE).

Is that what you were saying? Or did I completely misunderstand?
Nope, you got it. He works completely in Java or in J2EE apps, as do I. I don't know why he goes exclusively Java, but I do because I'm not a fan of the Studio way of doing things (and I tend not to do much dev work around the UI as it doesn't interest me).

Quote:
If that is what you are doing, where did you get the Sage library to link with?
Sage.jar is included with SageTV, but don't use that one. Use one of the wrappers around it and you'll thank yourself later. stuckless authors one of them (sagex-api) and GKusnick authors the other. They both provide wrapper jars around the official API jar. Pick one of those and use that to link in your projects.

Quote:
I found that java can be used in SageStudio (like you mentioned) and that there are some specific Sage hooks that be referenced (basically a method overload), but I didn't see anything that suggested the ability to create a project outside of SageStudio.

Thank you again for your time
Using the Java API, you can create a standard Eclipse project and have at it. Anything UI related is probably best done in Studio, but if you want to change backend/core behaviour of SageTV then Java is probably the easiest, definitely my preferred, method.

For what you're looking to do, a Java plugin is definitely the way to go.

Good luck!
__________________
Twitter: @ddb_db
Server: Intel i5-4570 Quad Core, 16GB RAM, 1 x 128GB OS SSD (Win7 Pro x64 SP1), 1 x 2TB media drive
Capture: 2 x Colossus
STB Controller: 1 x USB-UIRT
Software:Java 1.7.0_71; SageTV 7.1.9
Clients: 1 x HD300, 2 x HD200, 1 x SageClient, 1 x PlaceShifter
Plugins: Too many to list now...
Reply With Quote
  #10  
Old 02-22-2011, 07:04 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
I think Slugger summed it up nicely for me

(with the addition that I prefer Stuckless's sagex-apis, since they allow me to run entirely in an eclipse environment )
Reply With Quote
  #11  
Old 02-22-2011, 07:31 PM
razrsharpe razrsharpe is offline
Sage Icon
 
Join Date: Sep 2008
Location: Boston, MA
Posts: 2,111
Quote:
Originally Posted by stuckless View Post
(with the addition that I prefer Stuckless's sagex-apis, since they allow me to run entirely in an eclipse environment )
and you know... you wrote them
__________________
Server 2003 r2 32bit, SageTV9 (finally!)
2x Dual HDHR (OTA), 1x HD-PVR (Comcast), 1x HDHR-3CC via SageDCT (Comcast)
2x HD300, 1x SageClient (Win10 Test/Development)
Check out TVExplorer
Reply With Quote
  #12  
Old 02-22-2011, 09:08 PM
les_bloom les_bloom is offline
Sage Advanced User
 
Join Date: Feb 2011
Location: Kirkland, WA, USA
Posts: 187
Hi guys,

Wow, I find that pretty amazing that Sage gives us the library like that.

I can't wait to get in there and start poking at stuff. Guess I need to brush up on my Java Luckily it's not really that different then C++.

Thanks again for your help guys
Les
Reply With Quote
  #13  
Old 02-22-2011, 11:04 PM
Fuzzy's Avatar
Fuzzy Fuzzy is offline
SageTVaholic
 
Join Date: Sep 2005
Location: Jurupa Valley, CA
Posts: 9,957
Probably the best way to implement this would be to trigger on the EPGUpdateCompleted event. Iterate through the EPG data, and match show title and episode title to existing imports, and if found, mark the EPG airing as watched.

Or, you may be able to gleem the ID info from Zap2it for a show/episode, and make sure your imports use the proper ExternalID. I'm not sure if that is enough for sage to recognize the connection, but if it is, it would work.
__________________
Buy Fuzzy a beer! (Fuzzy likes beer)

unRAID Server: i7-6700, 32GB RAM, Dual 128GB SSD cache and 13TB pool, with SageTVv9, openDCT, Logitech Media Server and Plex Media Server each in Dockers.
Sources: HRHR Prime with Charter CableCard. HDHR-US for OTA.
Primary Client: HD-300 through XBoxOne in Living Room, Samsung HLT-6189S
Other Clients: Mi Box in Master Bedroom, HD-200 in kids room
Reply With Quote
  #14  
Old 02-23-2011, 03:09 PM
les_bloom les_bloom is offline
Sage Advanced User
 
Join Date: Feb 2011
Location: Kirkland, WA, USA
Posts: 187
So I was digging through the sageAPI a bit last night. I was just trying to get a rough idea of the class structures (Airing, Show, MediaFile, etc).

I think I have a decent idea of how everything is organized, but would you mind taking a look at this very-much-pseudo code and let me know if I am on track or not?

Code:
void OnEPGUpdate()
{
    MediaFile[] allMediaFilesInDatabase = GetMediaFiles("VL");
    //do i want "VL" or "TVL"?

   for(i = 0; i < allMediaFilesInDatabase.size; i++)
   {
       Airing mediaFileAiring = GetMediaFileAiring(allMediaFilesInDatabase[i]);

       Show mediaFileShow = GetShow(mediaFileAiring);
       //as long as i use BMT to setup my the meta data for all my media files
       //then this Show should have a valid TV Show Name and Episode Name right?

       Airing[] allComingUpAiringsForShow = GetAiringsForShow(mediaFileShow, 0);
       //i dont know if this will work or not. like i mentioned in the comment above,
       //the Show object for my mediaFile should have proper media data (in terms of names)
       //but will this GetAiringsForShow work off of the names data or some sort of Zap2it data thing?

       for(i = 0; i < allComingUpAiringsForShow.size; i++)
       {
            SetWatched(allComingUpAiringsForShow[i]);
       }
   }
}

It sounds too easy. If this code really worked, it seems like I wouldn't even have a problem to begin with.

Is my call to GetAiringsForShow even going to return anything?

Thanks again
Les

Last edited by les_bloom; 02-23-2011 at 05:24 PM.
Reply With Quote
  #15  
Old 02-23-2011, 05:56 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
les, i think the pseudo logic is close, but more like this...

Code:
public updateAiringsForRecordings() {
Object recordings = MediaFileAPI.GetMediaFiles("T");
for (Object rec: recordings) {
   String series = MediaFileAPI.GetTitle(rec);
   String epname = MediaFileAPI.GetEpisdoeName(rec);
   String showid = ShowAPI.GetShowId(rec);
   if (showid.charAt(2)=='m' && showid.charAt(3)=='t') {
       // bmt imported show, so lets find a matching airing
       Object airing = findAiring(series, epname);
       if (airing !=null) {
            MediaFileAPI.SetMediaFileAiring(rec, airing);
       }
   }
}
}

public Object findAiring(String title, String epname) {
     Object airings[] = GetAllEPGAirings(); // not show how, never done it
     for (Object a: airings) {
          if (title.equals(AiringAPI.GetAiringTitle(a) && epname.equals(ShowAPI.getEpsidoeName(a)) {
               return a;
          }
     }
     return null;
}
basically, the premise that you need to find an epg airing that matches the same title and episode title for the show that you imported. If you find one, then assign that airing to the mediafile, and then sage will think that it has it recorded.

It's not foolproof because it requires that you match based on the import series name and episode title.
Reply With Quote
  #16  
Old 02-23-2011, 06:32 PM
les_bloom les_bloom is offline
Sage Advanced User
 
Join Date: Feb 2011
Location: Kirkland, WA, USA
Posts: 187
hello again stuckless,

Quote:
Object recordings = MediaFileAPI.GetMediaFiles("T");
Are you using "T" and not "TL" because your BMT tool will flag my imported TV shows as a recording and not an import?

Quote:
MediaFileAPI.SetMediaFileAiring(rec, airing);
So this will link my imported TV episode with the EPG airing right? Since an Airing contains the Show data, and the Show data contains the meta data, does that mean this new linking will remove the BMT meta data association that originally existed for my imported TV episode? Because that BMT meta data was contained in a Show object that was contained in a different Airing object? Specifically, the fanart assocation and all that extra stuff? .... Did that make any sense lol? Just reading it back to myself sounds awkward.

In addition to creating this link, don't I need to set the EPG airing as watched? So that it won't record the airing?

Quote:
It's not foolproof because it requires that you match based on the import series name and episode title.
So maybe I just need to do a 'RemoveWhiteSpace' and 'UpperToLower' conversion on both strings before comparing or something. Then it should be fine right? Or is there more that I am missing?

Thank you again for your time
Reply With Quote
  #17  
Old 02-23-2011, 06:56 PM
les_bloom les_bloom is offline
Sage Advanced User
 
Join Date: Feb 2011
Location: Kirkland, WA, USA
Posts: 187
For getting all airings from the EPG, I think it's something like this: ?

Code:
Channel[] allChannels = ChannelAPI.GetAllChannels();

for(i = 0; i < allChannels.size; i++)
{
   Airing[] allAirings = Database.GetAiringsOnChannelAtTime(allChannels[i], startTime, endTime, false);
   //any idea about the times? that seconds, minutes, what?
   //also, these Database calls are limited to a return size of 1000. i presume
   //they will return the earliest airings first, and since this code will get run
   //once a day, that shouldnt matter


   /// do comparison code
}
Reply With Quote
  #18  
Old 02-23-2011, 07:28 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by les_bloom View Post
Are you using "T" and not "TL" because your BMT tool will flag my imported TV shows as a recording and not an import?
T is means a TV file in SageTV with is a Recording. TL would actually be an Archived TV file, so depending on how you imported your files using bmt, you may have to use T or TL. This assumes that you told BMT to import the TV file as a Recording... and then whether or not BMT should Archive or not.

Quote:
So this will link my imported TV episode with the EPG airing right? Since an Airing contains the Show data, and the Show data contains the meta data, does that mean this new linking will remove the BMT meta data association that originally existed for my imported TV episode? Because that BMT meta data was contained in a Show object that was contained in a different Airing object? Specifically, the fanart assocation and all that extra stuff? .... Did that make any sense lol? Just reading it back to myself sounds awkward.
It might lose some of the bmt metadata, specifically the description, but, you can always rescan the file using bmt later (as another step) if you need to.

Quote:
In addition to creating this link, don't I need to set the EPG airing as watched? So that it won't record the airing?
I debated that myself. I think you probably don't need to call setwatched on the airing, and do so, may actually mark the recording as watched, even though you haven't watched it.

Quote:
So maybe I just need to do a 'RemoveWhiteSpace' and 'UpperToLower' conversion on both strings before comparing or something. Then it should be fine right? Or is there more that I am missing?
Yeah... bmt actually does a lot of fuzzy logic comparisons when it attempts to match metadata based on titles and episode names... it then assigns a 'score' and then choses a result based on which one has the best score. For your needs you can probably just compare the two titles by applying a regex like... replace("[^a-zA-Z0-9]","") and that will remove all punctuation from the strings before comparing them. That way things like, "$##! My Dad Says" will match "$#!$ my dad says", etc, increasing the odds of getting a match.

Quote:
Originally Posted by les_bloom View Post
For getting all airings from the EPG, I think it's something like this: ?

Code:
Channel[] allChannels = ChannelAPI.GetAllChannels();

for(i = 0; i < allChannels.size; i++)
{
   Airing[] allAirings = Database.GetAiringsOnChannelAtTime(allChannels[i], startTime, endTime, false);
   //any idea about the times? that seconds, minutes, what?
   //also, these Database calls are limited to a return size of 1000. i presume
   //they will return the earliest airings first, and since this code will get run
   //once a day, that shouldnt matter


   /// do comparison code
}

I think start and end times are Dates as a long. ie, you'd need to specify the date/time as a long.

Good luck... and make backups of you wiz.bin... you are about to mess it up pretty good
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
Can you prevent recordings during certain hours? Ralphjb SageTV Software 16 10-19-2010 08:01 PM
SageTV Recordings: Missing Episodes? PeteCress SageTV Software 1 05-24-2010 07:42 PM
Directing recordings to specific directories tvmaster2 SageTV Software 1 10-22-2009 05:48 PM
tv recordings to specific location npereira SageTV Software 3 03-17-2008 07:33 AM
Prevent recording a favorite on a specific channel BLS SageTV Software 4 08-29-2003 01:05 PM


All times are GMT -6. The time now is 03:44 AM.


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