当前位置: 首页>>代码示例>>Java>>正文


Java IMediaFile.isType方法代码示例

本文整理汇总了Java中sagex.phoenix.vfs.IMediaFile.isType方法的典型用法代码示例。如果您正苦于以下问题:Java IMediaFile.isType方法的具体用法?Java IMediaFile.isType怎么用?Java IMediaFile.isType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sagex.phoenix.vfs.IMediaFile的用法示例。


在下文中一共展示了IMediaFile.isType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveMediaTitle

import sagex.phoenix.vfs.IMediaFile; //导入方法依赖的package包/类
private String resolveMediaTitle(String mediaTitle, IMediaFile mf) {
    if (mf == null)
        return mediaTitle;
    if (!StringUtils.isEmpty(mediaTitle))
        return mediaTitle;

    // check for music
    if (mf.isType(MediaResourceType.MUSIC.value())) {
        IAlbumInfo info = mf.getAlbumInfo();
        if (info != null) {
            mediaTitle = info.getArtist();
        }
        if (!StringUtils.isEmpty(mediaTitle))
            return mediaTitle;
    }

    IMetadata md = mf.getMetadata();
    if (md != null) {
        mediaTitle = md.getMediaTitle();
        if (StringUtils.isEmpty(mediaTitle))
            mediaTitle = null;
    }

    return Utils.returnNonNull(mediaTitle, mf.getTitle());
}
 
开发者ID:stuckless,项目名称:sagetv-phoenix-core,代码行数:26,代码来源:FanartAPI.java

示例2: visitFile

import sagex.phoenix.vfs.IMediaFile; //导入方法依赖的package包/类
@Override
public boolean visitFile(IMediaFile res, IProgressMonitor monitor) {
    if (res.isType(MediaResourceType.ANY_VIDEO.value())) {
        monitor.setTaskName(res.getTitle());

        Sage7ThumbnailPersistence p = new Sage7ThumbnailPersistence();
        try {
            p.storeMetadata(res, res.getMetadata(), null);
        } catch (MetadataException e) {
            log.warn("Failed to create Sage7 Thumbnail for " + res.getTitle(), e);
            monitor.setTaskName("Failed: " + res.getTitle());
        }

        monitor.worked(1);
    }
    return true;
}
 
开发者ID:stuckless,项目名称:sagetv-phoenix-core,代码行数:18,代码来源:ExportSageTV7ThumbnailVisitor.java

示例3: logMetadataUpdated

import sagex.phoenix.vfs.IMediaFile; //导入方法依赖的package包/类
public static void logMetadataUpdated(IMediaFile file) {
    try {
        IMetadata md = file.getMetadata();
        StringBuilder sb = new StringBuilder("UPDATE");
        sb.append("; ").append(PathUtils.getLocation(file));
        sb.append("; ").append(md.getMediaTitle());
        sb.append("; ").append(md.getMediaType());
        if (file.isType(MediaResourceType.TV.value())) {
            sb.append("; S").append(md.getSeasonNumber());
            if (md.getEpisodeNumber() > 0) {
                sb.append("; E").append(md.getEpisodeNumber());
            }
            if (md.getDiscNumber() > 0) {
                sb.append("; D").append(md.getDiscNumber());
            }
        }
        sb.append("; ").append(md.getExternalID());
        sb.append("; ").append(file.getId());

        Loggers.METADATA.info(sb.toString());
    } catch (Exception e) {
        Loggers.LOG.warn("Failed to write metadata log message", e);
    }
}
 
开发者ID:stuckless,项目名称:sagetv-phoenix-core,代码行数:25,代码来源:LogUtil.java

示例4: getRelativePathWithTitle

import sagex.phoenix.vfs.IMediaFile; //导入方法依赖的package包/类
public static String getRelativePathWithTitle(IMediaFile file, IMetadata md) {
    String title = null;
    if (!file.isType(MediaResourceType.RECORDING.value())) {
        Object obj = file.getMediaObject();
        String path = MediaFileAPI.GetMediaFileRelativePath(obj);
        if (!StringUtils.isEmpty(path) && !StringUtils.isEmpty(md.getMediaTitle())) {
            File f = new File(path);
            File dir = new File(f.getParentFile(), md.getMediaTitle());
            title = dir.getPath();
        }
    }

    if (title == null) {
        title = md.getMediaTitle();
    }

    return title;
}
 
开发者ID:stuckless,项目名称:sagetv-phoenix-core,代码行数:19,代码来源:MetadataUtil.java

