• 1(current)
  • 2
  • 3
  • 4
  • 5
  • 18
  •   
[RELEASE] SageTV recordings
#1
This is an addon to allow access to recordings from a SageTV server. You need to be running the SageTV webserver plugin in Sage to use this addon. It was started using Aaronb's code from this post. Thanks to some hard work by LehighBri it has come a long way and new things are being added weekly if not daily.

SageTV can be found in the official XBMC repo under Video-addons.

Bleeding edge development can be found at:
https://github.com/kricker/plugin.video.SageTV

Dependencies:
SageTV with:
  • Jetty Web Server 2.3.0.14 or newer
  • Sagex-api-services vs 7.1.9.10 or newer
  • Batch Metadata Tools 4.10.1
  • xbmc.js file (Copy included xbmc.js file to your "SageTV\SageTV\sagex\services" directory)
Reply
#2
Fantastic (considering I still use SageTV as my DVR but am trying hard to find an alternative). Until then, I got your plugin setup and configured and it pulls in my list of recordings which is good. Couple questions though:

1. What is the default sort for the recordings and can that be altered? I have XBMC sort by date descending, but it looks like it is sorting by title descending.
2. I can't get XBMC to play a show (I've updated the configuration to point to my sage recordings directory but my UNC path is blank... is it an either/or or do I need to fill in both.... perhaps one for playback, one for metadata?)
3. How much, if at all, do you plan to enhance this?
Reply
#3
1. You should be able to change the sort to whatever you want. I have.
2. Both items need to be filled in. What the addon does is replace the local file path name in the Sage DB and replace it with the UNC path you specified. If they are both on the sam PC then you might be able to skip the UNC part.
3. Probably not much. I took the code from aaronb's post. I hardly understand Python, much less able to write it.
Reply
#4
(2012-08-22, 20:30)kricker Wrote: 1. You should be able to change the sort to whatever you want. I have.
I can get it to sort by title, but the sorting by date doesn't appear to be working.

(2012-08-22, 20:30)kricker Wrote: 2. Both items need to be filled in. What the addon does is replace the local file path name in the Sage DB and replace it with the UNC path you specified. If they are both on the sam PC then you might be able to skip the UNC part.
That worked... I can playback now which is great. Only thing to consider is to make sure you end your SageTV folder path with a "\" or else playback won't work.
Reply
#5
You're right it appears that sorting by date isn't working properly. Maybe someone can view the code and figure out why.

The default value should have had the trailing "\" in it.
Reply
#6
I know a little bit about python as well as the SageTV metadata structure and am willing to spend some development effort on this.

I'd love it if it could operate a little more like the SageTV functionality in terms of the hierarchy... e.g. something like "All Shows" -> List of all shows -> List of all episodes for that show

I see how "xbmcplugin.addDirectoryItem" is used to add the top level "All Shows" directory, but I'd love some quick help on how to create Show specific sub-directories beneath that, that would still act as directories, and then when those are clicked, a list of episodes specific to that show would appear. Thoughts?

The only other issue is sorting... looks like the date is pulled into xbmc's aired field in "yyyy-mm-dd" format but the sorting on that isn't working. Could use some guidance there too.
Reply
#7
@LehighBri, I pm'd aaronb about creating folders per show. This is his reply:

Quote:To create a folder for each show you can use the commented out lines in the add-on as an example and modify them for your needs. For example, using this one:

#addDir('Sports',strUrl + '/sage/Search?searchType=TVFiles&Categories=Sports+event&SearchString=&xml=yes',2,'sports.jpg')

change the first argument Sports to whichever name you want for the folder, and then for the url string inside the quotes (starting with /sage/Search and ending with xml=yes) go to the web interface for SageTV and search for the that show, and copy the resulting url starting with /sage. The last argument, sports.jpg, you can put any image you want for the folder in the add-on directory under /resources/media and then put the filename as that argument. That step is optional, you don't have to have a picture, it's just one of the few customizations I was able to figure out how to do.

Adding these folders is pretty manual right now, this was my first add-on, as I get better with Python I'm hoping to figure out how to parse the entire show list and create the folders dynamically.

