gpt4 book ai didi

org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 13:15:45 27 4
gpt4 key购买 nike

本文整理了Java中org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor类的一些代码示例,展示了YoutubeStreamExtractor类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YoutubeStreamExtractor类的具体详情如下:
包路径:org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor
类名称:YoutubeStreamExtractor

YoutubeStreamExtractor介绍

暂无

代码示例

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

@Override
@Nonnull
public List<SubtitlesStream> getSubtitlesDefault() throws IOException, ExtractionException {
  return getSubtitles(MediaFormat.TTML);
}

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

@Override
public StreamExtractor getStreamExtractor(LinkHandler linkHandler, Localization localization) {
  return new YoutubeStreamExtractor(this, linkHandler, localization);
}

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

@Override
public StreamInfoItem getNextStream() throws IOException, ExtractionException {
  assertPageFetched();
  try {
    StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
    Elements watch = doc.select("div[class=\"watch-sidebar-section\"]");
    if (watch.size() < 1) {
      return null;// prevent the snackbar notification "report error" on age-restricted videos
    }
    
    collector.commit(extractVideoPreviewInfo(watch.first().select("li").first()));
    return collector.getItems().get(0);
  } catch (Exception e) {
    throw new ParsingException("Could not get next video", e);
  }
}

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

@Override
public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
  final String pageContent = getPageHtml(downloader);
  doc = Jsoup.parse(pageContent, getUrl());
  final String playerUrl;
  // Check if the video is age restricted
  if (pageContent.contains("<meta property=\"og:restrictions:age")) {
    final EmbeddedInfo info = getEmbeddedInfo();
    final String videoInfoUrl = getVideoInfoUrl(getId(), info.sts);
    final String infoPageResponse = downloader.download(videoInfoUrl);
    videoInfoPage.putAll(Parser.compatParseMap(infoPageResponse));
    playerUrl = info.url;
    isAgeRestricted = true;
  } else {
    final JsonObject ytPlayerConfig = getPlayerConfig(pageContent);
    playerArgs = getPlayerArgs(ytPlayerConfig);
    playerUrl = getPlayerUrl(ytPlayerConfig);
    isAgeRestricted = false;
  }
  if (decryptionCode.isEmpty()) {
    decryptionCode = loadDecryptionCode(playerUrl);
  }
  if (subtitlesInfos.isEmpty()) {
    subtitlesInfos.addAll(getAvailableSubtitlesInfo());
  }
}

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

@Nonnull
@Override
public String getDescription() throws ParsingException {
  assertPageFetched();
  try {
    return parseHtmlAndGetFullLinks(doc.select("p[id=\"eow-description\"]").first().html());
  } catch (Exception e) {
    throw new ParsingException("Could not get the description", e);
  }
}

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

@Override
@Nonnull
public List<SubtitlesStream> getSubtitles(final MediaFormat format) throws IOException, ExtractionException {
  assertPageFetched();
  List<SubtitlesStream> subtitles = new ArrayList<>();
  for (final SubtitlesInfo subtitlesInfo : subtitlesInfos) {
    subtitles.add(subtitlesInfo.getSubtitle(format));
  }
  return subtitles;
}

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

@Override
public List<VideoStream> getVideoStreams() throws IOException, ExtractionException {
  assertPageFetched();
  List<VideoStream> videoStreams = new ArrayList<>();
  try {
    for (Map.Entry<String, ItagItem> entry : getItags(URL_ENCODED_FMT_STREAM_MAP, ItagItem.ItagType.VIDEO).entrySet()) {
      ItagItem itag = entry.getValue();
      VideoStream videoStream = new VideoStream(entry.getKey(), itag.getMediaFormat(), itag.resolutionString);
      if (!Stream.containSimilarStream(videoStream, videoStreams)) {
        videoStreams.add(videoStream);
      }
    }
  } catch (Exception e) {
    throw new ParsingException("Could not get video streams", e);
  }
  return videoStreams;
}

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

@Nonnull
@Override
public String getUploaderName() throws ParsingException {
  assertPageFetched();
  String name = getStringFromMetaData("author");
  if(name == null) {
    try {
      // Fallback to HTML method
      name = doc.select("div.yt-user-info").first().text();
    } catch (Exception e) {
      throw new ParsingException("Could not get uploader name", e);
    }
  }
  if(name == null || name.isEmpty()) {
    throw new ParsingException("Could not get uploader name");
  }
  return name;
}

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

@Nonnull
@Override
public String getDashMpdUrl() throws ParsingException {
  assertPageFetched();
  try {
    String dashManifestUrl;
    if (videoInfoPage.containsKey("dashmpd")) {
      dashManifestUrl = videoInfoPage.get("dashmpd");
    } else if (playerArgs != null && playerArgs.isString("dashmpd")) {
      dashManifestUrl = playerArgs.getString("dashmpd", "");
    } else {
      return "";
    }
    if (!dashManifestUrl.contains("/signature/")) {
      String encryptedSig = Parser.matchGroup1("/s/([a-fA-F0-9\\.]+)", dashManifestUrl);
      String decryptedSig;
      decryptedSig = decryptSignature(encryptedSig, decryptionCode);
      dashManifestUrl = dashManifestUrl.replace("/s/" + encryptedSig, "/signature/" + decryptedSig);
    }
    return dashManifestUrl;
  } catch (Exception e) {
    throw new ParsingException("Could not get dash manifest url", e);
  }
}

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

@BeforeClass
public static void setUp() throws Exception {
  NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
  extractor = (YoutubeStreamExtractor) YouTube
      .getStreamExtractor("https://www.youtube.com/watch?v=fBc4Q_htqPg");
  extractor.fetchPage();
}

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

@Test
public void testGetAudioStreams() throws IOException, ExtractionException {
  assertFalse(extractor.getAudioStreams().isEmpty());
}

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

@Test
public void testGetAgeLimit() throws ParsingException {
  assertEquals(18, extractor.getAgeLimit());
}

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

@Test
public void testGetDashMpd() throws ParsingException {
  // we dont expect this particular video to have a DASH file. For this purpouse we use a different test class.
  assertTrue(extractor.getDashMpdUrl(),
      extractor.getDashMpdUrl() != null && extractor.getDashMpdUrl().isEmpty());
}

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

streamUrl = streamUrl + "&signature=" + decryptSignature(tags.get("s"), decryptionCode);

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

@Nullable
private String getStringFromMetaData(String field) {
  assertPageFetched();
  String value = null;
  if(playerArgs != null) {
    // This can not fail
    value = playerArgs.getString(field);
  }
  if(value == null) {
    // This can not fail too
    value = videoInfoPage.get(field);
  }
  return value;
}

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

@Override
public List<AudioStream> getAudioStreams() throws IOException, ExtractionException {
  assertPageFetched();
  List<AudioStream> audioStreams = new ArrayList<>();
  try {
    for (Map.Entry<String, ItagItem> entry : getItags(ADAPTIVE_FMTS, ItagItem.ItagType.AUDIO).entrySet()) {
      ItagItem itag = entry.getValue();
      AudioStream audioStream = new AudioStream(entry.getKey(), itag.getMediaFormat(), itag.avgBitrate);
      if (!Stream.containSimilarStream(audioStream, audioStreams)) {
        audioStreams.add(audioStream);
      }
    }
  } catch (Exception e) {
    throw new ParsingException("Could not get audio streams", e);
  }
  return audioStreams;
}

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

@Nonnull
@Override
public String getName() throws ParsingException {
  assertPageFetched();
  String name = getStringFromMetaData("title");
  if(name == null) {
    // Fallback to HTML method
    try {
      name = doc.select("meta[name=title]").attr(CONTENT);
    } catch (Exception e) {
      throw new ParsingException("Could not get the title", e);
    }
  }
  if(name == null || name.isEmpty()) {
    throw new ParsingException("Could not get the title");
  }
  return name;
}

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

@BeforeClass
public static void setUp() throws Exception {
  NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
  extractor = (YoutubeStreamExtractor) YouTube
      .getStreamExtractor("https://www.youtube.com/watch?v=T4XJQO3qol8");
  extractor.fetchPage();
}

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

@Ignore
@Test
public void testGetAudioStreams() throws IOException, ExtractionException {
  // audio streams are not always necessary
  assertFalse(extractor.getAudioStreams().isEmpty());
}

代码示例来源:origin: TeamNewPipe/NewPipeExtractor

@Test
@Ignore
public void testGetAgeLimit() throws ParsingException {
  assertEquals(18, extractor.getAgeLimit());
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com