krkeegan Site Admin

Joined: 04 Jan 2008 Posts: 412 Location: Los Angeles, CA
|
Posted: Sun Feb 17, 2008 5:54 pm Post subject: Log of Video Transfers |
|
|
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) |
|
|
spudnic
Joined: 03 Aug 2008 Posts: 2
|
Posted: Sun Aug 03, 2008 7:59 am Post subject: |
|
|
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); |
|