7 from BaseLib.Core.API import *
9 def create_torrent(source):
10 """ Creates a torrent file for the video source file. """
12 if isinstance(source, unicode):
15 usource = source.decode(sys.getfilesystemencoding())
17 duration = config.AVINFO_CLASS.get_video_duration(source, True)
19 print config.BT_TRACKER, duration, source
22 tdef.add_content(usource, playtime=duration)
23 tdef.set_tracker(config.BT_TRACKER)
25 tdef.set_piece_length(32768)
28 tdef.save(source + '.tstream')
31 if __name__ == '__main__':
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")
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)
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()
46 create_torrent(sys.argv[1])