CIS: torrent creation implemented
[living-lab-site.git] / cis / cisd.py
1 #!/usr/bin/env python
2
3 import sys
4 import config
5 import os
6
7 from BaseLib.Core.API import *
8
9 def create_torrent(source):
10     """ Creates a torrent file for the video source file. """
11
12     if isinstance(source, unicode):
13         usource = source
14     else:
15         usource = source.decode(sys.getfilesystemencoding())
16
17     duration = config.AVINFO_CLASS.get_video_duration(source, True)
18
19     print config.BT_TRACKER, duration, source
20
21     tdef = TorrentDef()
22     tdef.add_content(usource, playtime=duration)
23     tdef.set_tracker(config.BT_TRACKER)
24
25     tdef.set_piece_length(32768)
26
27     tdef.finalize()
28     tdef.save(source + '.tstream')
29
30
31 if __name__ == '__main__':
32     pass
33 #    transcoder = config.TRANSCODER_CLASS(sys.argv[1])
34 #    transcoder.transcode('webm', "vorbis", "vp8", a_bitrate="128k", a_samplingrate=22050, a_channels=2, v_bitrate="256k", v_framerate=15, v_resolution="320x240", v_dar="4:3")
35     
36 #    thumb_extractor = config.THUMB_EXTRACTOR_CLASS(sys.argv[1])
37 #    #print thumb_extractor.get_video_duration()
38 #    #thumb_extractor.extract_random_thumb()
39 #    print thumb_extractor.extract_summary_thumbs(5)
40
41 #    file_transfer = config.FILE_TRANSFERER_CLASS()
42 #    file_transfer.get(['vim_config.tar.gz'])
43 #    #file_transfer.put(['cisd.py'])
44 #    file_transfer.close()
45
46     create_torrent(sys.argv[1])