use of com.biglybt.pif.download.Download in project BiglyBT by BiglySoftware.
the class TranscodeManagerImpl method processCategory.
void processCategory(Category cat, Object[] details, DownloadManager dm) {
Download download = PluginCoreUtils.wrap(dm);
if (download == null) {
return;
}
if (download.getFlag(Download.FLAG_LOW_NOISE)) {
return;
}
String str = download.getAttribute(category_ta);
String cat_name = cat.getName();
if (cat.getType() == Category.TYPE_UNCATEGORIZED) {
cat_name = "<none>";
}
String cat_tag = cat_name + ";";
if (str != null && str.contains(cat_tag)) {
return;
}
try {
DeviceMediaRenderer device = (DeviceMediaRenderer) details[0];
TranscodeProfile profile = (TranscodeProfile) details[1];
log("Category " + cat_name + " - adding " + download.getName() + " to " + device.getName() + "/" + profile.getName());
DiskManagerFileInfo[] dm_files = download.getDiskManagerFileInfo();
int num_added = 0;
for (DiskManagerFileInfo dm_file : dm_files) {
if (num_added > 64) {
break;
}
if (dm_files.length == 1 || dm_file.getLength() >= 128 * 1024) {
try {
queue.add(device, profile, dm_file, false);
num_added++;
} catch (Throwable e) {
log(" add failed", e);
}
}
}
} finally {
download.setAttribute(category_ta, str == null ? cat_tag : (str + cat_tag));
}
}
use of com.biglybt.pif.download.Download in project BiglyBT by BiglySoftware.
the class DeviceUPnPImpl method syncCategoriesAndTags.
protected void syncCategoriesAndTags(TranscodeFileImpl tf, boolean inherit_from_download) {
try {
final Download dl = tf.getSourceFile().getDownload();
if (dl != null) {
if (inherit_from_download) {
setCategories(tf, dl);
setTags(tf, dl);
}
final String tf_key = tf.getKey();
dl.addAttributeListener(new DownloadAttributeListener() {
@Override
public void attributeEventOccurred(Download download, TorrentAttribute attribute, int eventType) {
TranscodeFileImpl tf = getTranscodeFile(tf_key);
if (tf != null) {
setCategories(tf, download);
} else {
dl.removeAttributeListener(this, upnp_manager.getCategoryAttibute(), DownloadAttributeListener.WRITTEN);
}
}
}, upnp_manager.getCategoryAttibute(), DownloadAttributeListener.WRITTEN);
TagManagerFactory.getTagManager().getTagType(TagType.TT_DOWNLOAD_MANUAL).addTagListener(PluginCoreUtils.unwrap(dl), new TagListener() {
@Override
public void taggableSync(Tag tag) {
}
@Override
public void taggableRemoved(Tag tag, Taggable tagged) {
update(tagged);
}
@Override
public void taggableAdded(Tag tag, Taggable tagged) {
update(tagged);
}
private void update(Taggable tagged) {
TranscodeFileImpl tf = getTranscodeFile(tf_key);
if (tf != null) {
setTags(tf, dl);
} else {
TagManagerFactory.getTagManager().getTagType(TagType.TT_DOWNLOAD_MANUAL).removeTagListener(tagged, this);
}
}
});
}
} catch (Throwable e) {
}
}
use of com.biglybt.pif.download.Download in project BiglyBT by BiglySoftware.
the class ColumnPeerBoost method setCheckBoxState.
@Override
protected void setCheckBoxState(Object datasource, boolean set) {
BuddyPlugin bp = getBuddyPlugin();
Peer peer = (Peer) datasource;
if (peer != null && bp != null) {
try {
Download download = peer.getManager().getDownload();
if (download != null) {
bp.setPartialBuddy(download, peer, set, true);
}
} catch (Throwable e) {
}
}
}
use of com.biglybt.pif.download.Download in project BiglyBT by BiglySoftware.
the class ColumnPeerBoost method getCheckBoxState.
@Override
protected Boolean getCheckBoxState(Object datasource) {
BuddyPlugin bp = getBuddyPlugin();
Peer peer = (Peer) datasource;
if (peer != null && bp != null) {
if (bp.isFullBuddy(peer)) {
return (true);
}
try {
Download download = peer.getManager().getDownload();
if (download != null) {
return (bp.isPartialBuddy(download, peer));
}
} catch (Throwable e) {
}
}
return (null);
}
use of com.biglybt.pif.download.Download in project BiglyBT by BiglySoftware.
the class ColumnTagGroupIcons method refresh.
@Override
public void refresh(TableCell cell) {
String sTags = null;
Download dm = (Download) cell.getDataSource();
if (dm != null) {
List<Tag> tags = tag_manager.getTagsForTaggable(interesting_tts, PluginCoreUtils.unwrap(dm));
if (tags.size() > 0) {
for (Tag t : tags) {
if (t.getGroupContainer() == tag_group) {
String file = t.getImageFile();
if (file != null) {
String str = t.getTagName(true);
if (sTags == null) {
sTags = str;
} else {
sTags += ", " + str;
}
}
}
}
}
}
cell.setSortValue(sTags);
cell.setToolTip((sTags == null) ? "" : sTags);
}
Aggregations