def upload_generate_torrents(request, upload_id): book_upload = BookUpload.objects.get(id=upload_id) target_temp_filename = book_upload.book_data.storage.path(book_upload.book_data) torrent_temp_filename = os.path.join(settings.UPLOAD_TEMP_DIR, os.path.splitext(book_upload.target_filename)[ 0] + '.torrent') if book_upload.bibliotik_torrent_file is None: utils.call_mktorrent(target_temp_filename, torrent_temp_filename, bibliotik.settings.BIBLIOTIK_ANNOUNCE, book_upload.target_filename) with open(torrent_temp_filename, 'rb') as file: book_upload.bibliotik_torrent_file = file.read() book_upload.save() os.remove(torrent_temp_filename) if book_upload.what_torrent_file is None: utils.call_mktorrent(target_temp_filename, torrent_temp_filename, WhatManager2.settings.WHAT_ANNOUNCE, book_upload.target_filename) with open(torrent_temp_filename, 'rb') as file: book_upload.what_torrent_file = file.read() book_upload.save() os.remove(torrent_temp_filename) return redirect('books.views.edit_upload', upload_id)
def generate_torrents(qobuz_upload): utils.call_mktorrent( qobuz_upload.temp_media_path, os.path.join(qobuz_upload.temp_media_path, qobuz_upload.torrent_name + '.torrent'), WHAT_ANNOUNCE, qobuz_upload.torrent_name) pass
def generate_torrents(qobuz_upload): utils.call_mktorrent( qobuz_upload.temp_media_path, os.path.join(qobuz_upload.temp_media_path, qobuz_upload.torrent_name + '.torrent'), WHAT_ANNOUNCE, qobuz_upload.torrent_name ) pass
def mktorrent(self): print 'Creating torrent file...' torrent_temp_filename = 'temp.torrent' try: os.remove(torrent_temp_filename) except OSError: pass call_mktorrent(self.torrent_dir_path, torrent_temp_filename, settings.WHAT_ANNOUNCE, self.torrent_new_name) with open(torrent_temp_filename, 'rb') as torrent_file: self.torrent_file_new_data = pthify_torrent(torrent_file.read()) self.torrent_new_infohash = get_info_hash_from_data( self.torrent_file_new_data) print 'New info hash is: ', self.torrent_new_infohash print 'Torrent file created'
def mktorrent(self): print 'Creating torrent file...' torrent_temp_filename = 'temp.torrent' try: os.remove(torrent_temp_filename) except OSError: pass call_mktorrent(self.torrent_dir_path, torrent_temp_filename, settings.WHAT_ANNOUNCE, self.torrent_new_name) with open(torrent_temp_filename, 'rb') as torrent_file: self.torrent_file_new_data = pthify_torrent(torrent_file.read()) self.torrent_new_infohash = get_info_hash_from_data(self.torrent_file_new_data) print 'New info hash is: ', self.torrent_new_infohash print 'Torrent file created'