Search in sources :

Example 61 with Download

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));
    }
}
Also used : DiskManagerFileInfo(com.biglybt.pif.disk.DiskManagerFileInfo) Download(com.biglybt.pif.download.Download)

Example 62 with Download

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) {
    }
}
Also used : TorrentAttribute(com.biglybt.pif.torrent.TorrentAttribute) DownloadAttributeListener(com.biglybt.pif.download.DownloadAttributeListener) Download(com.biglybt.pif.download.Download) ContentDownload(com.biglybt.core.content.ContentDownload)

Example 63 with Download

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) {
        }
    }
}
Also used : Peer(com.biglybt.pif.peers.Peer) Download(com.biglybt.pif.download.Download) BuddyPlugin(com.biglybt.plugin.net.buddy.BuddyPlugin)

Example 64 with Download

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);
}
Also used : Peer(com.biglybt.pif.peers.Peer) Download(com.biglybt.pif.download.Download) BuddyPlugin(com.biglybt.plugin.net.buddy.BuddyPlugin)

Example 65 with Download

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);
}
Also used : Tag(com.biglybt.core.tag.Tag) Download(com.biglybt.pif.download.Download)

Aggregations

Download (com.biglybt.pif.download.Download)80 DownloadManager (com.biglybt.core.download.DownloadManager)22 Torrent (com.biglybt.pif.torrent.Torrent)17 DiskManagerFileInfo (com.biglybt.pif.disk.DiskManagerFileInfo)12 File (java.io.File)12 TOTorrent (com.biglybt.core.torrent.TOTorrent)11 PluginInterface (com.biglybt.pif.PluginInterface)11 URL (java.net.URL)10 DownloadManagerState (com.biglybt.core.download.DownloadManagerState)8 PEPeerManager (com.biglybt.core.peer.PEPeerManager)8 List (java.util.List)7 Tag (com.biglybt.core.tag.Tag)6 MenuItem (com.biglybt.pif.ui.menus.MenuItem)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 DownloadException (com.biglybt.pif.download.DownloadException)5 DiskManager (com.biglybt.core.disk.DiskManager)4 DownloadManager (com.biglybt.pif.download.DownloadManager)4 DownloadScrapeResult (com.biglybt.pif.download.DownloadScrapeResult)4 Peer (com.biglybt.pif.peers.Peer)4