public List<MediaNode> getMediaNodes() throws Exception {
   final NodeList mediaNodeList =
       (NodeList) xpath.evaluate("/manifest/media", document, XPathConstants.NODESET);
   final List<MediaNode> mediaNodes = new ArrayList<MediaNode>();
   for (int i = 0; i < mediaNodeList.getLength(); i++) {
     mediaNodes.add(MediaNode.create(mediaNodeList.item(i), xpath));
   }
   return mediaNodes;
 }
Esempio n. 2
0
 public int compare(Object o1, Object o2) {
   MediaNode m1 = (MediaNode) o1;
   MediaNode m2 = (MediaNode) o2;
   boolean f1 = (m1 == null) ? false : m1.isFolder();
   boolean f2 = (m2 == null) ? false : m2.isFolder();
   if (f1 != f2) return f1 ? -1 : 1;
   sage.Show a1 = sage.PredefinedJEPFunction.getShowObj(m1.getDataObject());
   sage.Show a2 = sage.PredefinedJEPFunction.getShowObj(m2.getDataObject());
   String s1 = (a1 == null) ? "" : a1.getRated();
   String s2 = (a2 == null) ? "" : a2.getRated();
   return (ascending ? 1 : -1) * s1.compareToIgnoreCase(s2);
 }
 public HdsManifest(final HttpDownloadClient client, final String manifestUrl) throws IOException {
   try {
     final XPath xpath = XPathFactory.newInstance().newXPath();
     final F4mManifest manifest = F4mManifest.fetch(client, manifestUrl, xpath);
     final List<HdsMedia> medias = new ArrayList<HdsMedia>();
     final MediaNode firstMediaNode = manifest.getFirstMediaNode();
     if (!firstMediaNode.getHref().isEmpty()) {
       for (final MediaNode media : manifest.getMediaNodes()) {
         final String href = getUrl(manifestUrl, manifest.getBaseUrl(), media.getHref());
         final F4mManifest childManifest = F4mManifest.fetch(client, href, xpath);
         final MediaNode childMedia = childManifest.getFirstMediaNode();
         final BootstrapInfo info =
             childManifest.getBootstrapInfo(childMedia.getBootstrapInfoId());
         final String url = getUrl(href, childManifest.getBaseUrl(), childMedia.getUrl());
         medias.add(
             new HdsMedia(
                 url, manifest.getUrlQuery(), media.getBitrate(), info.getFragmentCount()));
       }
     } else {
       for (final MediaNode media : manifest.getMediaNodes()) {
         final BootstrapInfo info = manifest.getBootstrapInfo(media.getBootstrapInfoId());
         final String url = getUrl(manifestUrl, manifest.getBaseUrl(), media.getUrl());
         medias.add(
             new HdsMedia(
                 url, manifest.getUrlQuery(), media.getBitrate(), info.getFragmentCount()));
       }
     }
     logger.info("Found medias: " + medias.toString());
     this.medias = Collections.unmodifiableList(medias);
   } catch (final Exception e) {
     throw new IOException("Failed to parse manifest", e);
   }
 }
 public MediaNode getFirstMediaNode() throws Exception {
   return MediaNode.create(
       (Node) xpath.evaluate("/manifest/media", document, XPathConstants.NODE), xpath);
 }