Perhaps this will be of some help in getting the program list a bit more organized. I think this plugin has a lot of promise but I can't see scrolling through a ton of episodes to find the right one.
Reply
#8
I think it somehow needs to create the list of series automatically. I can't imagine having to set that up each time by hand to get a new series listed. There were some plugins and scripts long ago that did a similar thing to this current plugin and more. There may be some some code that can be borrowed and updated to work with XBMC's current addon structure.

Original SageTV script written by Coolwave then maintained by me from 2009.

Plugin version of the script written by jhh from 2009.
Reply
#9
You can also modify the search string to show only Tv Files (/sage/Search?searchType=TVFiles&xml=yes). The XML will then list all of your Tv files (tag <title>) . Parse that then create a loop that passes a single instance of the TV Title to:

addDir('TV Title',strUrl + '/sage/Search?searchType=TVFiles&SearchString=TV Title&xml=yes',2,'something.jpg')

Not sure about how the image is displayed but perhaps the tv banners that TV Explorer could be used. Also not sure how fast it would be. Anyone up for trying this?
Reply
#10
Sure. If you work up the code and send it to me, I'll test it.
Reply
#11
Making some progress. Add the following code to the bottom of the CATEGORIES method. Sorting still needs to be figured out... but it's a start on the path to having first the directory structure show the show titles, then you can drill into that to see the episodes:

Code:
req = urllib.urlopen(strUrl + '/sage/Recordings?xml=yes')
        content = parse(req)
        uniqueListOfShowTitles = []
        for showlist in content.getElementsByTagName('show'):
          strTitle = ''
          for shownode in showlist.childNodes:
            # Get the title of the show
            if shownode.nodeName == 'title':
              strTitle = shownode.toxml()
              strTitle = strTitle.replace('<title>','')
              strTitle = strTitle.replace('</title>','')
              if strTitle not in uniqueListOfShowTitles:
                uniqueListOfShowTitles.append(strTitle)
                addDir(strTitle, strUrl + '/sage/Search?searchType=TVFiles&SearchString=' + strTitle + '&DVD=on&sort2=airdate_asc&TimeRange=0&pagelen=100&sort1=title_asc&filename=&Video=on&search_fields=title&xml=yes',2,'icon.png')
Reply
#12
I've tried modifying the CATEGORIES function like this:

Code:
def CATEGORIES():

        strUrl = 'http://' + __settings__.getSetting("sage_user") + ':' + __settings__.getSetting("sage_pass") + '@' + __settings__.getSetting("sage_ip") + ':' + __settings__.getSetting("sage_port")
        addDir('All Shows', strUrl + '/sage/Recordings?xml=yes',2,'icon.png')
        addDir('Safety Patrol',strUrl + '/sage/Search?searchType=TVFiles&SearchString=Safety%20Patrol&DVD=on&sort2=airdate_asc&TimeRange=0&pagelen=100&sort1=title_asc&filename=&Video=on&search_fields=title&xml=yes',2,'dailyshow.jpg')
        addDir('Sports',strUrl + '/sage/Search?searchType=TVFiles&Categories=Sports+event&SearchString=&xml=yes',2,'sports.jpg')
    addDir('The Daily Show',strUrl + '/sage/Search?searchType=TVFiles&SearchString=Daily%20show&DVD=on&sort2=airdate_asc&TimeRange=0&pagelen=100&sort1=title_asc&filename=&Video=on&search_fields=title&xml=yes',2,'dailyshow.jpg')
    
    req = urllib.urlopen(strUrl + '/sage/Search?SearchString=&searchType=TVFiles&Video=on&xml=yes')
    content = parse(req)
    for showlist in content.getElementsByTagName('show'):
        strTitle= ''
        strTitleSearch = ''
        strCheckTitle = ''    
        for shownode in showlist.childNodes:
            # Get the title of the show

            if (shownode.nodeName == 'title') and (shownode.nodeName != strCheckTitle):
                strTitle = shownode.toxml()
                    strTitle = strTitle.replace('<title>','')
                    strTitle = strTitle.replace('</title>','')
                          strTitle = strTitle.replace('&amp;','&')
                          strTitleSearch = strTitle.replace(' ','%20')
                          strCheckTitle = StrTitle
                          addDir(strTitle,strUrl + '/sage/Search?searchType=TVFiles&SearchString=' + strTitleSearch + '&DVD=on&sort2=airdate_asc&TimeRange=0&pagelen=100&sort1=title_asc&filename=&Video=on&search_fields=title&xml=yes',2,'dailyshow.jpg')

