2016-09-27 20:18:16 +02:00
|
|
|
from lbrynet.lbryfile.StreamDescriptor import EncryptedFileStreamType, EncryptedFileStreamDescriptorValidator
|
2015-10-15 20:12:22 +02:00
|
|
|
from lbrynet.core.DownloadOption import DownloadOption, DownloadOptionChoice
|
2015-08-27 21:41:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
def add_lbry_file_to_sd_identifier(sd_identifier):
|
2016-09-27 20:18:16 +02:00
|
|
|
sd_identifier.add_stream_type(EncryptedFileStreamType, EncryptedFileStreamDescriptorValidator, EncryptedFileOptions())
|
2015-08-27 21:41:17 +02:00
|
|
|
|
|
|
|
|
2016-09-27 20:18:16 +02:00
|
|
|
class EncryptedFileOptions(object):
|
2015-08-27 21:41:17 +02:00
|
|
|
def __init__(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def get_downloader_options(self, sd_validator, payment_rate_manager):
|
|
|
|
prm = payment_rate_manager
|
|
|
|
|
|
|
|
def get_default_data_rate_description():
|
2016-10-13 19:35:55 +02:00
|
|
|
if prm.base.min_blob_data_payment_rate is None:
|
2015-08-27 21:41:17 +02:00
|
|
|
return "Application default (%s LBC/MB)" % str(prm.base.min_blob_data_payment_rate)
|
|
|
|
else:
|
2016-10-13 19:35:55 +02:00
|
|
|
return "%f LBC/MB" % prm.base.min_blob_data_payment_rate
|
2015-08-27 21:41:17 +02:00
|
|
|
|
|
|
|
rate_choices = []
|
2016-10-13 19:35:55 +02:00
|
|
|
rate_choices.append(DownloadOptionChoice(prm.base.min_blob_data_payment_rate,
|
2015-10-15 20:12:22 +02:00
|
|
|
"No change - %s" % get_default_data_rate_description(),
|
|
|
|
"No change - %s" % get_default_data_rate_description()))
|
2016-10-13 19:35:55 +02:00
|
|
|
if prm.base.min_blob_data_payment_rate is not None:
|
2015-10-15 20:12:22 +02:00
|
|
|
rate_choices.append(DownloadOptionChoice(None,
|
|
|
|
"Application default (%s LBC/MB)" % str(prm.base.min_blob_data_payment_rate),
|
|
|
|
"Application default (%s LBC/MB)" % str(prm.base.min_blob_data_payment_rate)))
|
|
|
|
rate_choices.append(DownloadOptionChoice(float,
|
|
|
|
"Enter rate in LBC/MB",
|
|
|
|
"Enter rate in LBC/MB"))
|
2015-08-27 21:41:17 +02:00
|
|
|
|
|
|
|
options = [
|
|
|
|
DownloadOption(
|
|
|
|
rate_choices,
|
|
|
|
"Rate which will be paid for data",
|
|
|
|
"data payment rate",
|
2016-10-13 19:35:55 +02:00
|
|
|
prm.base.min_blob_data_payment_rate,
|
2015-08-27 21:41:17 +02:00
|
|
|
get_default_data_rate_description()
|
|
|
|
),
|
|
|
|
DownloadOption(
|
|
|
|
[
|
2015-10-15 20:12:22 +02:00
|
|
|
DownloadOptionChoice(bool,
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
bool_options_description=("Allow", "Disallow")),
|
2015-08-27 21:41:17 +02:00
|
|
|
],
|
|
|
|
"Allow reuploading data downloaded for this file",
|
|
|
|
"allow upload",
|
|
|
|
True,
|
|
|
|
"Allow"
|
|
|
|
),
|
|
|
|
]
|
|
|
|
return options
|