Changeset a170d6003c3cee6cb73813fcfb94bf48a960d869

Show
Ignore:
Timestamp:
03/09/08 21:00:56 (8 months ago)
Author:
KRKeegan <-NOSPAM-kevin@krkeegan.com>
git-committer:
KRKeegan <-NOSPAM-kevin@krkeegan.com> 1205114456 -0700
git-parent:

[f975761fe7abe49e3bc883c08150fd8b60ecf011]

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

Transfers are functional with a glitch

For some reason the files are corrupt, I will look into this more in a bit.

Files:

Legend:

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

    rf975761 ra170d60  
    66from plugin import Plugin 
    77from urllib import unquote_plus, quote, unquote 
     8from urlparse import urlparse 
    89from xml.sax.saxutils import escape 
    910from lrucache import LRUCache 
     
    128129         
    129130    def NPL(self, handler, query): 
     131        subcname = query['Container'][0] 
     132        cname = subcname.split('/')[0] 
     133        for name, data in config.getShares(): 
     134            if cname == name: 
     135                if 'tivo_mak' in data: 
     136                    tivo_mak = data['tivo_mak'] 
     137                else: 
     138                    tivo_mak = "" 
    130139        folder = '/NowPlaying' 
    131140        if 'Folder' in query: 
    132141            folder += '/' + str(query['Folder'][0]) 
    133         theurl = 'https://192.168.1.150/TiVoConnect?Command=QueryContainer&Container=' + folder 
    134  
    135         password = '' #TiVo MAK 
     142        tivoIP = tivo_mak.split(':')[0] 
     143        theurl = 'https://'+ tivoIP +'/TiVoConnect?Command=QueryContainer&Container=' + folder 
     144 
     145        password = tivo_mak.split(':')[1] #TiVo MAK 
    136146 
    137147        r=urllib2.Request(theurl) 
    138148        auth_handler = urllib2.HTTPDigestAuthHandler() 
    139         auth_handler.add_password('TiVo DVR', '192.168.1.150', 'tivo', password) 
     149        auth_handler.add_password('TiVo DVR', tivoIP, 'tivo', password) 
    140150        opener = urllib2.build_opener(auth_handler) 
    141151        urllib2.install_opener(opener) 
     
    168178                if (len(link.getElementsByTagName("CustomIcon")) >= 1): 
    169179                    entry['Icon'] = link.getElementsByTagName("CustomIcon")[0].getElementsByTagName("Url")[0].firstChild.data 
     180                if (len(link.getElementsByTagName("Content")) >= 1): 
     181                    entry['Url'] = quote(link.getElementsByTagName("Content")[0].getElementsByTagName("Url")[0].firstChild.data) 
     182                    print entry['Url'] 
    170183                keys = ['SourceSize', 'Duration', 'CaptureDate', 'EpisodeTitle', 'Description', 'SourceChannel', 'SourceStation'] 
    171184                for key in keys: 
     
    176189                entry['SourceSize'] = "%.3f GB" % float(float(entry['SourceSize'])/(1024*1024*1024)) 
    177190                entry['Duration'] = str(int(entry['Duration'])/(60*60*1000)).zfill(2) + ':' \ 
    178                                     + str((int(entry['Duration'])/60*1000)%60).zfill(2) + ':' \ 
     191                                    + str((int(entry['Duration'])%(60*60*1000))/(60*1000)).zfill(2) + ':' \ 
    179192                                    + str((int(entry['Duration'])/1000)%60).zfill(2) 
    180193                entry['CaptureDate'] = time.strftime("%b %d, %Y", time.localtime(int(entry['CaptureDate'], 16))) 
     
    190203        if folder != '/NowPlaying': 
    191204            t.subfolder = True 
     205        t.status = status 
    192206        t.container = cname 
    193207        t.data = data 
    194         handler.wfile.write(t) 
    195  
    196     def ToGo(self, handler, query): 
    197         theurl = "http://192.168.1.150/download/Survivor%20Micronesia%20--%20Fans%20vs.%20Favorites.TiVo?Container=%2FNowPlaying&id=385244" 
    198         password = '' #TiVo MAK 
    199         tivoIP = '192.168.1.150' 
    200         outfile = "video.tivo" 
    201  
    202         status[theurl] = {'running':True, 'error':'', 'rate':''} 
    203  
    204         thread.start_new_thread(get_tivo_file, (theurl, password, tivoIP, outfile)) 
    205  
    206  
    207     def get_tivo_file(url, mak, tivoIP, outfile): 
    208         global status 
     208        t.unquote = unquote 
     209        handler.wfile.write(t) 
     210 
     211    def get_tivo_file(self, url, mak, tivoIP, outfile): 
     212        #global status 
    209213        cj = cookielib.LWPCookieJar() 
    210214 
     
    248252        f.close() 
    249253        return 
     254 
     255    def ToGo(self, handler, query): 
     256        subcname = query['Container'][0] 
     257        cname = subcname.split('/')[0] 
     258        for name, data in config.getShares(): 
     259            if cname == name: 
     260                if 'tivo_mak' in data: 
     261                    tivo_mak = data['tivo_mak'] 
     262                else: 
     263                    tivo_mak = "" 
     264                if 'togo_path' in data: 
     265                    togo_path = data['togo_path'] 
     266                else: 
     267                    togo_path = "" 
     268        if tivo_mak != "" and togo_path != "": 
     269            theurl = str(query['Url'][0]) 
     270            print theurl 
     271            password = tivo_mak.split(':')[1] #TiVo MAK 
     272            tivoIP = str(query['TiVo'][0]) + ":80" 
     273            name = unquote(urlparse(theurl)[2])[10:300].split('.') 
     274            name.insert(-1," - " + unquote(urlparse(theurl)[4]).split("id=")[1] + ".") 
     275            outfile = os.path.join(togo_path, "".join(name)) 
     276 
     277            status[theurl] = {'running':True, 'error':'', 'rate':''} 
     278 
     279            thread.start_new_thread(Admin.get_tivo_file, (self, theurl, password, tivoIP, outfile)) 
    250280             
     281            handler.send_response(200) 
     282            handler.end_headers() 
     283            t = Template(file=os.path.join(SCRIPTDIR,'templates', 'redirect.tmpl')) 
     284            t.container = cname 
     285            t.text = '<h3>Transfer Initiated.</h3>  <br>You selected transfer has been initiated.' 
     286            handler.wfile.write(t) 
     287        else: 
     288            handler.send_response(200) 
     289            handler.end_headers() 
     290            t = Template(file=os.path.join(SCRIPTDIR,'templates', 'redirect.tmpl')) 
     291            t.container = cname 
     292            t.text = '<h3>Missing Data.</h3>  <br>You must set both "tivo_mak" and "togo_path" before using this function.' 
     293            handler.wfile.write(t) 
     294             
  • plugins/admin/templates/npl.tmpl

    rf975761 ra170d60  
    6161                        $row['Duration'] 
    6262                        </td> 
    63                         <td>$row['CaptureDate']</td><td><a href="#">Transfer This.</a></td> 
     63                        <td>$row['CaptureDate']</td> 
     64                        #if 'Url' in $row 
     65                                #if $unquote($row['Url']) in $status 
     66                                        #set $this_status = $status[$unquote($row['Url'])] 
     67                                        #if $this_status['running'] and $this_status['rate'] != "" 
     68                                                <td>Transfering - $this_status['rate'] KB/s</td>                                         
     69                                        #elif $this_status['running'] and $this_status['rate'] == "" 
     70                                                <td>Initiating Transfer. Please Wait</td> 
     71                                        #elif $this_status['error'] 
     72                                                <td>Error - $this_status['error']</td> 
     73                                        #else 
     74                                                <td>Transfer Complete</td> 
     75                                        #endif 
     76                                #else 
     77                                        <td><a href="/TiVoConnect?Command=ToGo&Container=$(container)&Url=$(row['Url'])&TiVo=$(TiVo)">Transfer This.</a></td> 
     78                                #end if 
     79                        #else 
     80                                <td></td> 
     81                        #end if 
    6482                  #end if 
    6583                  </tr>