示例5: isRecordedMovie

import sagex.phoenix.vfs.IMediaFile; //导入方法依赖的package包/类
/**
 * Returns true if the resource is a recorded movie, or future recorded
 * movie
 *
 * @param resource
 * @return
 */
public static boolean isRecordedMovie(IMediaFile resource) {
    try {
        if (resource.isType(MediaResourceType.EPG_AIRING.value()) || resource.isType(MediaResourceType.RECORDING.value())) {
            Object sagemf = phoenix.media.GetSageMediaFile(resource);
            if (sagemf != null) {
                // Now check the alternate category
                String altCat = ShowAPI.GetShowCategory(sagemf);
                log.debug("checking category for movie " + altCat);
                if (!StringUtils.isEmpty(altCat)) {
                    if (altCat.equals("Movie") || altCat.equals(phoenix.config.GetProperty("alternate_movie_category"))) {
                        log.debug("this is a recorded movie " + resource);
                        return true;
                    }
                }
                String eid = resource.getMetadata().getExternalID();
                log.debug("testing show id " + eid);
                if (eid != null) {
                    return eid.startsWith("MV");
                }

                log.debug("this is a NOT recorded movie " + resource);
            } else {
                log.debug("failed to get sage mediafile for " + resource);
            }
        } else {
            log.debug("resource is not an airing or recording " + resource);
        }
    } catch (Exception e) {
        Loggers.LOG.warn("failed while attempting to set the media type based on alternate_movie_category", e);
    }

    return false;
}
 
开发者ID:stuckless,项目名称:sagetv-phoenix-core,代码行数:41,代码来源:MetadataUtil.java

示例6: resolveMediaType

import sagex.phoenix.vfs.IMediaFile; //导入方法依赖的package包/类
private MediaType resolveMediaType(MediaType mediaType, IMediaFile mf) {
    if (mf == null)
        return mediaType;
    if (mediaType != null)
        return mediaType;

    MediaType mt = null;
    IMetadata md = mf.getMetadata();
    if (md != null) {
        mt = MediaType.toMediaType(md.getMediaType());
    }
    if (mt == null) {
        if (mf.isType(MediaResourceType.TV.value())) {
            mt = MediaType.TV;
        } else if (mf.isType(MediaResourceType.MUSIC.value())) {
            mt = MediaType.MUSIC;
        } else {
            mt = MediaType.MOVIE;
        }
    }

    // do last check for movie files
    // TODO: Move this to the IMetadata implementations
    // AiringMetadataProxy has it already
    String altCat = ShowAPI.GetShowCategory(mf.getMediaObject());
    if (altCat != null) {
        if (altCat.equals("Movie") || altCat.equals(Configuration.GetProperty("alternate_movie_category", "Movie"))) {
            mt = MediaType.MOVIE;
        }
    }

    return mt;
}
 
开发者ID:stuckless,项目名称:sagetv-phoenix-core,代码行数:34,代码来源:FanartAPI.java

示例7: visitFile

import sagex.phoenix.vfs.IMediaFile; //导入方法依赖的package包/类
@Override
public boolean visitFile(IMediaFile res, IProgressMonitor monitor) {
    // skip recordings
    if (res.isType(MediaResourceType.RECORDING.value()))
        return true;

    if (useRelativePathInTitle) {
        res.getMetadata().setRelativePathWithTitle(MetadataUtil.getRelativePathWithTitle(res, res.getMetadata()));
    } else {
        res.getMetadata().setRelativePathWithTitle(res.getMetadata().getMediaTitle());
    }

    incrementAffected();
    return true;
}
 
开发者ID:stuckless,项目名称:sagetv-phoenix-core,代码行数:16,代码来源:FixTitlesVisitor.java

示例8: visitFile

import sagex.phoenix.vfs.IMediaFile; //导入方法依赖的package包/类
@Override
public boolean visitFile(IMediaFile res, IProgressMonitor monitor) {
    if (res.isType(MediaResourceType.TV.value()) || res.isType(MediaResourceType.VIDEO.value())) {

    }
    return false;
}
 
开发者ID:stuckless,项目名称:sagetv-phoenix-core,代码行数:8,代码来源:MissingFanartVisitor.java

示例9: searchByExisting

import sagex.phoenix.vfs.IMediaFile; //导入方法依赖的package包/类
/**
 * Given the existing MediaFile and optional metadata, find the metadata/fanart for this item.
 * This is useful to "refresh" the metadata for an item.
 *
 * @param file
 * @param md
 * @return
 * @throws MetadataException
 */
