def download(self): """ Downloads files for installation with DownloadManager. """ if self.files: downloader = DownloadManager(self.core, self) downloader.download(self.files)
def cleanup_download(self, torrent): if torrent.progress == 100: schedule_data = DownloadManager().get_schedule_data(torrent.hashString) if schedule_data: video_type = 'Episode' showname = schedule_data[1] else: video_type = DownloadManager().get_torrent_type(torrent.hashString) if video_type in ['Episode', 'Series', 'Season']: showname = ScheduleManager().guess_series_name(torrent.name) else: showname = None if video_type in ('Episode', 'Movie'): #single file try: video_file_name = DownloadManager().get_video_file_path(TransmissionManager().get_files(torrent.id)) except FakeDownloadException, e: print "FAKE DOWNLOAD DETECTED!" self.send_sms_to_subscribers(torrent, "BOOP. Fake download detected: %(name)s") if video_file_name is not None and video_type is not None: video_path = "%s/%s" % (TransmissionManager().get_session().download_dir, video_file_name) print strings.MOVING_VIDEO_FILE % (video_type, video_file_name.encode('ascii', 'ignore')) DownloadManager().move_video_file(video_path, video_type, showname) #if this was a decompress created folder, we want to delete the whole thing #otherwise we can count on transmission to delete it properly if video_path.endswith('/*'): print "DELETING GUID" file_path = video_path[:-2] DownloadManager().delete_video_file(file_path) TransmissionManager().remove(torrent.id, delete_data = True) print strings.DOWNLOAD_CLEAN_COMPLETED self.send_completed_sms_subscribers(torrent) else: print strings.UNSUPPORTED_FILE_TYPE % torrent.id elif video_type in ('Set', 'Season', 'Series'): #some movies bro try: video_files = DownloadManager().get_all_video_file_paths(TransmissionManager().get_files(torrent.id), kill_samples=("sample" not in torrent.name.lower())) except FakeDownloadException, e: print "FAKE DOWNLOAD DETECTED!" self.send_sms_to_subscribers(torrent, "BOOP. Fake download detected: %(name)s") if video_files is not None and video_type is not None: for vidja in video_files: video_path = "%s/%s" % (TransmissionManager().get_session().download_dir, vidja) print strings.MOVING_VIDEO_FILE % (video_type, vidja.encode('ascii', 'ignore')) DownloadManager().move_video_file(video_path, video_type) TransmissionManager().remove(torrent.id, delete_data = True) print strings.DOWNLOAD_CLEAN_COMPLETED self.send_completed_sms_subscribers(torrent) else: print strings.UNSUPPORTED_FILE_TYPE % torrent.id
def __init__(self): """""" DownloadManager.__init__(self, lambda x: x, []) Tree.__init__(self, [None], self) self.config = shared.configuration