The first few lines were just a test to see if I could get the folders to appear. They did and it works great. I then tried copying a portion from VIDEOLINKS function to try and pull the title names from a generic show-all-recordings type query on the sage server. I'm doing a check to make sure we only send the title once to the addDir function. I'm getting an error but I'm not sure where. Can someone spot what I'm doing wrong? I'm a hacker, not a programmer, so any help would be great.
Reply
#13
LehighBri,

That works well. Looks like we need to do some fixing of special characters like "&" though. Right now they show up as &amp;
Reply
#14
I fixed the ampersand in the title issue and also sorted the shows initially in alphabetical order. Try this (just copy over your existing CATEGORIES function)

Code:
def CATEGORIES():
        strUrl = 'http://' + __settings__.getSetting("sage_user") + ':' + __settings__.getSetting("sage_pass") + '@' + __settings__.getSetting("sage_ip") + ':' + __settings__.getSetting("sage_port")
        addDir('All Shows', strUrl + '/sage/Recordings?xml=yes',2,'icon.png')
        req = urllib.urlopen(strUrl + '/sage/Recordings?xml=yes')
        content = parse(req)
        uniqueListOfShowTitles = []
        for showlist in content.getElementsByTagName('show'):
          strTitle = ''
          for shownode in showlist.childNodes:
            # Get the title of the show
            if shownode.nodeName == 'title':
              strTitle = shownode.toxml()
              strTitle = strTitle.replace('<title>','')
              strTitle = strTitle.replace('</title>','')
              strTitle = strTitle.replace('&amp;','&')
              if strTitle not in uniqueListOfShowTitles:
                uniqueListOfShowTitles.append(strTitle)

        uniqueListOfShowTitles.sort()
        for strTitle in uniqueListOfShowTitles:
            urlToShowEpisodes = strUrl + '/sage/Search?searchType=TVFiles&SearchString=' + urllib2.quote(strTitle.encode("utf8")) + '&DVD=on&sort2=airdate_asc&TimeRange=0&pagelen=100&sort1=title_asc&filename=&Video=on&search_fields=title&xml=yes'
            print "ADDING strTitle=" + strTitle + "; urlToShowEpisodes=" + urlToShowEpisodes
            addDir(strTitle, urlToShowEpisodes,2,'icon.png')
Reply
#15
@LehighBri ... I'm trying to use your modification but am having trouble due to a special character in one of the program names. The title contains the é character. I'm getting this error:

Code:
13:27:55 T:1232   ERROR: Error Type: <type 'exceptions.UnicodeEncodeError'>
13:27:55 T:1232   ERROR: Error Contents: 'ascii' codec can't encode character u'\xe9' in position 18: ordinal not in range(128)
13:27:55 T:1232   ERROR: Traceback (most recent call last):
                                              File "C:\Users\Donny\AppData\Roaming\XBMC\addons\plugin.video.SageTV\default.py", line 159, in <module>
                                                CATEGORIES()
                                              File "C:\Users\Donny\AppData\Roaming\XBMC\addons\plugin.video.SageTV\default.py", line 32, in CATEGORIES
                                                print "ADDING strTitle=" + strTitle + "; urlToShowEpisodes=" + urlToShowEpisodes
                                              File "<string>", line 6, in write
                                            UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 18: ordinal not in range(128)
13:27:55 T:6424   ERROR: XFILE::CDirectory::GetDirectory - Error getting plugin://plugin.video.SageTV
13:27:55 T:6424   ERROR: CGUIMediaWindow::GetDirectory(plugin://plugin.video.SageTV) failed

*EDIT* Figured out how to sanitize the content. You need to:

Code:
import unicodedata

and add to the section where the & are fixed:
Code:
strTitle = unicodedata.normalize('NFKD', strTitle).encode('ascii','ignore')
Reply
  • 1(current)
  • 2
  • 3
  • 4
  • 5
  • 18
  •   
 
Thread Rating:
  • 2 Vote(s) - 5 Average



Logout Mark Read Team Forum Stats Members Help
[RELEASE] SageTV recordings52
This forum uses Lukasz Tkacz MyBB addons.