public IMetadata searchByExisting(IMediaFile file, IMetadata md) throws MetadataException {
    md = (md==null?file.getMetadata():md);
    SearchQuery q = new SearchQuery(getDefaultMetadataOptions());
    q.set(Field.PROVIDER, md.getMediaProviderID());
    q.set(Field.ID, md.getMediaProviderDataID());
    q.set(Field.IMDBID, md.getIMDBID());
    if (file.isType(MediaResourceType.TV.value())) {
        if (md.getEpisodeNumber() > 0) {
            q.set(Field.EPISODE, String.valueOf(md.getEpisodeNumber()));
            q.set(Field.SEASON, String.valueOf(md.getSeasonNumber()));
        }
    }

    if (sagex.phoenix.util.StringUtils.isAnyEmpty(q.get(Field.PROVIDER))) {
        log.info("Unable to find metadata for item by id.  Missing provider for " + file);
        throw new MetadataException("Can't find by ID, since provider is missing.", file, md);
    }

    // if IMDB is set as the provider, then remap to TMDB
    if ("imdb".equalsIgnoreCase(q.getProvider())) {
        q.setProvider("tmdb");
        q.setIMDBID(q.getId());
        q.setId(null);
    }

    if (!sagex.phoenix.util.StringUtils.hasAny(q.get(Field.ID), q.getIMDBId())) {
        log.info("Unable to find metadata for item by id.  Missing id or imdbid for " + file);
        throw new MetadataException("Can't find by ID, since id or imdbid is missing.", file, md);
    }

    List<IMetadataSearchResult> results = search(q);
    if (results==null || results.size()!=1) {
        throw new MetadataException("Search by ID failed", file, md);
    }

    return getMetdata(results.get(0));
}
 
开发者ID:stuckless,项目名称:sagetv-phoenix-core,代码行数:47,代码来源:MetadataManager.java

示例10: isImportedRecording

import sagex.phoenix.vfs.IMediaFile; //导入方法依赖的package包/类
/**
 * Returns true if this media was imported into the recordings, as opposed
 * to a native sagetv recording.
 *
 * @param file
 * @return
 */
public static boolean isImportedRecording(IMediaFile file) {
    if (file.isType(MediaResourceType.RECORDING.value())) {
        String eid = file.getMetadata().getExternalID();
        if (eid != null && eid.length() > 5) {
            return eid.charAt(2) == 'm' && eid.charAt(3) == 't';
        }
    }
    return false;
}
 
开发者ID:stuckless,项目名称:sagetv-phoenix-core,代码行数:17,代码来源:MetadataUtil.java

示例11: visitFile

import sagex.phoenix.vfs.IMediaFile; //导入方法依赖的package包/类
@Override
public boolean visitFile(IMediaFile res, IProgressMonitor monitor) {
    if (res.isType(MediaResourceType.ANY_VIDEO.value())) {
        IMetadata md = res.getMetadata();
        log.debug("Updating Ratings for " + res.getTitle() + " " + md.getEpisodeName());
        monitor.setTaskName("Updating Ratings for " + res.getTitle() + " " + md.getEpisodeName());

        if (fixParentalRating(res, md)) {
            incrementAffected();
        }
    }

    return true;
}
 
开发者ID:stuckless,项目名称:sagetv-phoenix-core,代码行数:15,代码来源:FixParentalRatingsVisitor.java

示例12: fixTVYear

import sagex.phoenix.vfs.IMediaFile; //导入方法依赖的package包/类
public static boolean fixTVYear(IMediaFile res, IMetadata md) {
    boolean updated = false;
    if (res.isType(MediaResourceType.TV.value())) {
        // Remove the Year metadata on TV shows
        if (!StringUtils.isEmpty(res.getMetadata().get(year))) {
            res.getMetadata().clear(year);
            updated = true;
        }
    }
    return updated;
}
 
开发者ID:stuckless,项目名称:sagetv-phoenix-core,代码行数:12,代码来源:FixTVYearVisitor.java

示例13: storeMetadata

