Changeset e5d0a3e3671bf2c9a4df8961caffe9c6f25d4782

Show
Ignore:
Timestamp:
03/26/08 13:09:08 (10 months ago)
Author:
KRKeegan <-NOSPAM-kevin@krkeegan.com>
git-committer:
KRKeegan <-NOSPAM-kevin@krkeegan.com> 1206554948 -0700
git-parent:

[ed1a74ce705bf51378ce1e823f31421bca5d4f88]

git-author:
KRKeegan <-NOSPAM-kevin@krkeegan.com> 1206554948 -0700
Message:

Limit number of items per page in NPL, simpler method to pass URL for redirect

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/admin/admin.py

    red1a74c re5d0a3e  
    144144         
    145145    def NPL(self, handler, query): 
     146        shows_per_page = 50 #Change this to alter the number of shows returned per page 
    146147        subcname = query['Container'][0] 
    147148        cname = subcname.split('/')[0] 
    148149        folder = '' 
     150        AnchorItem = '' 
     151        AnchorOffset= '' 
    149152        for name, data in config.getShares(): 
    150153            if cname == name: 
     
    160163        if 'TiVo' in query: 
    161164            tivoIP = query['TiVo'][0] 
    162             theurl = 'https://'+ tivoIP +'/TiVoConnect?Command=QueryContainer&Container=/NowPlaying' 
     165            theurl = 'https://'+ tivoIP +'/TiVoConnect?Command=QueryContainer&ItemCount='+ str(shows_per_page) +'&Container=/NowPlaying' 
    163166            if 'Folder' in query: 
    164167                folder += str(query['Folder'][0]) 
    165168                theurl += '/' + folder 
     169            if 'AnchorItem' in query: 
     170                AnchorItem += str(query['AnchorItem'][0]) 
     171                theurl += '&AnchorItem=' + quote(AnchorItem) 
     172            if 'AnchorOffset' in query: 
     173                AnchorOffset += str(query['AnchorOffset'][0]) 
     174                theurl += '&AnchorOffset=' + AnchorOffset 
    166175 
    167176            password = tivo_mak #TiVo MAK 
     
    212221            xmldoc = minidom.parseString(tivo_cache[theurl]['thepage']) 
    213222            items = xmldoc.getElementsByTagName('Item') 
     223            TotalItems = xmldoc.getElementsByTagName('Details')[0].getElementsByTagName('TotalItems')[0].firstChild.data 
     224            ItemStart = xmldoc.getElementsByTagName('ItemStart')[0].firstChild.data 
     225            ItemCount = xmldoc.getElementsByTagName('ItemCount')[0].firstChild.data 
     226            FirstAnchor = items[0].getElementsByTagName("Links")[0].getElementsByTagName("Content")[0].getElementsByTagName("Url")[0].firstChild.data 
    214227 
    215228            data = [] 
     
    248261            data = [] 
    249262            tivoIP = '' 
     263            TotalItems = 0 
     264            ItemStart = 0 
     265            ItemCount = 0 
     266            FirstAnchor = '' 
    250267 
    251268        subcname = query['Container'][0] 
     
    264281        t.unquote = unquote 
    265282        t.len = len 
     283        t.TotalItems = int(TotalItems) 
     284        t.ItemStart = int(ItemStart) 
     285        t.ItemCount = int(ItemCount) 
     286        t.FirstAnchor = quote(FirstAnchor) 
     287        t.shows_per_page = shows_per_page 
     288        t.redirect = quote(unquote_plus(handler.path).split('/')[1]) 
    266289        handler.wfile.write(t) 
    267290 
     
    323346                else: 
    324347                    togo_path = "" 
    325         folder = '' 
    326         if 'Folder' in query: 
    327             folder += str(query['Folder'][0]) 
    328348        if tivo_mak != "" and togo_path != "": 
    329349            parse_url = urlparse(str(query['Url'][0])) 
     
    344364            t.container = cname 
    345365            t.time = '3' 
    346             t.url = '/TiVoConnect?Command=NPL&Container=' + cname + '&TiVo=' + query['TiVo'][0] + '&Folder=' + folder 
     366            t.url = '/'+ query['Redirect'][0] 
    347367            t.text = '<h3>Transfer Initiated.</h3>  <br>You selected transfer has been initiated.'+\ 
    348                      '<br> The <a href="/TiVoConnect?Command=NPL&Container='+ cname + '&TiVo=' + query['TiVo'][0] + '&Folder=' + folder +'"> ToGo</a> page will reload in 3 seconds.' 
     368                     '<br> The <a href="/'+ query['Redirect'][0] +'"> ToGo</a> page will reload in 3 seconds.' 
    349369            handler.wfile.write(t) 
    350370        else: 
     
    354374            t.container = cname 
    355375            t.time = '10' 
    356             t.url = '/TiVoConnect?Command=NPL&Container=' + cname + '&TiVo=' + query['TiVo'][0] + '&Folder=' + folder 
     376            t.url = '/'+ query['Redirect'][0] 
    357377            t.text = '<h3>Missing Data.</h3>  <br>You must set both "tivo_mak" and "togo_path" before using this function.'+\ 
    358                      '<br> The <a href="/TiVoConnect?Command=NPL&Container='+ cname + '&TiVo=' + query['TiVo'][0] + '&Folder=' + folder +'"> ToGo</a> page will reload in 10 seconds.' 
     378                     '<br> The <a href="/'+ query['Redirect'][0] +'"> ToGo</a> page will reload in 10 seconds.' 
    359379            handler.wfile.write(t) 
    360380 
     
    362382        parse_url = urlparse(str(query['Url'][0])) 
    363383        theurl = 'http://' + parse_url[1].split(':')[0] + parse_url[2] + "?" + parse_url[4] 
    364         folder = '' 
    365         if 'Folder' in query: 
    366             folder += str(query['Folder'][0]) 
    367384         
    368385        status[theurl]['running'] = False 
     
    375392        t.container = cname 
    376393        t.time = '3' 
    377         t.url = '/TiVoConnect?Command=NPL&Container=' + cname + '&TiVo=' + query['TiVo'][0] + '&Folder=' + folder 
     394        t.url = '/'+ query['Redirect'][0] 
    378395        t.text = '<h3>Transfer Stopped.</h3>  <br>Your transfer has been stopped.'+\ 
    379                  '<br> The <a href="/TiVoConnect?Command=NPL&Container='+ cname + '&TiVo=' + query['TiVo'][0] + '&Folder=' + folder +'"> ToGo</a> page will reload in 3 seconds.' 
     396                 '<br> The <a href="/'+ query['Redirect'][0] +'"> ToGo</a> page will reload in 3 seconds.' 
    380397        handler.wfile.write(t) 
    381398 
  • plugins/admin/templates/npl.tmpl

    rf203746 re5d0a3e  
    3131      #if $tivoIP != '' 
    3232          <!-- If TiVoIP is present then we should display a NPL --> 
     33                  #if $ItemStart > 0 
     34                        #set $Offset = -($ItemStart + 1) 
     35                        #if $Offset < -($shows_per_page+1) 
     36                           #set $Offset = -($shows_per_page+1) 
     37                        #end if 
     38                        <a href="/TiVoConnect?Command=NPL&Container=$container&TiVo=$tivoIP&AnchorItem=$FirstAnchor&AnchorOffset=$Offset&Folder=$folder">Previous Page</a> 
     39                  #end if 
    3340                  <table> 
    3441                  #if $folder != '' 
     
    8592                                                #if $this_status['running'] and $this_status['rate'] != "" 
    8693                                                        Transfering - $this_status['rate'] KB/s<br> 
    87                                                         <a href="/TiVoConnect?Command=ToGoStop&Container=$(container)&Url=$(row['Url'])&TiVo=$tivoIP&Folder=$folder">Stop Transfer</a> 
     94                                                        <a href="/TiVoConnect?Command=ToGoStop&Container=$(container)&Url=$(row['Url'])&TiVo=$tivoIP&Redirect=$redirect">Stop Transfer</a> 
    8895                                                #elif $this_status['running'] and $this_status['rate'] == "" 
    8996                                                        Initiating Transfer.<br> 
     
    9198                                                #elif $this_status['error'] 
    9299                                                        Error - $this_status['error']<br> 
    93                                                         <a href="/TiVoConnect?Command=ToGo&Container=$(container)&Url=$(row['Url'])&TiVo=$tivoIP&Folder=$folder">Try Transfer Again.</a> 
     100                                                        <a href="/TiVoConnect?Command=ToGo&Container=$(container)&Url=$(row['Url'])&TiVo=$tivoIP&Redirect=$redirect">Try Transfer Again.</a> 
    94101                                                #elif $this_status['finished'] 
    95102                                                        Transfer Complete! 
    96103                                                #else 
    97104                                                        Transfer Stopped<br> 
    98                                                         <a href="/TiVoConnect?Command=ToGo&Container=$(container)&Url=$(row['Url'])&TiVo=$tivoIP&Folder=$folder">Try Transfer Again.</a> 
     105                                                        <a href="/TiVoConnect?Command=ToGo&Container=$(container)&Url=$(row['Url'])&TiVo=$tivoIP&Redirect=$redirect">Try Transfer Again.</a> 
    99106                                                #end if 
    100107                                        #else 
    101                                                 <a href="/TiVoConnect?Command=ToGo&Container=$(container)&Url=$(row['Url'])&TiVo=$tivoIP&Folder=$folder">Transfer This.</a> 
     108                                                <a href="/TiVoConnect?Command=ToGo&Container=$(container)&Url=$(row['Url'])&TiVo=$tivoIP&Redirect=$redirect">Transfer This.</a> 
    102109                                        #end if 
    103110                                        </td> 
     
    110117                  #end for 
    111118                  </table> 
     119                  #if ($TotalItems - $ItemCount) > ($ItemStart + 1) 
     120                     #set $Offset = $shows_per_page - 1 
     121                     <a href="/TiVoConnect?Command=NPL&Container=$container&TiVo=$tivoIP&AnchorItem=$FirstAnchor&AnchorOffset=$Offset&Folder=$folder">Next Page</a> 
     122                  #end if 
    112123          #else 
    113124                  <!-- No TiVo IP Provided so display instructions -->