use of com.frostwire.bittorrent.BTInfoAdditionalMetadataHolder in project frostwire by frostwire.
the class LibraryFilesTableDataLine method initialize.
/**
* Initialize the object.
* It will fail if not given a FileDesc or a File
* (File is retained for compatibility with the Incomplete folder)
*/
public void initialize(File file) {
super.initialize(file);
String fullPath = file.getPath();
try {
fullPath = file.getCanonicalPath();
} catch (IOException ignored) {
}
String _name = initializer.getName();
_type = "";
if (!file.isDirectory()) {
// _isDirectory = false;
int index = _name.lastIndexOf(".");
int index2 = fullPath.lastIndexOf(File.separator);
_path = fullPath.substring(0, index2);
if (index != -1 && index != 0) {
_type = _name.substring(index + 1);
_name = _name.substring(0, index);
}
} else {
_path = fullPath;
// _isDirectory = true;
}
// directories implicitly set SizeHolder to null and display nothing
if (initializer.isFile()) {
long _size = initializer.length();
_sizeHolder = new SizeHolder(_size);
} else {
_sizeHolder = ZERO_SIZED_HOLDER;
}
this.lastModified = new Date(initializer.lastModified());
this.actionsHolder = new LibraryActionsHolder(this, false);
this.nameCell = new NameHolder(_name);
if (initializer != null && initializer.isFile() && FilenameUtils.getExtension(initializer.getName()) != null && FilenameUtils.getExtension(initializer.getName()).toLowerCase().endsWith("torrent")) {
BTInfoAdditionalMetadataHolder additionalMetadataHolder = null;
try {
additionalMetadataHolder = new BTInfoAdditionalMetadataHolder(initializer, initializer.getName());
} catch (Throwable t) {
System.err.println("[InvalidTorrent] Can't create BTInfoAdditionalMetadataholder out of " + initializer.getAbsolutePath());
t.printStackTrace();
}
boolean hasLicense = additionalMetadataHolder != null && additionalMetadataHolder.getLicenseBroker() != null;
boolean hasPaymentOptions = additionalMetadataHolder != null && additionalMetadataHolder.getPaymentOptions() != null;
if (hasLicense) {
license = additionalMetadataHolder.getLicenseBroker().getLicenseName();
}
if (license == null) {
license = "";
}
if (hasPaymentOptions) {
paymentOptions = additionalMetadataHolder.getPaymentOptions();
} else {
paymentOptions = new PaymentOptions(null, null);
}
paymentOptions.setItemName(_name);
}
}
Aggregations