import sagex.phoenix.vfs.IMediaFile; //导入方法依赖的package包/类
@Override
public void storeMetadata(IMediaFile file, IMetadata md, Hints options) throws MetadataException {
    try {
        File f = PathUtils.getFirstFile(file);
        if (f != null && f.exists()) {
            MediaType mt = MediaType.MOVIE;
            if (file.isType(MediaResourceType.MUSIC.value())) {
                mt = MediaType.MUSIC;
            } else if (file.isType(MediaResourceType.TV.value())) {
                mt = MediaType.TV;
            } else if (file.isType(MediaResourceType.PICTURE.value())) {
                return;
            }
            File thumbfile = FanartUtil.getLocalFanartForFile(f, mt, MediaArtifactType.POSTER, false);
            if (thumbfile == null)
                return;
            if (thumbfile.exists()) {
                // do nothing, since it exists
                return;
            }

            String poster = phoenix.fanart.GetFanartPoster(file);
            if (poster == null)
                return;

            File posterFile = new File(poster);
            if (!posterFile.exists())
                return;

            PersistenceUtil.writeImageFromUrl(posterFile.toURI().toString(), thumbfile, 150);
        }
    } catch (Exception e) {
        throw new MetadataException("Failed to write Sage7 thumbnail file", file, md, e);
    }
}
 
开发者ID:stuckless,项目名称:sagetv-phoenix-core,代码行数:36,代码来源:Sage7ThumbnailPersistence.java

示例14: storeMetadata

import sagex.phoenix.vfs.IMediaFile; //导入方法依赖的package包/类
@Override
public void storeMetadata(IMediaFile file, IMetadata md, Hints options) throws MetadataException {
    try {
        File f = PathUtils.getFirstFile(file);
        if (f != null && f.exists()) {
            File propFile = FanartUtil.resolvePropertiesFile(f);

            Map<String, String> map = new HashMap<String, String>();
            IMetadata newMD = MetadataUtil.createMetadata(map);
            MetadataUtil.copyMetadata(md, newMD);

            // add a separate X-Watched flag for later importing state
            map.put(IMetadata.XWatched, String.valueOf(file.isWatched()));
            if (file.isType(MediaResourceType.RECORDING.value())) {
                map.put(IMetadata.XLibraryFile, String.valueOf(file.isLibraryFile()));
            }

            Properties props = new SortedProperties();
            for (Map.Entry<String, String> me : map.entrySet()) {
                if (!StringUtils.isEmpty(me.getValue())) {
                    props.setProperty(me.getKey(), me.getValue());
                }
            }

            PropertiesUtils.store(props, propFile, "Created by " + this.getClass().getName());
        }
    } catch (Exception e) {
        throw new MetadataException("Failed to store metadata", file, md, e);
    }
}
 
开发者ID:stuckless,项目名称:sagetv-phoenix-core,代码行数:31,代码来源:PropertiesPersistence.java

示例15: createSageFriendlyQuery

import sagex.phoenix.vfs.IMediaFile; //导入方法依赖的package包/类
/**
 * Most resources are Sage Resources, so this attempts to first create a
 * query using the existing Sage Resource to fill in the title, year,
 * episode title, etc.
 * <p/>
 * If the resource is a recording, airing, or already has a MediaType, then
 * it will simply use the existing metadata from the object as the query.
 * Otherwise it will do a scraped query.
 *
 * @param res
 */
public SearchQuery createSageFriendlyQuery(IMediaFile res, Hints hints) {
    SearchQuery q = null;
    if (res.isType(MediaResourceType.MUSIC.value())) {
        q = new SearchQuery(hints);
        IAlbumInfo info = res.getAlbumInfo();
        if (info != null) {
            q.set(Field.RAW_TITLE, res.getTitle());
            q.set(Field.ARTIST, info.getArtist());
            q.set(Field.ALBUM, info.getName());
            q.setMediaType(MediaType.MUSIC);
        }
    } else if (hints.getBooleanValue(MetadataHints.KNOWN_RECORDING, false) || res.isType(MediaResourceType.RECORDING.value())
            || res.isType(MediaResourceType.EPG_AIRING.value())) {
        if (MetadataUtil.isImportedRecording(res)) {
            // these were non sage recordings, that we imported, so we'll do
            // a full scape.
            q = createQueryFromFilename(res, hints);
        } else {
            // do a clean query
            q = createQueryFromExistingMetadata(res, hints);
        }
    } else {
        // do a normal scraped query
        q = createQueryFromFilename(res, hints);
    }
    return q;
}
 
开发者ID:stuckless,项目名称:sagetv-phoenix-core,代码行数:39,代码来源:SearchQueryFactory.java


注:本文中的sagex.phoenix.vfs.IMediaFile.isType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。