pyTivo Discussion Forum Forum Index pyTivo Discussion Forum
Answers and the development of pyTivo a TiVo transcoding server
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Log of Video Transfers

 
Post new topic   Reply to topic    pyTivo Discussion Forum Forum Index -> Hacks
 View previous topic :: View next topic  
Author Message
krkeegan
Site Admin


Joined: 04 Jan 2008
Posts: 412
Location: Los Angeles, CA

PostPosted: Sun Feb 17, 2008 5:54 pm    Post subject: Log of Video Transfers Reply with quote

Description:
This hack will create a log of video files that have been transfered and the date and time of the transfer. The log will be stored in the base pyTivo folder using the name transfers.txt.

The Hack:
Open plugins/video/video.py with your favorite python editor.

Find the following section near line 203:
Code:
    def send_file(self, handler, container, name):
        if handler.headers.getheader('Range') and \
           handler.headers.getheader('Range') != 'bytes=0-':
            handler.send_response(206)
            handler.send_header('Connection', 'close')
            handler.send_header('Content-Type', 'video/x-tivo-mpeg')
            handler.send_header('Transfer-Encoding', 'chunked')
            handler.end_headers()
            handler.wfile.write("\x30\x0D\x0A")
            return

        tsn = handler.headers.getheader('tsn', '')

        o = urlparse("http://fake.host" + handler.path)
        path = unquote(o[2])
        handler.send_response(200)
        handler.end_headers()
        transcode.output_video(container['path'] + path[len(name) + 1:],
                               handler.wfile, tsn)


Change it to the following:
Code:
    def send_file(self, handler, container, name):
        if handler.headers.getheader('Range') and \
           handler.headers.getheader('Range') != 'bytes=0-':
            handler.send_response(206)
            handler.send_header('Connection', 'close')
            handler.send_header('Content-Type', 'video/x-tivo-mpeg')
            handler.send_header('Transfer-Encoding', 'chunked')
            handler.end_headers()
            handler.wfile.write("\x30\x0D\x0A")
            return

        tsn = handler.headers.getheader('tsn', '')

        o = urlparse("http://fake.host" + handler.path)
        path = unquote(o[2])
        handler.send_response(200)
        handler.end_headers()
       
        ## The following three lines create the transfers log hack
        fdebug = open('transfers.txt', 'a')
        fdebug.write(str(datetime.now()) + ': ' + container['path'] + path[len(name) + 1:] + '\n')
        fdebug.close()
       
        transcode.output_video(container['path'] + path[len(name) + 1:],
                               handler.wfile, tsn)
Back to top
View user's profile Send private message Visit poster's website
TreborPugly



Joined: 04 Jan 2008
Posts: 52

PostPosted: Mon Feb 18, 2008 7:36 pm    Post subject: Reply with quote

Cool!
Back to top
View user's profile Send private message
spudnic



Joined: 03 Aug 2008
Posts: 2

PostPosted: Sun Aug 03, 2008 7:59 am    Post subject: Reply with quote

I am using this cool hack in conjunction with the following little perl script. I have it scheduled to run each morning. It moves files that have been transferred to a zz_transfered directory in case I want to keep something.

Of course it could just delete transferred files if desired.

Warning: Windows paths below. Change for your platform. This is just mainly for the concept.

#!/usr/bin/perl

use File::Find;
use File::Copy;


$infile = "c:\\Program Files\\pytivo\\transfers.txt";

open (MIF, $infile);

while (<MIF>) {
chomp;
s/^.*?c\:/c\:/igm;
s/\\/\\\\/igm;
move $_, "c:\\publish\\zz_Transfered";
}
close (MIF);

unlink($infile);
exit(0);
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    pyTivo Discussion Forum Forum Index -> Hacks All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum
Site is in NO WAY affiliated with TiVo Inc

Powered by phpBB © 2001, 2005 phpBB Group
phpBB SEO
[ Time: 0.3083s ][ Queries: 13 (0.1591s) ][ Debug on ]