Search in sources :

Example 16 with DiskManagerFileInfo

use of com.biglybt.pif.disk.DiskManagerFileInfo 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 17 with DiskManagerFileInfo

use of com.biglybt.pif.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.

the class TranscodeManagerImpl method processTag.

void processTag(Tag tag, 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(tag_ta);
    String tag_name = tag.getTagName(true);
    String tag_tag = tag.getTagType().getTagType() + "." + tag.getTagID() + ";";
    if (str != null && str.contains(tag_tag)) {
        return;
    }
    try {
        DeviceMediaRenderer device = (DeviceMediaRenderer) details[0];
        TranscodeProfile profile = (TranscodeProfile) details[1];
        log("Tag " + tag_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(tag_ta, str == null ? tag_tag : (str + tag_tag));
    }
}
Also used : DiskManagerFileInfo(com.biglybt.pif.disk.DiskManagerFileInfo) Download(com.biglybt.pif.download.Download)

Example 18 with DiskManagerFileInfo

use of com.biglybt.pif.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.

the class PlayUtils method isExternallyPlayableSupport.

private static boolean isExternallyPlayableSupport(Download d, int file_index, boolean complete_only) {
    int primary_file_index = -1;
    if (file_index == -1) {
        DownloadManager dm = PluginCoreUtils.unwrap(d);
        if (dm == null) {
            return (false);
        }
        DiskManagerFileInfo file = null;
        try {
            file = PluginCoreUtils.wrap(dm.getDownloadState().getPrimaryFile());
        } catch (DownloadException e) {
            return false;
        }
        if (file == null) {
            return (false);
        }
        if (file.getDownloaded() != file.getLength()) {
            if (complete_only || getMediaServerContentURL(file) == null) {
                return (false);
            }
        }
        primary_file_index = file.getIndex();
    } else {
        DiskManagerFileInfo file = d.getDiskManagerFileInfo(file_index);
        if (file.getDownloaded() != file.getLength()) {
            if (complete_only || getMediaServerContentURL(file) == null) {
                return (false);
            }
        }
        primary_file_index = file_index;
    }
    if (primary_file_index == -1) {
        return false;
    }
    return (isExternallyPlayable(d.getDiskManagerFileInfo()[primary_file_index]));
}
Also used : DiskManagerFileInfo(com.biglybt.pif.disk.DiskManagerFileInfo) DownloadException(com.biglybt.pif.download.DownloadException)

Example 19 with DiskManagerFileInfo

use of com.biglybt.pif.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.

the class PlayUtils method getExternallyPlayableFileIndexes.

public static int[] getExternallyPlayableFileIndexes(Download d, boolean complete_only) {
    int[] playableIndexes = {};
    DiskManagerFileInfo[] fileInfos = d.getDiskManagerFileInfo();
    for (int i = 0; i < fileInfos.length; i++) {
        DiskManagerFileInfo fileInfo = fileInfos[i];
        if (complete_only && fileInfo.getLength() != fileInfo.getDownloaded()) {
            continue;
        }
        if (isExternallyPlayable(fileInfo)) {
            int[] newPlayableIndexes = new int[playableIndexes.length + 1];
            System.arraycopy(playableIndexes, 0, newPlayableIndexes, 0, playableIndexes.length);
            newPlayableIndexes[playableIndexes.length] = i;
            playableIndexes = newPlayableIndexes;
        }
    }
    return playableIndexes;
}
Also used : DiskManagerFileInfo(com.biglybt.pif.disk.DiskManagerFileInfo)

Example 20 with DiskManagerFileInfo

use of com.biglybt.pif.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.

the class DataSourceUtils method getFileInfo.

public static com.biglybt.core.disk.DiskManagerFileInfo getFileInfo(Object ds) {
    try {
        if (ds instanceof DiskManagerFileInfo) {
            return PluginCoreUtils.unwrap((DiskManagerFileInfo) ds);
        } else if (ds instanceof com.biglybt.core.disk.DiskManagerFileInfo) {
            return (com.biglybt.core.disk.DiskManagerFileInfo) ds;
        } else if ((ds instanceof ISelectedContent) && ((ISelectedContent) ds).getFileIndex() >= 0) {
            ISelectedContent sc = (ISelectedContent) ds;
            int idx = sc.getFileIndex();
            DownloadManager dm = sc.getDownloadManager();
            return dm.getDiskManagerFileInfoSet().getFiles()[idx];
        } else if (ds instanceof TranscodeJob) {
            TranscodeJob tj = (TranscodeJob) ds;
            try {
                return PluginCoreUtils.unwrap(tj.getFile());
            } catch (DownloadException e) {
            }
        } else if (ds instanceof TranscodeFile) {
            TranscodeFile tf = (TranscodeFile) ds;
            try {
                DiskManagerFileInfo file = tf.getSourceFile();
                return PluginCoreUtils.unwrap(file);
            } catch (DownloadException e) {
            }
        }
    } catch (Exception e) {
        Debug.printStackTrace(e);
    }
    return null;
}
Also used : DiskManagerFileInfo(com.biglybt.pif.disk.DiskManagerFileInfo) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) DownloadException(com.biglybt.pif.download.DownloadException) TranscodeFile(com.biglybt.core.devices.TranscodeFile) DownloadManager(com.biglybt.core.download.DownloadManager) DownloadException(com.biglybt.pif.download.DownloadException) TranscodeJob(com.biglybt.core.devices.TranscodeJob)

Aggregations

DiskManagerFileInfo (com.biglybt.pif.disk.DiskManagerFileInfo)23 Download (com.biglybt.pif.download.Download)11 DownloadException (com.biglybt.pif.download.DownloadException)5 IPCInterface (com.biglybt.pif.ipc.IPCInterface)5 Torrent (com.biglybt.pif.torrent.Torrent)3 Point (org.eclipse.swt.graphics.Point)3 ContentFile (com.biglybt.core.content.ContentFile)2 TranscodeFile (com.biglybt.core.devices.TranscodeFile)2 TranscodeJob (com.biglybt.core.devices.TranscodeJob)2 DownloadManager (com.biglybt.core.download.DownloadManager)2 TOTorrent (com.biglybt.core.torrent.TOTorrent)2 MenuItem (com.biglybt.pif.ui.menus.MenuItem)2 MenuItemFillListener (com.biglybt.pif.ui.menus.MenuItemFillListener)2 MenuItemListener (com.biglybt.pif.ui.menus.MenuItemListener)2 TableContextMenuItem (com.biglybt.pif.ui.tables.TableContextMenuItem)2 TableRow (com.biglybt.pif.ui.tables.TableRow)2 ISelectedContent (com.biglybt.ui.selectedcontent.ISelectedContent)2 File (java.io.File)2 URL (java.net.URL)2 ActivitiesEntry (com.biglybt.activities.ActivitiesEntry)1