remove unused EncryptedFileOpener
This commit is contained in:
parent
14636a5d38
commit
6f71a5003c
2 changed files with 2 additions and 99 deletions
|
@ -29,7 +29,6 @@ from lbrynet.reflector import reupload
|
|||
from lbrynet.reflector import ServerFactory as reflector_server_factory
|
||||
from lbrynet.core.log_support import configure_loggly_handler
|
||||
from lbrynet.lbry_file.client.EncryptedFileDownloader import EncryptedFileSaverFactory
|
||||
from lbrynet.lbry_file.client.EncryptedFileDownloader import EncryptedFileOpenerFactory
|
||||
from lbrynet.lbry_file.client.EncryptedFileOptions import add_lbry_file_to_sd_identifier
|
||||
from lbrynet.lbry_file.EncryptedFileMetadataManager import DBEncryptedFileMetadataManager
|
||||
from lbrynet.lbry_file.StreamDescriptor import EncryptedFileStreamType
|
||||
|
@ -578,17 +577,8 @@ class Daemon(AuthJSONRPCServer):
|
|||
self.session.wallet,
|
||||
self.download_directory
|
||||
)
|
||||
self.sd_identifier.add_stream_downloader_factory(
|
||||
EncryptedFileStreamType, file_saver_factory)
|
||||
file_opener_factory = EncryptedFileOpenerFactory(
|
||||
self.session.peer_finder,
|
||||
self.session.rate_limiter,
|
||||
self.session.blob_manager,
|
||||
self.stream_info_manager,
|
||||
self.session.wallet
|
||||
)
|
||||
self.sd_identifier.add_stream_downloader_factory(
|
||||
EncryptedFileStreamType, file_opener_factory)
|
||||
self.sd_identifier.add_stream_downloader_factory(EncryptedFileStreamType,
|
||||
file_saver_factory)
|
||||
return defer.succeed(None)
|
||||
|
||||
def _download_blob(self, blob_hash, rate_manager=None, timeout=None):
|
||||
|
|
|
@ -282,90 +282,3 @@ class EncryptedFileSaverFactory(EncryptedFileDownloaderFactory):
|
|||
@staticmethod
|
||||
def get_description():
|
||||
return "Save"
|
||||
|
||||
|
||||
class EncryptedFileOpener(EncryptedFileDownloader):
|
||||
def __init__(self, stream_hash, peer_finder, rate_limiter, blob_manager, stream_info_manager,
|
||||
payment_rate_manager, wallet):
|
||||
EncryptedFileDownloader.__init__(self, stream_hash,
|
||||
peer_finder, rate_limiter,
|
||||
blob_manager, stream_info_manager,
|
||||
payment_rate_manager, wallet,
|
||||
)
|
||||
self.process = None
|
||||
self.process_log = None
|
||||
|
||||
def stop(self, err=None):
|
||||
d = EncryptedFileDownloader.stop(self, err=err)
|
||||
d.addCallback(lambda _: self._delete_from_info_manager())
|
||||
return d
|
||||
|
||||
def _get_progress_manager(self, download_manager):
|
||||
return FullStreamProgressManager(self._finished_downloading,
|
||||
self.blob_manager,
|
||||
download_manager)
|
||||
|
||||
def _setup_output(self):
|
||||
def start_process():
|
||||
if os.name == "nt":
|
||||
paths = [r'C:\Program Files\VideoLAN\VLC\vlc.exe',
|
||||
r'C:\Program Files (x86)\VideoLAN\VLC\vlc.exe']
|
||||
for p in paths:
|
||||
if os.path.exists(p):
|
||||
vlc_path = p
|
||||
break
|
||||
else:
|
||||
raise ValueError("You must install VLC media player to stream files")
|
||||
else:
|
||||
vlc_path = 'vlc'
|
||||
self.process_log = open("vlc.out", 'a')
|
||||
try:
|
||||
self.process = subprocess.Popen([vlc_path, '-'], stdin=subprocess.PIPE,
|
||||
stdout=self.process_log, stderr=self.process_log)
|
||||
except OSError:
|
||||
raise ValueError("VLC media player could not be opened")
|
||||
|
||||
d = threads.deferToThread(start_process)
|
||||
return d
|
||||
|
||||
def _close_output(self):
|
||||
if self.process is not None:
|
||||
self.process.stdin.close()
|
||||
self.process = None
|
||||
return defer.succeed(True)
|
||||
|
||||
def _get_write_func(self):
|
||||
def write_func(data):
|
||||
if self.stopped is False and self.process is not None:
|
||||
try:
|
||||
self.process.stdin.write(data)
|
||||
except IOError:
|
||||
reactor.callLater(0, self.stop)
|
||||
return write_func
|
||||
|
||||
def _delete_from_info_manager(self):
|
||||
return self.stream_info_manager.delete_stream(self.stream_hash)
|
||||
|
||||
|
||||
class EncryptedFileOpenerFactory(EncryptedFileDownloaderFactory):
|
||||
def can_download(self, sd_validator):
|
||||
if which('vlc'):
|
||||
return True
|
||||
elif os.name == "nt":
|
||||
paths = [r'C:\Program Files\VideoLAN\VLC\vlc.exe',
|
||||
r'C:\Program Files (x86)\VideoLAN\VLC\vlc.exe']
|
||||
for p in paths:
|
||||
if os.path.exists(p):
|
||||
return True
|
||||
return False
|
||||
|
||||
def _make_downloader(self, stream_hash, payment_rate_manager, stream_info):
|
||||
return EncryptedFileOpener(stream_hash, self.peer_finder,
|
||||
self.rate_limiter, self.blob_manager,
|
||||
self.stream_info_manager,
|
||||
payment_rate_manager, self.wallet,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def get_description():
|
||||
return "Stream"
|
||||
|
|
Loading…
Reference in a new issue