def start_torrent(self, torrent): tdef = TorrentDef.load(torrent) if not os.access(self._directory, os.F_OK): os.makedirs(self._directory) dscfg = DownloadStartupConfig() dscfg.set_dest_dir(self._directory) dscfg.set_video_events([ simpledefs.VODEVENT_START, simpledefs.VODEVENT_PAUSE, simpledefs.VODEVENT_RESUME ]) dscfg.set_max_speed(simpledefs.DOWNLOAD, self._max_dl_rate) dscfg.set_max_speed(simpledefs.UPLOAD, self._max_ul_rate) dscfg.set_peer_type("S") #dscfg.set_video_event_callback(self.video_callback) # supporter should not play the files ! d = self._session.start_download(tdef, dscfg) d.set_state_callback(self.state_callback) time.sleep(1) # give the download some time to fully initialize d.sd.dow.choker.set_supporter_server(True) self._tracker_url = tdef.get_tracker()[:tdef.get_tracker(). find("announce")] self._id = d.sd.peerid self._choke_objects.append(d.sd.dow.choker)
def start_torrent(self, torrent): tdef = TorrentDef.load(torrent) if not os.access(self._directory, os.F_OK): os.makedirs(self._directory) dscfg = DownloadStartupConfig() dscfg.set_dest_dir(self._directory) dscfg.set_video_events([simpledefs.VODEVENT_START, simpledefs.VODEVENT_PAUSE, simpledefs.VODEVENT_RESUME]) dscfg.set_max_speed(simpledefs.DOWNLOAD, self._max_dl_rate) dscfg.set_max_speed(simpledefs.UPLOAD, self._max_ul_rate) dscfg.set_peer_type("S") #dscfg.set_video_event_callback(self.video_callback) # supporter should not play the files ! d = self._session.start_download(tdef, dscfg) d.set_state_callback(self.state_callback) time.sleep(1) # give the download some time to fully initialize d.sd.dow.choker.set_supporter_server(True) self._tracker_url = tdef.get_tracker()[:tdef.get_tracker().find("announce")] self._id = d.sd.peerid self._choke_objects.append(d.sd.dow.choker)
BITRATE = tdef.get_bitrate() print >>sys.stderr, "Calculated bitrate is %d" % BITRATE client_stats['video_duration'] = int(tdef.get_length() / tdef.get_bitrate()) if not os.access(options.directory, os.F_OK): os.makedirs(options.directory) dscfg = DownloadStartupConfig() dscfg.set_dest_dir(options.directory) global my_dir my_dir = options.directory dscfg.set_video_events([simpledefs.VODEVENT_START, simpledefs.VODEVENT_PAUSE, simpledefs.VODEVENT_RESUME]) dscfg.set_video_event_callback(vod_event_callback) dscfg.set_max_speed(simpledefs.DOWNLOAD, options.dlrate) dscfg.set_max_speed(simpledefs.UPLOAD, options.ulrate) if dscfg.get_mode() == simpledefs.DLMODE_VOD: print >>sys.stderr, 'Client runs in streaming mode' d = s.start_download(tdef, dscfg) d.set_state_callback(state_event_callback) time.sleep(1) communicator = TrackerCommunicator(tracker_url, options.port, d.sd.peerid) #communicator.send_registration() try:
client_stats['video_duration'] = int(tdef.get_length() / tdef.get_bitrate()) if not os.access(options.directory, os.F_OK): os.makedirs(options.directory) dscfg = DownloadStartupConfig() dscfg.set_dest_dir(options.directory) global my_dir my_dir = options.directory dscfg.set_video_events([ simpledefs.VODEVENT_START, simpledefs.VODEVENT_PAUSE, simpledefs.VODEVENT_RESUME ]) dscfg.set_video_event_callback(vod_event_callback) dscfg.set_max_speed(simpledefs.DOWNLOAD, options.dlrate) dscfg.set_max_speed(simpledefs.UPLOAD, options.ulrate) if dscfg.get_mode() == simpledefs.DLMODE_VOD: print >> sys.stderr, 'Client runs in streaming mode' d = s.start_download(tdef, dscfg) d.set_state_callback(state_event_callback) time.sleep(1) communicator = TrackerCommunicator(tracker_url, options.port, d.sd.peerid) #communicator.send_registration() try: