gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-19 18:47:31 26 4
gpt4 key购买 nike

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

YoutubeSubscriptionExtractor介绍

[英]Extract subscriptions from a YouTube export (OPML format supported)
[中]从YouTube导出中提取订阅(支持OPML格式)

代码示例

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

@Override
public SubscriptionExtractor getSubscriptionExtractor() {
  return new YoutubeSubscriptionExtractor(this);
}

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

@Override
public List<SubscriptionItem> fromInputStream(InputStream contentInputStream) throws ExtractionException {
  if (contentInputStream == null) throw new InvalidSourceException("input stream is null");
  return getItemsFromOPML(contentInputStream);
}

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

throwIfTagIsNotFound(contentBuilder.toString());
    hasTag = true;
throwIfTagIsNotFound(fileContent);

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

@Test
public void testEmptySourceException() throws Exception {
  String emptySource = "<opml version=\"1.1\"><body>" +
      "<outline text=\"Testing\" title=\"123\" />" +
      "</body></opml>";
  List<SubscriptionItem> items = subscriptionExtractor.fromInputStream(new ByteArrayInputStream(emptySource.getBytes("UTF-8")));
  assertTrue(items.isEmpty());
}

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

private List<SubscriptionItem> getItemsFromOPML(InputStream contentInputStream) throws ExtractionException {
  final List<SubscriptionItem> result = new ArrayList<>();
  final String contentString = readFromInputStream(contentInputStream);
  Document document = Jsoup.parse(contentString, "", org.jsoup.parser.Parser.xmlParser());
  if (document.select("opml").isEmpty()) {
    throw new InvalidSourceException("document does not have OPML tag");
  }
  if (document.select("outline").isEmpty()) {
    throw new InvalidSourceException("document does not have at least one outline tag");
  }
  for (Element outline : document.select("outline[type=rss]")) {
    String title = outline.attr("title");
    String xmlUrl = outline.attr("abs:xmlUrl");
    if (title.isEmpty() || xmlUrl.isEmpty()) {
      throw new InvalidSourceException("document has invalid entries");
    }
    try {
      String id = Parser.matchGroup1(ID_PATTERN, xmlUrl);
      result.add(new SubscriptionItem(service.getServiceId(), BASE_CHANNEL_URL + id, title));
    } catch (Parser.RegexException e) {
      throw new InvalidSourceException("document has invalid entries", e);
    }
  }
  return result;
}

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

if (invalidContent != null) {
  byte[] bytes = invalidContent.getBytes("UTF-8");
  subscriptionExtractor.fromInputStream(new ByteArrayInputStream(bytes));
} else {
  subscriptionExtractor.fromInputStream(null);

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

@BeforeClass
public static void setupClass() {
  NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
  subscriptionExtractor = new YoutubeSubscriptionExtractor(ServiceList.YouTube);
  urlHandler = ServiceList.YouTube.getChannelLHFactory();
}

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

@Test
public void testFromInputStream() throws Exception {
  File testFile = new File("extractor/src/test/resources/youtube_export_test.xml");
  if (!testFile.exists()) testFile = new File("src/test/resources/youtube_export_test.xml");
  List<SubscriptionItem> subscriptionItems = subscriptionExtractor.fromInputStream(new FileInputStream(testFile));
  assertTrue("List doesn't have exactly 8 items (had " + subscriptionItems.size() + ")", subscriptionItems.size() == 8);
  for (SubscriptionItem item : subscriptionItems) {
    assertNotNull(item.getName());
    assertNotNull(item.getUrl());
    assertTrue(urlHandler.acceptUrl(item.getUrl()));
    assertFalse(item.getServiceId() == -1);
  }
}

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